Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simulator delay

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

    Simulator delay

    Why execution in strategy analyzer is delayed?

    Time frame in sample: 12 minutes.


    Sample strategy:
    protected override void Initialize()
    {
    SMA(Fast).Plots[0].Pen.Color = Color.Orange;
    SMA(Slow).Plots[0].Pen.Color = Color.Green;

    Add(SMA(Fast));
    Add(SMA(Slow));

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick).
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (CrossAbove(SMA(Fast), SMA(Slow), 1))
    {
    this.Print( string.Format( "EnterLong ON {0}", Time[0] ) );
    EnterLong();
    }
    else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
    {
    this.Print( string.Format( "EnterShort ON {0}", Time[0] ) );
    EnterShort();
    }
    }
    ----

    Debug results:
    EnterShort ON 23.09.2010 10:00:00
    EnterLong ON 23.09.2010 15:24:00
    EnterShort ON 23.09.2010 17:24:00
    EnterLong ON 23.09.2010 18:12:00

    Trades list in simulator is attached.

    Time in strategy is Time[0] = 10:00 and execute EnterShort.
    But Simulator wait one bar - 12 minutes for execution, start position at 10:12:00.
    MarketReplay work correctly, execute trade on 10:00:08

    Does someone know, why simulator delay order execution after one bar?
    Thank you.
    Attached Files

    #2
    Bob, this is expected as in backtesting the earliest trade location is the next bar open after your condition for entry is triggered, i.e. entering at the close of a bar really means being at the open the following one.

    Comment


      #3
      But MarketReplay doesn't have this shift, I think that live trading doesn't have this shift too.
      If Strategy analyzer have Time[0] = 10:00:00 and Enter position on this time, I think that this position shouldn't start at close time of next bar.
      This give different results in strategy analyzer backtest compared to MarketReplay - indicators give slightly different signals because of this shift.

      Comment


        #4
        Bob, for an explanation of what discrepancies between backtesting, Market Replay and live trading are routinely observed please review this link - http://www.ninjatrader-support.com/H...sBacktest.html

        If you with CalculateOnBarClose = true, the trade would be entered on the next bar open in Market Replay testing as well.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        95 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        49 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        31 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        35 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        72 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X