Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to calculate daily RSI(2) at the end of the day

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

    How to calculate daily RSI(2) at the end of the day

    Hi,

    I want to run backtest that buy/short stock at the end of the day (e.g. last 5 minutes).
    Running the strategy on a daily timeframe will buy at the open of the next day, so I'm running it on 5 minute chart and when the time is the last 5 minutes, then I place an order.

    Let's assume that my strategy is checking for daily RSI(2) and triggers according to it.
    The problem is that when running on intraday data, I can't access daily indicators, because it will return the previous day data (since the day wasn't ended yet).

    So...
    I need to calculate current daily RSI 2 (and I can't write RSI(2,1)[0] because it will return yesterday RSI) - how can I do it?

    I know that there is the formula in many places to calculate RSI, but when I calculate RSI 2 after 2 days up, then the RSI is 100 - but it should be something else.

    Does anyone have a code that calculate daily RSI on intraday?

    Btw, I'm using Ninjatrader 7.

    Thanks,

    #2
    Hello shayhz,

    Thank you for writing in.

    As backtesting will run your strategy logic only at the close of a bar, you would need to add a more granular time frame to your script.

    More information about running your NinjaScript strategies with an intrabar granularity can be found here: http://ninjatrader.com/support/forum...ead.php?t=6652

    Additionally, more information about using a script that utilizes multiple instruments/time-frames can be found here: https://ninjatrader.com/support/help...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks you.

      I didn't mention it, but I did add 1 day series to the script, but the primary timeframe that I'm running the strategy is 1 minute.
      So, in order to get daily RSI 2 I write: RSI(BarsArray[2],2,1)[0], but "0" is the last day, which is yesterday and I need to get the value of today's rsi (when I'm at the end of the day).

      Thanks,

      Comment


        #4
        Hello shayhz,

        With NinjaTrader 7 this would not be possible.
        When in historical data Calculate on bar close is always true. Because of this, the input series to the indicator will not have the updated day. (In real-time data with Calculate on bar close set to false, then Closes[2][0] would refer to the current updated day)

        With NinjaTrader 8, the concept of tick-replay has been introduced to allow for the equivalent of updating in real-time when processing historically. This does cause high resource usage when backtesting, however, this would accomplish your goal.

        Below is a link to the NinjaTrader 8 help guide detailing tick replay.

        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rtwave, 04-12-2024, 09:30 AM
        2 responses
        20 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by tsantospinto, 04-12-2024, 07:04 PM
        5 responses
        67 views
        0 likes
        Last Post tsantospinto  
        Started by cre8able, Today, 03:20 PM
        0 responses
        6 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        49 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        115 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X