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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      73 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X