Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      4 responses
      23 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Brevo, Today, 01:45 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by rjbtrade1, 11-30-2023, 04:38 PM
      2 responses
      73 views
      0 likes
      Last Post DavidHP
      by DavidHP
       
      Started by suroot, 04-10-2017, 02:18 AM
      5 responses
      3,021 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Stanfillirenfro, Today, 07:23 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X