I am trying to create a very simple indicator. It is compose of two SMAs (one short and on long). I need to color the region between these two SMAs depending on the trend of the SMAs.
If the short SMA is > than the long SMA I want to color the region using a specific color. And if the short SMA is < than the long SMA I want to change the color of the region.
I have tried the next code without success:
protected override void OnBarUpdate()
{
if(CurrentBar < 50) return;
SMAShort[0] = SMA(10)[0];
SMALong[0] = SMA(50)[0];
if (SMA(10)[0] > SMA(50)[0])
Draw.Region(this, "tag1", CurrentBar, 0, ExampleDrawRegionSMAs().SMAShort, ExampleDrawRegionSMAs().SMALong, null, Brushes.Blue, 50);
else
Draw.Region(this, "tag2", CurrentBar, 0, ExampleDrawRegionSMAs().SMAShort, ExampleDrawRegionSMAs().SMALong, null, Brushes.Red, 50);
}
The region has always the same color.
Could you tell me please, how to do this?
Thank you in advance.
Comment