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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X