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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.