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/

    Question on order

    General Discussion
    3
    7
    1557
    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.
    • N
      Nagesh G.R. last edited by

      I have a question on order and how to achieve it. In a day assume price pattern is like this:
      open 10, High: 11 Low:6, Close:7

      I want to do checking on these prices and give order to execute on the same day.
      For example, I want to check whether my stop loss that is set at 8 is hit. In this case since low is 6, so it falls within that range. So I want to exit position on the same day at 8 (my stop loss). Is it feasible?

      An additional point, I have a stop and target price, it needs to check both and see whether price is hit and issue order accordingly.

      I referred this link. But since it has only open, it may not serve my purpose:
      https://www.backtrader.com/blog/posts/2016-07-13-day-in-steps/day-in-steps.html

      Thanks in advance

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

        In case of stop loss and take profit orders you don't need to check prices. Just issue the appropriate order(stop or limit) and backtrader will execute it if price will allow it.

        Here is more description on the order execution -
        https://www.backtrader.com/docu/order-creation-execution/order-creation-execution.html

        Also you may want to check parallel thread about stop losses -
        https://community.backtrader.com/topic/163/trailing-stop-loss

        N 1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators last edited by

          To execute on the same day you want to use cheat-on-close. See: Docs - Broker

          You can evaluate the prices and issue an order which will be executed on the same bar.

          N 1 Reply Last reply Reply Quote 0
          • N
            Nagesh G.R. @ab_trader last edited by

            @ab_trader Thank you very much for guiding. It was very helpful.

            1 Reply Last reply Reply Quote 0
            • N
              Nagesh G.R. @backtrader last edited by

              @backtrader Thanks a lot. I tried. Its very easy way to do. I suspect cheat-on-close behaves differently depending on whether we are acting on position already present (self.position). When acted on a position thats freshly initiated (if not self.position), its taking today's value. Otherwise its moving to next day value. I didn't investigate in detail. But thought will share observation anyway.

              1 Reply Last reply Reply Quote 0
              • B
                backtrader administrators last edited by

                cheat-on-close makes no difference with regards to an existing position. This functionality is implemented in the broker and looks only at what an order is asking for.

                If you think there is something wrong, a sample would be needed to understand what's happening.

                N 1 Reply Last reply Reply Quote 0
                • N
                  Nagesh G.R. @backtrader last edited by

                  @backtrader You are right. I messed up elsewhere. Kindly ignore. Sorry.

                  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(); }); }