protected override void OnBarUpdate()
{
if (enTrade)
{
buttonsArray[0].Foreground = Brushes.Black;
if (!greenLight )
{
buttonsArray[0].Background = Brushes.Yellow;
}
else buttonsArray[0].Background = Brushes.LightGreen;
if (!greenLight) EnterLongStopMarket(aL2[0]);
else EnterShortStopMarket(aL[0] - TickSize);
}
}
When this method is called I get "Strategy 'ChartTraderCustomButtonsExample': Error on calling 'OnBarUpdate' method on bar 2406: The calling thread cannot access this object because a different thread owns it"
How should I code this correctly?
Comment