i am trying to color the region above the bollinger band green when the 30ema>60ema, & red when the 30ema<60ema, using "if "& "else" statements.
the chart when refreshed does the job except when you move it...then it goes all green above the bollinger band & the red disappears ?? the upper, middle & lower bands were set to tranparent on the chart. here's my attempt & thanks for any help.
protectedoverridevoid OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Upperband.Set(SMA(Period)[0] + NumStdDev * StdDev(Period)[0]);
Middleband.Set(SMA(Period)[0]);
Lowerband.Set(SMA(Period)[0] - NumStdDev * StdDev(Period)[0]);
{
if (EMA(30)[0] > EMA(60)[0])
DrawRegion("tag1", CurrentBar, 0, Bollinger(NumStdDev, Period).Upper, 1000000, Color.Empty, Color.Lime, 2);
else
DrawRegion("tag1", CurrentBar, 0, Bollinger(NumStdDev, Period).Upper, 1000000, Color.Empty, Color.LightSalmon, 2);
}
}
Comment