I try to develop a indicator that is as same as system indicator VOL. the only different i try to do is show different color of volume bar dependence on a bar is long bar or short bar. I create a new indicator and copy relevant code from system indicator VOL to my source code file. and the key code is below:
protected override void OnBarUpdate()
{
Value[0] = Instrument.MasterInstrument.InstrumentType == InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[0]) : Volume[0];
// here a exception is thrown
BarBrushes[0] = (Open[0] >= Close[0]) ? this.ShortBarBrush : this.LongBarBrush;
}
the exception message is :
System.InvalidOperationException: 'The calling thread cannot access this object because a different thread owns it.'
I also try to use PlotBrushes, but it still does not work. any suggestion?
Thanks

Comment