PROTECTED SOURCE SCRIPT
W%R Cycle Swings - MTF Trend

📄 English Description
Overview
The W%R Cycle Swings – MTF Trend indicator is a market-structure tool built on top of Williams %R cycle logic. It detects meaningful swing highs and lows from W%R behavior, then uses those swings to locate the first Market Structure Shift (MSS-first) and track multi-timeframe trend bias + cancel levels.
This is not a random mashup of indicators: all components are derived from one core concept—W%R cycles—and are combined into a single, coherent framework for reading structure and trend across timeframes.
Core Concepts
1. Williams %R Cycle Swings (Current Timeframe)
Instead of using price swings based only on highs/lows, this script uses Williams %R behavior to define swing points:
Swing High pattern: OS → OB → OS
Swing Low pattern: OB → OS → OB
The script:
Tracks overbought/oversold states using user-defined levels.
Builds a zone for each potential swing (accumulating the extremums during the OB/OS phase).
Confirms a swing only when the opposite state appears again.
Plots labels on the chart:
Swing High label above price
Swing Low label below price
Optional price display on the label (toggle in settings).
This makes the swing points cycle-based rather than purely bar-based.
2. MSS-first (Market Structure Shift on Current TF)
Once swings are defined, the script looks for the first break of the most recent swing:
Bullish MSS-first: price breaks above the last confirmed swing high.
Bearish MSS-first: price breaks below the last confirmed swing low.
You can choose whether to confirm by close or by wick (mssByClose input).
When an MSS-first is detected:
A colored label (bullish/bearish) is drawn at the relevant swing level.
A horizontal line is drawn from the swing bar to the MSS bar to visually connect the structure break.
Internal trendBias is updated to Up or Down, preventing duplicate MSS labels in the same direction.
This gives a clear, visual definition of when the structure actually shifted based on W%R-driven swings.
3. MTF MSS-first Trend & Cancel Logic
The same MSS-first concept is applied inside a function and called via request.security() on multiple timeframes (5m, 15m, 30m, 1h, 4h).
For each timeframe, the function:
Recalculates W%R swings with the same parameters.
Detects MSS-first events (bullish or bearish).
Tracks a trend state:
1 → Up trend
-1 → Down trend
0 → Unknown / Neutral
Maintains a cancel level, which represents the price that would invalidate the current trend:
In an uptrend, cancel is typically the last relevant swing low.
In a downtrend, cancel is typically the last relevant swing high.
This provides:
Trend direction per TF (Up / Down / -)
A concrete price level that acts as a structural “stop” or invalidation level.
4. MTF Trend Table (Visual Overview)
If enabled, a compact table is displayed on the chart (position configurable):
Columns: 5m, 15m, 30m, 1h, 4h
Rows:
Trend → shows Up, Down or -, with color-coded background.
Cancel → shows the current cancel price for that timeframe.
This creates a multi-timeframe structure dashboard that tells you:
Which timeframes are currently in an Up or Down MSS-based trend.
At which price the current structural view would be canceled.
5. Alert Conditions
The script includes alert conditions for:
Current timeframe MSS-first:
Bullish MSS-first (structure break up).
Bearish MSS-first (structure break down).
MTF MSS-first events for:
5m, 15m, 30m, 1h, 4h (Bullish & Bearish separately).
This allows you to receive notifications when a fresh structural shift happens on any of the tracked timeframes.
How to Use
Use Swing High / Swing Low labels to understand the current W%R cycle structure on your main timeframe.
Watch for MSS-first labels to catch the first break of structure after a swing completes.
Use the MTF Trend table:
Trade in the direction of higher-timeframe trends.
Use cancel levels as logical invalidation areas or structural stop guides.
Combine the current timeframe swings with MTF bias:
Example: look for long setups when H1/H4 show Up trend and price forms new bullish MSS on lower TF.
The tool is suitable for both intraday and swing trading, on any symbol and timeframe.
Why This Script Is Original
It links cycle-based swings from Williams %R directly to MSS-first detection, rather than using generic pivot logic.
It combines:
W%R-driven swing definition,
MSS-first structural breaks,
Multi-timeframe trend state,
Cancel (invalidation) levels,
Alerts for MSS events on multiple TFs,
into a single, coherent market-structure framework.
The MTF table is not a generic dashboard: it is specifically built around this W%R-MSS-first structural model, which gives traders both trend context and exact invalidation prices.
🇹🇭 Thai Description — คำอธิบายภาษาไทย
ภาพรวม
อินดิเคเตอร์ W%R Cycle Swings – MTF Trend เป็นเครื่องมืออ่านโครงสร้างราคา โดยใช้ “วงจรของ Williams %R” เป็นหลักในการหา Swing High / Swing Low แล้วใช้จุด Swing เหล่านั้นมาหา MSS-first (จุดเปลี่ยนโครงสร้างครั้งแรก) จากนั้นต่อยอดไปสู่ การดูแนวโน้มหลายกรอบเวลา + ระดับ Cancel (จุดที่โครงสร้างจะถูกมองว่าพัง)
แนวคิดหลัก
Swing จาก Williams %R (TF ปัจจุบัน)
ใช้รูปแบบ OS → OB → OS เพื่อยืนยัน Swing High
และ OB → OS → OB เพื่อยืนยัน Swing Low
เมื่อยืนยันแล้วจะสร้าง Label “Swing High / Swing Low” บนกราฟ และสามารถแสดงราคาบนป้ายได้
ทำให้จุด Swing มีพื้นฐานจาก “Cycle ของ W%R” ไม่ใช่แค่ high/low เฉย ๆ
MSS-first บน TF ปัจจุบัน
ถ้าราคาทะลุ Swing High ล่าสุด → มองเป็น Bullish MSS-first
ถ้าราคาทะลุ Swing Low ล่าสุด → มองเป็น Bearish MSS-first
เลือกได้ว่าจะยืนยันจาก Close หรือจาก ไส้แท่งเทียน
วาดป้าย MSS + เส้นเชื่อมจาก Swing ไปยังจุดที่เกิด MSS
มีตัวแปร trendBias ป้องกันไม่ให้ยิง MSS ซ้ำในทิศทางเดิมจนรก
MTF MSS-first + Cancel Logic
นำ Logic เดียวกันไปใช้กับ TF: 5m, 15m, 30m, 1h, 4h
สำหรับแต่ละ TF จะได้:
สถานะแนวโน้ม: Up / Down / Unknown
ระดับ Cancel: ราคาที่ถ้าหลุดจะถือว่าโครงสร้างเทรนด์นั้นถูก “ยกเลิก”
เช่น ในเทรนด์ขาขึ้น ระดับ Cancel มักมาจาก Swing Low ล่าสุด ฯลฯ
MTF Table บนกราฟ
แสดง Trend + Cancel ของ 5 TF ในรูปแบบตาราง
อ่านง่าย: แถว Trend เป็น Up/Down พร้อมสีพื้น, แถว Cancel เป็นตัวเลขราคา
ใช้ดูภาพรวมโครงสร้างหลาย TF ในมุมมองเดียว
Alert Conditions
แจ้งเตือน MSS-first ของ TF ปัจจุบัน
แจ้งเตือน MSS-first ของ TF 5m / 15m / 30m / 1h / 4h แยก Bull / Bear
วิธีใช้งาน
ใช้ Swing High / Swing Low เพื่อดูว่าโครงสร้าง cycle ปัจจุบันอยู่ตรงไหน
รอให้เกิด MSS-first เพื่อมองว่า “โครงสร้างราคาเริ่มกลับตัวแล้ว”
ใช้ Table MTF:
ดูว่า TF ไหนเป็น Up / Down
ใช้ราคาบรรทัด Cancel เป็นแนว “จุดตัดขาดทุนเชิงโครงสร้าง” หรือจุดเปลี่ยนมุมมอง
เทรดตามทิศทาง TF ใหญ่ แล้วหา Entry จาก MSS ของ TF เล็ก
จุดเด่น / ความเป็น Original
ใช้ Williams %R เป็นฐานในการสร้าง Swing Pattern แทนการใช้ Pivot ธรรมดา
เชื่อม W%R Swing เข้ากับแนวคิด MSS-first อย่างเป็นระบบ
มีทั้ง:
ป้าย Swing
ป้าย MSS + เส้นเชื่อม
MTF Trend + Cancel
Alert เตือน MSS ในหลาย TF
อยู่ในสคริปต์เดียว
เหมาะกับคนที่ต้องการอ่านโครงสร้างราคาแบบมีที่มาที่ไป ไม่ใช่แค่ตามอินดี้ตัวเดียวครับ ✅
Overview
The W%R Cycle Swings – MTF Trend indicator is a market-structure tool built on top of Williams %R cycle logic. It detects meaningful swing highs and lows from W%R behavior, then uses those swings to locate the first Market Structure Shift (MSS-first) and track multi-timeframe trend bias + cancel levels.
This is not a random mashup of indicators: all components are derived from one core concept—W%R cycles—and are combined into a single, coherent framework for reading structure and trend across timeframes.
Core Concepts
1. Williams %R Cycle Swings (Current Timeframe)
Instead of using price swings based only on highs/lows, this script uses Williams %R behavior to define swing points:
Swing High pattern: OS → OB → OS
Swing Low pattern: OB → OS → OB
The script:
Tracks overbought/oversold states using user-defined levels.
Builds a zone for each potential swing (accumulating the extremums during the OB/OS phase).
Confirms a swing only when the opposite state appears again.
Plots labels on the chart:
Swing High label above price
Swing Low label below price
Optional price display on the label (toggle in settings).
This makes the swing points cycle-based rather than purely bar-based.
2. MSS-first (Market Structure Shift on Current TF)
Once swings are defined, the script looks for the first break of the most recent swing:
Bullish MSS-first: price breaks above the last confirmed swing high.
Bearish MSS-first: price breaks below the last confirmed swing low.
You can choose whether to confirm by close or by wick (mssByClose input).
When an MSS-first is detected:
A colored label (bullish/bearish) is drawn at the relevant swing level.
A horizontal line is drawn from the swing bar to the MSS bar to visually connect the structure break.
Internal trendBias is updated to Up or Down, preventing duplicate MSS labels in the same direction.
This gives a clear, visual definition of when the structure actually shifted based on W%R-driven swings.
3. MTF MSS-first Trend & Cancel Logic
The same MSS-first concept is applied inside a function and called via request.security() on multiple timeframes (5m, 15m, 30m, 1h, 4h).
For each timeframe, the function:
Recalculates W%R swings with the same parameters.
Detects MSS-first events (bullish or bearish).
Tracks a trend state:
1 → Up trend
-1 → Down trend
0 → Unknown / Neutral
Maintains a cancel level, which represents the price that would invalidate the current trend:
In an uptrend, cancel is typically the last relevant swing low.
In a downtrend, cancel is typically the last relevant swing high.
This provides:
Trend direction per TF (Up / Down / -)
A concrete price level that acts as a structural “stop” or invalidation level.
4. MTF Trend Table (Visual Overview)
If enabled, a compact table is displayed on the chart (position configurable):
Columns: 5m, 15m, 30m, 1h, 4h
Rows:
Trend → shows Up, Down or -, with color-coded background.
Cancel → shows the current cancel price for that timeframe.
This creates a multi-timeframe structure dashboard that tells you:
Which timeframes are currently in an Up or Down MSS-based trend.
At which price the current structural view would be canceled.
5. Alert Conditions
The script includes alert conditions for:
Current timeframe MSS-first:
Bullish MSS-first (structure break up).
Bearish MSS-first (structure break down).
MTF MSS-first events for:
5m, 15m, 30m, 1h, 4h (Bullish & Bearish separately).
This allows you to receive notifications when a fresh structural shift happens on any of the tracked timeframes.
How to Use
Use Swing High / Swing Low labels to understand the current W%R cycle structure on your main timeframe.
Watch for MSS-first labels to catch the first break of structure after a swing completes.
Use the MTF Trend table:
Trade in the direction of higher-timeframe trends.
Use cancel levels as logical invalidation areas or structural stop guides.
Combine the current timeframe swings with MTF bias:
Example: look for long setups when H1/H4 show Up trend and price forms new bullish MSS on lower TF.
The tool is suitable for both intraday and swing trading, on any symbol and timeframe.
Why This Script Is Original
It links cycle-based swings from Williams %R directly to MSS-first detection, rather than using generic pivot logic.
It combines:
W%R-driven swing definition,
MSS-first structural breaks,
Multi-timeframe trend state,
Cancel (invalidation) levels,
Alerts for MSS events on multiple TFs,
into a single, coherent market-structure framework.
The MTF table is not a generic dashboard: it is specifically built around this W%R-MSS-first structural model, which gives traders both trend context and exact invalidation prices.
🇹🇭 Thai Description — คำอธิบายภาษาไทย
ภาพรวม
อินดิเคเตอร์ W%R Cycle Swings – MTF Trend เป็นเครื่องมืออ่านโครงสร้างราคา โดยใช้ “วงจรของ Williams %R” เป็นหลักในการหา Swing High / Swing Low แล้วใช้จุด Swing เหล่านั้นมาหา MSS-first (จุดเปลี่ยนโครงสร้างครั้งแรก) จากนั้นต่อยอดไปสู่ การดูแนวโน้มหลายกรอบเวลา + ระดับ Cancel (จุดที่โครงสร้างจะถูกมองว่าพัง)
แนวคิดหลัก
Swing จาก Williams %R (TF ปัจจุบัน)
ใช้รูปแบบ OS → OB → OS เพื่อยืนยัน Swing High
และ OB → OS → OB เพื่อยืนยัน Swing Low
เมื่อยืนยันแล้วจะสร้าง Label “Swing High / Swing Low” บนกราฟ และสามารถแสดงราคาบนป้ายได้
ทำให้จุด Swing มีพื้นฐานจาก “Cycle ของ W%R” ไม่ใช่แค่ high/low เฉย ๆ
MSS-first บน TF ปัจจุบัน
ถ้าราคาทะลุ Swing High ล่าสุด → มองเป็น Bullish MSS-first
ถ้าราคาทะลุ Swing Low ล่าสุด → มองเป็น Bearish MSS-first
เลือกได้ว่าจะยืนยันจาก Close หรือจาก ไส้แท่งเทียน
วาดป้าย MSS + เส้นเชื่อมจาก Swing ไปยังจุดที่เกิด MSS
มีตัวแปร trendBias ป้องกันไม่ให้ยิง MSS ซ้ำในทิศทางเดิมจนรก
MTF MSS-first + Cancel Logic
นำ Logic เดียวกันไปใช้กับ TF: 5m, 15m, 30m, 1h, 4h
สำหรับแต่ละ TF จะได้:
สถานะแนวโน้ม: Up / Down / Unknown
ระดับ Cancel: ราคาที่ถ้าหลุดจะถือว่าโครงสร้างเทรนด์นั้นถูก “ยกเลิก”
เช่น ในเทรนด์ขาขึ้น ระดับ Cancel มักมาจาก Swing Low ล่าสุด ฯลฯ
MTF Table บนกราฟ
แสดง Trend + Cancel ของ 5 TF ในรูปแบบตาราง
อ่านง่าย: แถว Trend เป็น Up/Down พร้อมสีพื้น, แถว Cancel เป็นตัวเลขราคา
ใช้ดูภาพรวมโครงสร้างหลาย TF ในมุมมองเดียว
Alert Conditions
แจ้งเตือน MSS-first ของ TF ปัจจุบัน
แจ้งเตือน MSS-first ของ TF 5m / 15m / 30m / 1h / 4h แยก Bull / Bear
วิธีใช้งาน
ใช้ Swing High / Swing Low เพื่อดูว่าโครงสร้าง cycle ปัจจุบันอยู่ตรงไหน
รอให้เกิด MSS-first เพื่อมองว่า “โครงสร้างราคาเริ่มกลับตัวแล้ว”
ใช้ Table MTF:
ดูว่า TF ไหนเป็น Up / Down
ใช้ราคาบรรทัด Cancel เป็นแนว “จุดตัดขาดทุนเชิงโครงสร้าง” หรือจุดเปลี่ยนมุมมอง
เทรดตามทิศทาง TF ใหญ่ แล้วหา Entry จาก MSS ของ TF เล็ก
จุดเด่น / ความเป็น Original
ใช้ Williams %R เป็นฐานในการสร้าง Swing Pattern แทนการใช้ Pivot ธรรมดา
เชื่อม W%R Swing เข้ากับแนวคิด MSS-first อย่างเป็นระบบ
มีทั้ง:
ป้าย Swing
ป้าย MSS + เส้นเชื่อม
MTF Trend + Cancel
Alert เตือน MSS ในหลาย TF
อยู่ในสคริปต์เดียว
เหมาะกับคนที่ต้องการอ่านโครงสร้างราคาแบบมีที่มาที่ไป ไม่ใช่แค่ตามอินดี้ตัวเดียวครับ ✅
受保护脚本
此脚本以闭源形式发布。 However, you can use it freely and without any limitations – learn more here.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
受保护脚本
此脚本以闭源形式发布。 However, you can use it freely and without any limitations – learn more here.
免责声明
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.