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(this,"tag1","Text to draw",10,1000,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:
    https://ninjatrader.com/support/help...currentbar.htm
    https://ninjatrader.com/support/help.../?ticksize.htm

    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 NeverDownMoney, Today, 02:42 PM
          2 responses
          9 views
          0 likes
          Last Post NeverDownMoney  
          Started by localappleseed, Today, 02:20 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by asmmbillah, Today, 02:48 PM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by KacemRhaz, Today, 01:31 PM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_ChristopherD  
          Started by ronaldgreene828, Today, 12:08 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X