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 algospoke, Yesterday, 06:40 PM
        2 responses
        18 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        180 views
        0 likes
        Last Post jeronymite  
        Working...
        X