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 script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.