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/

    how to execute on the close price of the next bar

    General Code/Help
    2
    5
    64
    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.
    • E
      ellery last edited by

      Hello,I come across a problem that I want my order executed on the close price of next bar instead of the open price.Since I use minute-based data,"order.Close" cannot deal with my problem.It is not executed by next minute.I also try to use coc,but it executed on the close of this bar,it is not what I want.

      I hope anyone can give me an opinion,thanks a lot!

      E 1 Reply Last reply Reply Quote 0
      • F
        flix last edited by

        newbie here.

        self.buy(price=self.dataclose[1]) may help

        E 2 Replies Last reply Reply Quote 0
        • E
          ellery @flix last edited by

          @flix thanks,I will have a try,hope it works.

          1 Reply Last reply Reply Quote 0
          • E
            ellery @flix last edited by

            @flix It doesn't work,the order is still executed on the open price of next bar

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

              @ellery said in how to execute on the close price of the next bar:

              Hello,I come across a problem that I want my order executed on the close price of next bar instead of the open price.Since I use minute-based data,"order.Close" cannot deal with my problem.It is not executed by next minute.I also try to use coc,but it executed on the close of this bar,it is not what I want.

              I hope anyone can give me an opinion,thanks a lot!

              The reason why using this method is that I want to backtest on bid_ask data. As I buy on ask price and sell on bid price, I have to trade on two different prices instead of the open price.Then I set bid as open and ask as close, with selling on the next open and buying on the next close.But how could I to make it in practice?

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