• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stochastics Max Minimum

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

    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?

    #2
    Hello Hammerhorn,

    Thank you for your post.

    Can you provide an example of the maxed out Stochastics on your chart?

    If possible please provide a screenshot of this plotted on your chart.

    I look forward to your response.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      See attached image. Thank you.
      Attached Files

      Comment


        #4
        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])));
        You could remove the Math.Min aspect of this if you did not wish to limit it to 100:
        Code:
        fastK.Set(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.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Hammerhorn View Post
          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?
          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.

          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]);
           }
          A chart with the StochasticsT3 is attached.

          You could also make experiments with a Hull moving average (HMA) or a Kalman filter.
          Attached Files

          Comment


            #6
            Originally posted by Hammerhorn View Post
            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?
            What you need to do is write the spec to handle all the instances that you will encounter, then code it.

            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
            }
            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.

            Comment


              #7
              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 maggie3, Today, 02:05 AM
              0 responses
              3 views
              0 likes
              Last Post maggie3
              by maggie3
               
              Started by qewcool, Today, 01:14 AM
              0 responses
              3 views
              0 likes
              Last Post qewcool
              by qewcool
               
              Started by fredrikn, 05-08-2019, 04:01 AM
              17 responses
              669 views
              1 like
              Last Post emtrader  
              Started by zacharydw00, Yesterday, 10:19 PM
              0 responses
              3 views
              0 likes
              Last Post zacharydw00  
              Started by chafan11, Yesterday, 09:28 PM
              0 responses
              7 views
              0 likes
              Last Post chafan11  
              Working...
              X