|
3 | 3 | import talib.abstract as ta
|
4 | 4 | from freqtrade.strategy.interface import IStrategy
|
5 | 5 | from freqtrade.strategy import (merge_informative_pair,
|
6 |
| - DecimalParameter, IntParameter, CategoricalParameter, stoploss_from_open) |
| 6 | + DecimalParameter, IntParameter, CategoricalParameter) |
7 | 7 | from pandas import DataFrame
|
8 | 8 | from functools import reduce
|
9 | 9 | from freqtrade.persistence import Trade
|
@@ -105,40 +105,23 @@ class MultiMA_TSL(IStrategy):
|
105 | 105 | # Number of candles the strategy requires before producing valid signals
|
106 | 106 | startup_candle_count: int = 300
|
107 | 107 |
|
108 |
| - # trailing stoploss hyperopt parameters |
109 |
| - # hard stoploss profit |
110 |
| - pHSL = DecimalParameter(-0.200, -0.040, default=-0.15, decimals=3, space='sell', optimize=False, load=True) |
111 |
| - # profit threshold 1, trigger point, SL_1 is used |
112 |
| - pPF_1 = DecimalParameter(0.008, 0.020, default=0.018, decimals=3, space='sell', optimize=False, load=True) |
113 |
| - pSL_1 = DecimalParameter(0.008, 0.020, default=0.013, decimals=3, space='sell', optimize=False, load=True) |
114 |
| - |
115 |
| - # profit threshold 2, SL_2 is used |
116 |
| - pPF_2 = DecimalParameter(0.040, 0.100, default=0.080, decimals=3, space='sell', optimize=False, load=True) |
117 |
| - pSL_2 = DecimalParameter(0.020, 0.070, default=0.040, decimals=3, space='sell', optimize=False, load=True) |
118 |
| - |
119 |
| - # Custom Trailing Stoploss by Perkmeister |
120 | 108 | def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime,
|
121 | 109 | current_rate: float, current_profit: float, **kwargs) -> float:
|
122 | 110 |
|
123 |
| - # hard stoploss profit |
124 |
| - HSL = self.pHSL.value |
125 |
| - PF_1 = self.pPF_1.value |
126 |
| - SL_1 = self.pSL_1.value |
127 |
| - PF_2 = self.pPF_2.value |
128 |
| - SL_2 = self.pSL_2.value |
129 |
| - |
130 |
| - # For profits between PF_1 and PF_2 the stoploss (sl_profit) used is linearly interpolated |
131 |
| - # between the values of SL_1 and SL_2. For all profits above PL_2 the sl_profit value |
132 |
| - # rises linearly with current profit, for profits below PF_1 the hard stoploss profit is used. |
133 |
| - |
134 |
| - if (current_profit > PF_2): |
135 |
| - sl_profit = SL_2 + (current_profit - PF_2) |
136 |
| - elif (current_profit > PF_1): |
137 |
| - sl_profit = SL_1 + ((current_profit - PF_1)*(SL_2 - SL_1)/(PF_2 - PF_1)) |
138 |
| - else: |
139 |
| - sl_profit = HSL |
140 |
| - |
141 |
| - return stoploss_from_open(sl_profit, current_profit) |
| 111 | + if (current_profit > 0.3): |
| 112 | + return 0.05 |
| 113 | + elif (current_profit > 0.2): |
| 114 | + return 0.04 |
| 115 | + elif (current_profit > 0.1): |
| 116 | + return 0.03 |
| 117 | + elif (current_profit > 0.06): |
| 118 | + return 0.02 |
| 119 | + elif (current_profit > 0.03): |
| 120 | + return 0.01 |
| 121 | + elif (current_profit > 0.018): |
| 122 | + return 0.005 |
| 123 | + |
| 124 | + return 0.99 |
142 | 125 |
|
143 | 126 | def get_ticker_indicator(self):
|
144 | 127 | return int(self.timeframe[:-1])
|
@@ -177,7 +160,7 @@ def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: f
|
177 | 160 | current_time: datetime, **kwargs) -> bool:
|
178 | 161 |
|
179 | 162 | current_profit = trade.calc_profit_ratio(rate)
|
180 |
| - if (sell_reason.startswith('sell signal ') and (current_profit > self.pPF_1.value)): |
| 163 | + if (sell_reason.startswith('sell signal (') and (current_profit > 0.018)): |
181 | 164 | # Reject sell signal when trailing stoplosses
|
182 | 165 | return False
|
183 | 166 | return True
|
|
0 commit comments