I am trying to write an indicator using OnMarketData() method and have it color bars based on the bar values. However, it seems like BarColor is being completely ignored in this case.
I can see that bar values go from positive to negative but the bar color remains the same - the one specified in indicator properties in UI. What am I doing wrong? Should I be using a different Plot constructor?
public class TugOfWar : Indicator { ... private static readonly Color BULL_BAR_COLOR = Color.FromKnownColor(KnownColor.DodgerBlue); private static readonly Color BEAR_BAR_COLOR = Color.FromKnownColor(KnownColor.Firebrick); protected override void Initialize() { Plot p = new Plot(BULL_BAR_COLOR, PlotStyle.Bar, "BarWinners"); Add(p); p.Pen.Width = 5; Overlay = false; CalculateOnBarClose = false; } protected override void OnBarUpdate() {} // currently not used - empty protected override void OnMarketData(MarketDataEventArgs md) { ... int diff = volAtAsk - volAtBid; BarColor = (diff >= 0 ? BULL_BAR_COLOR : BEAR_BAR_COLOR); BarWinners.Set(diff); }
Comment