OPEN-SOURCE SCRIPT

Scalping Trend Power for MT5 - Updated

132
### **Scalping Trend Power for MT5 – Full Technical Documentation**

> **Asset class:** FX · CFDs · Futures
> **Style:** Intraday trend-following / scalping
> **Script type:** Pine v5 *strategy* with optional PineConnector execution
> **Author:** AlgoSystems – released for educational & non-commercial use
> **Warning:** No script can guarantee profits; live results may differ from back-tests.

---

## 1. High-Level Idea

Scalping Trend Power couples a **fast/slow EMA crossover** with an **RSI exhaustion filter** to time impulsive pullbacks **inside a dominant short-term trend**.
Unlike classic MA cross systems, it waits for *N consecutive bars* of confirmation, then layers in **ATR-scaled risk, adaptive trailing stops, volume-aware stop tightening,** and *three* optional partial-profit targets.
An **upper-time-frame RSI check** acts as an early-warning exit to avoid overstaying.

---

## 2. Signal Stack in Detail

| Layer | Purpose | Formula / Condition |
| ----------------------- | ------------------ | ----------------------------------------------------------------------------------------- |
| **Trend Bias** | Detect micro-trend | `emaShort > emaLong` ⇒ bullish bias, else bearish |
| **Momentum Health** | Prevent chasing | *Long* trades allowed only if `RSI < RSI_OB`; *Short* only if `RSI > RSI_OS` |
| **Bar Confirmation** | Noise filter | Both rules must hold for `Confirmation Bars` candles in a row |
| **Entry Trigger** | Market order | The candle that completes the confirmation window |
| **Initial Stop** | Volatility sizing | `ATR × TrailingStopMultiplier`, then divided by `(volume / avgVolume × VolumeMultiplier)` |
| **Trailing Logic** | Lock profit | Max( pivot-based stop, ATR-base stop ) for longs; Min(..) for shorts |
| **Higher-TF RSI Guard** | Context exit | Flat if higher-TF RSI breaches OB/OS levels |
| **TP Grid (opt.)** | Incremental exits | TP1/TP2/TP3 at `ATR × {1.0, 1.5, 2.0}` (default multipliers) |
| **Trade Throttle** | Over-trading brake | Max `baseLongTrades – TradeDecreaseFactor` longs per trend leg |
| **Connector Hooks** | MT5 routing | All alerts follow PineConnector’s `risk=` (lots) syntax |

---

## 3. Inputs Explained

| Category | Parameter | Effect |
| -------------------- | -------------------------------------- | ------------------------------------------------------ |
| **Sizing** | `Lot Size` · `Lot Multiplier` | Base lot × multiplier ⇒ *final* `risk=` lots |
| | `Risk/Reward Ratio` | Scales `dynamicTP = ATR × R/R` |
| | `Trailing-Stop Multiplier` | Wider ⇒ looser stop, lower ⇒ tighter |
| **Indicators** | `EMA Short / Long` | 9 & 21 default – suitable for 1-5 min TFs |
| | `RSI Length` | 14 by default |
| | `RSI OB / OS` | OB=70, OS=30 (lower = more entries; higher = stricter) |
| **Exit Context** | `Higher TF` | Any higher timeframe string (e.g. “30”, “60”) |
| | `Higher-TF RSI OB / OS` | Exits when breached |
| **Volume & Pivots** | `Volume Look-Back` | SMA length for avg volume |
| | `Volume Multiplier` | < 1.0 tightens SL in thin liquidity |
| | `Pivot Look-Back` | Bars left/right for swing pivots |
| **Partial Exit** | Toggle + TP multipliers + % lot splits | 0–3 targets; if disabled, single full exit |
| **Execution Limits** | `Confirmation Bars` | 1–n candles |
| | `Trade Decrease Factor` | Reduce # allowable longs as trend matures |
| **Connector** | Activate + License Code | Enables webhook output of orders |

All inputs are **tool-tipped** inside the script for quick reference.

---

## 4. Alert & PineConnector Workflow

1. **Add script to chart** → set inputs.
2. **Create an alert**

* *Condition*: **Any alert() call**
* *Webhook*: `webhook.pineconnector.com`
* *Message*: **leave blank** (script fills each alert).
3. In **MT5**, attach PineConnector EA to the **same symbol**; keep *VolumeType = Lots*.
4. Copy-paste your **License ID** into the script and tick **Activate PineConnector**.
5. Script now pushes:

* `buy` / `sell` with `risk=<lots>` (entries)
* `closelongvol` / `closeshortvol` with proportional lots (TP1-TP3)
* `closelong` / `closeshort` (full exit or stop)

> **Latency note:** Webhook round-trip ≈ 100-300 ms. Use on liquid 1-M, 5-M, 15-M charts; avoid sub-second scalps.

---

## 5. Best-Practice Checklist

| ✔︎ Do | ✘ Avoid |
| --------------------------------------------------------------------------- | ------------------------------------------------------------- |
| Walk forward-test on *new* data, not in-sample optimisation. | Optimising every input – will over-fit. |
| Calibrate *only* money-management (lot multiplier / TP %) per account size. | Running with fixed lots on variable leverage accounts. |
| Increase ATR multipliers if trading high-spread pairs (exotics, crypto). | Using the same ATR factor across radically different symbols. |
| Re-check higher-TF filter values before volatile sessions (NFP, CPI). | Trading news spikes with confirmation bars = 1. |
| Keep **PineConnector EA** running 24/5 on a VPS (if auto-trading). | Expecting alerts to fire with TradingView tab closed. |

---

## 6. Limitations & Warnings

* Strategy **assumes constant spread** in back-test; real P/L will differ.
* Sub-minute charts may repaint pivots during live candles.
* Over-leveraged lot sizes can wipe accounts quickly – risk strictly!
* PineConnector routing is “fire-and-forget”; EA must handle slippage / rejects.

---

## 7. License & Attribution

Released under the **MIT License** – keep the copyright header if you remix.
If you publish derivatives, please link back to this original post.

---

## 8. Disclaimer

This publication is **NOT** investment advice. Use on demo accounts first, understand all parameters, and comply with your jurisdiction’s regulations. AlgoSystems is **not liable** for any financial loss arising from the use of this code.

---

**Ready to trade?**
Copy the script ⇨ set your risk ⇨ run an alert ⇨ connect PineConnector – and monitor results responsibly. Feedback & pull-requests welcome!

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.