OPEN-SOURCE SCRIPT
Automatic Support & Resistance Indicator

The script finds swing pivot highs/lows (local turning points) on multiple timeframes (your execution TF + 1H + 4H). Each pivot price becomes a candidate level.
When a new pivot appears, it either:
Merges into an existing nearby level (within a tolerance), or
Creates a new level.
The merge tolerance is based on ATR × multiplier and a tick-based minimum.
Each level keeps simple stats:
Touches = how many pivot events have merged into that level (a proxy for “importance”)
Updated time = how recently it was reinforced
Source tags = which TFs contributed pivots (e.g., 15m/1H/4H)
It then selects which levels to display:
Always includes the nearest level below price (support candidate) and nearest level above price (resistance candidate).
Fills the rest (up to maxLevels) by a score dominated by touches + recency.
“Support vs Resistance” is dynamic:
If current price is above a level → it’s treated/labeled as Support.
If current price is below a level → it’s treated/labeled as Resistance.
Lines are drawn as true horizontal levels:
Using extend=extend.both, and the script only updates the Y price, so levels stay glued to price when you pan/zoom.
Labels show what you’re seeing:
S or R (current role)
touch count (strength proxy)
source TF tags (where the level came from)
optional * marking the nearest S/R.
If you like this indicator, I would be happy if you could paypal me some coffee money: paypal.me/Ccholl
When a new pivot appears, it either:
Merges into an existing nearby level (within a tolerance), or
Creates a new level.
The merge tolerance is based on ATR × multiplier and a tick-based minimum.
Each level keeps simple stats:
Touches = how many pivot events have merged into that level (a proxy for “importance”)
Updated time = how recently it was reinforced
Source tags = which TFs contributed pivots (e.g., 15m/1H/4H)
It then selects which levels to display:
Always includes the nearest level below price (support candidate) and nearest level above price (resistance candidate).
Fills the rest (up to maxLevels) by a score dominated by touches + recency.
“Support vs Resistance” is dynamic:
If current price is above a level → it’s treated/labeled as Support.
If current price is below a level → it’s treated/labeled as Resistance.
Lines are drawn as true horizontal levels:
Using extend=extend.both, and the script only updates the Y price, so levels stay glued to price when you pan/zoom.
Labels show what you’re seeing:
S or R (current role)
touch count (strength proxy)
source TF tags (where the level came from)
optional * marking the nearest S/R.
If you like this indicator, I would be happy if you could paypal me some coffee money: paypal.me/Ccholl
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน