Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market reply vs backtesting for multi-instrument strategy

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

    Market reply vs backtesting for multi-instrument strategy

    Hello,
    I am trying to implement a pair strategy. And it works fine on backtesting but when I start testing it with Sim account or use market reply it has big differences with backtesting. And I don't understand where those problems come from.

    The logic is simple. I have main 1 minute bar which works like clocks. And two tick series.

    I have a code like this:

    if (this.BarsInProgress != 0)
    {
    return;
    }

    var close1 = this.Closes[1][0];
    var close2 = this.Closes[2][0];

    // Use some indicator to calculate if I need to open or close positions based on close1 and close2 prices.

    I have COBC=true for main bar.

    It would be good to have results as close as posible to backtesting.

    I have made some test with this code:

    I have main bar "APA" with with 1 minute period type.

    and two additional instruments:
    this.Add("APA", PeriodType.Tick, 1);
    this.Add("APC", PeriodType.Tick, 1);

    protected override void OnBarUpdate()
    {
    this.PrintWithTimeStamp(this.BarsInProgress + " " + this.Times[0][0] + " " + this.Times[1][0] + " " + this.Times[2][0]);
    }

    And have this result for market reply:

    31/05/2012 8:09:48 AM 2 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:48 AM

    31/05/2012 8:09:49 AM 2 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:49 AM

    31/05/2012 8:09:45 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:45 AM 31/05/2012 8:09:49 AM

    31/05/2012 8:09:50 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:50 AM 31/05/2012 8:09:49 AM

    31/05/2012 8:09:50 AM 1 31/05/2012 8:09:00 AM 31/05/2012 8:09:50 AM 31/05/2012 8:09:49 AM

    This never happens on backtesting. And I don't understand why it happens on real testing.
    I can't undertand why tick with time 8:09:45 comes after tick with timestamp 8:09:49.

    I use Kinetick data. My clocks are syncronized.

    Thanks

    #2
    Welcome to our forums here silar - do you use the replay on recorded Kinetick data, is this correct?

    What do you mean by COBC = true for the main bar please? Do you have COBC for the script set to false and filter the main series via FirstTickOfBar?

    What you see here is the time of the last tick for this series, NT will update / call each bars in progress as a tick is seen - there series are not synched together in realtime, they will update whenever a tick is seen - so this would not be a timed based, but purely event based environment you operate in with your script.

    Comment


      #3
      Replay data was recorded when NT was connected to Kinetick and IB as a second connection (I was testing it on paper account and recorded for replay at the same time)

      > What do you mean by COBC = true for the main bar please?
      I have COBC = true option in the script. At least I believed it was set to true.

      > Do you have COBC for the script set to false and filter the main series via FirstTickOfBar?
      No I don't use FirstTickOfBar option (as I said I have COBC = true)

      Actually I have tried it with both 1) COBC = true, and 2) using FirstTickOfBar option with COBC = false
      And in both case signals are different from backtesting.

      > there series are not synched together in realtime, they will update whenever a tick is seen

      Sorry I still don't understand how it happens. In my understanding Kinetick should send a tick information to NT as soon as it happened on Stock Exchange. I can understand that some information about a tick can be delayed and arrive after other tick which happened later this one. But this is a 5sec delay - not a small one. Do you think this is a normal delay?

      Comment


        #4
        Hello again,
        Sorry that I confused you. Now I am thinking that it is possible that I had COBC = false in this particular example. I am on different computer to check it right now. But question about 5 second delay is still valid.

        Comment


          #5
          Hi Silar, did you recheck how you ran your test setting wise? NinjaTrader stamps generally with the ending bars time, with Kinetick being connected first in your setup > you would use this price data stream for the Market Replay record as well. In realtime / replay those series updates are processed as they are seen by NT.

          The print you refer to is done when BarsInProgress 1 calls the OnBarUpdate(), at that time the last seen tick has this timestamp.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sjsj2732, Yesterday, 04:31 AM
          0 responses
          33 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          286 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          285 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          133 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          91 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X