Backtrader Community

    • 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/

    Found it hard to control buy and sell at the exact bar position/timing

    General Code/Help
    2
    5
    82
    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.
    • J
      JamesPP last edited by

      Hi all,

      I found it is difficult to use the APIs (together with COC and COO) to control buy and sell at different locations of the bars. For example, just for the sake of being able to control, I want to buy with market orders at the open of every bar and sell at the close at the same bar on odd days, and sell at the open with market orders and buy at the close at the same bar on even days. How can I implement that?

      I cannot seem to find an easy way to do that easy strategy. Can anyone please help?

      E 1 Reply Last reply Reply Quote 0
      • E
        EMR @JamesPP last edited by

        @jamespp An easy solution would be to use lower time frame inside the bars you want to "cheat" with coc & coo.

        J 1 Reply Last reply Reply Quote 0
        • J
          JamesPP @EMR last edited by

          @emr thank you for replying to me. How to do generate that lower timeframe data? You meant to split the original bar into 2 (or maybe 3) bars which are right after open and right before close? do you have some example for doing that?

          J E 2 Replies Last reply Reply Quote 0
          • J
            JamesPP @JamesPP last edited by

            @EMR @backtrader could you experts help here please? I am stuck here. thank you

            1 Reply Last reply Reply Quote 0
            • E
              EMR @JamesPP last edited by

              @jamespp To use lower time frame, you have to have lower time frame data. Ex. : instead of using 1 hour data, you can use 1 mn data, aggregate it to obtain 1 hour data and use the underlying 1 mn data to enter and exit trades.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors