OPEN-SOURCE SCRIPT

RV 5 Min Scalping Strategy

How This Script Works
1. Trend Filter Using 5-Minute Data:
The 200‑period EMA is calculated on a 5‑minute timeframe via the request.security() function. Long trades are allowed only if the current close (on the 1‑minute chart) is above this EMA; short trades are allowed only if below it.
2. 1-Minute Entry Conditions:
On the local (1‑minute) chart, a 20‑period EMA is used. A long entry is triggered when the price crosses above the 20‑EMA, while a short entry is triggered when it crosses below.
3. Risk Management:
The risk per trade is set to 0.5% (riskPerc = 0.005) of the entry price. The stop loss is placed 0.5% away from the entry, and the take profit is set at twice that distance (1:2 risk–reward).
4. Debug Visuals:
Small shape markers (green for longs, red for shorts) are plotted on the chart so you can verify when conditions are met.

Next Steps
• Backtesting:
Run this strategy on historical 1‑minute data while ensuring your chart is set to 1‑minute. Confirm that the 5‑minute trend filter (ema200_5) is working correctly.
• Optimization:
You may adjust the EMA lengths, risk percentage, or even the entry conditions (for example, using additional confirmation like volume or other indicators) to further optimize profitability for scalping.
• Real-Time Considerations:
Scalping strategies can be sensitive to execution delays and spread. When forward-testing, consider the fill conditions and the effect of recalculation on every tick.

Penafian