OPEN-SOURCE SCRIPT
Trend Pullback Detector

Detects high-momentum impulse legs in real time and alerts you the moment they complete — so you're ready when the 50% retracement sets up.
How it works
The indicator scans for consecutive large bullish or bearish candles that together form a significant directional leg. When a qualifying run ends, it locks in two points:
From there it plots the 50% midpoint of the leg and watches for price to retrace into that zone.
When price pulls back the right amount and begins to recover, it marks the Entry, Stop Loss, and Profit Target directly on the chart.
Three alert conditions
Set your preferred alert and get notified the moment a leg completes — giving you time to watch for the retracement before the next move begins.
Key settings
Works on any market and timeframe. Best used on liquid instruments where momentum legs are clean and decisive — equities, ETFs, futures, crypto.
How it works
The indicator scans for consecutive large bullish or bearish candles that together form a significant directional leg. When a qualifying run ends, it locks in two points:
- Leg A — the origin of the move (open of the first candle)
- Leg B — the terminus of the move (high/low of the last candle)
From there it plots the 50% midpoint of the leg and watches for price to retrace into that zone.
When price pulls back the right amount and begins to recover, it marks the Entry, Stop Loss, and Profit Target directly on the chart.
Three alert conditions
- A/B Bull Leg Detected
- A/B Bear Leg Detected
- A/B Bull or Bear Leg Detected
Set your preferred alert and get notified the moment a leg completes — giving you time to watch for the retracement before the next move begins.
Key settings
- Min Consecutive Candles — how many qualifying candles define a leg
- Min Candle Size — filters out small or indecisive candles within the run
- Min Total Leg Size — ensures the full move is significant relative to current volatility (ATR-based)
- Retrace Zone — the pullback depth range that qualifies as a valid 50% setup (default 38–65%)
Works on any market and timeframe. Best used on liquid instruments where momentum legs are clean and decisive — equities, ETFs, futures, crypto.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Jason Parker is the author of tradinghabits.com/ an editorial site on trading and investing.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Jason Parker is the author of tradinghabits.com/ an editorial site on trading and investing.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน