Announcement

Collapse
No announcement yet.

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:



    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

        Comment


          #5
          Magic. Thank you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          23 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          120 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X