Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 00:25:41 +0000



[User Discussion] - How are entry/exit Price calculated for MKT orders on Historical BackTest?

View Count: 1226

[2014-04-29 11:57:38]
Israel Gottlieb - Posts: 14
I have a simple AutoTrade system (trade signals based on MACD & Stochastic) that uses MKT orders only; it also executes such orders only on Bar Completion (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED). When running a backtest on historical data, the fill prices don't seem to follow any clear pattern; they certainly do not (consistently) correspond to the CLOSE of the bar where filled. What algorithm is used to determine the fill price? Is it documented?

Further, the date for entry/exit given in Trade Activity is often 1 bar prior to the one where the entry/exit signal occurred. (I checked this by logging all trade signal data for each Autotrade iteration.) Why?? In some cases, the fill price is identical to the CLOSE of this prior bar, where the trade signal could not possibly have been recognized yet. (Again, documentation??)

Thanks Much, IG
[2014-04-30 06:39:31]
Sierra Chart Engineering - Posts: 104368
This is documented on this page here:
http://www.sierrachart.com/index.php?l=doc/doc_TradeSimulation.php


Are you referring to the fill Date-Time for real-time trading or for replay/back testing?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2014-04-30 08:03:16]
Israel Gottlieb - Posts: 14
I'm referring to Replay/Backtesting. To be concrete, I have ready screenshots of the chart showing the results of the autotrader + the TradeActivity log . . . however, the file upload (Edit Attached Files) doesn't seem to work. [Provide address where I can send the files . . . ?]

In a specific example (chart: CLX13) the Autotrader is exiting on a very simple signal of 2 consecutive increases of MACD Histogram -- which occurs for the first time on 2013-08-01, as correctly indicated by the Autotrader where it draws an aqua color arrow for the exit fill. However, the TradeActivity Log shows the fill as executed 1 day earlier, on 2013-07-31. Further, the exit price is logged as 102.94, which is the CLOSE price of the earlier bar, i.e. on 2013-07-31. However, the signal was not realized until the CLOSE of the following bar. The OPEN on 2013-08-01 is 1 pt away from this price, however, the autotrader restricts all trades to sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED, hence should be ignoring the OPEN and using the CLOSE price only. NOTE that all orders are MKT for this autotrader.

On other occasions -- with the same autotrader, the fill price is not the same, or even very close to any of the OHLC prices.

Would appreciate any clarification or pointer to documentation re exactly what happens here . . .
IG
[2014-04-30 08:18:19]
Sierra Chart Engineering - Posts: 104368
We did not ask for any files. Please do not provide us any files. We will not look at them.

Sounds like you are working with a Historical Daily chart?
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2014-05-11 07:19:24
[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
[2014-04-30 19:08:03]
Sierra Chart Engineering - Posts: 104368
We need time to review this. Please allow us a few days.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2014-05-01 06:20:10]
Israel Gottlieb - Posts: 14
Ok -- looking forward to your reply,
IG
[2014-05-11 08:47:09]
Sierra Chart Engineering - Posts: 104368
however, the autotrader restricts all trades to sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_CLOSED, hence should be ignoring the OPEN and using the CLOSE price only.
When the bar has closed, the order will be filled at the Open price. This is how it works since a bar is not considered closed until there is an open of a new bar which occurs.



1, 2, 3. We initially did not see this. We then changed the time zone to a time zone forward of GMT and then we encountered it. It is a time zone issue involving Historical charts.


4. We see no problem with the order prices. In our testing they do correspond with the Open, High, Low, Close values.


However, the TradeActivity log shows no bid/ask prices.
Yes it does! These prices are in the Order Action Source field for each fill.


The auto trade back testing documentation has been updated to make reference to this in case of resting orders:
http://www.sierrachart.com/index.php?l=doc/doc_TradeSimulation.php#HowOrdersAreFilled

You are also overwhelming us with information that we do not need and we do not fully understand because we do not know exactly what you are doing. And we do not want to hear about any further details. You are providing too much information that is not useful to us. You could have simply said that the order fill is displaying on a bar before the date which it actually occurs on. And that you are using a Historical Daily chart. This is all. And there is no need to comment on what we said here. We have heard enough. We are marking this as a User Discussion because we can spend no further time on it.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2014-05-11 08:48:44

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account