Freqtrade: Trailing stoploss overtaking ROI in backtesting.

Created on 29 Apr 2020  路  4Comments  路  Source: freqtrade/freqtrade

Step 1: Have you search for this issue before posting it?

If you have discovered a bug in the bot, please search our issue tracker.
If it hasn't been reported, please create a new issue.

Step 2: Describe your environment

  • Operating system: ubuntu-1804-bionic-v20200218
  • Python Version: 3.7.6
  • CCXT version: ccxt==1.23.30
  • Branch: Master | Develop
  • Last Commit ID: ab71d1b9

Step 3: Describe the problem:

In live mode the bot is selling exactly as configured but the backtester ignores the minimal roi and uses the trailing stoploss and sells at higher profit.

Steps to reproduce:

Config and strategy parameter
image

image

Observed Results:

  • What happened?

backtest result
image

  • What did you expect to happen?
    live mode
    image

    Relevant code exceptions or logs:

This is not isolated to one strategy it's happening on all and i have tested on the latest version the results are same.

Backtest Question Wont fix / Not a bug

All 4 comments

Well this is intended behaviour.

please read and understand the documentation regarding backtesting assumptions.

Stoplosses will ALWAYS be evaluated first (this includes trailing stoploss) to protect users capital.

Since we don't know what happens intra-candle during backtesting, freqtrade has to take certain assumptions.
This problem is obviously bigger when using longer timeframes (it's less obvious when using 5m candles), since the movements / % changes become bigger with bigger timeframes.

So what happens is simply the following:

  • stoploss logic pulls stoploss to "high - 0.75%".
  • stoploss is evaluated (since low is < 0.75% it'll trigger).

Now if this is correct or wrong obviously depends if high happens before low or viceversa - but this information is unavailable during backtesting.

To summarize,

backtesting tries to be conservative, and tries to always evaluate stoplosses first.
The endresult will show you slightly lower results for backtesting, and higher profits in live.
This is intentional, and reversing the above logic would cause the reverse behaviour if the intra-candle movements were different.

Basically i need to increase my roi and put my strategies on trailing stoploss to benefit the most.

But we should highlight this in docs to let people know stoploss including trailing stoploss have higher privilege in backtesting. And minmal roi wont be able to get executed properly in backtester.
As results are different and one might get confused.

But we should highlight this in docs

馃憤 Pls review: https://github.com/freqtrade/freqtrade/pull/3235

And minmal roi wont be able to get executed properly in backtester.

Well this is not correct. It is executed properly - unless stoploss triggers first (as said above - being conservative and assuming the worse scenario).

Personally, i find 0.75% on trailing stop too tight - but in combination with the offset it MAY work ... although i think this can still trigger early - depending on your pairs (certain pairs have a spread higher than this ...).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

issamBD picture issamBD  路  4Comments

nickbarmore7 picture nickbarmore7  路  4Comments

King-Techno picture King-Techno  路  3Comments

Axel-CH picture Axel-CH  路  3Comments

rraallvv picture rraallvv  路  3Comments