Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Draw.Text Example not Working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Draw.Text Example not Working

    Not sure if I'm doing something incorrect but I copied the text from the manual

    Code:
    Draw.Text([COLOR=#0000ff]this[/COLOR],[COLOR=#ffffff] [/COLOR][COLOR=#800000]"tag1"[/COLOR],[COLOR=#ffffff] [/COLOR][COLOR=#800000]"Text to draw"[/COLOR],[COLOR=#ffffff] [/COLOR][COLOR=#ff6600]10[/COLOR],[COLOR=#ffffff] [/COLOR][COLOR=#ff6600]1000[/COLOR],[COLOR=#ffffff] [/COLOR]Brushes.Black);
    And pasted it into my strategy OnBarUpdate()

    And when I load the strategy I have an error: Object reference not set to an instance of an object

    Do I need to initialize Draw.Text? How is that done?

    Thanks!

    #2
    Hello Bluebeep,

    The Draw.Text() example will draw the text "Text to draw" 10 bars ago from the current bar at the price level of 1000.

    If you are not using a current bar check before that statement then you would get an error when the indicator is loaded with the first bar.
    Try this:

    If (CurrentBar <= 10) return;

    Draw.Text(this,"tag1","Text to draw",10,1000,Brushes.Black);


    Also, if you are applying this to an instrument that is not currently showing a price of 1000 then you would need to change your scale to see that value. Alternatively, you might replace 1000 with something like High[0] + 5 * TickSize to put the text 5 ticks above the high of the bar.

    Draw.Text(this,"tag1","Text to draw",10,High[0] + 5 * TickSize,Brushes.Black);

    Reference:



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you! It was the CurrentBar thing. Works well now except the text runs under the bars as the bars develop. Is there a way to ensure that the text is legible (i.e. something like Stay On Top)?

      Comment


        #4
        Hello Bluebeep,

        You can alter the z-order priority of the candles.
        Please see "How to change the z-order (paint order) of a chart object" https://ninjatrader.com/support/help...rt_objects.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Magic. Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          30 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          943 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          9 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          5 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          28 views
          0 likes
          Last Post wzgy0920  
          Working...
          X