Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Modifying a Live Strategy Code to Increase the Backtest Accuracy

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

    Modifying a Live Strategy Code to Increase the Backtest Accuracy

    Hi,

    we have the following entry condition in one of our live strategies which doesn't reflect accurately on the backtest because of minute granularity restriction of NT7 backtest:

    if (Opens[1][0] < price && GetCurrentAsk() >= price && entryOrderLong == null)

    Am I correct to understand that with Opens[1][0], we are looking at the opening price of the secondary time series, which in the real version would be set to "tick", so does this mean in the real version the strategy is checking the opening price of each tick or a larger time frame ?

    Accordingly, to replicate this behavior in the backtest, would a code like (MIN(Low, 3)[0] <= price) be accurate enough, (looking at the low of the last 3 minutes, to effectively cover all the ticks that happened), or would you suggest I use the identical code for the real version too (but then again, in the live version (MIN(Low, 3)[0] would be equal to just last 3 ticks right?)


    Warm Regards,
    Vispilio

    #2
    Hello Vispilio,

    Thank you for writing in.

    Please note that GetCurrentAsk() is going to return the close price of the evaluated bar when ran historically: https://ninjatrader.com/support/help...currentask.htm

    You'll need to add an additional series with the market data type of ask and check that series' value if you wish to obtain the ask: http://ninjatrader.com/support/helpGuides/nt7/?add3.htm

    Opens[1][0] will return the value of the open on your secondary series' current bar. Do remember that when running a multi-series strategy, OnBarUpdate() is called at the close of a bar on each of your series. You'll want to make sure to use a BarsInProgress check if you wish for your logic to only occur on a specific series.

    More information about running a multi-series script can be found here: https://ninjatrader.com/support/help...nstruments.htm

    The MIN() method is going to return the lowest value over the specified period: https://ninjatrader.com/support/help...inimum_min.htm

    Can you please clarify what you are using this method for?
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Dear Zachary,

      Thank you for the response. I've already replaced the GetCurrentAsk for the backtest and it's working great.

      The only question is, the Min(Low,3) is a good solution for the backtest; however I'm using it under the assumption that (Opens[1][0]) will look at each upcoming tick in the live version of the strategy, as my Period Type of Non-Day Timeseries = Tick for the real version (and the primary series is daily you are right). Am I correct to assume that (Opens[1][0] will return the value of every upcoming tick in this case ?

      What this entire condition achieves is it creates a virtual Stop Limit order, which only triggers after the Price retraces back to below Stop Trigger Level (for longs, and above Stop for shorts). I just want to confirm with you that using (Opens[1][0]) will indeed check for every tick (which I think what our secondary time series is set for), so converting it to something like (MIN(Low, 3)[0] on the backtest will create an identical result (as the min(low) will have checked for all the ticks for the length of the specified minute bars).

      Let me know what you make of it.


      Best,
      Vispilio

      Comment


        #4
        Hello Vispilio,

        Thank you for your response.

        If your secondary series is 1 Tick, it would updat eon each tick on historical data. In realtime if you use CalculateOnBarClose = False even your primary series will update on each tick.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mattbsea, Today, 05:44 PM
        0 responses
        2 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        31 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        2 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,281 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Working...
        X