OPEN-SOURCE SCRIPT
ที่อัปเดต: Premium/Discount Retracement Indicator

The indicator works in four layers.
**The major swing** — it scans the chart for a significant impulse move using a pivot-based lookback. Once it finds a clear swing low and swing high (or high then low), it locks that range in and draws a horizontal 50% line across the middle. Everything above that line is premium, everything below is discount.
**The retracement zone** — after the major move, it watches for a smaller pullback forming within the range. When that pullback produces its own local high and local low, those two levels become the zone boundaries. The zone is drawn as a two-colour box: teal on top, red on the bottom, split at the midpoint. Only zones sitting in the discount area qualify for buys, and only zones in the premium area qualify for sells, so it automatically filters out setups that go against the structure.
**The entry** — a limit order line sits at the exact midpoint of the zone. Nothing happens until price returns to that level. If price dips into the zone but reverses before touching the midpoint and then closes back above the zone boundary, the zone is marked as rejected and the limit is cancelled automatically. This handles the scenario where price taps the upper portion of the zone but doesn't commit.
**Trade levels** — once the limit is hit, three levels are displayed. The stop loss is placed just beyond the outer zone boundary with a small buffer. The take profit is calculated at 1:2 risk-to-reward from the entry. A break-even line sits at the 1:1 level, and an alert fires when price reaches it so you know when to move your stop to entry.
There are also four alerts: zone created, order filled, zone cancelled, and move to break even.
**The major swing** — it scans the chart for a significant impulse move using a pivot-based lookback. Once it finds a clear swing low and swing high (or high then low), it locks that range in and draws a horizontal 50% line across the middle. Everything above that line is premium, everything below is discount.
**The retracement zone** — after the major move, it watches for a smaller pullback forming within the range. When that pullback produces its own local high and local low, those two levels become the zone boundaries. The zone is drawn as a two-colour box: teal on top, red on the bottom, split at the midpoint. Only zones sitting in the discount area qualify for buys, and only zones in the premium area qualify for sells, so it automatically filters out setups that go against the structure.
**The entry** — a limit order line sits at the exact midpoint of the zone. Nothing happens until price returns to that level. If price dips into the zone but reverses before touching the midpoint and then closes back above the zone boundary, the zone is marked as rejected and the limit is cancelled automatically. This handles the scenario where price taps the upper portion of the zone but doesn't commit.
**Trade levels** — once the limit is hit, three levels are displayed. The stop loss is placed just beyond the outer zone boundary with a small buffer. The take profit is calculated at 1:2 risk-to-reward from the entry. A break-even line sits at the 1:1 level, and an alert fires when price reaches it so you know when to move your stop to entry.
There are also four alerts: zone created, order filled, zone cancelled, and move to break even.
Release Note
updated bugsRelease Note
fixedRelease Note
updateRelease Note
updatedสคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน