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

Panel Plot Min and Max

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

    #16
    Originally posted by Zeos6 View Post
    Hi,
    Is it possible to set a max and min value for the panels below the price pane? I would like to set the y-axis to be between min = 0 and max = 1.35. If yes, how? Thank you.
    Try this and let us know how it goes:
    Code:
     
    public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
     {
      base.GetMinMaxValues(chartControl, ref min, ref max); 
      min = desiredMinValue; 
      max = desiredMaxValue; 
     }

    Comment


      #17
      That works like a charm! koganam, many, many thanks!

      Comment


        #18
        Hello,
        I'm having the same issues with plots that have larger values therefore they become flat. So as I tried koganam's code:
        Code:
        public override void GetMinMaxValues(Gui.Chart.ChartControl chartControl, ref double min, ref double max)
                 {
                     base.GetMinMaxValues(chartControl, ref min, ref max); 
                      min = desiredMinValue;   
                      max = desiredMaxValue; 
                 }
        I get the following error:
        "....no suitable method found to override"

        Thanks in advance

        Comment


          #19
          Hello 2Look4me,

          Thank you for writing in.

          GetMinMaxValues() is an indicator class method. Please ensure you are utilizing the override within an indicator.

          Please, let us know if we may be of further assistance.
          Zachary G.NinjaTrader Customer Service

          Comment


            #20
            Originally posted by NinjaTrader_AdamP View Post
            Zeos,

            If you want to totally cut out these values, you could simply check for max/min and truncate.

            I.e.

            If ( MyDataSeries[0] > 1.35)
            {
            MyDataSeries[0] = 1.35;
            }

            Something like that. You can even keep track of a secondary data series that is the actual values, then truncate only the plot values.
            Hello,

            I have been trying to use the above example to filter out values that are very high or very low from a plot which disappears when I use a low value tick chart, but it is not working. For example, in NT8, on the M6A instrument, currently if I use a 12Tick chart, ChartPanel.MaxValue = 1972.64; ChartPanel.MinValue = -0.1803, and I can see the plot line (between values 14 & 1 on chart). If I use a 8Tick chart, ChartPanel.MaxValue = 2957.7; ChartPanel.MinValue = -6E-06, there is no plot on the chart and the values in the left scale range from 0.0001 down to 0.000005. Where do I need to place the filter code so that I can restrict the chart scale for the plot to say 20 and -5, so that I can still see the plot.

            Comment


              #21
              GeorgeW, the filtering would be normally in OnBarUpdate() where find your bar by bar calcs and plot values to set. Are you trying to override the scale by setting min / max values as well?



              Perhaps you have an example / screenshot for us to review - thanks.
              BertrandNinjaTrader Customer Service

              Comment


                #22
                Thanks for responding, Bertrand.

                I have attached an image of what I am trying to achieve. The blue and red plots are in the same panel as the input series, and the scale justification is to the left, and ranges between 1 and 7. When I reduce the chart Tick value, the plots can disappear, and the scale justification to the left changes - as per the 2nd image. There is not always a consistency in the Tick value that will cause this to happen.

                I have tried your solution, but the plots disappear and the scale values to the left change to the price levels, which is not what I want, I want the values as per my calculations. Also, what is the NT7 method for OnCalculateMinMax()?
                Attached Files

                Comment


                  #23
                  I have tried the code below to restrict the plots. The scale to the left looks ok, but the plots do not display - although you can see the values for the current plot position with the red and blue markers on the scale.
                  Code:
                  protected override void OnBarUpdate()
                  {
                  	myDataSeriesBear[0] = ((Math.Round(bearVolPerTick/ bullVolPerTick, 2)/Period));
                  	myDataSeriesBull[0] = ((Math.Round(bullVolPerTick/ bearVolPerTick, 2)/Period));
                  		
                  			//To filter out extreme values that cause plot to disappear
                  			if (myDataSeriesBear[0] > 7) 
                  			{
                  				myDataSeriesBear[0] = 7;
                  			}
                  			if (myDataSeriesBear[0] < 0) 
                  			{
                  				myDataSeriesBear[0] = 0;
                  			}
                  			if (myDataSeriesBull[0] > 7) 
                  			{
                  				myDataSeriesBull[0] = 7;
                  			}
                  			if (myDataSeriesBull[0] < 0) 
                  			{
                  				myDataSeriesBull[0] = 0;
                  			}
                  	
                  
                  /* Plotting the SMA of the intermediate calculation step stored in DataSeries object*/
                  			BslShortPeriodBear[0] = (SUM(myDataSeriesBear, Period)[0]);
                  			BslShortPeriodBull[0] = (SUM(myDataSeriesBull, Period)[0]);
                  }
                  
                  
                  protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                  			{         
                  			  // the maximum value of the chart scale
                  			  double maxValue   = chartScale.MaxValue;
                  			  double minValue   = chartScale.MinValue;		
                  			 
                  			  maxValue = 7;
                  			  minValue = 0;	
                  			}
                  Attached Files

                  Comment


                    #24
                    Hello,

                    Thank you for the post.

                    Would you be able to either upload an export of this script for me to review or email it to our platform support @ ninjatrader.com?

                    I would like to see the logic in its entirety and also try the script to achieve the same result you are. Can you tell me, does the script work overall if the scale is set to the Right instead? I am just curious if this is specifically related to the scale or if the indicator still does not plot.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment


                      #25
                      Thanks for your response,Jesse.

                      The script is currently private.

                      I have tried ScaleJustification.Right, but this just compresses all the price bars, as the scaling for prices and the plots are different. With ScaleJustification.Overlay, the markers for the plot positions are to the right of the chart, but the plots do not display.

                      Comment


                        #26
                        Hello,

                        Thank you for the reply.

                        I had just noted that you are missing the base call in your OnRender, I had missed this the first time I reviewed the code. The indicator not plotting would be a result of not calling the base OnRender() method.
                        Code:
                        protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
                        {        
                                [B]base.OnRender(chartControl, chartScale); [/B]
                        	// the maximum value of the chart scale
                        	double maxValue   = chartScale.MaxValue;
                        	double minValue   = chartScale.MinValue;		
                        			 
                        	maxValue = 7;
                        	minValue = 0;	
                        }

                        If you add this to OnRender, and then remove/re add the indicator you should see it plot.


                        I look forward to being of further assistance.
                        JesseNinjaTrader Customer Service

                        Comment


                          #27
                          Thanks for that, Jesse.
                          Unfortuantely, it doesn't work and the plot still disappears when very low value tick charts are used. I think it's the same as the issue which has been identified in this thread: Chart Fixed Scale Y-Axis with Dynamic Range, and one which NT will hopefully work on.

                          Comment


                            #28
                            I have sorted out the problem of my indicators disappearing when using lower value tick charts and post my solution here as it may be of help to someone else:

                            Using Math.Round in the computations for the MyBuySell series of indicators was also causing the NaN problem and indicators to disappear. This is because if Math.Round rounded a computation to say 4 decimal places, and the 1st number in the computation was at 5 decimal places, the computation would return 0 (Zero). Then this would cause errors when it was used in later computations. I have removed Math.Round from these indicators, and it has solved the issue.

                            Comment


                              #29
                              Note, it is possible to restrict the scale for a plot to say 0-100 like the scale for the StochasticsFast - see calculations @ Ln79 there. For my plots, I needed to set up OS/OB+OS or OB/OB+OS so that they can only be 0 to 1, then multiply by 100, so that Max can be 100 - inside Math.Max comp, then wrap all in Math.Min comps.

                              The final calculations for the plots as below:
                              Code:
                              Values[0][0] =	Math.Min(100, Math.Max(0, 100*osObStochK[0]/(osObStochK[0] + osObStochK2nd[0])));
                              Values[1][0] =	Math.Min(100, Math.Max(0, 100*osObStochK2nd[0]/(osObStochK[0] + osObStochK2nd[0])));

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by elderan, Today, 08:03 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post elderan
                              by elderan
                               
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post algospoke  
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              169 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X