I dont see anyone answering your question in post#3
Assuming you have OrderFillResolution.Standard and Slippage=0:
a) If you are in the context of a Ask data series then a market buy order will get filled at GetOpen(CurrentBar+1). This is a correct simulation of what would likely have happened in Realtime, ie the broker would probably have filled at the opening Ask price of the bar-being-built which is when OnBarUpdate gets executed.
b) If you are in the context of a Bid data series then a market sell order will get filled at GetOpen(CurrentBar+1). This is a correct simulation of what would likely have happened in Realtime, ie the broker would probably have filled at the opening Bid price of the bar-being-built which is when OnBarUpdate gets executed.
c) However if you are in the context of a Ask data series then a market sell order gets filled at the same price as a buy. This is obviously inaccurate and I suppose that the idea of the Slippage property was to set this to some 'average' spread and then you might get a slightly more realistic sell order.
Similar problem applies to executing market buy on a Bid series.
So for instance optimizing SampleMACrossOver with default Slippage=0 will give an illusion of higher profits (or lower losses) that you would have got Realtime, simply because the Bid Ask spread has not been taken into account.
With the fill engine as at RC2: The only way I can see to get accurate inclusion of the historical Bid Ask spread (which might vary wildly) into backtests, is by ensuring that all Buy orders get executed on a Ask data series and all Sell orders get executed on a Bid data series. But then your code is going to look a lot more complicated than SampleMACrossOver! Has anyone got a better idea?

Leave a comment: