Timeframe
4h
Direction
Long & Short
Stoploss
-4.0%
Trailing Stop
Yes
ROI
0m: 12.0%, 480m: 8.0%, 1440m: 5.0%, 4320m: 3.0%
Interface Version
3
Startup Candles
300
Indicators
8
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
"""Winner 4h — same logic, larger timeframe"""
from pandas import DataFrame
import talib.abstract as ta
from freqtrade.strategy import IStrategy
class W4h(IStrategy):
INTERFACE_VERSION = 3; timeframe = '4h'; can_short = True
stoploss = -0.04; trailing_stop = True
trailing_stop_positive = 0.015; trailing_stop_positive_offset = 0.035
trailing_only_offset_is_reached = True
minimal_roi = {"0": 0.12, "480": 0.08, "1440": 0.05, "4320": 0.03, "8640": 0}
max_open_trades = 4; startup_candle_count = 300
process_only_new_candles = True; use_exit_signal = False
def populate_indicators(self, d, m):
d['e10'] = ta.EMA(d, 10); d['e30'] = ta.EMA(d, 30); d['e50'] = ta.EMA(d, 50)
md = ta.MACD(d); d['md'] = md['macd']; d['ms'] = md['macdsignal']
d['mom'] = ta.ROC(d, 3); d['adx'] = ta.ADX(d, 14)
d['vr'] = d['volume'] / ta.SMA(d['volume'], 20)
d['rsi'] = ta.RSI(d, 14)
d['atr'] = ta.ATR(d, 14) / d['close'] * 100
bb = ta.BBANDS(d, 20)
d['bb_pos'] = (d['close'] - bb['lowerband']) / (bb['upperband'] - bb['lowerband'] + 0.0001)
return d
def populate_entry_trend(self, d, m):
# Long: EMA多头 + MACD金叉 + 动量 + 趋势 + 不追高
d.loc[
(d['e10'] > d['e30']) & (d['md'] > d['ms']) & (d['mom'] > 0.2) &
(d['adx'] > 20) & (d['vr'] > 1.0) & (d['rsi'] < 70) &
(d['bb_pos'] < 0.85) & (d['volume'] > 0),
['enter_long', 'enter_tag']
] = (1, 'L')
# Short: EMA空头 + MACD死叉 + 动量 + 趋势 + 不追低
d.loc[
(d['e10'] < d['e30']) & (d['md'] < d['ms']) & (d['mom'] < -0.2) &
(d['adx'] > 20) & (d['vr'] > 1.0) & (d['rsi'] > 30) &
(d['bb_pos'] > 0.15) & (d['volume'] > 0),
['enter_short', 'enter_tag']
] = (1, 'S')
return d
def populate_exit_trend(self, d, m): return d
class W1d(IStrategy):
INTERFACE_VERSION = 3; timeframe = '1d'; can_short = True
stoploss = -0.06; trailing_stop = True
trailing_stop_positive = 0.025; trailing_stop_positive_offset = 0.05
trailing_only_offset_is_reached = True
minimal_roi = {"0": 0.20, "720": 0.12, "2160": 0.08, "4320": 0.05, "8640": 0}
max_open_trades = 3; startup_candle_count = 200
process_only_new_candles = True; use_exit_signal = False
def populate_indicators(self, d, m):
d['e10'] = ta.EMA(d, 10); d['e30'] = ta.EMA(d, 30); d['e50'] = ta.EMA(d, 50)
md = ta.MACD(d); d['md'] = md['macd']; d['ms'] = md['macdsignal']
d['mom'] = ta.ROC(d, 3); d['adx'] = ta.ADX(d, 14)
d['vr'] = d['volume'] / ta.SMA(d['volume'], 20)
d['rsi'] = ta.RSI(d, 14); d['atr'] = ta.ATR(d, 14) / d['close'] * 100
bb = ta.BBANDS(d, 20)
d['bb_pos'] = (d['close'] - bb['lowerband']) / (bb['upperband'] - bb['lowerband'] + 0.0001)
return d
def populate_entry_trend(self, d, m):
d.loc[
(d['e10'] > d['e30']) & (d['md'] > d['ms']) & (d['mom'] > 0.3) &
(d['adx'] > 22) & (d['vr'] > 1.0) & (d['rsi'] < 65) & (d['volume'] > 0),
['enter_long', 'enter_tag']
] = (1, 'L')
d.loc[
(d['e10'] < d['e30']) & (d['md'] < d['ms']) & (d['mom'] < -0.3) &
(d['adx'] > 22) & (d['vr'] > 1.0) & (d['rsi'] > 35) & (d['volume'] > 0),
['enter_short', 'enter_tag']
] = (1, 'S')
return d
def populate_exit_trend(self, d, m): return d