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 gravdigaz6, Today, 11:40 PM
      0 responses
      4 views
      0 likes
      Last Post gravdigaz6  
      Started by MarianApalaghiei, Today, 10:49 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by XXtrader, Today, 11:30 PM
      0 responses
      4 views
      0 likes
      Last Post XXtrader  
      Started by love2code2trade, Yesterday, 01:45 PM
      4 responses
      28 views
      0 likes
      Last Post love2code2trade  
      Started by funk10101, Today, 09:43 PM
      0 responses
      9 views
      0 likes
      Last Post funk10101  
      Working...
      X