OPEN-SOURCE SCRIPT
A program written by a beginner

# TXF Choppy Market Detector (Whipsaw Filter)
## Introduction
This project is a technical indicator developed in **Pine Script v5**, specifically optimized for **Taiwan Index Futures (TXF)** intraday trading.
The TXF market is known for its frequent periods of low-volatility consolidation following sharp moves, often resulting in "whipsaws" (double-loss scenarios for trend followers). This script utilizes **volatility analysis** and **trend efficiency metrics** to filter out noise and detect potential "Stop Hunting" or "Liquidity Sweep" setups within range-bound markets.
## Methodology & Algorithms
The strategy operates on the principle of **Mean Reversion**, combining two core components:
### 1. Market Regime Filter: Choppiness Index (CHOP)
We use the Choppiness Index (originally developed by E.W. Dreiss) to determine if the market is trending or consolidating based on **Fractal Dimension** theory.
* **Logic**:
The index ranges from 0 to 100. Higher values indicate low trend efficiency (consolidation), while lower values indicate strong directional trends.
* **Condition**: `CHOP > Threshold` (Default: 50).
* **Application**: When this condition is met, the background turns **gray**, signaling a "No-Trade Zone" for trend strategies and activating the Mean Reversion logic.
### 2. Whipsaw Detection: Bollinger Bands
Bollinger Bands are used to define the dynamic statistical extremities of price action.
* **Logic**:
We identify **Fakeouts** (False Breakouts) that occur specifically during the choppy regime identified above. This is often where institutional traders hunt for liquidity (stops) before reversing the price.
#### Signal Algorithms (Pseudocode)
**A. Bull Trap (Washout High)**
A false upside breakout designed to trap long traders.
```pine
Condition:
1. Is_Choppy == true (Market is sideways)
2. High > Upper_Bollinger_Band (Price pierces the upper band)
3. Close < Upper_Bollinger_Band (Price fails to hold and closes back inside)
## Introduction
This project is a technical indicator developed in **Pine Script v5**, specifically optimized for **Taiwan Index Futures (TXF)** intraday trading.
The TXF market is known for its frequent periods of low-volatility consolidation following sharp moves, often resulting in "whipsaws" (double-loss scenarios for trend followers). This script utilizes **volatility analysis** and **trend efficiency metrics** to filter out noise and detect potential "Stop Hunting" or "Liquidity Sweep" setups within range-bound markets.
## Methodology & Algorithms
The strategy operates on the principle of **Mean Reversion**, combining two core components:
### 1. Market Regime Filter: Choppiness Index (CHOP)
We use the Choppiness Index (originally developed by E.W. Dreiss) to determine if the market is trending or consolidating based on **Fractal Dimension** theory.
* **Logic**:
The index ranges from 0 to 100. Higher values indicate low trend efficiency (consolidation), while lower values indicate strong directional trends.
* **Condition**: `CHOP > Threshold` (Default: 50).
* **Application**: When this condition is met, the background turns **gray**, signaling a "No-Trade Zone" for trend strategies and activating the Mean Reversion logic.
### 2. Whipsaw Detection: Bollinger Bands
Bollinger Bands are used to define the dynamic statistical extremities of price action.
* **Logic**:
We identify **Fakeouts** (False Breakouts) that occur specifically during the choppy regime identified above. This is often where institutional traders hunt for liquidity (stops) before reversing the price.
#### Signal Algorithms (Pseudocode)
**A. Bull Trap (Washout High)**
A false upside breakout designed to trap long traders.
```pine
Condition:
1. Is_Choppy == true (Market is sideways)
2. High > Upper_Bollinger_Band (Price pierces the upper band)
3. Close < Upper_Bollinger_Band (Price fails to hold and closes back inside)
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.