OPEN-SOURCE SCRIPT

SMA Crossover High/Low Lines

58
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.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.