# Backtesting open vs. close price



## Neural (10 May 2015)

All the back testing I've seen, seems to use close price for back testing.

If someone trades at EOD, so at the end of the bar, the action is taken on the close price. But if an order is placed, it would be executed at the open price of Day+1 ignoring slippage.

Then at the end of Day+1 another action is taken to decide to sell, that would be executed against the open price of the following Day+2.

So to calc todays profit if you were to buy at end of today you need to take into account tomorrows open and the following days open. Nothing to do with close prices at all.

Does this sound right to you guys?


----------



## VSntchr (10 May 2015)

Neural said:


> All the back testing I've seen, seems to use close price for back testing.
> 
> If someone trades at EOD, so at the end of the bar, the action is taken on the close price. But if an order is placed, it would be executed at the open price of Day+1 ignoring slippage.
> 
> ...




Well it depends on the individual traders routine I would guess. Trades could be placed in the EOD auction (4:00 to 4.10pm). But if the traders eyes aren't available for screen time until after close, a situation I imagine many EOD traders would find themselves in - then the next open appears the most realistic option.


----------



## pixel (10 May 2015)

VSntchr said:


> Well it depends on the individual traders routine I would guess. Trades could be placed in the EOD auction (4:00 to 4.10pm). But if the traders eyes aren't available for screen time until after close, a situation I imagine many EOD traders would find themselves in - then the next open appears the most realistic option.




Complicating matters further, I'd question whether an EOD trader would necessarily place orders "at market". During times when I am forced to leave buy/sell orders to be executed in my absence, I never put them at market, but buy at what I perceive as support - maybe a tick above if I really want to get a position, and sell at or just below resistance. At least 90% of traders I'm in contact with operate that way. We even operate that way for many trades that we execute *during* the day; the only modification may come in when we find a reason to adjust our calculation of support and resistance levels, which may in turn lead to order amendments.


----------



## minwa (10 May 2015)

You can place market on close orders (with filters that only goes in if your trigger is set up) if you can't watch the screen. Probably not advised in ASX as even big names sometimes have spreads of few cents. Depends on what your strategy is, to enter/exit at todays close or tommorrows open, both are very viable in real trading.


----------



## howardbandy (11 May 2015)

Greetings --

If a trading system uses end-of-day data, it might be possible to compute the trading signal using the closing price of that day and place the trade at or near the time of the close of trading.  There are several ways do accomplish this:

1.  Use a real-time data feed, interpret the price near the close as if it is the close, compute the indicators using that data, place the trade for execution at the close.  Check the requirements for orders that will be executed as "market on close" by the broker or exchange you use.  Some require that the order be placed some number of minutes (15 or 20 is typical) prior to the close to be included in execution at the official closing price.  

2.  Use end-of-day data, wait until just after the close of trading to learn the actual closing price, compute the indicators, place your trade in the aftermarket a few minutes after the close.

3.  If your indicators are reasonable well defined and well behaved, pre-compute the price at which a signal will be generated.  Then either watch the price action near the close and compare prices with the signal-price, or pre-enter a limit order some time before the close for execution at the close.  (This can be done for most indicator or rule based systems, without regard for the complexity of the calculation, and without inverting the formula, or even knowing the formula.  All that is required is that the indicator can be calculated by your trading system platform, the decision be based on a single value, such as closing price, and that a single price value or price limit separates the signal state space into buy and not buy categories.)   

Why bother?

If a trading system based on closing prices is accurate in the direction of the price change from today's close to tomorrow's close, about one-third of that price change happens in the overnight trading.  An accurate system is rewarded for being in the market overnight.  Waiting until the next open to enter the position loses the opportunity for that overnight gain.  Emphasis is on accurate.  Even systems that hold longer than one or two days might have considerable favorable price movement in the first overnight period.  (If that is not true, consider revising the system so that it is true.  Try delaying the signal one day before entering the position.)

For systems that hold a short period of time -- say one or two days -- profit targets can be efficient exits.  If your system enters at the close of trading of the signal bar and uses a profit target as one of its exits, consider entering a limit order to exit at a profit and allow that order to be executed in the overnight trading.  (But I recommend not using overnight limit orders to enter positions.)

As always, carefully define your system, then test it thoroughly, including out-of-sample validation.

Best regards,
Howard


----------



## lftrader (27 May 2015)

On several occasions when I placed an order for the close even in advance according to broker instructions I did not get a fill due to an imbalance. So I agree that backtests based on close are not reliable.


----------



## howardbandy (28 May 2015)

Hi lftrader --

Depending on which issue is being traded, which exchange it is being traded on, and which type of order is submitted, you may be legally entitled to a fill at the official closing price.

Best,
Howard


----------



## lftrader (28 May 2015)

howardbandy said:


> Hi lftrader --
> 
> Depending on which issue is being traded, which exchange it is being traded on, and which type of order is submitted, you may be legally entitled to a fill at the official closing price.
> 
> ...




Thanks Howard. Do you have a link with related info?


----------



## howardbandy (29 May 2015)

Hi lftrader --

You might begin with the documentation provided by your broker.  Either they, or the exchange on which your trades are executed, will list the requirements for orders that will be executed as Market On Close.

Best,
Howard


----------



## lftrader (1 June 2015)

howardbandy said:


> Hi lftrader --
> 
> You might begin with the documentation provided by your broker.  Either they, or the exchange on which your trades are executed, will list the requirements for orders that will be executed as Market On Close.
> 
> ...




Thanks


----------

