• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 ksarin, Today, 12:39 PM
          2 responses
          8 views
          0 likes
          Last Post ksarin
          by ksarin
           
          Started by ttodua, Today, 12:03 PM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by tomtr27, Today, 11:35 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Uregon, Today, 07:30 AM
          2 responses
          9 views
          0 likes
          Last Post bltdavid  
          Started by Induna, 02-20-2020, 05:38 AM
          4 responses
          26 views
          0 likes
          Last Post NinjaTrader_Kate  
          Working...
          X