OPEN-SOURCE SCRIPT

Candle vs 8 SMA - Red & Green

171
📈 Script Name: Candle vs 8 SMA – Red & Green
This TradingView Pine Script visually compares each candle's close price to the 8-period Simple Moving Average (SMA) and highlights the chart accordingly:

🔍 What It Does:
Calculates the 8-period SMA

sma8 = ta.sma(close, 8)

This line computes the average of the last 8 closing prices to smooth out short-term fluctuations.

Plots the SMA Line

Orange line shown on the chart.

Helps you visually track the short-term trend.

Identifies Candle Position

candleAbove: true if the candle’s close is above the SMA

candleBelow: true if the candle’s close is below the SMA

Highlights Background

If the close is above the 8 SMA → Green background (indicating bullish behavior)

If the close is below the 8 SMA → Red background (indicating bearish behavior)

Plots Triangle Shapes

Green triangle below candle when above the SMA

Red triangle above candle when below the SMA

Helps quickly identify conditions at a glance

🧠 Why Use It?
This script is useful for:

Intraday trend confirmation

Spotting momentum shifts

Visual clarity on how price reacts to a dynamic support/resistance (SMA)

Aiding quick decisions for scalping or intraday trades

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.