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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        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
         
        Started by Tim-c, Today, 02:10 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X