How does backtesting handle stops in the middle of a bar?

Posted By: scotpip

How does backtesting handle stops in the middle of a bar? - 01/04/22 21:52

Hi

Evaluating Zorro for a new project. Trying to understand how the backtester handles the scenario where a resting stop is straddled by a bar during bar-resolution backtesting.

According to the docs:

Quote
When entry, stop, or profit limits are triggered by the high or low of a historical tick or by OrderDelay in realistic fill mode, positions are filled in this way:
Long Entry stop: max of Entry and tick end price.
...


https://manual.zorro-project.com/conversion.htm

Unless I'm misreading this, it doesn't seem to make sense.

Say price is at 0.01 and I have a long entry stop sitting at 0.02, and the next bar closes at 0.08.

I would expect the backtester to open the trade at 0.02 + the allowance for spread and slippage.

But "the max of Entry and tick end price" would open the trade at 0.08 + spread and slippage.

The docs call this "slightly pessimistic". But it's surely far too conservative, and would distort the backtest results? Especially if the entry stop was at the start of a large bar.

Can someone please clarify. Am I misunderstanding something?
Posted By: jcl

Re: How does backtesting handle stops in the middle of a bar? - 01/05/22 08:56

Apparently. Believe me, when a price really rises by 800% in a single tick, you want a realistic backtest rather than a bad surprise in live trading.
Posted By: scotpip

Re: How does backtesting handle stops in the middle of a bar? - 01/05/22 14:28

Thanks for responding.

We have extensive experience of trading this system manually and aren't seeing anything remotely approaching that level of slippage in practice.

As this is central to the system it seems that Zorro won't be well suited to this automation project.

I'd urge you to consider making this configurable, so backtesting can be tuned to what we are experiencing in our trading venue...
Posted By: Petra

Re: How does backtesting handle stops in the middle of a bar? - 01/10/22 13:13

All is configurable, but the problem is maybe you simply confused ticks witrh bars?

Tick = price quote in historical data
Bar = Time period of a candle

I think the default settings are pretty good, the Zorro backtester is probably one of the most accurate on the market. But if you want more optimistic backtests, use naive fill mode, Fill = 0.
Posted By: Zheka

Re: How does backtesting handle stops in the middle of a bar? - 01/10/22 13:25

jcl promised to implement this feature for limit orders: https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=484613#Post484613

The same setting can be made to work also for entry stops.

Try setting Slippage=0 and see if this gets you closer to the desired situation.

And check 'ticks' (be it M1 bars or real ticks) in the t6 file: is there indeed a gap at the time of entry?

Posted By: jcl

Re: How does backtesting handle stops in the middle of a bar? - 01/11/22 09:05

A flat fill price offset is planned for the next release. But indeed, when I see the title of this thread, it seems a confusion of ticks and bars - if it were bars, the complain would make some sense.
© 2024 lite-C Forums