OPEN-SOURCE SCRIPT

Candle vs 8 SMA - Red & Green

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

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.