Update docs to not promote stoploss / take-profit
This commit is contained in:
parent
cc916ab2e9
commit
7c8a367442
@ -44,9 +44,9 @@ class AwesomeStrategy(IStrategy):
|
|||||||
|
|
||||||
## Custom sell signal
|
## 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
|
``` python
|
||||||
from freqtrade.strategy import IStrategy, timeframe_to_prev_date
|
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()
|
trade_row = dataframe.loc[dataframe['date'] == trade_open_date].squeeze()
|
||||||
|
|
||||||
# Sell when price falls below value in stoploss column of taken buy signal.
|
# Sell when price falls below value in stoploss column of taken buy signal.
|
||||||
if 'stop_loss' in trade_row:
|
# above 20% profit, sell when rsi < 80
|
||||||
if current_rate <= trade_row['stop_loss'] < trade.open_rate:
|
if current_profit > 0.2:
|
||||||
return 'stop_loss'
|
if trade_row['rsi'] < 80:
|
||||||
|
return 'rsi_below_80'
|
||||||
|
|
||||||
# Sell when price reaches value in take_profit column of taken buy signal.
|
# Between 2% and 10%, sell if EMA-long above EMA-short
|
||||||
if 'take_profit' in trade_row:
|
if 0.02 < current_profit < 0.1:
|
||||||
if trade.open_rate < trade_row['take_profit'] <= current_rate:
|
if trade_row['emalong'] > trade_row['emashort']:
|
||||||
return 'take_profit'
|
return 'ema_long_below_80'
|
||||||
|
|
||||||
# Sell any positions at a loss if they are held for more than two days.
|
# 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'
|
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
|
## Custom stoploss
|
||||||
|
|
||||||
|
@ -251,7 +251,8 @@ class Backtesting:
|
|||||||
sell_row: Tuple) -> Optional[LocalTrade]:
|
sell_row: Tuple) -> Optional[LocalTrade]:
|
||||||
|
|
||||||
sell = self.strategy.should_sell(dataframe, trade, sell_row[OPEN_IDX], # type: ignore
|
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])
|
low=sell_row[LOW_IDX], high=sell_row[HIGH_IDX])
|
||||||
|
|
||||||
if sell.sell_flag:
|
if sell.sell_flag:
|
||||||
|
Loading…
Reference in New Issue
Block a user