OPEN-SOURCE SCRIPT
Dual MA Trendline with Angle Lock

"Dual MA Trendline with Angle Lock + Multiplier Bands" is a trend-following overlay indicator that combines two moving averages (MAs), each with a special "angle lock" mechanism.
Key mechanics: Instead of plotting the raw MA directly as the main trend line, it creates a piecewise-linear trendline for each MA.
The trendline locks its slope (angle) and starting value whenever the MA's recent slope changes significantly (more than the user-defined angleThreshold).
Between these "slope reset" points, the trendline continues with constant slope (straight line segments), producing flatter, more persistent trend representations than a curving MA.
Around the locked trendline, it draws symmetric bands:Base band (1×) — always shown
Optional multiplier bands (2×, 4×, 8×) — configurable
Bands can be in percentage (volatility-adaptive) or fixed points (useful for forex/crypto with small price units or tick-based instruments).
It also plots fills between the two MAs' bands/trendlines → visually highlights:Upper zone (greenish fill)
Middle zone (blueish fill)
Lower zone (reddish fill)
In short: two independent "locked-angle trend ribbons" with multiplier deviation bands + inter-ribbon fills.
Main Use Cases
Trend direction & strength visualization
The locked-slope trendlines stay straighter and change direction less frequently than normal MAs → clearer visual read of the prevailing trend (especially useful on noisy charts).
Dynamic support/resistance zones
1× bands act as near-term dynamic S/R.
2× / 4× / 8× bands serve as progressively stronger support/resistance or "overextended" levels.
→ Many traders watch for price rejection, bounces, or acceleration once price reaches 2×–4× bands.
Mean-reversion / pullback entries (especially in ranging or mildly trending markets)
Price touching or exceeding outer multiplier bands + returning toward the trendline often signals good mean-reversion setups.
Trend-continuation / breakout filtering Price riding above the upper bands in uptrend → strong momentum continuation. Price breaking and closing outside 4×–8× bands → potential acceleration or trend exhaustion signal.
Dual-timeframe / dual-speed MA comparison MA 1 is usually longer/slower (default 128), MA 2 is shorter/faster (default 14).
The fills between them act like a "trend tunnel" — wide middle fill = strong trend, narrowing = consolidation, color changes = possible reversal.
Clean chart alternative to channels / regression / envelopes
The angle-locking creates straighter, less whipsaw-prone lines than typical Bollinger Bands, Keltner Channels, or regression channels, while still adapting to price.
Typical settings example MA1: longer period (50–200), small angle threshold → persistent major trend
MA2: shorter period (9–34), larger angle threshold → more responsive minor trend
Use percentage bands on stocks/indices, fixed points on forex/crypto with small pip values.
Overall → very popular style among traders who like clean, low-repaint trend + deviation band systems (similar spirit to SuperTrend + envelopes, but with custom slope-locking logic).
Key mechanics: Instead of plotting the raw MA directly as the main trend line, it creates a piecewise-linear trendline for each MA.
The trendline locks its slope (angle) and starting value whenever the MA's recent slope changes significantly (more than the user-defined angleThreshold).
Between these "slope reset" points, the trendline continues with constant slope (straight line segments), producing flatter, more persistent trend representations than a curving MA.
Around the locked trendline, it draws symmetric bands:Base band (1×) — always shown
Optional multiplier bands (2×, 4×, 8×) — configurable
Bands can be in percentage (volatility-adaptive) or fixed points (useful for forex/crypto with small price units or tick-based instruments).
It also plots fills between the two MAs' bands/trendlines → visually highlights:Upper zone (greenish fill)
Middle zone (blueish fill)
Lower zone (reddish fill)
In short: two independent "locked-angle trend ribbons" with multiplier deviation bands + inter-ribbon fills.
Main Use Cases
Trend direction & strength visualization
The locked-slope trendlines stay straighter and change direction less frequently than normal MAs → clearer visual read of the prevailing trend (especially useful on noisy charts).
Dynamic support/resistance zones
1× bands act as near-term dynamic S/R.
2× / 4× / 8× bands serve as progressively stronger support/resistance or "overextended" levels.
→ Many traders watch for price rejection, bounces, or acceleration once price reaches 2×–4× bands.
Mean-reversion / pullback entries (especially in ranging or mildly trending markets)
Price touching or exceeding outer multiplier bands + returning toward the trendline often signals good mean-reversion setups.
Trend-continuation / breakout filtering Price riding above the upper bands in uptrend → strong momentum continuation. Price breaking and closing outside 4×–8× bands → potential acceleration or trend exhaustion signal.
Dual-timeframe / dual-speed MA comparison MA 1 is usually longer/slower (default 128), MA 2 is shorter/faster (default 14).
The fills between them act like a "trend tunnel" — wide middle fill = strong trend, narrowing = consolidation, color changes = possible reversal.
Clean chart alternative to channels / regression / envelopes
The angle-locking creates straighter, less whipsaw-prone lines than typical Bollinger Bands, Keltner Channels, or regression channels, while still adapting to price.
Typical settings example MA1: longer period (50–200), small angle threshold → persistent major trend
MA2: shorter period (9–34), larger angle threshold → more responsive minor trend
Use percentage bands on stocks/indices, fixed points on forex/crypto with small pip values.
Overall → very popular style among traders who like clean, low-repaint trend + deviation band systems (similar spirit to SuperTrend + envelopes, but with custom slope-locking logic).
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน