OPEN-SOURCE SCRIPT
Directional SMA Trend Line

Short description
A directional trend line based on the fast SMA. The line changes color when the trend regime shifts, using the relationship between a short SMA and a long SMA. Simple, visual, and effective for trend-following and swing trading.
Full description
The Directional SMA Trend Line is a clean trend-following indicator built around two simple moving averages.
The indicator plots the fast SMA as the main trend line. Its color changes depending on the relationship between the fast SMA and the slow SMA:
Green when the fast SMA is above the slow SMA
Purple when the fast SMA is below the slow SMA
This creates a clear directional line that helps traders stay aligned with the prevailing trend. When the color changes, it signals a potential shift in trend direction or market regime.
Suggested settings
On the weekly timeframe, a 10-period fast SMA and a 20-period slow SMA work very well for swing trading. This combination offers a strong balance between responsiveness and trend stability. In many cases, the 10/20 weekly setup is a reliable way to follow medium-term directional moves.
On the daily timeframe, shorter combinations such as 4/7 can also be effective. However, there is no universal setting that works best for every stock. Each stock has its own rhythm and volatility profile, so traders are encouraged to test different fast/slow ratios to find what fits best.
Over time, you may notice that certain categories of stocks tend to respond well to similar SMA relationships. Even so, the weekly 10/20 setup remains a strong baseline for identifying swing trends.
Core idea
The trend is your friend. This indicator is designed to keep the trend visually simple: follow the line, watch the color, and stay on the right side of momentum.
How to use it
Notes
This is a trend-following tool, not a prediction tool. Like all moving-average-based indicators, it may react later in fast reversals or sideways markets.
A directional trend line based on the fast SMA. The line changes color when the trend regime shifts, using the relationship between a short SMA and a long SMA. Simple, visual, and effective for trend-following and swing trading.
Full description
The Directional SMA Trend Line is a clean trend-following indicator built around two simple moving averages.
The indicator plots the fast SMA as the main trend line. Its color changes depending on the relationship between the fast SMA and the slow SMA:
Green when the fast SMA is above the slow SMA
Purple when the fast SMA is below the slow SMA
This creates a clear directional line that helps traders stay aligned with the prevailing trend. When the color changes, it signals a potential shift in trend direction or market regime.
Suggested settings
On the weekly timeframe, a 10-period fast SMA and a 20-period slow SMA work very well for swing trading. This combination offers a strong balance between responsiveness and trend stability. In many cases, the 10/20 weekly setup is a reliable way to follow medium-term directional moves.
On the daily timeframe, shorter combinations such as 4/7 can also be effective. However, there is no universal setting that works best for every stock. Each stock has its own rhythm and volatility profile, so traders are encouraged to test different fast/slow ratios to find what fits best.
Over time, you may notice that certain categories of stocks tend to respond well to similar SMA relationships. Even so, the weekly 10/20 setup remains a strong baseline for identifying swing trends.
Core idea
The trend is your friend. This indicator is designed to keep the trend visually simple: follow the line, watch the color, and stay on the right side of momentum.
How to use it
Notes
This is a trend-following tool, not a prediction tool. Like all moving-average-based indicators, it may react later in fast reversals or sideways markets.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。