OPEN-SOURCE SCRIPT

EMA Trend Screener

76
//version=5

indicator("EMA Trend Screener", shorttitle="ETS", format=format.inherit)



// EMA Calculations

ema10 = ta.ema(close, 10)

ema20 = ta.ema(close, 20)

ema50 = ta.ema(close, 50)

ema100 = ta.ema(close, 100)

ema200 = ta.ema(close, 200)



// RSI Calculations

rsi_daily = ta.rsi(close, 14)

rsi_weekly = request.security(syminfo.tickerid, "1W", ta.rsi(close, 14))



// Core Conditions with 99% thresholds

price_above_10ema = close > (ema10 * 0.99)

ema10_above_20 = ema10 > (ema20 * 0.99)

ema20_above_50 = ema20 > (ema50 * 0.99)

ema50_above_100 = ema50 > (ema100 * 0.99)

ema100_above_200 = ema100 > (ema200 * 0.99)



// RSI Conditions

rsi_daily_bullish = rsi_daily > 50

rsi_weekly_bullish = rsi_weekly > 50



// EMA Spread Calculation

ema_max = math.max(ema10, math.max(ema20, math.max(ema50, math.max(ema100, ema200))))

ema_min = math.min(ema10, math.min(ema20, math.min(ema50, math.min(ema100, ema200))))

ema_spread_pct = (ema_max / ema_min - 1) * 100



// Price to 20 EMA Distance

price_to_20ema_pct = (close / ema20 - 1) * 100



// Additional Conditions

ema_spread_ok = ema_spread_pct < 10

price_to_20ema_ok = price_to_20ema_pct < 10

ema200_positive = ema200 > 0



// Final Signal Calculation

all_conditions_met = price_above_10ema and ema10_above_20 and ema20_above_50 and

ema50_above_100 and ema100_above_200 and rsi_daily_bullish and

rsi_weekly_bullish and ema_spread_ok and price_to_20ema_ok and ema200_positive



// SCREENER OUTPUT - This is the key for premium screener

// Return 1 for stocks meeting criteria, 0 for those that don't

screener_signal = all_conditions_met ? 1 : 0



// Plot the screener signal (this will be the column value)

plot(screener_signal, title="EMA Trend Signal", display=display.none)



// Additional screener columns you can add

plot(rsi_daily, title="RSI Daily", display=display.none)

plot(rsi_weekly, title="RSI Weekly", display=display.none)

plot(ema_spread_pct, title="EMA Spread %", display=display.none)

plot(price_to_20ema_pct, title="Price to 20EMA %", display=display.none)



// Screener-friendly outputs for individual conditions

plot(price_above_10ema ? 1 : 0, title="Price > 10EMA", display=display.none)

plot(ema10_above_20 ? 1 : 0, title="10EMA > 20EMA", display=display.none)

plot(ema20_above_50 ? 1 : 0, title="20EMA > 50EMA", display=display.none)

plot(ema50_above_100 ? 1 : 0, title="50EMA > 100EMA", display=display.none)

plot(ema100_above_200 ? 1 : 0, title="100EMA > 200EMA", display=display.none)



// Market cap condition (note: market cap data may not be available in all cases)

// You'll need to set this in the main screener interface



// Performance 3Y condition

// This also needs to be set in the main screener interface as it's fundamental data

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.