Update docs to not promote stoploss / take-profit

This commit is contained in:
Matthias 2021-04-28 20:36:06 +02:00
parent cc916ab2e9
commit 7c8a367442
2 changed files with 14 additions and 12 deletions

View File

@ -44,9 +44,9 @@ class AwesomeStrategy(IStrategy):
## Custom sell signal
It is possible to define custom sell signals. This is very useful when we need to customize sell conditions for each individual trade.
It is possible to define custom sell signals. This is very useful when we need to customize sell conditions for each individual trade, or if you need the trade profit to take the sell decision.
An example of how we can set stop-loss and take-profit targets in the dataframe and also sell trades that were open longer than 1 day:
An example of how we can use different indicators depending on the current profit and also sell trades that were open longer than 1 day:
``` python
from freqtrade.strategy import IStrategy, timeframe_to_prev_date
@ -58,21 +58,22 @@ class AwesomeStrategy(IStrategy):
trade_row = dataframe.loc[dataframe['date'] == trade_open_date].squeeze()
# Sell when price falls below value in stoploss column of taken buy signal.
if 'stop_loss' in trade_row:
if current_rate <= trade_row['stop_loss'] < trade.open_rate:
return 'stop_loss'
# above 20% profit, sell when rsi < 80
if current_profit > 0.2:
if trade_row['rsi'] < 80:
return 'rsi_below_80'
# Sell when price reaches value in take_profit column of taken buy signal.
if 'take_profit' in trade_row:
if trade.open_rate < trade_row['take_profit'] <= current_rate:
return 'take_profit'
# Between 2% and 10%, sell if EMA-long above EMA-short
if 0.02 < current_profit < 0.1:
if trade_row['emalong'] > trade_row['emashort']:
return 'ema_long_below_80'
# Sell any positions at a loss if they are held for more than two days.
if current_profit < 0 and (current_time.replace(tzinfo=trade.open_date_utc.tzinfo) - trade.open_date_utc).days >= 1:
if current_profit < 0.0 and (current_time - trade.open_date_utc).days >= 1:
return 'unclog'
```
See [Custom stoploss using an indicator from dataframe example](strategy-customization.md#custom-stoploss-using-an-indicator-from-dataframe-example) for explanation on how to use `dataframe` parameter.
See [Custom stoploss using an indicator from dataframe example](#custom-stoploss-using-an-indicator-from-dataframe-example) for explanation on how to use `dataframe` parameter.
## Custom stoploss

View File

@ -251,7 +251,8 @@ class Backtesting:
sell_row: Tuple) -> Optional[LocalTrade]:
sell = self.strategy.should_sell(dataframe, trade, sell_row[OPEN_IDX], # type: ignore
sell_row[DATE_IDX], sell_row[BUY_IDX], sell_row[SELL_IDX],
sell_row[DATE_IDX].to_pydatetime(), sell_row[BUY_IDX],
sell_row[SELL_IDX],
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX])
if sell.sell_flag: