Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stochastics Max Minimum
Collapse
X
-
Stochastics Max Minimum
Never modified plotting of an indicator before and need to know if it possible to change the max and minimum values for Stochastics that came with NT7? My strategy parameters combined with my chart type max it out so my strategy does not see it as rising. Thought about having an equal to ## as rising no longer works when maxed out. Would prefer to have the indicator modified though. I have reviewed the script and nothings jumps out at me, can you point me in the right direction?Tags: None
-
-
Hello Hammerhorn,
Thank you for your response.
The following line checks to see if the fastK's calculations are greater than 100, if so it defaults the value to 100:
You could remove the Math.Min aspect of this if you did not wish to limit it to 100:Code:fastK.Set(Math.Min(100, Math.Max(0, 100 * nom[0] / den[0])));
You would need to right click in the Stochastics NinjaScript Editor and select Save As to give the file a new name in order to edit it.Code:fastK.Set(Math.Max(0, 100 * nom[0] / den[0]));
Comment
-
The problem is not only the MAX or MIN function. The Stochastics indicator simply does what it is supposed to do. With a short lookback period and your UniRenko bars - which smooth price action - you will quickly drive the Stochastics to the maximum value. This is as expected, if you look at the Stochastics formula.Originally posted by Hammerhorn View PostNever modified plotting of an indicator before and need to know if it possible to change the max and minimum values for Stochastics that came with NT7? My strategy parameters combined with my chart type max it out so my strategy does not see it as rising. Thought about having an equal to ## as rising no longer works when maxed out. Would prefer to have the indicator modified though. I have reviewed the script and nothings jumps out at me, can you point me in the right direction?
If you wish that the Stochastics is driven to higher values than 100, you would need to replace the SMA in the Stochastics formula with an infinite impulse response (IIR) filter, which has a reduced lag and overshoots the input variable.
One example for an appropriate IIR filter would be the Tillson T3, for which the amplification can be set to a larger value then 0.7. It will then show the desired behavior of overshooting the input variable. The T3 is a system indicator, so you just need to replace the SMA in the Stochastics formula with the T3. Use the same period as for the SMA, and set the vFactor to 1. Here is the code:
A chart with the StochasticsT3 is attached.Code:protected override void OnBarUpdate() { nom.Set(Close[0] - MIN(Low, PeriodK)[0]); den.Set(MAX(High, PeriodK)[0] - MIN(Low, PeriodK)[0]); if (den[0].Compare(0, 0.000000000001) == 0) fastK.Set(CurrentBar == 0 ? 50 : fastK[1]); else fastK.Set(100 * nom[0] / den[0]); K.Set(T3(fastK, Smooth, 3, 1)[0]); D.Set(T3(K, PeriodD, 3, 1)[0]); }
You could also make experiments with a Hull moving average (HMA) or a Kalman filter.
Comment
-
What you need to do is write the spec to handle all the instances that you will encounter, then code it.Originally posted by Hammerhorn View PostNever modified plotting of an indicator before and need to know if it possible to change the max and minimum values for Stochastics that came with NT7? My strategy parameters combined with my chart type max it out so my strategy does not see it as rising. Thought about having an equal to ## as rising no longer works when maxed out. Would prefer to have the indicator modified though. I have reviewed the script and nothings jumps out at me, can you point me in the right direction?
You cannot increase or decrease the maximum or minimum values of the Stochastics indicator. Look at the formula and you will see that the max and min are always going to be 100 and 0. Of course, you can multiply all values by a factor, but that just serves to change absolute values: relative values and hence any logic that depends on the values will not change.Code:Pseudocode: if (rising) { //what to do 1 } else if (falling) { //what to do 2 } else if (maxedOut) { //what to do 3 } else if (minPegged) { //what to do 4 }
Comment
-
Harry - Thank you very much. StochasticsT3 is just beautiful. Thanks for the code, saved me some headache time.
Koganam - If Harry's advice did not work I would have then reverted to you example. I need to know how to do that anyway, so thanks again.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment