Calculates the Average Directional Index (ADX), Directional Movement Index (DMI), and an Exponential Moving Average to trade strong directional momentum.
//@version=5
strategy("ADX Trend Strength - Eterna",
overlay=true,
initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=10,
commission_type=strategy.commission.percent,
commission_value=0.075)
// ==================== Parameters ====================
adxLength = input.int(14, "ADX Length", minval=1)
adxThreshold = input.int(25, "ADX Threshold", minval=1)
diLength = input.int(14, "DI Length", minval=1)
emaLength = input.int(50, "Trend EMA", minval=1)
leverage = input.int(5, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, step=0.001)
webhookMessage = input.string('{"action":"{{strategy.order.action}}", "symbol":"{{ticker}}", "size":' + str.tostring(positionSize) + ', "leverage":' + str.tostring(leverage) + '}',
"Webhook JSON", group="Webhook")
// ==================== ADX Calculation ====================
[diPlus, diMinus, adx] = ta.dmi(diLength, adxLength)
trendEMA = ta.ema(close, emaLength)
// ==================== Entry Conditions ====================
// Strong trend: ADX above threshold
strongTrend = adx > adxThreshold
// Bullish: DI+ crosses above DI- with strong ADX and price above EMA
bullishDI = ta.crossover(diPlus, diMinus)
longCondition = bullishDI and strongTrend and close > trendEMA
// Bearish: DI- crosses above DI+ with strong ADX and price below EMA
bearishDI = ta.crossover(diMinus, diPlus)
shortCondition = bearishDI and strongTrend and close < trendEMA
// Exit when DI crosses opposite or ADX drops below threshold
exitLong = ta.crossunder(diPlus, diMinus) or adx < adxThreshold * 0.7
exitShort = ta.crossover(diPlus, diMinus) or adx < adxThreshold * 0.7
// ==================== Strategy Execution ====================
if longCondition
strategy.entry("Long", strategy.long, alert_message=str.replace(webhookMessage, "{{strategy.order.action}}", "buy"))
if shortCondition
strategy.entry("Short", strategy.short, alert_message=str.replace(webhookMessage, "{{strategy.order.action}}", "sell"))
if exitLong
strategy.close("Long", alert_message='{"action":"close", "symbol":"{{ticker}}"}')
if exitShort
strategy.close("Short", alert_message='{"action":"close", "symbol":"{{ticker}}"}')
// ==================== Plotting ====================
plot(trendEMA, "Trend EMA", color=color.orange, linewidth=2)
// Plot ADX in separate pane (will appear as overlay labels)
plotshape(longCondition, "Long Signal", shape.triangleup, location.belowbar, color.green, size=size.normal,
text="ADX:" + str.tostring(adx, "#.#"))
plotshape(shortCondition, "Short Signal", shape.triangledown, location.abovebar, color.red, size=size.normal,
text="ADX:" + str.tostring(adx, "#.#"))
// Background color based on trend strength
bgcolor(strongTrend ? (diPlus > diMinus ? color.new(color.green, 92) : color.new(color.red, 92)) : color.new(color.gray, 95))
// Show DI crossovers
plotshape(bullishDI and strongTrend, "DI+ Cross", shape.circle, location.belowbar, color.new(color.green, 50), size=size.tiny)
plotshape(bearishDI and strongTrend, "DI- Cross", shape.circle, location.abovebar, color.new(color.red, 50), size=size.tiny)
Overview
ADX Trend Strength - Eterna enters long when the DI+ line crosses above DI- while ADX exceeds a threshold and price is above the EMA. Short positions trigger under mirrored conditions. Trades exit when directional indicators cross back or ADX falls below a fraction of the threshold. It plots the EMA, background trend highlights, and signal markers on the price chart, operating without a hard stop loss.
ADX and Directional Movement Index trend filter
EMA baseline trend confirmation
Dynamic exits on DI reversal or ADX decline
Configurable webhook alert formatting
Visual background coloring based on trend strength
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the
This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can
This strategy combines Arnaud Legoux Moving Average percentage price change calculations with an adaptive Gaussian Moving Average to generate trend-following signals. Long and short entries are triggered when the ALMA change calculation crosses above or below
This strategy generates trading signals based on a selectable momentum engine, supporting MACD, RSI, Stochastic, or Rate of Change. Entries trigger on signal crosses, zero-line crosses, or threshold crosses, with an optional moving average trend filter. Risk m
255 EMA Strategy combines an exponential moving average with Average True Range bands and standard MACD crossovers to generate entry signals. Drawn directly on the price chart, it plots the central 255 EMA along with upper and lower volatility envelopes. Trade
This strategy evaluates simple moving averages and the Relative Strength Index to generate trading signals. It calculates a 10-period SMA, a 30-period SMA, and a 14-period RSI. Long positions are entered when the fast SMA crosses above the slow SMA while RSI i