For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

StopTrail(Limit)


  • administrators

    Use the link below to go the original post

    Click here to see the full blog post



  • Many thanks DRo :D



  • Hi, thanks for the post. I realize this is an old post, but I like to clarify something. In an "ideal" back test, my traillig stop orders are based off high for each trading day for a buy (long) position, and off the low of the day for sell (short) postion. So, the trailing stop orders are updated each day after the close based on the highs and lows reached. If the next day, the low is below the trailing stop order, the long trade is closed for the day at the traling stop limit price, neglecting slippage. I see your example here all trail stops are based off the close, is there a way that I can impliment my way of testing? Can I choose the data set that the trailing stop orders are adjusted and executed based on? thanks.


  • administrators

    @michael172 said in StopTrail(Limit):

    I see your example here all trail stops are based off the close

    The trail stops are based off the latest available data point. Which when looking at a bar is the close. But when you have live data it will be the last incoming tick.

    @michael172 said in StopTrail(Limit):

    Can I choose the data set that the trailing stop orders are adjusted and executed based on?

    The functioning of the StopTrail order simulate what actual brokers offer. Your custom behavior has to be manually coded.



  • @backtrader Thanks for the quick reply. I understand what you are saying. It would be nice if I had intrady data when I do my backtest, then this wold work perfectly with data playback. Unfortunatly, I only have access to Open, High, Low, Close data, so I'll have to dig around to see if there is a sample code that does what I need or god forbid... have to write my own... :)