Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT7 to NT8 conversion - what is bounds in the Plot function?

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

    NT7 to NT8 conversion - what is bounds in the Plot function?

    Hello, I am trying to convert indicator from NT7 to NT8. I tried searching on the web but did not find answer. The NT7 docs do not mention Plot. The breaking changes docs on NT7 -> NT8 also do not mention this.

    The NT7 uses Plot(Graphics graphics, Rectangle bounds, double min, double max) and NT8 uses OnRender(ChartControl chartControl, ChartScale chartScale).

    In the code pasted below could you please help me identify what would be the bounds?

    It is used in these lines:

    int rangeHighY = (bounds.Y + bounds.Height) - ((int) ((( highPrice - min ) / ChartControl.MaxMinusMin(max, min)) * bounds.Height))-1;
    int rangeLowY = (bounds.Y + bounds.Height) - ((int) ((( lowPrice - min ) / ChartControl.MaxMinusMin(max, min)) * bounds.Height))-1;​


    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
    {
    
    base.Plot(graphics, bounds, min, max);
    
    
    if (Bars == null)
    return;
    
    
    int actualRange = (int) Math.Round(Math.Max(Close[0] - Low[0], High[0] - Close[0]) / Bars.Instrument.MasterInstrument.TickSize);
    int rangeCount = Bars.Period.Value - actualRange ;
    
    int barRange = (int) Math.Round( (High[0] - Low[0]) / Bars.Instrument.MasterInstrument.TickSize);
    int margin = (Bars.Period.Value - barRange);
    
    double highPrice = High[0] + (margin*TickSize);
    double lowPrice = Low[0] - (margin*TickSize);
    
    int rangeHighY = (bounds.Y + bounds.Height) - ((int) ((( highPrice - min ) / ChartControl.MaxMinusMin(max, min)) * bounds.Height))-1;
    int rangeLowY = (bounds.Y + bounds.Height) - ((int) ((( lowPrice - min ) / ChartControl.MaxMinusMin(max, min)) * bounds.Height))-1;
    int height = rangeLowY - rangeHighY;
    int rangeX = ChartControl.GetXByBarIdx(Bars, CurrentBar) - (ChartControl.BarSpace/2) ;
    int width = (ChartControl.BarSpace);
    }​
    Thanks in advance

    #2
    Hello 09try,

    In most cases you can replace the bounds with the ChartPanel.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    For example ChartPanel.W would be the width of the panel, ChartPanel.H would be the height, ChartPanel.Y would be the top of the panel.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea, thanks. Do you know what would be the double min, double max in the Plot signature and ChartControl.MaxMinusMin(max, min)?

      I have tried with

      var min = chartScale.MinValue;
      var max = chartScale.MaxValue;​
      and
      chartScale.MaxMinusMin

      chartScale from the OnRender

      but it does not produce good values so I assume it is not correct.

      Comment


        #4
        Hello 09try,

        Are you looking for the Y value of the bottom of the panel?

        This would be ChartPanel.Y + ChartPanel.H.

        If you are looking for the top price of scale minus bottom price of the scale this would be chartScale.MaxMinusMin.
        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks, but honestly I do not know if I am looking for Y value of the bottom of the panel.

          The indicator uses Plot(Graphics graphics, Rectangle bounds, double min, double max) and I am looking for what the double min, double max from the Plot would be in NT8.

          Comment


            #6
            Hello 09try,

            You may be looking for chartScale.MinValue, and chartScale.MaxValue.
            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

            Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

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