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/

    Cannot seem to adjust trailing stop

    General Code/Help
    1
    2
    80
    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.
    • B
      booboothefool last edited by

      Hi if I have code like this:

      self.long_order = self.buy_bracket(exectype=bt.Order.Stop, stopexec=bt.Order.StopTrail, size=qty, valid=self.valid,
                  limitprice=TP2_price,
                  
                  price=entry_price,
                  
                  stopprice=stoploss_price,
                  # trailpercent=0.05,
              )
      

      I see that its taking effect because I am getting trailing stop order notifications, and they are getting hit somehow as long as I specify stopexec=bt.Order.StopTrail.

      Buy Stops            - 68
      Sell Stops           - 120
      Trailing Stop Losses - 179
      Take Profits         - 9
      

      However when I try to change the trailing stop, for example have it trail by 5%:

      self.long_order = self.buy_bracket(exectype=bt.Order.Stop, stopexec=bt.Order.StopTrail, size=qty, valid=self.valid,
                  limitprice=TP2_price,
                  
                  price=entry_price,
                  
                  stopprice=stoploss_price,
                  trailpercent=0.05,
              )
      

      I get the same result, the value is not being adjusted.

      Buy Stops            - 68
      Sell Stops           - 120
      Trailing Stop Losses - 179
      Take Profits         - 9
      
      B 1 Reply Last reply Reply Quote 0
      • B
        booboothefool @booboothefool last edited by

        Oh, documentation kinda makes it look like it should go on the root level but it should be nested in stopargs. My mistake.

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