Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Hacking out a Breakout Strategy on Tick Data

    Indicators/Strategies/Analyzers
    2
    6
    131
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Esa J. Obande
      Esa J. Obande last edited by

      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: https://www.backtrader.com/blog/posts/2016-03-08-escape-from-ohlc-land/escape-from-ohlc-land/

      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.

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        @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?

        1 Reply Last reply Reply Quote 0
        • Esa J. Obande
          Esa J. Obande last edited by

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

          1 Reply Last reply Reply Quote 0
          • A
            ab_trader last edited by

            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.

            1 Reply Last reply Reply Quote 1
            • Esa J. Obande
              Esa J. Obande last edited by

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

              1 Reply Last reply Reply Quote 0
              • A
                ab_trader last edited by

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

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
                $(document).ready(function () { app.coldLoad(); }); }