Trailing stop in Backtesting

Forums ProRealTime English forum ProOrder support Trailing stop in Backtesting

Viewing 15 posts - 1 through 15 (of 18 total)
  • #6517

    Dear all,

    I wrote a system which behaves completely different in Backtesting and Proorder.

    I think it’s due to the fact of using trailing stop.

    Does somebody know when a trailing stop is executed in backtesting?

    to my knowledge  in ProOrder it is executed when the situation occurs. e.g. Program runs in 15 min timeframe and trailing stop is reached within the 15 minutes then it’s immediately executed.

    thanks for your help

    Klaus

    #6571

    Hello Klaus,

    This difference occur because conditions are only tested once per bar. In the backtest, trailing stop move stoploss to a price that will be tested only one time each time a new bar will open. In real time, your stoploss will be executed instantly by the broker because your SL is written in his order book.

    In a near future, backtest will be improved to be more accurate and better reflect real time trading.

    #6593

    Hi Nicolas,

     

    thanks for the explanation, i just tested again. What I see is, that the close of an order is done random since it’s not always the price at the close of a candle. Just want to find out under which conditions a close is done. In the attached example the trailing stop was 10 points.

     

     

    #6598

    It’s because trailing are made on the same candle that the trade opened and Probacktest has no clue of how the ticks went on this candle in real time.

    #6606

    Thanks Nicolas,

    I understood, the ticks are not known. If the trailing stop is reached at the end of the candle, the order will be closed. What I would like to know, at what price the order is closed. Is it the closing price of the candle, or something calculated based on various factors?

    By the way, I am new in this forum and have to say it’s very useful. Especially your assistance and knowledge

    #6608

    The order is closed at the price level the trailing stop has moved your stoploss to. But if you are trading (for example) the 1 hour timeframe, your stoploss may has occurred between the beginning of the candle and its end. Since there is no way actually to know at what time it occurred, the backtest only test if the stoploss price was between the high and low of the candlestick and close your trade at the next open bar (in backtest only).

    #6694

    short info about progress:

    I modified the program. removed trailing stop and instead check at next open bar if trailing level is reached and closed order. But the result of this version is different to the trailing stop version. Unfortunately. Maybe my mistake have to check code again.

    #6702

    If you can post your code here, I could have a look about what’s going wrong.

    #6704

    Hi Nicolas,

    thanks a lot for your help. I’ll return home tomorrow. then will post ist.

     

    cu Klaus

    #6748

    Here it is Nicolas,

    the program run on DAX in 15 minute timeframe

    this is with trailing stop

     

    and this one with the simulation

     

     

    #6767

    Thanks for the code. What you have written between the lines 19 to 26 is a basic stoploss test at 9 points from the order open price. There is no ‘trailing’ here 😉

    I’ll post a complete trailing stop code later in this thread.

     

    #6777

    yes, the idea was to simulate what backtest is doing, as you described in one of the previous posts.

    nice try. 🙂

     

    #6782

    I have just written an article about trailing stop implementation into a strategy, please find it here :

    http://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/

    If you need assistance, just ask! 🙂

    #6855

    Nicolas,

    I tested your manual trailing stop. Results are quiet different from real trailing stop.

    Just read your reply on “Backtest vs Real trading limits and stops”. This explains why we never will have same results

    ok. Lets wait for another version of prt.

    anyhow, thanks for your help

    cu Klaus

    #10521

    Hi Klaus,

    How different were your results? In my case it made relatively profitable system to be a significant loss system. Both, i believe, based on the end of bar information and real performance is a big question.

Viewing 15 posts - 1 through 15 (of 18 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login