Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting: Confirmation of a Few Things

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

    Backtesting: Confirmation of a Few Things

    Howdy--

    I just wanted to confirm a few items on a backtesting script. However, before asking my clarification questions, I'd like to first lay out what I am trying to backtest.
    1. Let's assume that the chart that I am trading will be a 60 min chart, and I will be looking for orders to fire as soon as a key price level is hit (i.e., COBC = false).
    2. I will load a 1 min secondary series for order placement backtesting purposes.
    3. At the open of the primary series Bar[0] I need to place a limit order on the 1 min secondary series with a limit entry price 1 tick below the low of the primary series Bar[1] for a short and 1 tick above the high of the primary bar series Bar[1] for a long. I want the orders placed at the open of the current bar so that my limit order has a higher order position than if the limit order is placed after the signal is hit.
    4. I will place the limit entry orders via custom "GoShort()" and "GoLong()" methods that will also place the associated OCO stop and PT orders.
    5. As soon as Bar[0] hits 1 tick below the low of Bar[1], I'd like to assume that I get filled at my entry price using NT's backtest fill engine assumptions.


    Here are the points I am seeking clarification on:
    1. To place my short and long limit orders, I will call the secondary series via: EnterShortLimit(1, 1, "short") and EnterLongLimit(1, 1, "long"), correct?
    2. From my understanding on the EnterShortLimit() and EnterLongLimit() calls, the first parameter is barsInProgressIndex, which by calling the 1 indicates that I have asked for the orders to be placed on the 1 min secondary series, correct?
    3. Because I'll be calling the GoShort() and GoLong() methods from within OnBarUpdate() is it okay that I call the GoShort() and GoLong() methods from BarsInProgress == 0 (i.e., the primary series), even though I am looking to place the orders on the secondary series (i.e., BarsInProgress == 1)? Does simply indicating the barsInProgressIndex within the EnterShortLimit() and EnterLongLimit() calls allow me to place the orders on the secondary series, or do I also need to somehow call the GoShort() and GoLong() methods from within BarsInProgress == 1 (i.e., from the secondary series)?
    4. Hypothetically, if the primary bar series opens at 8:30:00a and closes at 9:29:59a and the Low[0] is less than the short entry price (which should be resting at 1 tick below Low[1]), the backtest engine will call the first bar of the secondary series opening at 8:30:00a and closing at 8:30:59a, and then the second bar opening at 8:31:00a and closing at 8:31:59a, etc until price hits the limit entry price, at which point the entry, stop and PT orders will be executed?
    5. Under what circumstances in the backtest would the entry, stop and PT orders be properly executed and not executed at all (i.e., how can I know this is a solid backtest)? How could the backtest results differ from live trading?
    6. The OCO stop and PT orders will be set before the EnterShortLimit() and EnterLongLimit() orders, and I will place them via SetStopLoss("short", CalculationMode.Price, priceStop, true) and SetProfitTarget("short", CalculationMode.Price, pricePT), correct?
    7. If I am in a long position and a short signal comes up (or vice versa) that I am filled on, what happens to the long OCO orders? Are they taken out by the short order executions or do I need to manually cancel them?
    8. Can I remove the secondary series portion of the code for when I am trading live or will I still need the secondary series (i.e., do I need two sets of code: one for backtesting and one for forward testing)?
    9. I realize that NT8 Beta is not yet out, however am I going to have to relearn all of this again with your new "Look Inside" feature or will much of the secondary series code architecture still work in backtesting? I'm not too interested in getting a ways down the road and then having to double back to the last intersection to go in a different direction (i.e., wasted time and effort).


    I'm sure I'll have more questions, but that should get me going in the right direction.

    I really appreciate your help.

    Thanks,

    Aventeren

    #2
    Hello Aventeren,

    Thank you for your post.
    1. Incorrect, you need to use the following syntax: EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)
    2. Please see my answer above.
    3. You are correct, you can use BIP = 0 and still place order to BIP = 1.
    4. The backtest engine will call the secondary series bars after the close of the bar that triggers the condition.
    5. Please review the following link for information on this matter: http://www.ninjatrader.com/support/h...ime_vs_bac.htm
    6. No, your entry needs to be submitted before the SetStopLoss and SetProfitTarget. And in general these need to be submitted either in the Initialize() method or when the entry order is filled.
    7. The orders will be cancelled.
    8. Yes, you can remove the secondary series when trading live with CalculateOnBarClose = false as the secondary series would not be needed for the executions.
    9. There is no word on the changes and what will or will not be changed.

    Comment


      #3
      Thanks, Patrick.

      If I plan on trading a 60 min chart (i.e., my primary series), will there be any problems if my secondary series for backtesting purposes is a 1 range chart as opposed to a 1 min chart?

      Thanks,

      Aventeren

      Comment


        #4
        Hello Aventeren,

        Thank you for your response.

        If the strategy is designed for the 1 Range as the secondary series, then there should be no problems.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, Yesterday, 04:31 AM
        0 responses
        31 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
        283 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