Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot Indicator Result on Every Bar

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

    Plot Indicator Result on Every Bar

    I have an indicator that plots a ratio between a bar and the preceding bar. I need to display this ratio either above or below each bar on the price plot. I want to be able to see the historical result from the indicator calculation for several bars in the past. It could a varying (User defined) number of bars or, it could be every visible bar.I can print the result for the bar that has just closed. I am not sure how to print the result for all the previous bars, and keep them visible. Any help on how to do this would be appreciate.?

    #2
    Hello Kaiviti57,
    You can use Draw.Text() for this. Hope it helps!

    Comment


      #3
      Hello Kaiviti57,

      Thanks for your post.

      As forum member s.Kinra has advised you could use Draw.Text(). In order to draw and retain those drawings, you would need to use a unique "tag name" for each object to retain. Otherwise, the default is to remove the previous version and draw the new version. A common way to do this is to create a tag name and then append the system's current bar number to it, for example, "myTagname"+CurrentBar. This would allow one unique draw object per bar.

      Reference: https://ninjatrader.com/support/help...?draw_text.htm
      Last edited by NinjaTrader_PaulH; 03-09-2021, 07:53 AM. Reason: added reference to help guide section.

      Comment


        #4
        Thanks Paul. That has done the trick. Now for 2 more questions.

        1) How do I limit the number of bars with reslts? Let's say I only want to show 20 bars with the results.
        2) how do I control the font size of the printed result. It is currently rather large and I would like to set a user defined font size.

        Thanks in advance.

        Comment


          #5
          Hello Kaiviti57,
          1. You can refer this thread : https://ninjatrader.com/support/foru...icator-signals
          You need as below:
          Example:

          if (conditions to draw an object)
          {
          myDrawCounter++; // increment draw counter

          Draw.Dot(this, "myDot"+myDrawcounter, 0....);
          }

          if (myDrawCounter == 100)
          {
          myDrawCounter == 0; // reset for next 100 objects
          }

          This way you only ever see 100 of the latest drawn objects.
          2. You can use below syntax:
          • Draw.Text(NinjaScriptBaseowner,stringtag,boolisAutoScale,stringtext,intbarsAgo,doubley,intyPixelOffset,BrushtextBrush,SimpleFontfont,TextAli gnmentalignment,BrushoutlineBrush,BrushareaBrush,intareaOpacity)
          • Draw.Text(NinjaScriptBaseowner,stringtag,boolisAutoScale,stringtext,DateTimetime,doubley,intyPixelOffset,BrushtextBrush,SimpleFontfont,TextAli gnmentalignment,BrushoutlineBrush,BrushareaBrush,intareaOpacity)

          Comment


            #6
            Hello Kaiviti57,

            Thanks for your reply.

            Member s.Kinra has pointed to an example I provided on another thread on a simple means to limit the drawn objects.

            Member s.Kinra also provided the Draw.text method overloads that allow you to specify the font.

            In this page of the help guide is a great example of creating the simplefont and its usage in Draw.Text(): https://ninjatrader.com/support/help...font_class.htm The example would print with a 50 size bold Courier new type font. Note that the Simple font is created in the variable "myFont". Once created you can then use myFont in any Draw.Text() that has the font overload in it. (Meaning you only need to create myFont once)

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            603 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            349 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            104 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            560 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X