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

Hacking out a Breakout Strategy on Tick Data

  • Hello All,

    I'm obviously new to Backtrader (fantastic framework by the way).

    I want to create a breakout strategy using the H & L of current bar (with a 5 pip buffer for example), dynamically. I do not want to use the open of the next bar as that is too late (standard backtrader usage).

    My idea is:

    1. Get tick data and use the method here to load it:

    OR just set each tick as O,H,L,C and load as first data stream

    1. Resample to desired BreakOut time-frame as second data stream.

    2. Compare the tick data stream to the resampled data stream and execute the market orders

    The problem is keeping both streams in sync so that, after a breakout, the current resampled bar (where the BO occurred) is then used for the next breakout and also using the previous bar of the resampled data stream for SL calculation of created orders.

    Maybe its possible using the datetime values of both streams??

    Any sample code is much appreciated.

    Apologies if this has been covered before, I wasn't able to find exactly what I was looking for during my search.

  • @Esa-J-Obande said in Hacking out a Breakout Strategy on Tick Data:

    using the H & L of current bar

    just wondering - how do you know the H and L of the current bar before the bar close?

  • oops my error, I meant to say 'previous bar'

  • If you issue buy stop order on each bar using Hcur of the bar as the stop price, than it will be executed on the next bar at the Hcur (or Onext if it will be a large gap). I assume this is what you want.

  • Hmm, I will test that out and see how the results pan out, thank you

  • You will also need to cancel orders which were not executed after the period of waiting (probably one bar in your case).

Log in to reply