20-EMA Reversal Scalp Strategy
1. Introduction & Basics
📚 Pine Script 101: Basics for Beginners
Pine Script is the programming language used to create custom indicators and strategies on TradingView. It's designed to be simple and powerful. Here are the core components you need to know: More Info Here
This strategy is specially optimized for high-momentum instruments like **NIFTY, BANKNIFTY, Bitcoin (BTC), and Ethereum (ETH)** on a 5-minute chart. It's a quick, mechanical approach to trading volatility.
2. Simplified Core Logic: The Rubber Band Effect
The strategy is based on the powerful concept of **Mean Reversion**. Think of the **20-EMA** as the anchor (or mean value). When the price is pushed too far away from the anchor by a sudden surge in volume and an extreme RSI reading, the market tends to 'snap back' to the 20-EMA very quickly. This script identifies that overextended moment for a rapid scalp trade.
🎯 The trade goal is simple: Enter at the extreme reversal point and exit when the price touches the 20-EMA.
3. What the Pine Script Automates
This is an **automated strategy** that initiates the trade, closes the trade at the EMA, and uses smart parameters based on the market selected.
-
Entry Conditions (4-Factor Confirmation):
- **Big Move:** Price movement must be significantly larger than the average movement (ATR Multiplier).
- **RSI Extreme:** RSI (3 period) must confirm **oversold** (for Long) or **overbought** (for Short) conditions using market-specific levels (e.g., Nifty 22/78, BTC 18/82).
- **Volume Surge:** Requires a sudden volume spike (e.g., 2.5x the average) to validate the conviction.
- **EMA Distance:** Ensures the price is far enough from the 20-EMA line.
-
Exit Condition (Profit Target):
The script automatically executes a `strategy.close()` command when the price closes near the 20-EMA, locking in the reversal profit.
4. Step-by-Step Usage Guide
- Setup & Chart: Open **TradingView**, load your symbol (e.g., NSE:NIFTY), and switch to the **5-minute chart**.
- Install Script: Open the **Pine Editor (F4)**, paste the code from Section 5 below, and click **"Add to Chart."**
- Configure Inputs: In the strategy settings, ensure you select the correct **Market** (`NIFTY`, `BANKNIFTY`, `BTC`, or `ETH`). The script adjusts its internal logic automatically.
- Set Stop Loss Manually: **Crucial Step:** The Pine Script closes the trade automatically for profit (at EMA), but you **MUST** place a manual Stop Loss order with your broker (e.g., -35 points for Nifty, -2.5% for BTC) to manage risk.
5. Pine Script Code (Copy-Paste)
//@version=5
strategy("Simple 20-EMA Reversal - NIFTY/BTC", overlay=true)
// Basic Inputs
market_type = input.string("NIFTY", "Market", options=["NIFTY", "BANKNIFTY", "BTC", "ETH"])
// Indicators
atr_value = ta.atr(14)
ema_20 = ta.ema(close, 20)
rsi_fast = ta.rsi(close, 3)
volume_avg = ta.sma(volume, 20)
// Market-specific settings (Conditional Assignments)
atr_multiplier = market_type == "NIFTY" ? 1.6 : market_type == "BANKNIFTY" ? 1.8 : market_type == "BTC" ? 1.9 : 1.8
rsi_upper = market_type == "NIFTY" ? 78 : market_type == "BANKNIFTY" ? 80 : market_type == "BTC" ? 82 : 81
rsi_lower = market_type == "NIFTY" ? 22 : market_type == "BANKNIFTY" ? 20 : market_type == "BTC" ? 18 : 19
volume_multiplier = market_type == "NIFTY" ? 2.2 : market_type == "BANKNIFTY" ? 2.5 : market_type == "BTC" ? 2.8 : 2.6
// Signals
price_move = math.abs(close - close[1])
big_move = (price_move / atr_value) >= atr_multiplier
volume_surge = (volume / volume_avg) >= volume_multiplier
ema_distance = (math.abs(close - ema_20) / atr_value) >= 1.0
long_signal = big_move and close < close[1] and rsi_fast <= rsi_lower and volume_surge and ema_distance
short_signal = big_move and close > close[1] and rsi_fast >= rsi_upper and volume_surge and ema_distance
// Execute trades
if long_signal
strategy.entry("Long", strategy.long)
if short_signal
strategy.entry("Short", strategy.short)
// Exit at EMA (Profit Target)
if strategy.position_size > 0 and math.abs(close - ema_20) <= (close * 0.0005)
strategy.close("Long")
if strategy.position_size < 0 and math.abs(close - ema_20) <= (close * 0.0005)
strategy.close("Short")
// Visuals
plot(ema_20, "20 EMA", color=color.blue)
plotshape(long_signal, "Long", shape.triangleup, location.belowbar, color=color.green)
plotshape(short_signal, "Short", shape.triangledown, location.abovebar, color=color.red)
Your Next Step: Start Small, Learn Daily!
This strategy emphasizes **consistency** over big, occasional wins. Start with **paper trading** or very small risk (e.g., ₹500) to understand the reversal timing before scaling up. Never neglect your broker's stop-loss!