OPEN-SOURCE SCRIPT

Enhanced Scalping Strategy with Stop Loss

📌 Overview
The Enhanced Scalping Strategy with Stop Loss is a trend-following and momentum-based trading system designed for scalpers and short-term traders. It leverages Exponential Moving Averages (EMAs), Relative Strength Index (RSI), and Average True Range (ATR) to identify potential trading opportunities while implementing a stop-loss mechanism to minimize risk.

This script is designed to be used in various timeframes, with optimizations for 1-minute and 5-minute charts. The strategy focuses on momentum breakouts, ensuring that trades are taken in strong trending conditions while filtering out false signals using volatility-based confirmation.

🔍 How It Works
This strategy uses three main indicators to generate trade signals:

1️⃣ Moving Averages (Fast & Slow EMAs)
Fast EMA (default: 9-period)
Slow EMA (default: 21-period)
A bullish crossover (Fast EMA crossing above Slow EMA) signals a potential long trade.
A bearish crossover (Fast EMA crossing below Slow EMA) signals a potential short trade.
2️⃣ Relative Strength Index (RSI)
The RSI is used as an overbought/oversold filter.
Default settings:
Overbought Level: 70 → Avoid long trades when RSI is too high.
Oversold Level: 30 → Avoid short trades when RSI is too low.
3️⃣ Average True Range (ATR) Multiplier
ATR is used to filter out low-volatility conditions.
The script ensures that price exceeds a threshold based on ATR before confirming a trade, reducing false breakouts.
4️⃣ Stop Loss Mechanism
Stop loss is dynamically calculated based on a percentage of the entry price (default: 1%).
Long Trade Stop Loss: Set 1% below entry price.
Short Trade Stop Loss: Set 1% above entry price.
The strategy will automatically exit trades if the stop loss is hit.
🎯 Entry & Exit Conditions
🔵 Long Entry (Buy Signal)
Fast EMA crosses above Slow EMA (Bullish crossover).
RSI is below overbought (70) → Avoid buying into extreme conditions.
Price is above Fast EMA + ATR Multiplier → Ensures a strong trend.
Stops any active short trade before entering long.
🔴 Short Entry (Sell Signal)
Fast EMA crosses below Slow EMA (Bearish crossover).
RSI is above oversold (30) → Avoid shorting into extreme weakness.
Price is below Fast EMA - ATR Multiplier → Ensures a strong trend.
Stops any active long trade before entering short.
🔄 Exit Conditions
Long Trade Exit:
Fast EMA crosses below Slow EMA (Bearish crossover).
OR Stop loss is hit (price drops 1% below entry).
Short Trade Exit:
Fast EMA crosses above Slow EMA (Bullish crossover).
OR Stop loss is hit (price rises 1% above entry).
🛠 How to Use
1️⃣ Adding the Strategy
Open TradingView.
Navigate to the Pine Script Editor.
Copy and paste the script.
Click Add to Chart.
2️⃣ Customizing Settings
Adjust the Moving Average lengths to suit different timeframes.
Modify the RSI overbought/oversold levels for better filtering.
Change the ATR Multiplier to fine-tune the volatility filter.
Customize the Stop Loss Percentage to match your risk tolerance.
3️⃣ Best Timeframes for Scalping
1-Minute (M1): Fast scalping, more signals.
5-Minute (M5): Reduced noise, better trend identification.
15-Minute (M15) and higher: Can be used for intraday trading.
4️⃣ Alerts & Notifications
Set up alerts to receive buy/sell signals.
Alerts include:
Long Entry Alert (Buy Signal)
Short Entry Alert (Sell Signal)
Exit Long Alert (Close Buy Position)
Exit Short Alert (Close Sell Position)
📊 Visuals on the Chart
✅ Buy Signals: Displayed as green upward arrows.
✅ Sell Signals: Displayed as red downward arrows.
✅ EMA Lines:

Fast EMA (blue)
Slow EMA (orange)
✅ RSI Background Coloring:
Red background when RSI is overbought.
Green background when RSI is oversold.
🔎 Pros & Cons
✅ Pros
✔️ Works on multiple timeframes with automatic adjustments.
✔️ Uses ATR to confirm trends, reducing false signals.
✔️ Built-in stop loss for better risk management.
✔️ Alerts & visual signals for easy trade execution.
✔️ Can be customized for different trading styles.

❌ Cons
❌ May perform poorly in ranging markets.
❌ Stop-loss percentage may need optimization for different assets.
❌ Higher timeframes might require different parameters for best performance.

Aviso legal