Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 01:46:11 +0000



Post From: How are entry/exit Price calculated for MKT orders on Historical BackTest?

[2014-04-30 14:03:25]
Israel Gottlieb - Posts: 14
Correct.

Note that I have upgraded to the latest release (ver. 1129), just in case any issues have been resolved -- all the below apply after the upgrade.

To verify the behavior I described in my post, I took the simple "Trading Example" you provide with Sierra (entry on crossover, exit on target/stop hit), ran it on the same chart (CLX13) and checked the Trading Activity log. The following were noted (you can easily check it by pulling up the chart and applying the "Trading Example" with Bar BackTest):

1. The exits are consistently logged w/ date 1 day prior to the bar which is flagged with an arrow on the chart. (In this case, the entry dates match; only the exit dates show this anomaly. However, in the autotrader I wrote, the anomaly is observed also for entry dates)

2. The fill price shown in the Trade Activity log, in many cases, is not realized anywhere for the date indicated; it is realized only in the subsequent bar -- further suggesting the date is incorrect.

3. In cases where the fill occurs on e.g. a Monday or after holiday, there is no bar at all for the date 1 day prior (i.e. 1 day prior to the fill bar marked w/ an arrow by the "Trading Example"). Nevertheless, the Trading Activity log indicates a date of 1 day prior. For example, an exit from short position is indicated w/ an arrow on 2013-9-23. The bar immediately prior has date 2013-9-20, but the Trade Activity log shows it as 2013-9-22, i.e. a date on which the market was closed. (Here as well, the fill price on the log is not realized anywhere in the prior bar; it is realized on the bar marked w/ an arrow.)

4. The above issue w/ an early fill date needs to be clarified, but doesn't prevent me from working the system -- I can simply assume the fill date shown is 1 day early (but please advise if I'm missing something). Much more problematic, however -- I can't figure out how the fill prices are determined. For example, the 1st trade on the chart is entered on 2013-6-3 and shows on the Trade Activity log with a fill of 92.79. This value does not correspond to any of OHLC, nor even a midpoint between Hi/Lo. How is it calculated? The next trade is filled at the CLOSE price, the one following at 14 points below the CLOSE, the next one 5 points below the CLOSE, the next at the CLOSE and the next 18 points below the CLOSE. The main difficulty is that in the example Autotrader "Trading Example" the condition GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED is applied before any trade is entered, from which I would have assumed that fills are restricted to occur at the CLOSE price. Is that not correct?? Lack of clarity about the method for determining fill prices means that performance results may be substantially skewed, and makes backtesting with the system problematic, to say the least.

On your Trade Simulation documentation page, a rough description is given of the algorithm used to determine fills -- based on algorithmically inferred bid/ask prices. However, the TradeActivity log shows no bid/ask prices. I assume this means that the bid/ask algorithm applies only to intraday (scid) data, not historical data -- which I'm using. On the "Auto Trade System Back Testing" documentation page, there's a different description of how fills are calculated. It says that sampling is simulated 4 times, at each of OHLC, and that fills will be within 1 tick of these prices. As indicated above, this is not what I'm seeing.

Any light on this would be appreciated,
IG