OPEN-SOURCE SCRIPT
Telah dikemas kini Reverse Pulse System

# Reverse Pulse Trading System – Strategy Description for TradingView
---
## Overview
**Reverse Pulse** is a deterministic sweep-and-reverse trading system for TradingView. It identifies liquidity sweeps at fractal-defined Point-of-Interest (POI) levels and enters counter-trend when the price fails to follow through—using an "Attempted Candle" or "Trigger Break" confirmation.
- **Type:** Mean-reversion / Sweep-reversal
- **Timeframe:** M5 (recommended)
- **Instruments:** XAUUSD, EURUSD, and similar liquid pairs
- **Session:** 09:00–20:00 (Europe/Berlin, DST-safe; default for Gold US session)
- **Non-repainting:** Closed-bar logic, no lookahead bias
---
## Concept
1. **Trend Bias (H1):** Supertrend on H1 with body-break confirmation—long setups only when bias is long, short setups only when bias is short.
2. **POI Level:** Fractal highs (short bias) or fractal lows (long bias) define the key levels to watch.
3. **Sweep:** Price breaks the POI level (wick) but reverses back.
4. **Entry:** "Attempted Candle"—the candle that prints the new extreme and confirms reversal (either directly bullish/bearish or via a trigger break).
---
## Components
### Trend Bias (Supertrend H1)
- Supertrend on H1 with adjustable Factor and ATR Length.
- **Body-break:** Direction change only when the candle body breaks the Supertrend line (not just the wick).
- Reduces false signals from volatile wicks.
### POI (Point of Interest)
- **MTF Fractals [RunRox]** – CC BY-NC-SA 4.0
- Long bias: Fractal low as POI (lowest fractal low in lookback).
- Short bias: Fractal high as POI (highest fractal high in lookback).
- Fractal size: 3, 5, 7, or 9 bars.
- Optional: Higher timeframe for fractals (MTF).
### Sweep Detection
- **Long:** Price makes a new low below the POI level.
- **Short:** Price makes a new high above the POI level.
- While sweep is active, the extreme low/high is tracked.
### Entry Logic (Two Paths)
**1. Attempted Candle (direct)** – Sweep + failure on the same candle:
- **Long:** `low < poiLevel` (sweep), `close > open` (bullish), `low < low[1]` (new low).
- **Short:** `high > poiLevel` (sweep), `close < open` (bearish), `high > high[1]` (new high).
- SL: Low/High of this attempted candle. Entry: Close.
**2. Trigger + Break** – Candle prints the extreme but has the wrong color → wait for break:
- **Long:** Trigger candle = bearish, prints low. Trigger level = its high. Entry when a bullish candle closes above the trigger level.
- **Short:** Trigger candle = bullish, prints high. Trigger level = its low. Entry when a bearish candle closes below the trigger level.
- SL: Option A = Low/High of the break candle. Option B = Low/High of the trigger candle.
### Williams %R Filter (Optional)
- **Long:** Trade only if Williams %R (0–100) reached at least 95 (overbought) within the last X bars.
- **Short:** Trade only if Williams %R (0–100) reached at most 5 (oversold) within the last X bars.
- Default lookback: 20 bars. Default length: 14.
- When disabled, the filter is not applied.
---
## Exits
- **TP:** Minimum R:R (e.g. 2R)—Take-Profit = Entry ± (Risk × Min R:R).
- **SL:** Stop-Loss based on entry logic (Low/High of the relevant candle).
---
## Risk Management
- **Position sizing:** `qty = RiskAmount / (SL distance × USD per point)`.
- **XAUUSD:** USD per point = 1 (1 USD P&L per 1 USD price move per oz).
- **Daily stop:** After N stop-loss losses (default: 4), no further trades until session reset (09:00).
- **Max Qty:** Upper limit for position size (e.g. 500 oz for Gold).
---
## Session & Time
- **DST-safe:** Timestamps use IANA timezone (e.g. `Europe/Berlin`).
- **Default:** 09:00–20:00 Europe/Berlin (for Gold US session).
- **Session OFF:** Debug option to disable session filter (24/7 testing).
---
## Settings Overview
| Group | Parameter | Default |
|-------|-----------|---------|
| Session | Start/End Hour, Min, Timezone | 09:00–20:00, Europe/Berlin |
| Supertrend | Factor, ATR Length | 3.0, 10 |
| Fractals | Bars in Fractal, Timeframe | 5, Chart TF |
| Entry | Trigger-Break SL (A/B) | A |
| Filter Williams %R | Use Filter, Lookback, Length | Off, 20, 14 |
| Filter Williams %R | Min for Long, Max for Short | 95, 5 |
| Risk | Risk %, USD per Point, Max Qty | 1%, 1, 500 |
| Risk | Min R:R, Max SL per Day | 2, 4 |
| Debug | Show Debug, Level Lines, Legend | true, true, true |
---
## Recommended Instruments
- **XAUUSD** (Gold)
- **EURUSD**
- Other liquid forex and metal pairs with suitable tick size
---
## Technical Notes
- **process_orders_on_close:** Orders are executed at bar close.
- **pyramiding:** 0 (no pyramiding).
- **Float comparison:** `approxEq()` with `syminfo.mintick` for stable behavior.
---
## License Notice
- Fractals: MTF Fractals [RunRox] – CC BY-NC-SA 4.0
creativecommons.org/licenses/by-nc-sa/4.0/
---
## Disclaimer
This system is for educational and research purposes only. There is no guarantee of profits. Trading involves substantial risk. Only trade with capital you can afford to lose.
---
## Overview
**Reverse Pulse** is a deterministic sweep-and-reverse trading system for TradingView. It identifies liquidity sweeps at fractal-defined Point-of-Interest (POI) levels and enters counter-trend when the price fails to follow through—using an "Attempted Candle" or "Trigger Break" confirmation.
- **Type:** Mean-reversion / Sweep-reversal
- **Timeframe:** M5 (recommended)
- **Instruments:** XAUUSD, EURUSD, and similar liquid pairs
- **Session:** 09:00–20:00 (Europe/Berlin, DST-safe; default for Gold US session)
- **Non-repainting:** Closed-bar logic, no lookahead bias
---
## Concept
1. **Trend Bias (H1):** Supertrend on H1 with body-break confirmation—long setups only when bias is long, short setups only when bias is short.
2. **POI Level:** Fractal highs (short bias) or fractal lows (long bias) define the key levels to watch.
3. **Sweep:** Price breaks the POI level (wick) but reverses back.
4. **Entry:** "Attempted Candle"—the candle that prints the new extreme and confirms reversal (either directly bullish/bearish or via a trigger break).
---
## Components
### Trend Bias (Supertrend H1)
- Supertrend on H1 with adjustable Factor and ATR Length.
- **Body-break:** Direction change only when the candle body breaks the Supertrend line (not just the wick).
- Reduces false signals from volatile wicks.
### POI (Point of Interest)
- **MTF Fractals [RunRox]** – CC BY-NC-SA 4.0
- Long bias: Fractal low as POI (lowest fractal low in lookback).
- Short bias: Fractal high as POI (highest fractal high in lookback).
- Fractal size: 3, 5, 7, or 9 bars.
- Optional: Higher timeframe for fractals (MTF).
### Sweep Detection
- **Long:** Price makes a new low below the POI level.
- **Short:** Price makes a new high above the POI level.
- While sweep is active, the extreme low/high is tracked.
### Entry Logic (Two Paths)
**1. Attempted Candle (direct)** – Sweep + failure on the same candle:
- **Long:** `low < poiLevel` (sweep), `close > open` (bullish), `low < low[1]` (new low).
- **Short:** `high > poiLevel` (sweep), `close < open` (bearish), `high > high[1]` (new high).
- SL: Low/High of this attempted candle. Entry: Close.
**2. Trigger + Break** – Candle prints the extreme but has the wrong color → wait for break:
- **Long:** Trigger candle = bearish, prints low. Trigger level = its high. Entry when a bullish candle closes above the trigger level.
- **Short:** Trigger candle = bullish, prints high. Trigger level = its low. Entry when a bearish candle closes below the trigger level.
- SL: Option A = Low/High of the break candle. Option B = Low/High of the trigger candle.
### Williams %R Filter (Optional)
- **Long:** Trade only if Williams %R (0–100) reached at least 95 (overbought) within the last X bars.
- **Short:** Trade only if Williams %R (0–100) reached at most 5 (oversold) within the last X bars.
- Default lookback: 20 bars. Default length: 14.
- When disabled, the filter is not applied.
---
## Exits
- **TP:** Minimum R:R (e.g. 2R)—Take-Profit = Entry ± (Risk × Min R:R).
- **SL:** Stop-Loss based on entry logic (Low/High of the relevant candle).
---
## Risk Management
- **Position sizing:** `qty = RiskAmount / (SL distance × USD per point)`.
- **XAUUSD:** USD per point = 1 (1 USD P&L per 1 USD price move per oz).
- **Daily stop:** After N stop-loss losses (default: 4), no further trades until session reset (09:00).
- **Max Qty:** Upper limit for position size (e.g. 500 oz for Gold).
---
## Session & Time
- **DST-safe:** Timestamps use IANA timezone (e.g. `Europe/Berlin`).
- **Default:** 09:00–20:00 Europe/Berlin (for Gold US session).
- **Session OFF:** Debug option to disable session filter (24/7 testing).
---
## Settings Overview
| Group | Parameter | Default |
|-------|-----------|---------|
| Session | Start/End Hour, Min, Timezone | 09:00–20:00, Europe/Berlin |
| Supertrend | Factor, ATR Length | 3.0, 10 |
| Fractals | Bars in Fractal, Timeframe | 5, Chart TF |
| Entry | Trigger-Break SL (A/B) | A |
| Filter Williams %R | Use Filter, Lookback, Length | Off, 20, 14 |
| Filter Williams %R | Min for Long, Max for Short | 95, 5 |
| Risk | Risk %, USD per Point, Max Qty | 1%, 1, 500 |
| Risk | Min R:R, Max SL per Day | 2, 4 |
| Debug | Show Debug, Level Lines, Legend | true, true, true |
---
## Recommended Instruments
- **XAUUSD** (Gold)
- **EURUSD**
- Other liquid forex and metal pairs with suitable tick size
---
## Technical Notes
- **process_orders_on_close:** Orders are executed at bar close.
- **pyramiding:** 0 (no pyramiding).
- **Float comparison:** `approxEq()` with `syminfo.mintick` for stable behavior.
---
## License Notice
- Fractals: MTF Fractals [RunRox] – CC BY-NC-SA 4.0
creativecommons.org/licenses/by-nc-sa/4.0/
---
## Disclaimer
This system is for educational and research purposes only. There is no guarantee of profits. Trading involves substantial risk. Only trade with capital you can afford to lose.
Nota Keluaran
Change of default values. Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.