OPEN-SOURCE SCRIPT

Auto BOS + CHoCH (Fixed Version)

153
🔹 1. Automatically detects:
BOS (Break of Structure): A continuation of trend

CHoCH (Change of Character): A potential trend reversal

🔹 2. Plots lines and labels:
🔰 Green lines for BOS

🔴 Red lines for CHoCH

Labels appear directly on the chart at the price level where the event occurs

🔹 3. Sets up alerts:
You get notified when either a BOS or CHoCH is detected

🔍 How It Works Internally
🔹 1. Swing Structure Detection
It looks for:

A Swing High: Highest high in a certain number of candles (default: 5)

A Swing Low: Lowest low in a certain number of candles

This mimics how Smart Money traders identify structural turning points.

pinescript
Copy
Edit
isSwingHigh = high[length] == ta.highest(high, length * 2 + 1)
isSwingLow = low[length] == ta.lowest(low, length * 2 + 1)
🔹 2. BOS Logic
If a new candle closes above the last swing high → BOS Up

If it closes below the last swing low → BOS Down

This confirms trend continuation.

🔹 3. CHoCH Logic
If the market makes a lower low after a bullish trend → CHoCH Down

If the market makes a higher high after a bearish trend → CHoCH Up

This suggests a trend reversal or start of a deeper retracement.

🔹 4. Visual Markers
When one of these events is detected, the script draws:

Event Line Label
BOS ↑ Green Line “BOS ↑”
BOS ↓ Green Line “BOS ↓”
CHoCH ↑ Red Line “CHoCH ↑”
CHoCH ↓ Red Line “CHoCH ↓”

You can toggle line and label visibility in the script settings.

🔹 5. Alerts
The script includes alertcondition() logic, so you can create alerts:

For any BOS (up/down)

For any CHoCH (up/down)

Just go to the TradingView alert menu, and choose your condition.

📊 Use Cases in Trading
Goal How This Script Helps
Confirm trend Use BOS to confirm continuation of direction
Spot reversals early Use CHoCH to detect when the market shifts character
Entry/exit confirmation Trade after CHoCH → OB → FVG confluence
Build trade bias Detect structure shift on higher timeframes

✅ Best Practices
Use on 5m, 15m, 1H depending on your style

Combine with:

Order Blocks

Fair Value Gaps

Liquidity sweeps

Higher timeframe CHoCH = more reliable

Wait for candle close past the level for confirmation

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。