OPEN-SOURCE SCRIPT
Moving Average Band Strategy

Overview
The Moving Average Band Strategy is a fully customizable breakout and trend-continuation system designed for traders who need both simplicity and control.
The strategy creates adaptive bands around a user-selected moving average and executes trades when price breaks out of these bands, with advanced risk-management settings including optional Risk:Reward targets.
This script is suitable for intraday, swing, and positional traders across all markets — equities, futures, crypto, and forex.
Key Features
✔ Six Moving Average Types
Choose the MA that best matches your trading style:
SMA
EMA
WMA
HMA
VWMA
RMA
✔ Dynamic Bands
Upper Band built from MA of highs
Lower Band built from MA of lows
Adjustable band offset (%)
Color-coded band fill indicating price position
✔ Configurable Strategy Preferences
Toggle Long and/or Short trades
Toggle Risk:Reward Take-Profit
Adjustable Risk:Reward Ratio
Default position sizing: % of equity (configurable via strategy settings)
Entry Conditions
Long Entry
A long trade triggers when:
Price crosses above the Upper Band
Long trades are enabled
No existing long position is active
Short Entry
A short trade triggers when:
Price crosses below the Lower Band
Short trades are enabled
No existing short position is active
Clear entry markers and price labels appear on the chart.
Risk Management
This strategy includes a complete set of risk-controls:
Stop-Loss (Fixed at Entry)
Long SL: Lower Band
Short SL: Upper Band
These levels remain constant for the entire trade.
Optional Risk:Reward Take-Profit
Enabled/disabled using a toggle switch.
When enabled:
Long TP = Entry + (Risk × Risk:Reward Ratio)
Short TP = Entry – (Risk × Risk:Reward Ratio)
When disabled:
Exits are handled by reverse crossover signals.
Exit Conditions
Long Exit
Stop-Loss Hit (touch-based)
Take-Profit Hit (if enabled)
Reverse Band Crossover (if TP disabled)
Short Exit
Stop-Loss Hit (touch-based)
Take-Profit Hit (if enabled)
Reverse Band Crossover (if TP disabled)
Exit markers and price labels are plotted automatically.
Visual Tools
To improve clarity:
Upper & Lower Band (blue, adjustable width)
Middle Line
Dynamic band fill (green/red/yellow)
SL & TP line plotting when in position
Entry/Exit markers
Price labels for all executed trades
These are built to help users visually follow the strategy logic.
Alerts Included
Every trading event is covered:
Long Entry
Short Entry
Long SL / TP / Cross Exit
Short SL / TP / Cross Exit
Combined Alert for webhook/automation (JSON-formatted)
Perfect for algo trading, Discord bots, or automation platforms.
Best For
This strategy performs best in:
Trending markets
Breakout environments
High-momentum instruments
Clean intraday swings
Works seamlessly on:
Stocks
Index futures
Commodities
Crypto
Forex
⚠️ Important Disclaimer
This script is for educational purposes only.
Trading involves risk. Backtest results are not indicative of future performance.
Always validate settings and use proper position sizing.
The Moving Average Band Strategy is a fully customizable breakout and trend-continuation system designed for traders who need both simplicity and control.
The strategy creates adaptive bands around a user-selected moving average and executes trades when price breaks out of these bands, with advanced risk-management settings including optional Risk:Reward targets.
This script is suitable for intraday, swing, and positional traders across all markets — equities, futures, crypto, and forex.
Key Features
✔ Six Moving Average Types
Choose the MA that best matches your trading style:
SMA
EMA
WMA
HMA
VWMA
RMA
✔ Dynamic Bands
Upper Band built from MA of highs
Lower Band built from MA of lows
Adjustable band offset (%)
Color-coded band fill indicating price position
✔ Configurable Strategy Preferences
Toggle Long and/or Short trades
Toggle Risk:Reward Take-Profit
Adjustable Risk:Reward Ratio
Default position sizing: % of equity (configurable via strategy settings)
Entry Conditions
Long Entry
A long trade triggers when:
Price crosses above the Upper Band
Long trades are enabled
No existing long position is active
Short Entry
A short trade triggers when:
Price crosses below the Lower Band
Short trades are enabled
No existing short position is active
Clear entry markers and price labels appear on the chart.
Risk Management
This strategy includes a complete set of risk-controls:
Stop-Loss (Fixed at Entry)
Long SL: Lower Band
Short SL: Upper Band
These levels remain constant for the entire trade.
Optional Risk:Reward Take-Profit
Enabled/disabled using a toggle switch.
When enabled:
Long TP = Entry + (Risk × Risk:Reward Ratio)
Short TP = Entry – (Risk × Risk:Reward Ratio)
When disabled:
Exits are handled by reverse crossover signals.
Exit Conditions
Long Exit
Stop-Loss Hit (touch-based)
Take-Profit Hit (if enabled)
Reverse Band Crossover (if TP disabled)
Short Exit
Stop-Loss Hit (touch-based)
Take-Profit Hit (if enabled)
Reverse Band Crossover (if TP disabled)
Exit markers and price labels are plotted automatically.
Visual Tools
To improve clarity:
Upper & Lower Band (blue, adjustable width)
Middle Line
Dynamic band fill (green/red/yellow)
SL & TP line plotting when in position
Entry/Exit markers
Price labels for all executed trades
These are built to help users visually follow the strategy logic.
Alerts Included
Every trading event is covered:
Long Entry
Short Entry
Long SL / TP / Cross Exit
Short SL / TP / Cross Exit
Combined Alert for webhook/automation (JSON-formatted)
Perfect for algo trading, Discord bots, or automation platforms.
Best For
This strategy performs best in:
Trending markets
Breakout environments
High-momentum instruments
Clean intraday swings
Works seamlessly on:
Stocks
Index futures
Commodities
Crypto
Forex
⚠️ Important Disclaimer
This script is for educational purposes only.
Trading involves risk. Backtest results are not indicative of future performance.
Always validate settings and use proper position sizing.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.