For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Backtest with lowest timeframe to be close to real prices - is that right?



  • Hi all,

    I know that during backtesting the order execution price can be skewed because the system can only think in terms of bar OHLC prices and in the real time price is always in moving.

    Hence I wonder - when I have a trading strategy that operates say on 4H timeframe (=uses 4H OHLCV data to make its buy/sell decisions), would the right thing be to include a much lower timeframe, say 5min, along to have backtrader operate in 5min bars?
    Would then the order execution price get closer to reality?

    Thanks
    T.


  • administrators

    You use the lowest possible timeframe and replay. With that combination you see the 4 hours bar as you would see it constructed in real-time.

    With the same constraints as listening musing from a CD. The analog input is quantized to give you a digital output, which can no longer reproduce exactly the original, but it is more than good enough for humans.

    Additional considerations: you may also simply use slippage. The goal is to worsen what the usage of a raw 4-hours bar would give you. In most cases it's enough to understand if an algorithm is good enough to pursue its development further or you can simply toss it in the bin.



  • @backtrader yes, that's right, I completely forgot about the replaydata(), thanks!

    Nice analogy with the CD, by the way.

    T.