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; }
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!
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
NinjaTrader
Panel Plot Min and Max
Collapse
X
-
Originally posted by Zeos6 View Post
Code:
-
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; }
"....no suitable method found to override"
Thanks in advance
Comment
-
Originally posted by NinjaTrader_AdamP View PostZeos,
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.
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
-
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
-
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()?
Comment
-
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; }
Comment
-
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
-
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
-
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
-
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
-
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
-
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 johnnymustard, Today, 09:52 AM
|
0 responses
1 view
0 likes
|
Last Post Today, 09:52 AM | ||
Started by SnailHorn, 03-27-2024, 09:54 AM
|
4 responses
17 views
0 likes
|
Last Post
by SnailHorn
Today, 09:19 AM
|
||
Started by ninza33, Today, 07:16 AM
|
3 responses
18 views
0 likes
|
Last Post
by ninza33
Today, 09:01 AM
|
||
Started by foxtrott21, Today, 08:27 AM
|
0 responses
4 views
0 likes
|
Last Post
by foxtrott21
Today, 08:27 AM
|
||
Started by jaypelle3, Today, 08:26 AM
|
0 responses
3 views
0 likes
|
Last Post
by jaypelle3
Today, 08:26 AM
|
Comment