Whenever I am in a position, I want my background color to reflect it.
I need to have "CalculateOnBarClose = false" so that I execute on every tick.
Now I didn't think it necessary to change BackColor on every single tick so I included a FirstTickOfBar qualifier thinking that it would only change the color once per bar when the bar opened.
In operation, the color change occurs for only the first bar when I enter a position. Otherwise, it works as expected.
Any ideas?
protected override void OnBarUpdate() { if(Historical) return; if(stratPos > 0) { if(FirstTickOfBar) BackColor = Color.AliceBlue; swLow = swStop.ZigZagLow[0]; if(Bars.CurrentBid < swLow) CloseMyPosition(); } if(stratPos < 0) { if(FirstTickOfBar) BackColor = Color.MistyRose; swHigh = swStop.ZigZagHigh[0]; if(Bars.CurrentAsk > swHigh) CloseMyPosition(); } }
Comment