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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      214 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      130 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      147 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      230 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      192 views
      0 likes
      Last Post CarlTrading  
      Working...
      X