I'm having a problem trying to render text on a blueprint chart. Here's what I'm using:
public class Ver14 : Strategy { // Define custom fonts for use in this section NinjaTrader.Gui.Tools.SimpleFont Arial_7pt = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 7); NinjaTrader.Gui.Tools.SimpleFont Arial_8pt = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 8); NinjaTrader.Gui.Tools.SimpleFont Arial_9pt = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 9); NinjaTrader.Gui.Tools.SimpleFont Arial_10pt = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 10); NinjaTrader.Gui.Tools.SimpleFont Arial_12pt = new NinjaTrader.Gui.Tools.SimpleFont("Arial", 12); NinjaTrader.Gui.Tools.SimpleFont Wingdings2_12pt = new NinjaTrader.Gui.Tools.SimpleFont("Wingdings 2", 12); NinjaTrader.Gui.Tools.SimpleFont Wingdings2_16pt = new NinjaTrader.Gui.Tools.SimpleFont("Wingdings 2", 16); // Freeze the colors we want to use Brush expensive_green = new SolidColorBrush(Color.FromArgb(0, 0, 100, 0)); Brush bargain_green = new SolidColorBrush(Color.FromArgb(0, 0, 128, 0)); Brush delta_green = new SolidColorBrush(Color.FromArgb(0, 203, 236, 181)); Brush expensive_red = new SolidColorBrush(Color.FromArgb(0, 177, 14, 20)); Brush bargain_red = new SolidColorBrush(Color.FromArgb(0, 221, 17, 25)); Brush delta_red = new SolidColorBrush(Color.FromArgb(0, 255, 204, 203)); protected override void OnBarUpdate() { // Freeze the brushes we will be using in the script expensive_green.Freeze(); bargain_green.Freeze(); delta_green.Freeze(); expensive_red.Freeze(); bargain_red.Freeze(); delta_red.Freeze(); } // end of on bar update private void chart_print_indicatorIcons() { // Green/Expensive if (delta_momentum_meter == 5 && price_momentum_meter == -5) { chart_counter++; // Increase the chart counter Draw.Text(this, chart_counter.ToString(), true, "q 444", 1, // Show a dark green arrow with three dollar signs to signal expensive buys Close[0], 1, expensive_green, Wingdings2_12pt, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0); } // Red/Expensive else if (delta_momentum_meter == -5 && price_momentum_meter == -5) { chart_counter++; // Increase the chart counter Draw.Text(this, chart_counter.ToString(), true, "444 w", 1, // Show a dark red arrow with three dollar signs to signal expensive sells Close[0], 1, expensive_red, Wingdings2_12pt, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0); } (etc.)
I generate the following error on running the script:
Error on calling 'OnBarUpdate' method on bar 10: The calling thread cannot access this object because a different thread owns it.
For reference, "chart_print_indicatorIcons()" is called whenever there's a particular event in the code that gets triggered.
Also, I'm not sure where to place a Dispatcher.ASync reference in there, but please help me out if you could.
It's weird because I never encountered this in NT7.
Thanks in advance!
Comment