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

Multi-timeframe Historical calculation inaccurate

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

    Multi-timeframe Historical calculation inaccurate

    I just wanted to see if the dev team is working on or has a solution to this problem before I spend the time to conjure up my own work around:

    If you have an indicator or strategy that uses another timeframe, let's call it timeframe B, (and the primary timeframe let's call timeframe A) and you want to perform some action on timeframe A based on some indicator that's calculating it's values on timeframe B, your historical calculations (and therefore actions) will be all inaccurate. Let me explain:

    When NT calls an OnUpdateBar for the timeframe A, you are at the close of a bar on timeframe A. However, you will most likely be in the middle of a bar on timeframe B. Because timeframe B's bar has not closed, it's bar should have the same "current price" (closing price) as the timeframe A, as this is currently the most recently known price.

    However NT will simply uses the previous bar (this is if you use BarsArray[1][0]), which is problematic if you are relying on intrabar evaluations on timeframe B.

    Naturally the High's and Low's are also a problem; and while this may be a small error if your timeframe B is not so large, it's a much bigger problem the larger that timeframe.

    Basically it means you are must use the market replay to do accurate backtesting, which is a pity considering how comprehensive the backtesting tool in NT is.

    It seems to me that the information is already basically there for timeframe B for a better way to do this: the Open of the next bar for timeframe B is known, as well as the current price, so you have the information to create an interim bar for timeframe B (except the high or low would be problematic, but at least you have the open/close).

    Jeremy
    Last edited by Jeremytang; 09-22-2011, 09:10 AM.
    Jeremytang
    NinjaTrader Ecosystem Vendor - Shark Indicators

    #2
    Hello Jeremytang,

    Thank you for your post.

    When backtesting, this will always be calculate on bar close = true. This means that there would not be any intrabar granularity on a single series.

    However by using multi time frames, you can setup your strategy to use intrabar granularity by submitting orders to the lower time frame. Please see our Reference Sample on this for more information:

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks Matthew, I am aware that you can submit your orders to a higher granularity timeframe, but this does still does not solve the issue with the calculations regarding indicators.
      Jeremytang
      NinjaTrader Ecosystem Vendor - Shark Indicators

      Comment


        #4
        Jeremy, what you would need to do is run a much lower series and simulate your conditions / calculations on this series to get intrabar values for those emulating the higher timeframe. Enhancing our support and flexibility in this area on the list of for future consideration though.

        Thanks for your feedback on this topic,
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          Many traders utilize strategies that rely on a "higher" timeframe view to get a birds eye assessment of the market. So going down to a lower timeframe defeats that purpose.

          Simulating the larger timeframe's indicators on a lower timeframe is definitely not trivial.
          Jeremytang
          NinjaTrader Ecosystem Vendor - Shark Indicators

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by jpeep, 08-16-2020, 08:31 AM
          17 responses
          502 views
          0 likes
          Last Post notenufftime  
          Started by ETFVoyageur, 05-07-2024, 07:05 PM
          15 responses
          119 views
          0 likes
          Last Post ETFVoyageur  
          Started by esmall, Today, 07:14 PM
          0 responses
          9 views
          0 likes
          Last Post esmall
          by esmall
           
          Started by Option Whisperer, 05-09-2024, 07:58 PM
          6 responses
          26 views
          0 likes
          Last Post Option Whisperer  
          Started by rayyyu12, Today, 05:38 PM
          0 responses
          12 views
          0 likes
          Last Post rayyyu12  
          Working...
          X