OPEN-SOURCE SCRIPT
STOC - Moving Average Trend & Signals

STOC – Moving Average Trend & Signals is a trend-following indicator designed to simplify moving-average analysis using four widely followed averages:
• 10 EMA – Short-term momentum
• 20 EMA – Short/intermediate trend
• 50 SMA – Intermediate trend
• 200 SMA – Long-term market structure
The indicator combines price position, moving-average direction and MA alignment to identify potential entries, exits and broader trend conditions.
SIGNAL MODES
1. MA Stack
A Buy signal occurs when the averages newly align in bullish order:
10 EMA > 20 EMA > 50 SMA > 200 SMA
The standard exit occurs when this bullish alignment breaks.
2. Price vs MA
A Buy signal occurs when price crosses above the selected signal MA. The standard exit occurs when price crosses below it.
The selectable signal averages are:
• 10 EMA
• 20 EMA
• 50 SMA
• 200 SMA
3. Fast/Slow Crossover
A Buy signal occurs when the 10 EMA crosses above the 20 EMA. The standard exit occurs when the 10 EMA crosses below the 20 EMA.
EXIT METHODS
1. MA Signal Exit
Uses the corresponding exit condition of the selected signal mode.
2. ATR Trailing Exit
Replaces the standard MA exit with a volatility-adjusted trailing stop. The ATR stop follows the highest price reached after entry and never moves downward during an active trade.
The ATR exit is confirmed only when a candle closes below the trailing stop. Intrabar touches do not trigger an exit.
OPTIONAL FILTERS
• Moving-average slope confirmation
• Volume confirmation
• Minimum separation between the 10 EMA and 200 SMA
• Bar-close signal confirmation
• Flat or choppy market filter
DASHBOARD
The high-contrast dashboard is designed to remain visible on both light and dark chart themes. It displays:
• Current market trend
• Moving-average alignment
• Selected signal MA
• Price position
• MA direction
• Active exit method
• Current ATR stop
• Volume-filter status
• Current trade status
VISUAL FEATURES
• Individually configurable moving-average plots
• Buy and Exit labels
• Bullish and bearish trend backgrounds
• Optional ATR trailing-stop line
• Adjustable dashboard position and size
ALERTS
Alert conditions are included for:
• Buy signals
• All exit signals
• MA-based exits
• ATR trailing exits
• Beginning of a strong uptrend
• Beginning of a strong downtrend
For more reliable live alerts, keep “Confirm Signals on Bar Close” enabled and select “Once Per Bar Close” when creating the TradingView alert.
SUGGESTED USE
The indicator can be used across stocks, indices, futures, forex and cryptocurrencies. Higher timeframes such as 4-hour, daily and weekly charts generally provide cleaner trend signals, while lower timeframes may generate more frequent signals and market noise.
This indicator is a trend-following decision-support tool. It does not predict future prices or guarantee profitable trades. Signals should be combined with appropriate position sizing, risk management, support and resistance analysis, and independent market evaluation.
• 10 EMA – Short-term momentum
• 20 EMA – Short/intermediate trend
• 50 SMA – Intermediate trend
• 200 SMA – Long-term market structure
The indicator combines price position, moving-average direction and MA alignment to identify potential entries, exits and broader trend conditions.
SIGNAL MODES
1. MA Stack
A Buy signal occurs when the averages newly align in bullish order:
10 EMA > 20 EMA > 50 SMA > 200 SMA
The standard exit occurs when this bullish alignment breaks.
2. Price vs MA
A Buy signal occurs when price crosses above the selected signal MA. The standard exit occurs when price crosses below it.
The selectable signal averages are:
• 10 EMA
• 20 EMA
• 50 SMA
• 200 SMA
3. Fast/Slow Crossover
A Buy signal occurs when the 10 EMA crosses above the 20 EMA. The standard exit occurs when the 10 EMA crosses below the 20 EMA.
EXIT METHODS
1. MA Signal Exit
Uses the corresponding exit condition of the selected signal mode.
2. ATR Trailing Exit
Replaces the standard MA exit with a volatility-adjusted trailing stop. The ATR stop follows the highest price reached after entry and never moves downward during an active trade.
The ATR exit is confirmed only when a candle closes below the trailing stop. Intrabar touches do not trigger an exit.
OPTIONAL FILTERS
• Moving-average slope confirmation
• Volume confirmation
• Minimum separation between the 10 EMA and 200 SMA
• Bar-close signal confirmation
• Flat or choppy market filter
DASHBOARD
The high-contrast dashboard is designed to remain visible on both light and dark chart themes. It displays:
• Current market trend
• Moving-average alignment
• Selected signal MA
• Price position
• MA direction
• Active exit method
• Current ATR stop
• Volume-filter status
• Current trade status
VISUAL FEATURES
• Individually configurable moving-average plots
• Buy and Exit labels
• Bullish and bearish trend backgrounds
• Optional ATR trailing-stop line
• Adjustable dashboard position and size
ALERTS
Alert conditions are included for:
• Buy signals
• All exit signals
• MA-based exits
• ATR trailing exits
• Beginning of a strong uptrend
• Beginning of a strong downtrend
For more reliable live alerts, keep “Confirm Signals on Bar Close” enabled and select “Once Per Bar Close” when creating the TradingView alert.
SUGGESTED USE
The indicator can be used across stocks, indices, futures, forex and cryptocurrencies. Higher timeframes such as 4-hour, daily and weekly charts generally provide cleaner trend signals, while lower timeframes may generate more frequent signals and market noise.
This indicator is a trend-following decision-support tool. It does not predict future prices or guarantee profitable trades. Signals should be combined with appropriate position sizing, risk management, support and resistance analysis, and independent market evaluation.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Building STOC: Systematic and Rule Based Trading - Crypto, Commodities, India & Global Investments.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
Building STOC: Systematic and Rule Based Trading - Crypto, Commodities, India & Global Investments.
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。