OPEN-SOURCE SCRIPT
Quarterly-Inspired EMA Swing Strategy

🚀 Quarterly EMA Strategy: Simplified
This strategy uses quarterly trends and pullbacks to EMAs (Exponential Moving Averages) to buy low and sell high in strong uptrends (longs) or short weak stocks in strong downtrends.
⸻
🔧 Core Setup
• Timeframe: Quarterly (1 candle = 3 months or ~65 trading days).
• Stocks: Liquid NSE F&O stocks (e.g., Reliance, Bajaj Finance, Tata Motors, etc.).
• Indicators Used:
• 10-quarter EMA → Shorter-term trend.
• 21-quarter EMA → Long-term trend.
• 13-week EMA → Weekly confirmation.
• ATR → For stop-loss.
• VIX → Volatility control.
• Relative Strength vs Nifty → Filter strong/weak stocks.
⸻
🟢 LONG SETUP (Buy on Pullback in Uptrend)
✅ Conditions:
1. Quarterly Trend is Bullish
Price > 10Q EMA > 21Q EMA
2. Pullback Happens
Price closes within 3% of 10Q or 21Q EMA, or touches it and bounces.
• E.g., Stock close = 8200, 10Q EMA = 8000 → Pullback = Valid (2.5% gap)
3. Previous Trend is Strong
• Last 1-2 quarters were making higher highs OR closing well above 10Q EMA
4. Candle Shows Rejection
• Lower wick (buying pressure from EMA)
• Small body (<5% total candle range)
5. Market Support Filters
• Nifty > its 4-quarter EMA (sloping upward)
• India VIX < 20 (low panic)
• Stock’s last 2 quarters’ return > 1.1× Nifty’s return
6. Weekly Confirmation
• Price > 13-week EMA
• 13W EMA is rising
• Bullish pattern in last 2 candles
• Volume ≥ 75% of 20-week average
⸻
📈 Example (Bajaj Finance):
• Close: 8200,
• 10Q EMA: 8000 (bullish),
• 21Q EMA: 7800
• Weekly price > 13W EMA → Confirmation ✅
⸻
🎯 Trade Plan (Long):
• Entry: 8200 (Quarterly) or near 13W EMA (Weekly)
• Stop-Loss: 2× ATR below 21Q EMA or candle low
• Target: 2:1 reward
• Exit 1: Book 50% at target
• Exit 2: Trail 21Q EMA
• Optional Hedge: Buy Nifty PUT if VIX > 15
⸻
🔴 SHORT SETUP (Sell on Pullback in Downtrend)
✅ Conditions:
1. Quarterly Trend is Bearish
Price < 10Q EMA < 21Q EMA
2. Pullback to EMA
Price closes within 3% of 10Q or 21Q EMA, or touches and gets rejected
3. Prior Trend is Down
Last 1-2 quarters had lower lows or closing >5% below 10Q EMA
4. Bearish Candle Setup
• Upper wick (rejection from EMA)
• Small body
5. Market Support Filters
• Nifty < its 4-quarter EMA (sloping down)
• India VIX < 20
• Stock’s 2-quarter return < 0.9× Nifty’s return
6. Weekly Confirmation
• Price < 13-week EMA
• 13W EMA is falling
• Bearish candles (engulfing, lower highs)
• Volume ≥ 75% of 20-week average
⸻
📉 Example (Vodafone Idea):
• Close: ₹8
• 10Q EMA: ₹8.2 → Close is 2.5% below
• Weekly close < 13W EMA
• Bearish candle → Confirmation ✅
⸻
🔻 Trade Plan (Short):
• Entry: 8
• Stop-Loss: 2× ATR above 21Q EMA or candle high
• Target: 2:1 reward
• Exit 1: Book 50% at target
• Exit 2: Trail 21Q EMA
• Optional Hedge: Buy Nifty CALL if VIX > 15
⸻
📊 Position Sizing (Same for Long & Short):
• Risk per trade: 0.5–1% of total capital
• Example:
• Capital = ₹10 lakh
• Risk = ₹10,000
• Stop = 800 points → Buy 12 shares
⸻
✅ Exit Rules Summary
This strategy uses quarterly trends and pullbacks to EMAs (Exponential Moving Averages) to buy low and sell high in strong uptrends (longs) or short weak stocks in strong downtrends.
⸻
🔧 Core Setup
• Timeframe: Quarterly (1 candle = 3 months or ~65 trading days).
• Stocks: Liquid NSE F&O stocks (e.g., Reliance, Bajaj Finance, Tata Motors, etc.).
• Indicators Used:
• 10-quarter EMA → Shorter-term trend.
• 21-quarter EMA → Long-term trend.
• 13-week EMA → Weekly confirmation.
• ATR → For stop-loss.
• VIX → Volatility control.
• Relative Strength vs Nifty → Filter strong/weak stocks.
⸻
🟢 LONG SETUP (Buy on Pullback in Uptrend)
✅ Conditions:
1. Quarterly Trend is Bullish
Price > 10Q EMA > 21Q EMA
2. Pullback Happens
Price closes within 3% of 10Q or 21Q EMA, or touches it and bounces.
• E.g., Stock close = 8200, 10Q EMA = 8000 → Pullback = Valid (2.5% gap)
3. Previous Trend is Strong
• Last 1-2 quarters were making higher highs OR closing well above 10Q EMA
4. Candle Shows Rejection
• Lower wick (buying pressure from EMA)
• Small body (<5% total candle range)
5. Market Support Filters
• Nifty > its 4-quarter EMA (sloping upward)
• India VIX < 20 (low panic)
• Stock’s last 2 quarters’ return > 1.1× Nifty’s return
6. Weekly Confirmation
• Price > 13-week EMA
• 13W EMA is rising
• Bullish pattern in last 2 candles
• Volume ≥ 75% of 20-week average
⸻
📈 Example (Bajaj Finance):
• Close: 8200,
• 10Q EMA: 8000 (bullish),
• 21Q EMA: 7800
• Weekly price > 13W EMA → Confirmation ✅
⸻
🎯 Trade Plan (Long):
• Entry: 8200 (Quarterly) or near 13W EMA (Weekly)
• Stop-Loss: 2× ATR below 21Q EMA or candle low
• Target: 2:1 reward
• Exit 1: Book 50% at target
• Exit 2: Trail 21Q EMA
• Optional Hedge: Buy Nifty PUT if VIX > 15
⸻
🔴 SHORT SETUP (Sell on Pullback in Downtrend)
✅ Conditions:
1. Quarterly Trend is Bearish
Price < 10Q EMA < 21Q EMA
2. Pullback to EMA
Price closes within 3% of 10Q or 21Q EMA, or touches and gets rejected
3. Prior Trend is Down
Last 1-2 quarters had lower lows or closing >5% below 10Q EMA
4. Bearish Candle Setup
• Upper wick (rejection from EMA)
• Small body
5. Market Support Filters
• Nifty < its 4-quarter EMA (sloping down)
• India VIX < 20
• Stock’s 2-quarter return < 0.9× Nifty’s return
6. Weekly Confirmation
• Price < 13-week EMA
• 13W EMA is falling
• Bearish candles (engulfing, lower highs)
• Volume ≥ 75% of 20-week average
⸻
📉 Example (Vodafone Idea):
• Close: ₹8
• 10Q EMA: ₹8.2 → Close is 2.5% below
• Weekly close < 13W EMA
• Bearish candle → Confirmation ✅
⸻
🔻 Trade Plan (Short):
• Entry: 8
• Stop-Loss: 2× ATR above 21Q EMA or candle high
• Target: 2:1 reward
• Exit 1: Book 50% at target
• Exit 2: Trail 21Q EMA
• Optional Hedge: Buy Nifty CALL if VIX > 15
⸻
📊 Position Sizing (Same for Long & Short):
• Risk per trade: 0.5–1% of total capital
• Example:
• Capital = ₹10 lakh
• Risk = ₹10,000
• Stop = 800 points → Buy 12 shares
⸻
✅ Exit Rules Summary
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.