OPEN-SOURCE SCRIPT
MA200 Expansion and Drawdown Thermometer

MA200 Expansion & Drawdown Thermometer
Overview
This indicator measures and classifies every historical price cycle above and below a moving average, building a statistical thermometer that tells you — in real time — how extended the current move is relative to all past cycles.
How It Works
Every time price crosses above the selected moving average, the script opens a new expansion cycle and tracks the maximum percentage distance the HIGH reaches from the MA before price closes back below it. Symmetrically, every time price crosses below the MA, a drawdown cycle begins and tracks how far the LOW drops before price recovers. When each cycle ends, its peak expansion (or drawdown) percentage is stored in a historical array.
Thermometer Lines
At the right edge of the chart, three horizontal dashed lines project forward from the current MA value:
🔺 EXP MAX — the largest upside expansion ever recorded in the selected period
⚠️ EXP 75%ile — the 75th percentile of all historical expansions
📊 EXP AVG — the average expansion across all cycles
The same three levels are mirrored below the MA for drawdown cycles (blue/purple palette). Coloured fill zones between the lines create an intuitive heat-map: yellow → orange → red for upside risk, teal → purple → blue for downside risk.
Live Cycle Label
When price is currently in an active cycle, a label on the latest bar shows:
Maximum % reached so far in this cycle
Current close % distance from the MA
Remaining headroom to the historical maximum
Historical Table
A compact side table displays:
Period indicator — shows whether you are viewing the full history or a custom lookback window
Top N expansions (ranked, colour-coded by intensity vs. average and 75th percentile)
Top N drawdowns (same logic, mirrored below a divider)
Average and MAX summary for both sections
LIVE row (highlighted in yellow) when a cycle is currently active
Settings
Parameter Description
MA Length Period of the moving average (default 200)
MA Type SMA / EMA / WMA / HMA
Anni di storico Lookback window in years — 0 = full history
Top N per sezione How many ranked cycles to show in the table
Table Position Top/Bottom × Left/Right
Background tint Subtle colour fill above/below the MA
Coloured zones Toggle the thermometer fill bands
Overview
This indicator measures and classifies every historical price cycle above and below a moving average, building a statistical thermometer that tells you — in real time — how extended the current move is relative to all past cycles.
How It Works
Every time price crosses above the selected moving average, the script opens a new expansion cycle and tracks the maximum percentage distance the HIGH reaches from the MA before price closes back below it. Symmetrically, every time price crosses below the MA, a drawdown cycle begins and tracks how far the LOW drops before price recovers. When each cycle ends, its peak expansion (or drawdown) percentage is stored in a historical array.
Thermometer Lines
At the right edge of the chart, three horizontal dashed lines project forward from the current MA value:
🔺 EXP MAX — the largest upside expansion ever recorded in the selected period
⚠️ EXP 75%ile — the 75th percentile of all historical expansions
📊 EXP AVG — the average expansion across all cycles
The same three levels are mirrored below the MA for drawdown cycles (blue/purple palette). Coloured fill zones between the lines create an intuitive heat-map: yellow → orange → red for upside risk, teal → purple → blue for downside risk.
Live Cycle Label
When price is currently in an active cycle, a label on the latest bar shows:
Maximum % reached so far in this cycle
Current close % distance from the MA
Remaining headroom to the historical maximum
Historical Table
A compact side table displays:
Period indicator — shows whether you are viewing the full history or a custom lookback window
Top N expansions (ranked, colour-coded by intensity vs. average and 75th percentile)
Top N drawdowns (same logic, mirrored below a divider)
Average and MAX summary for both sections
LIVE row (highlighted in yellow) when a cycle is currently active
Settings
Parameter Description
MA Length Period of the moving average (default 200)
MA Type SMA / EMA / WMA / HMA
Anni di storico Lookback window in years — 0 = full history
Top N per sezione How many ranked cycles to show in the table
Table Position Top/Bottom × Left/Right
Background tint Subtle colour fill above/below the MA
Coloured zones Toggle the thermometer fill bands
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
FOLLOW ME ON YOUTUBE
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
FOLLOW ME ON YOUTUBE
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน