OPEN-SOURCE SCRIPT

Candle vs 8 SMA - Red & Green

355
📈 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

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.