What I'm trying to achieve is to have both MA's Green when MA1 is above MA2 and Both MA's Red when MA1 is below MA2.
Here is the code I have been working on but it doesnt do what I am trying to achieve. Any help would be appreciated.
thanks.
Jason
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.SpringGreen), PlotStyle.Line, "FastAbove"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "FastBelow"));
Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "SlowAbove"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "SlowBelow"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
bool Bearish=(EMA(6)[0] < SMA(14)[0]);
bool Bullish=(EMA(6)[0] > SMA (14) [0]);
if (Bearish)
FastBelow.Set(EMA(6)[0]);
if (Bearish)
SlowBelow.Set(SMA(14)[0]);
if (Bullish)
FastAbove.Set(EMA(6)[0]);
SlowAbove.Set(SMA(14)[0]);
}
Comment