Peeking into tick data to backtest same-bar trades on minute bars
Author: adgenor
Creation Date: 1/20/2016 5:00 AM
profile picture

adgenor

#1
Hi,

I'm actually trading a minute chart, but I'm using tick data to backtest trades with entry and exit in the same candle, trades that last less than a minute. I'm facing a problem regading slippage. Once the one Tick Chart is a unique value per bar, with same OHLC, wealth-lab won't add slippage to Orders. It won't execute a trade at a price outside the range of the bar.

Is it possible to do it in another way ? Maybe add slippage to LastPosition by script or even create a commission setting that has different comissions for positive and negative trades ?

Thanks
profile picture

Eugene

#2
Hi,

Slippage probably can't be added to a Position object but you could try building a custom commission plan following our open source example.
profile picture

adgenor

#3
How do I pass the information: if the current closed trade is positive or negative to Commission Structure? I've created some customized Commission Structures in Visual Studio that work, but I don't know how to do this...
profile picture

Eugene

#4
1. As you're not taxed by your broker depending on trade outcome, there's no built-in approach flexible enough to achieve this. As you can see the only parameter that allows for any customization in Calculate() is "Bars bars". In theory, you could assign a custom value to Bars.Tag on each Position but I doubt that this would work reliably for your purpose. Seems like you've hit a limitation.

2. Provided you don't have two unique trades in a symbol (where TradeType and OrderType and orderPrice and shares would all match) you could dump the trade details to e.g. a CSV file and read that back in your Commission class.

Any better workarounds are not obvious to me. But is slippage on minute orders such a considerable problem to go out of your way? Maybe you're overestimating it.
profile picture

adgenor

#5
1- Unfortunately It doesn't work. I found that wealth-lab considers only the value of Tag property at (bar==Bars.Count-2) to perform Calculate() for all Positions.

2- Don't think this will work fine through Optimization process...

Will try to think olher ways....

Thanks !


profile picture

Eugene

#6
1 - Using Bars.Tag would be a pretty ugly kludge anyway so it's a reasonable outcome that it doesn't work.

Good luck in your venture.
profile picture

adgenor

#7
I give up ! However, it's good to know that it's possible to backtest operational Minute(s) Charts TradeSystems with tick precision in Wealth-Lab with few limitations though.

Actually, the tradsystem I'm running backtest now worked perfectly even regarding slippage, because only the losses come from Stop Orders... so I could get orderType as the reference I needed in Calculate() inside Commission Structure to apply slippage only to losses.

It follows a code of yours I got elsewhere so this topic gets more complete. It shows how to get minute(s) bars from a 1 Tick Chart. It's usefull for minute(s) basis indicators calculation or other purposes:


CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).