Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting Order fills outside of the candle

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

    Backtesting Order fills outside of the candle

    Hi,

    When I use the Strategy Analyzer and backtest my strategy,some of my orders are getting filled outside of the candle range?

    Any idea what I did wrong?

    Attached is an image of my problem.

    Thank you!

    Francis
    Attached Files

    #2
    Hello fladou246,

    Is this a sell stop limit order?

    At what price was the stop set, at what price was the limit set?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      the entry is a :

      EnterShort(DefaultQuantity, "");

      And the stop is :

      SetProfitTarget("", CalculationMode.Ticks, 57);
      SetStopLoss("", CalculationMode.Ticks, 50, true);

      And I have a condition that :

      if (Position.MarketPosition == MarketPosition.Short && CrossAbove(EMA(BarsArray[1],8), EMA(BarsArray[1],21), 1))
      {
      ExitShort("","" );
      }


      The stop is always working great. Its only the entry that is not in the candle range

      thank you!

      Francis

      Comment


        #4
        Hi fladou246,

        Thanks for your reply.

        A market order outside of the bar is not expected...

        I'd to test your script on my end.

        May I have an export of this?
        To export your script do the following:
        1. Click File -> Utilities -> Export NinjaScript
        2. Enter a unique name for the file in the value for 'File name:'
        3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
        4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


        Below is a link to the help guide on Exporting NinjaScripts.
        http://www.ninjatrader.com/support/h...nt7/export.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          No problem!

          Here is the exported file. If you try it with the CL09-14, you can see the problem happening on the 01-08-2014(today).

          Also, I was wondering how to get filled as a GTC trade.

          Thank you!

          Francis
          Attached Files

          Comment


            #6
            Hi fladou246,

            The issue here is that you are using multiple data series.

            The order is being placed while BarsInProgress == 2, as you are not doing any kind of check to see what BarsInProgress is running. This means that orders can enter on any of these data series.

            Below is a link to the help guide on BarsInProgress.
            http://www.ninjatrader.com/support/h...inprogress.htm

            BarsInProgress 2 is your 10 minute data series. The order is being placed as the 9:40 10 minute bar closes and is showing with the 9:50 10 minute bar.

            When NinjaTrader is running with Calculate on bar close (COBC) as true, orders are placed after the bar closes using logic calculated from that bar.

            Below is a link to the help guide on Calculate on bar close.
            http://www.ninjatrader.com/support/h...onbarclose.htm

            This means that any orders that are triggered from that bar are submitted after the bar closes as the new bar opens. As the order is placed as the new bar opens and the timestamp of the order is within the time of the next bar, the order will show on the next bar.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Bend70, Today, 06:20 AM
            0 responses
            1 view
            0 likes
            Last Post Bend70
            by Bend70
             
            Started by elliot5, Today, 05:31 AM
            0 responses
            2 views
            0 likes
            Last Post elliot5
            by elliot5
             
            Started by Stanfillirenfro, Today, 02:32 AM
            2 responses
            9 views
            0 likes
            Last Post Stanfillirenfro  
            Started by isataris, 06-23-2022, 04:29 AM
            6 responses
            64 views
            1 like
            Last Post Bend70
            by Bend70
             
            Started by ラリー, Today, 02:35 AM
            0 responses
            7 views
            0 likes
            Last Post ラリー  
            Working...
            X