EMA Crossover Strategy with Filters by pankaj3singh789

By version

Performance Metrics

Description

//version=5strategy("EMA Crossover Strategy with Filters", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)// EMA lengthsema9_len = 9ema50_len = 50ema100_len = 100ema200_len = 200// EMA calculationema9 = ta.ema(close, ema9_len)ema50 = ta.ema(close, ema50_len)ema100 = ta.ema(close, ema100_len)ema200 = ta.ema(close, ema200_len)// Plot EMAsplot(ema9, color=color.yellow, title="9 EMA")plot(ema50, color=color.orange, title="50 EMA")plot(ema100, color=color.green, title="100 EMA")plot(ema200, color=color.blue, title="200 EMA")// Entry conditionslongCondition = ta.crossover(ema100, ema200) and ema9 > ema50shortCondition = ta.crossunder(ema100, ema200) and ema9 < ema50// Exit conditionslongExit = ta.crossunder(ema100, ema50)shortExit = ta.crossover(ema100, ema50)// Execute tradesif (longCondition) strategy.entry("Long", strategy.long)if (shortCondition) strategy.entry("Short", strategy.short)if (longExit) strategy.close("Long")if (shortExit) strategy.close("Short")

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView