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/

    Creating buy order with trailing stop and take profit. All in one

    General Code/Help
    4
    6
    2257
    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.
    • S
      sunnyalgotrader last edited by

      Re: Trailing stop loss

      Hi, I have searched forum and found few relevant discussions. Specifically I have read
      https://community.backtrader.com/topic/163/trailing-stop-loss/3

      What I want do is following:

      • Create a Buy order, let's say at price = 100, trailingstop = 10, takeprofit =20

      I see there are new order types like StopTrail, but they are still separate orders?

      Is there a way to create one order which has parameters to define buying price, trailiningstop and takeprofit (all in one) ?
      If yes, please share code snippet, that would really help.

      If not, how backtrader ties up a Buy order to another corresponding StopTrail order created for it?

      Thanks

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

        Bracket Orders

        S 1 Reply Last reply Reply Quote 2
        • S
          sunnyalgotrader @ab_trader last edited by

          @ab_trader
          Hi,

          Thanks for your answer. It works and allows to specify all in one. However, I noticed, if I am issuing a buy bracket order and skip mentioning the
          limitprice parameter, it still submits a limit order with same price as the buy order.

          I am sure this is the norm, which means if using bracket orders, we will always have 3 orders in action ?

          What if I only want to place a buy order with a trailing stop. What's the most elegant way to achieve this in backtrader ?

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

            @sunnyalgotrader
            from the first look into docs bt always issues 3 orders. If it is true, then I would set limit price very far from entry price, so the chances to get there are low. But maybe @backtrader can clarify this question and offer better solution.

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

              Actually version 1.9.61.122 allows the suppression of one of the two brackets.

              See: Community - Release 1.9.61.122

              Look for the reference in the corresponding methods of the strategy: buy_bracket, sell_bracket. See: Docs - Strategy

              ? 1 Reply Last reply Reply Quote 1
              • ?
                A Former User @backtrader last edited by

                Make sure to use the appropriate stop. In a volatile market, a StopTrailLimit vs StopTrail(Market) can cost you a lot of money.

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