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/

    Trade on next bar at close

    General Code/Help
    1
    2
    41
    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.
    • A
      adamb032 last edited by

      I know that by default trades are executed on the next bar at the open price of it, and you can use cheat-on-close to trade on the current bar at the close, but what I was wondering if there is a way to trade on the next bar, but instead of the open, on the close.

      its looks like I could re-write the _try_exec_market function in the Broker class, but wondering if there is an easier way?

      My hack to do this has been to create a datas where the open=close, so that the open price is the close price, but that seems like a weird workaround.

      A 1 Reply Last reply Reply Quote 0
      • A
        adamb032 @adamb032 last edited by

        @adamb032 i found the solution to use exectype=Order.Close in the self.buy/sell parameters.

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