Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Back-testing with accuracy

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

    Back-testing with accuracy

    Hi fellow programmers,

    I'm not able to really get great information on how the back-testing is worked. Let's say that I'm testing a moving average crossover strategy on hourly time frame. Let's say that I enter a position when a crossover takes place. Would that happen instantaneous or after the completion of that bar? I been away from ninjascript for a little while doing other projects and if I recall correctly, I believe I seen that I always entered the position on the opening of the next bar. If that is the case, is there a setting that I can use to make it instantaneous. Also, within an hourly bar, their is 60 one minute bars. I'm assuming that ninjascript doesn't keep track of tick-by-tick data, but I'm sure that they do have the one-minute timeframe.Let me say that I'm aiming for 25 pips. Let me also say that I entered a trade at 8:21( if possible) and I hit my 25 pip target at 8:47. Would the ninjascript robot know to get me out at that time or it would get me out at 9:00 since I'm doing hourly. Thanks!!

    #2
    Hello BernWillChris,

    Thanks for your post.

    When doing backtesting it is important to understand that it is using historical data which only consists of the Open, High, Low and Close of the bar. When running a backtest, the strategy is called on each OnBarUpdate which when using historical bars would be once per bar, at the end of the bar. Your observation that the strategy does the analysis and orders are filled on the next bar is correct. In the case of hourly bars you would not be able to accomplish your goals.

    There are two options to improve the back testing in your situation, 1) change the granularity that the strategy is applied to or 2) change the strategy to build in a more granular timeframe in addition to the hourly timeframe.

    1) Changing the granularity from hourly bars to a lower time frame such as 1 minute bars. Doing this will provide 59 more OnBarUpdate events with which to trigger your entry and exits. This is the easiest option as you can do so without internally changing your strategy.

    2) If operating the strategy on anything other than 60 minute bars is undesirable, you can change the strategy to add a secondary dataseries (of any type, such a tick, minute, second, etc). By adding a secondary faster timeframe you will get the benefit of more OnBarUpdate events while maintaining the integrity of the strategy based on hourly bars. If this option is of interest we have a reference of how to accomplish this here: http://ninjatrader.com/support/forum...ead.php?t=6652
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      When doing backtesting it is important to understand that it is using historical data which only consists of the Open, High, Low and Close of the bar.
      I use range bars. Is what you're saying any different from running Market Replay with OnBarClose=True in the strategy?

      Comment


        #4
        Hello reynoldsn,

        Thanks for your post.

        Market replay using CalculateOnBarClose = true would be approximately the same except that Market replay uses a simulation engine for determining order fills. Please see: http://ninjatrader.com/support/helpG...ime_vs_bac.htm
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        2 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        389 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        30 views
        0 likes
        Last Post yertle
        by yertle
         
        Working...
        X