Backtesting a strategy helps in quantifying a strategy’s historical risk and return expectation. Armed with this data, traders get the confidence to deploy large sums of capital into their strategies. But sometimes, your daily backtested data might differ from your Live trading and forward testing results. Below we have tried to explain some of the reasons as why this might be so:
Slippages – Instrument depth, liquidity & broker congestion
Backtesting a strategy assumes you get the best price as defined by the parameters of the strategy. It does not take into consideration the market depth and liquidity of the instrument, slippages & broker congestion. Here is how these factors can affect your backtest vs Live/forward testing results:
Market Depth: Whether there is a counterparty available who is willing to trade the quantity you want to buy/sell at that price. This issue can be more easily seen with ITM options.
Liquidity: Whether the bid/ask spread is small enough so that you are able to get the same price close LTP which the backtest engine uses.
Slippages: Sometimes sudden moves in the market, especially during expiry, lead to a spike in option prices due to the gamma effect. The rise is so swift that the time taken for the system to process that the SL price has been breached to actual fulfillment of the SL order is enough to result in a big difference between the SL price and the exit price.
Broker Congestion: Due to congestion of order flow at the broker’s end, especially during the morning, the entry into your instrument might be delayed by 1 or 2 sec. This delay can lead to different entry prices or/and potentially different strikes from what the backtesting engine uses for your strategy compared your live trade and forward test. In forward testing, we assume you are able to get the orders at a specific time without accounting for any delay from the brokers end.
As a result of the above, your trades entry prices and/or strikes and thus the SL, profits target and TSL might be different from our backtest results.
Solution: Add slippages to reduce differences caused by such factors.
SL-L order triggered but market never reached SL price
AlgoTest offers the use of SL-L order for your SL orders. The SL-L orders are placed in your broker’s order book (Check this: https://algotest.in/blog/faqs-about-sl-l-orders-algo-trading-software-india/) at the time of entry in the strategy and are quite helpful in reducing slippages that might occur due to sudden moves in the market. A SL-L order has a trigger price and a limit price defined by the user at the time of activating their strategy. Say for example, we have the following strategy:
Entry time = 9:20 AM
SL = 20%
Trigger buffer = 2 points
Limit buffer = 4 Points
Entry price @ 9:20 is:
Sell CE = Rs 100
Sell PE = Rs 100
Hence the SL-L orders will be:
CE SL-L order: Trigger price Rs 118, Limit price Rs 124
PE SL-L order: Trigger price Rs 118, Limit price Rs 124
Now, if the LTP of the CE reaches Rs 118.05 our trigger price will be breached and a limit order a to buy the CE will be placed at Rs 124 and we shall be stopped out of the CE leg.
If the the price of the call makes a high of Rs 119 and reverses from there, then according to the backtest we are still in the trade whereas in live deployment we have been stopped out. This can lead to mismatch in backtest results vs live trade and forward test.
Solution: Keep the trigger buffer as Rs 0 and limit buffer at Rs 2 (anything other than 0).
Overall SL and Profit Target feature on strategy
As mentioned earlier, our backtest uses 1-min OHLC data to give results. When using 1-min OHLC data, the only time you can be sure about the overall profit or loss of a strategy is either at the open or close of the candle. AlgoTest uses the close of a 1-min candle to calculate the overall profit and loss for a strategy.
Meanwhile in live trading, the overall profit/loss conditions are checked continuously. Hence, there can be a mismatch between your day’s backtest and live/forward testing results using overall strategy level conditions.
Your strategy might have reached its defined Overall Target profit or SL in LIVE trading but the 1-min Candle close might not have reflected this.
Square off – Complete
One of the features that AlgoTest has under its legwise SL settings is SL complete (Check out: https://algotest.in/blog/definition-of-terms-used-in-backtesting-platform/#square-off). Under this condition, if the SL of any of the legs in a strategy is hit, the whole strategy is exited. Since we use 1-min OHLC data, we can determine the exit price of the SL leg, as defined in the strategy, but we cannot determine the price of the other legs at the time the SL is hit. Hence, we use the close price of the 1-min candle to determine the exit price of all the other legs in the strategy.
Meanwhile in live trading, once any leg’s SL is hit all the other legs are exited at the same time using market order. Thus, leading to a difference between liv trade/forward test.
Re-entry ASAP, Re-entry ASAP reverse, Re-entry momentum & Re-entry Momentum Reverse
Under all the above features, the Re-entry at the new ATM is taken as soon as a leg’s SL is hit (check out: https://algotest.in/blog/definition-of-terms-used-in-backtesting-platform/#reentry). In live as well as forward testing, the new strikes and prices are fetched as per the current market price, whereas in backtesting the strategy the prices taken and strikes selected are of the close of the 1-min candle where the SL is hit. This can lead to a difference between Backtest and Live trade/forward test results.
Delay is price feed from your broker
There can sometimes be a delay of milliseconds from your broker’s price feed to our Live execution system. If the spot at that time is in between two ATM strikes, there can be a difference between the backtest, forward test and live trade. Such differences are unavoidable sometimes.
Entry and exit in the first minute candle
AlgoTest uses 1-min OHLC data for backtesting a strategy. Based on the conditions of your strategy, for example simple momentum, say the entry (BUY) of your strategy happens on the 15th second of the minute. After entry, the price of your instrument hits the SL price within the same minute candle but closes above the SL price. In this case, at the end of the candle, the backtest will show entry in the strategy but in Live trade and foward test your leg would have stopped out. Let us illustrate this with an example and the following strategy conditions:
Entry time: 9:20 AM
Simple momentum: CE = 20 Points up, PE = 20 Points up
SL: 5% for both legs
TSL points: X = 10, Y = 5 for both legs
9:20 Bank Nifty ATM Spot = 38000
9:20 CE Price = Rs 400
9:20 PE Price = Rs 420
Say at 9:25 the 38000 CE opened at Rs 405. The simple momentum conditions are met on 9:25:15 and the following trade takes place:
9:25:15 Buy CE 38000 @ Rs 420 (SL = Rs 399)
After entry the market moves down and at 9:25:30 a LOW of Rs 399 is made
9:25:30 Sell CE 38000 @ Rs 399 (SL HIT)
The market reverses and moves up with the price of the option closing at Rs 410 in that minute. There after the market keeps moving up for the rest of the day and eventually a time exit or a TSL exit happens.
So, our 9:26 1-min candle (checkout how we define a candle here: https://algotest.in/blog/how-does-algotest-define-a-candle) has the following parameters:
Open = Rs 405
High = Rs 420
Low = Rs 399
Close = 410
According to that day’s backtest results, the entry happened at Rs 420 and since the close of the entry 1-min candle was above our SL price of Rs 399, the system assumed that the strategy was still running at the end of that candle. Whereas, in live trade the strategy was already stopped out.
These are some of the drawbacks of working with a 1-min OHLC data for backtesting your strategy. You may avoid such cases by having higher SLs for your strategies.
2 thoughts on “Why is there is difference between my Live Trade vs Forward Testing vs Backtest results?”
Dear Sir ,
Today I executed a Paper Trade suing Trailing SL . System triggered the SL wrongly . As per the defined strategy rule , SL should not have been triggered . I am not able to identify the reason . Kindly help pl.
Please send us the trade details and the strategy logic, we would be happy to help you.