OPEN-SOURCE SCRIPT
SMA Crossover High/Low Lines

SMA Crossover High/Low Lines (version=5)
Purpose
This indicator plots horizontal lines and optional price labels on the high and low of candles where the price crosses a Simple Moving Average (SMA). It helps identify buy/sell signals visually on the chart.
Inputs
smaLength – Length of the SMA (default: 50).
showType – Which crossovers to show: "Both", "Buy Only", or "Sell Only".
lineLength – How many bars the horizontal line extends (default: 10).
showPriceLabels – Whether to show price labels at crossover points (true/false).
Logic
SMA Calculation – Computes a simple moving average of the closing price.
Crossover Detection:
crossUp → price crosses above SMA (buy signal).
crossDown → price crosses below SMA (sell signal).
Draw Horizontal Lines – At candle high and low of crossover:
Green for buy (crossUp)
Red for sell (crossDown)
Lines extend for lineLength bars
Optional Labels – Shows the high/low price at the end of the horizontal line if showPriceLabels is true.
Visualization
SMA line plotted in blue.
Buy crossovers → green horizontal lines and labels.
Sell crossovers → red horizontal lines and labels.
In short:
This indicator highlights buy/sell points where price crosses the SMA by marking candle highs/lows with colored lines and optional price labels for easy visual reference.
Purpose
This indicator plots horizontal lines and optional price labels on the high and low of candles where the price crosses a Simple Moving Average (SMA). It helps identify buy/sell signals visually on the chart.
Inputs
smaLength – Length of the SMA (default: 50).
showType – Which crossovers to show: "Both", "Buy Only", or "Sell Only".
lineLength – How many bars the horizontal line extends (default: 10).
showPriceLabels – Whether to show price labels at crossover points (true/false).
Logic
SMA Calculation – Computes a simple moving average of the closing price.
Crossover Detection:
crossUp → price crosses above SMA (buy signal).
crossDown → price crosses below SMA (sell signal).
Draw Horizontal Lines – At candle high and low of crossover:
Green for buy (crossUp)
Red for sell (crossDown)
Lines extend for lineLength bars
Optional Labels – Shows the high/low price at the end of the horizontal line if showPriceLabels is true.
Visualization
SMA line plotted in blue.
Buy crossovers → green horizontal lines and labels.
Sell crossovers → red horizontal lines and labels.
In short:
This indicator highlights buy/sell points where price crosses the SMA by marking candle highs/lows with colored lines and optional price labels for easy visual reference.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.