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



  • 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
    


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


Log in to reply
 

});