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

Oscillators Rest to Zero at Session Start

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

    Oscillators Rest to Zero at Session Start

    Dear Support,

    Looking for a reference or a sample script to have an oscillator (i.e, %Change, RSI, etc.) reset to Zero at the start of a session or a certain user-defined time.

    This was a feature request that has been tracked since 2013.

    Many Thanks.

    #2
    Hello aligator,

    Thank you for your note.

    The following reference sample demonstrates how to reset variable at the start of a session, using

    Code:
    if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)


    If you were to replace the above line with,

    Code:
    if(ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 93100)
    Then the variables will be reset at 930.

    Regarding a reference sample which would reset the oscillator to zero at the start of the session, I’m not sure I understand how this could be achieved given something like the RSI has two periods, ex 3 and 14, so it would need at least 14 bars of data to calculate. If you only wanted to use today's data, RSI output would not be available till the 14th bar. Perhaps you could provide more information on what you’re looking for and how you would like to deal with an indicator needing previous data.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AlanP View Post
      Hello aligator,

      Thank you for your note.

      The following reference sample demonstrates how to reset variable at the start of a session, using

      Code:
      if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)


      If you were to replace the above line with,

      Code:
      if(ToTime(Time[0]) >= 93000 && ToTime(Time[0]) < 93100)
      Then the variables will be reset at 930.

      Regarding a reference sample which would reset the oscillator to zero at the start of the session, I’m not sure I understand how this could be achieved given something like the RSI has two periods, ex 3 and 14, so it would need at least 14 bars of data to calculate. If you only wanted to use today's data, RSI output would not be available till the 14th bar. Perhaps you could provide more information on what you’re looking for and how you would like to deal with an indicator needing previous data.

      Please let us know if you need further assistance.
      Thank you for responding Alan,

      The idea is to be able to compare performance of two or more instruments from a set time, let's say from the beginning of session at 9:30 AM to 16:00. Similar to RadarScreen indicator by Trade Station.

      In the case of RSI, that ranges from 0-100, it will be re-set to 50 (mid-line) at 9:30 and progressing from that point to the end of session. A comparison of the RSI for two or more instruments will indicate which instruments leads or lags in strength during the session.

      Same idea can also be applied to total change in price starting from 0% at 9:30 for comparing two or more instruments, comparing their accumulated % price change at any time during the session.

      Many thanks.

      Comment


        #4
        Hello alligator,

        A percent change from the start of the day would be a different situation, as you only need the start price and the last price for any calculation. The RSI indicator takes 14 periods of input to produce an output. From a math perspective, I’m not sure how the RSI indicator could be re-set at 50 each day. On the bar after the opening bar for the day, the RSI output is going to be calculated off 1 bar today, and 13 on the previous day.

        The solution to what it sounds like you’re looking to do, would be to have another indicator reference the change (point change or % change) in the RSI indicator from 930 throughout the day. Or you would have to write your own indicator which only uses today’s data for calculation, but this would be a custom script rather than a feature request for oscillators.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AlanP View Post
          Hello alligator,

          A percent change from the start of the day would be a different situation, as you only need the start price and the last price for any calculation. The RSI indicator takes 14 periods of input to produce an output. From a math perspective, I’m not sure how the RSI indicator could be re-set at 50 each day. On the bar after the opening bar for the day, the RSI output is going to be calculated off 1 bar today, and 13 on the previous day.

          The solution to what it sounds like you’re looking to do, would be to have another indicator reference the change (point change or % change) in the RSI indicator from 930 throughout the day. Or you would have to write your own indicator which only uses today’s data for calculation, but this would be a custom script rather than a feature request for oscillators.

          Please let us know if you need further assistance.
          Thanks Alan,

          So, perhaps the solution for RSI, as you suggested, is to create a %Price Change indicator (not the same as PPO) and set to 0 at the session open and use the RSI value as Input.

          Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jclose, Today, 09:37 PM
          0 responses
          5 views
          0 likes
          Last Post jclose
          by jclose
           
          Started by WeyldFalcon, 08-07-2020, 06:13 AM
          10 responses
          1,414 views
          0 likes
          Last Post Traderontheroad  
          Started by firefoxforum12, Today, 08:53 PM
          0 responses
          11 views
          0 likes
          Last Post firefoxforum12  
          Started by stafe, Today, 08:34 PM
          0 responses
          11 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by sastrades, 01-31-2024, 10:19 PM
          11 responses
          169 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X