OPEN-SOURCE SCRIPT

A program written by a beginner

106
# 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)

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.