Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable Autoscaling for the current bar

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

    Disable Autoscaling for the current bar

    Hi there,

    I've been developing an indicator for NinjaTrader 8 that uses 6 plots.

    I wanted to disable autoscaling for the 5th and 6th plots.

    Using the "OnCalculateMinMax()" works great for this, however I've noticed it will then only disable autoscaling for the 5th and 6th plots on the bars before the current bar.

    Is there any way to ensure it disables autoscaling of those specific plots (5th and 6th plots) for the current bar as well?

    Here is my code:
    public override void OnCalculateMinMax()
    {
    double tmpMin = double.MaxValue;
    double tmpMax = double.MinValue;

    for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index++)
    {
    double plotValue1 = Values[0].GetValueAt(index);
    double plotValue2 = Values[1].GetValueAt(index);
    double plotValue3 = Values[2].GetValueAt(index);
    double plotValue4 = Values[3].GetValueAt(index);
    double plotValue5 = Values[4].GetValueAt(index);

    tmpMin = Math.Min(tmpMin, Math.Min(Math.Min(plotValue1, plotValue2), Math.Min(plotValue3, Math.Min(plotValue4, plotValue5))));
    tmpMax = Math.Max(tmpMax, Math.Max(Math.Max(plotValue1, plotValue2), Math.Max(plotValue3, Math.Max(plotValue4, plotValue5))));
    }

    MinValue = tmpMin;
    MaxValue = tmpMax;
    }

    Any help will be much appreciated.​

    #2
    Hello RoswellTrader,

    OnCalculateMinMax() is not a data-driven-method.

    This means you would need to use TriggerCustomEvent() to sync the series first, or use <Series>.GetValueAt().
    I would recommend using <Series>.GetValueAt() as this will use less compute.



    Also, you would need to have Calculate set to .OnPriceChange or .OnEachTick.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Excellent, thanks for the help Chelsea, it is much appreciated!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      600 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      347 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
      558 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X