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.
- 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).
- I will load a 1 min secondary series for order placement backtesting purposes.
- 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.
- I will place the limit entry orders via custom "GoShort()" and "GoLong()" methods that will also place the associated OCO stop and PT orders.
- 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:
- 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?
- 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?
- 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)?
- 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?
- 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?
- 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?
- 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?
- 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)?
- 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

Comment