Timeframe
15m
Direction
Long & Short
Stoploss
-2.5%
Trailing Stop
Yes
ROI
0m: 10.0%, 960m: 6.0%, 2880m: 3.0%, 5760m: 0.0%
Interface Version
3
Startup Candles
500
Indicators
5
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
"""
MTF_Strict - 1d EMA200 directional filter, no neutral trading
Bull → only long. Bear → only short. Neutral → no trade.
"""
from pandas import DataFrame
import talib.abstract as ta
import numpy as np
from freqtrade.strategy import IStrategy
class MTF_Strict(IStrategy):
INTERFACE_VERSION = 3
timeframe = '15m'
can_short = True
stoploss = -0.025
trailing_stop = True
trailing_stop_positive = 0.004
trailing_stop_positive_offset = 0.020
trailing_only_offset_is_reached = True
minimal_roi = {"0": 0.10, "960": 0.06, "2880": 0.03, "5760": 0}
max_open_trades = 8
startup_candle_count = 500
process_only_new_candles = True
use_exit_signal = False
def populate_indicators(self, d, m):
# 15m trend
d['e20'] = ta.EMA(d, 20)
d['e50'] = ta.EMA(d, 50)
macd = ta.MACD(d, 12, 26, 9)
d['md'] = macd['macd']
d['ms'] = macd['macdsignal']
d['adx'] = ta.ADX(d, 14)
d['di_plus'] = ta.PLUS_DI(d, 14)
d['di_minus'] = ta.MINUS_DI(d, 14)
d['vr'] = d['volume'] / ta.SMA(d['volume'], 20)
# 1d regime
d['ema200_1d'] = ta.EMA(d, 19200)
d['ema200_rising'] = d['ema200_1d'] > d['ema200_1d'].shift(96)
d['ema200_falling'] = d['ema200_1d'] < d['ema200_1d'].shift(96)
d['regime_bull'] = (d['close'] > d['ema200_1d']) & d['ema200_rising']
d['regime_bear'] = (d['close'] < d['ema200_1d']) & d['ema200_falling']
d['rsi'] = ta.RSI(d, 14)
return d
def populate_entry_trend(self, d, m):
# V6 base conditions
long_v6 = (
(d['e20'] > d['e50']) & (d['close'] > d['e50']) &
(d['md'] > d['ms']) & (d['adx'] > 20) &
(d['di_plus'] > d['di_minus']) & (d['vr'] > 0.8) &
(d['volume'] > 0)
)
short_v6 = (
(d['e20'] < d['e50']) & (d['close'] < d['e50']) &
(d['md'] < d['ms']) & (d['adx'] > 20) &
(d['di_minus'] > d['di_plus']) & (d['vr'] > 0.8) &
(d['volume'] > 0)
)
# STRICT: bull only long, bear only short, neutral trades NOTHING
d.loc[long_v6 & d['regime_bull'] & (d['rsi'] < 75), ['enter_long', 'enter_tag']] = (1, 'L_strict')
d.loc[short_v6 & d['regime_bear'] & (d['rsi'] > 25), ['enter_short', 'enter_tag']] = (1, 'S_strict')
return d
def populate_exit_trend(self, d, m): return d