Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnCalculateMinMax MinValue / MaxValue doesn't match chartScale.MinValue/MaxValue

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

    OnCalculateMinMax MinValue / MaxValue doesn't match chartScale.MinValue/MaxValue

    Code:
                    public override void OnCalculateMinMax()
    		{        
    		    //Set the charts min/max values to 50 Ticks above/below MyPlot
    		    double tmpMin = double.MaxValue;
      			double tmpMax = double.MinValue;
    			for(int key = ChartBars.FromIndex; key <= ChartBars.ToIndex && key < sortedDicList.Count;key++) 
    			{
    				double cl = closeRenko[key];
    				if(tmpMin > cl) tmpMin = cl;
    				if(tmpMax < cl) tmpMax = cl;
    			}
    			
    			MinValue = tmpMin;
      			MaxValue = tmpMax;
    			
    			
    		}
                    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                    {
                           chartScale.MinValue ...
                    }

    chartScale.MinValue = 6918 doesn't match MinValue = 6954.
    chartScale.MaxValue = 6972 doesn't match MaxValue = 6969.

    The scale Range is set to automatic w/ Percent = 6. Seems like its pulling the low value of the chart series (6921) despite me setting the min / max in the indicator. how do I fix this?

    #2
    is this the correct code to put in OnRender?

    Code:
                                  if(chartScale.Properties.YAxisRangeType == YAxisRangeType.Automatic){
    					double ex = MaxValue - MinValue;
    					
    					chartScale.MaxValue  = MaxValue+ex/100*chartScale.Properties.AutoScaleMarginUpper;
    					chartScale.MinValue  = MinValue-ex/100*chartScale.Properties.AutoScaleMarginLower;
    				}

    Comment


      #3
      Hello,

      Thank you for the post.

      Can you provide more detail on what you are trying to accomplish with the provided syntax? Are you trying to scale the chart using the OnCalculateMinMax and it is not working as expected? If so, are you able to see the sample in the help guide working as expected? https://ninjatrader.com/support/help...alculateMinMax

      I am not certain of the syntax you have provided and what the overall goal is. There also seems to be some code used in OnRender but is not shown in your sample. I would not be sure of what the problem may be in contrast to what you have provided. If you could provide a more specific example I would be happy to help.

      I look forward to being of further assistance.

      Comment

      Latest Posts

      Collapse

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