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
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:
Code:fastK.Set(Math.Min(100, Math.Max(0, 100 * nom[0] / den[0])));
Code:fastK.Set(Math.Max(0, 100 * nom[0] / den[0]));
Comment
-
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:
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
-
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?
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 jourdale, 03-16-2024, 06:33 AM
|
3 responses
40 views
0 likes
|
Last Post Today, 06:44 PM | ||
Started by henryd333, 03-22-2021, 08:18 AM
|
18 responses
930 views
0 likes
|
Last Post Today, 06:07 PM | ||
Started by PaulMohn, Today, 05:51 PM
|
0 responses
4 views
0 likes
|
Last Post
by PaulMohn
Today, 05:51 PM
|
||
Started by johnathanhebert, 03-01-2024, 05:38 PM
|
8 responses
60 views
0 likes
|
Last Post Today, 05:48 PM | ||
Started by endystrike, 12-06-2016, 09:52 AM
|
144 responses
8,611 views
0 likes
|
Last Post
by bobperez
Today, 04:08 PM
|
Comment