Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Range of Candle in realtime

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

    Draw Range of Candle in realtime

    Hello,

    i´m trying to get an indicator working, that shows me the Range of the completed candles and of the current developing candle as a text above the high of each candle.
    is this possible ?

    So far i have:

    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Overlay = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.

    double netChange = Math.Round(High[0] - Low[0],10)*100;
    DrawText("CurrentBar", netChange.ToString(), 0, High[0] + (TickSize *10), Color.Red);

    It would be great if you could give me a hint how i get further with this project.
    Thank You !

    #2
    nt2010, to see realtime updates to your calculations you need to run the script the with CalculateOnBarClose set to false - http://www.ninjatrader.com/support/h...onbarclose.htm

    Comment


      #3
      You have to destroy the draw object before you draw it, or it will keep drawing over itself and be unreadable. You might also want to use CurrentBar.ToString() instead of "CurrentBar" as your identifier. I have seen CurrentBar (without the quotes) used successfully, but it is technically incorrect, as CuurentBar is an integer, not a string. I believe what you have will only be painting over the last bar as you are effectively modifying the draw object represented by the never changing literal string named "CurrentBar".

      If you want real time updates, you have to use CalculateOnBarClose = false; in the Initialize() function. Once you do that, that is why the text paints over itself, requiring you to destroy the Draw object before you write the new one. I know the literature says that you are modifying the existing object, which would imply that the newly drawn text would show in place of the old text. In my experience, that is not quite how it works, and the drawn text quickly becomes unintelligible unless one destroys the object before rewriting it. Look at the yellow highlight on the attached chart for an illustration of what I mean.
      Attached Files

      Comment

      Latest Posts

      Collapse

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