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

Trail Orders don't use high and low, is that on purpose?



  • Browsing throw the code, I found that trailadjust use "pclose" when adjusting the price of the trail stoploss.
    Shouldn't it use high or low, depending of order type?
    For example, for a sell trailing stoploss, with trailpercent is 0.05, and my OHLC is 100-105-98-103 for the day, it will set a new threshold at 103*(1-.05) instead of 105*1(1-.05).

    Am I wrong, or is my assumption incorrect ?

    Thanks :)



  • @KevinSL said in Trail Orders don't use high and low, is that on purpose?:

    Shouldn't it use high or low, depending of order type?

    This is bt implementation. Trailing stop orders can be developed based on a lot of different things: high/low channels, moving averages, close price channels, parabolic SAR etc.



  • Hi,

    I find it inconvenient when using daily bars to get the trailing stop calculated by backtrader on the close value of my daily candle, but not on the high value of it (in case of going long).

    I am not yet trading live but I would assume that a broker like Interactive Brokers will adjust the trailing stop on a finer timescale than daily, even if I requested to get daily data from it via backtrader, wouldn`t it? Correct me if I am wrong.

    Is there any workaround during pure backtesting, so that the high value of a daily candle is used for calculation instead of the close?

    If there is a workaround, code examples are welcome. :-)

    Thanks in advance!



  • I think @ab_trader has the best experience for this question. I'm using a manual solution at this time. See this early thread on the topic.



  • Thanks @run-out for your comment.

    As far as I understand the code example given in Below is full code for sample trading system, implementing fixed stop loss and take profit orders., this takes care for adjusting the trailing stop from one next() to another.

    This might be too late, if during one day I have a very big high, as any closing of the trade will come only at the following day, isn't it?



  • @NewestTrader said in Trail Orders don't use high and low, is that on purpose?:

    This might be too late, if during one day I have a very big high, as any closing of the trade will come only at the following day, isn't it?

    Yes, using the daily bars trailing stop price calculated based on the high of the bar can be updated only after the current bar closure and can be matched (=order executed) only on the next bar. If you think this is late, than you need to move to intraday data or use limit order, which can close your position in case of large price move.


Log in to reply
 

});