Strategy vault / Machine learning
ADX EFI 50 Moving Average Channel Pullback Strategy
This strategy uses a combination of the 50-period moving average channel, ADX directional index and EFI energy index for trend trading. When the EFI energy index shows a trend start, it enters the market during a…
Overview
This strategy uses a combination of the 50-period moving average channel, ADX directional index and EFI energy index for trend trading. When the EFI energy index shows a trend start, it enters the market during a pullback within the 50 MA channel area. The strategy is suitable for the 1-minute timeframe.
Strategy Logic
Calculate the 50-period moving average channel, with the upper band being the moving average of high prices and the lower band being the moving average of low prices.
Calculate the ADX directional index to determine trend strength, and only consider trading during strong trends (ADX>20).
Calculate the long-term (120-period) and short-term (15-period) EFI energy indexes. The long-term index above 0 indicates an overall upward trend in energy, while the short-term index below 0 indicates a short-term uptrend retreat.
When the long and short term EFI indexes give a buy signal, and the price pulls back to the 50 MA channel, a long position is taken.
When the long and short term EFI indexes give a sell signal, and the price pulls back to the 50 MA channel, a short position is taken.
Advantage Analysis
This strategy combines trend, momentum and pullback signals to effectively filter out most false breakouts. The specific advantages are:
The 50 MA channel clearly determines the main trend direction.
The ADX index ensures trading only occurs during clear trends, avoiding whipsaws in ranging markets.
The EFI index captures trend energy surges for low-risk entry points.
Waiting for pullbacks allows better risk-reward ratios.
Multiple indicator combinations effectively filter false breakout risks.
Risk Analysis
The main risks of this strategy are:
Strong trends can also have larger pullbacks, requiring wider stop-loss ranges.
In ranging markets, the EFI may give false signals, requiring pairing with trend-filtering indicators like ADX.
Pullbacks that are too deep can miss entry points, possibly requiring MA tuning.
A single trading instrument fails to diversify market systematic risks.
Optimization Directions
This strategy can be improved in several aspects:
Test on more instruments to find optimal universal parameters.
Add profit-taking via trailing stop losses.
Parameter optimization of ADX, EFI settings and more.
Incorporate machine learning for robust trend vs false breakout detection.
Add multi-timeframe analysis with position sizing between timeframes.
Evaluate more trend-filtering indicators to improve signal quality.
Summary
Overall this is an excellent trend pullback strategy for beginners, combining trend, momentum and pullback signals to filter false breakouts. With refinements in stop-loss, parameter tuning, timeframes and more, it can become a robust trend following system. In summary, a very practical and research-worthy trend trading strategy.
Source Pine Script
/*backtest
start: 2023-08-19 00:00:00
end: 2023-09-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © trent777brown
//@version=5
// strategy("adx efi 50 ema channel, trend pullback", overlay=true, margin_long=100, margin_short=100, currency=currency.USD, initial_capital= 100000, close_entries_rule="ANY")
//bollingerbands
[basis, upperband, lowerband]= ta.bb(ohlc4, 50, 3)
[basis2, upperband2, lowerband2]= ta.bb(ohlc4, 50, 2)
psar= ta.sar(.1, .1, .09)
ema50= ta.ema(hlc3, 50)
ema50hi= ta.ema(high, 50)
ema50lo= ta.ema(low, 50)
ema18= ta.wma(hlc3, 15)
wma9= ta.wma(open, 9)
wma5= ta.wma(ohlc4, 5)
ema34= ta.rma(hlc3, 10)
[macdline, signalline, histline]= ta.macd(hlc3, 5, 34, 5)
[macdline2, signalline2, histline2]= ta.macd(hlc3, 15,70, 24)
[diplus, diminus, adx]= ta.dmi(20, 20)
[diplus2, diminus2, adx2]= ta.dmi(12, 12)
rsi= ta.rsi(hlc3, 14)
rsisma= ta.sma(rsi, 10)
stoch= ta.stoch(close, high, low, 21)
k= ta.wma(stoch, 3)
d= ta.wma(k, 3)
trendline5= ta.wma(hlc3, 300)
trendline9= ta.wma(open, 540)
trendline18= ta.wma(open, 1080)
atr=ta.atr(14)
plot(psar, color=color.red, style=plot.style_circles)
plot(ema50, color=color.white, linewidth=4)
plot(ema50hi, color=color.yellow, linewidth=4)
plot(ema50lo, color=color.yellow, linewidth=4)
plot(ema34, color=color.aqua, linewidth=4)
plot(wma9, color=color.gray, linewidth=4)
plot(wma5, color=color.lime, linewidth=4)
plot(trendline18, color=color.orange, linewidth=4)
plot(upperband, color=color.navy, linewidth=4)
plot(lowerband, color=color.navy, linewidth=4)
plot(upperband2, color=color.navy, linewidth=4)
plot(lowerband2, color=color.navy, linewidth=4)
plot(trendline9, color=color.maroon, linewidth=4)
plot(trendline5, color=color.yellow, linewidth=4)
efi = ta.rma(ta.change(close) * volume, 15)
efi2= ta.rma(ta.change(close) * volume, 120)
buy= efi2 > 0 and efi < 0 and efi[1] < efi and adx >= 20 and open < ema50hi
sell= efi2 < 0 and efi > 0 and efi[1] > efi and adx >= 20 and open > ema50lo
//ell= rsi > 50 and ta.crossunder(wma5, wma9) and psar > high and ema18 <= ema50hi and macdline > 0 and macdline < signalline
//buy= ta.crossunder(close, ema50) and rsi < 50 and adx2 < adx2[1] and k < 25 and psar > high
//uy= rsi < 60 and ta.crossover(wma5, wma9) and psar < low and ema18 >= ema50 and macdline2 > 0 and diplus2 < 30 // and histline2 < 0
//buy= ema18 > ema50 and ta.crossunder(rsi, 45) and open < ema50hi and adx2[3] < adx2 and diplus2 < 25 and macdline < 0 and adx < 10
//sell= ta.crossover(close, ema50) and rsi > 50 and adx2 < adx2[1] and k > 75 and psar < low
//ell= ema18 < ema50 and ta.crossover(rsi, 60) and open > ema50lo and diminus2 < 30 and macdline2 < 0 and adx2[2] < adx2
//buy sell conditions 1
//buy= ta.crossover(wma5, ema18) and ema18 > ema50lo and diplus > 22 and diminus < 22 and adx > 15
//ell= ta.crossover(psar, high) and macdline2 < signalline2 and rsi < rsisma
//when conditions
buytrig= ema34 >= ema50lo
selltrig= ema34 <= ema50hi
//strategy
sl= low - atr * 8
tp= high + atr * 4
sellsl= high + atr * 8
selltp= low - atr * 4
if(buy)
strategy.entry("buy", strategy.long, when= buytrig)
strategy.exit("exit buy", "buy", limit= tp, stop= sl)
strategy.close("close", when= ta.crossunder(ema34, ema50lo))
if(sell)
strategy.entry("sell", strategy.short, when= selltrig)
strategy.exit("exit sell", "sell", limit= selltp, stop= sellsl)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-19. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/ADX-EFI-50-Moving-Average-Channel-Pullback-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Triple Moving Average Combined with MACD Quantitative StrategyPine Script · Machine learning · 1d
- Multi indicator Combination StrategyPine Script · Machine learning · 1d
- Multi indicator Assisted StrategyPine Script · Machine learning · 1d
- Multi Indicator Comprehensive Analysis Quantitative Trading Strategy Trend Momentum and Volatility Collaborative Prediction ModelPine Script · Momentum · 3m
- Advanced Multi Indicator Trend Following and Momentum Quantitative Trading StrategyPine Script · Momentum · 1h
- EMA and RSI Quantitative Trading StrategyPine Script · Machine learning · 1h