Colored EMA Indicator





This is a modified version of the exponential moving average indicator. The only difference is that it changes color based on price action.

How It Works

When the closing price is above the EMA, the EMA will turn green for bullish.

When the closing price is below the EMA, the EMA will turn red for bearish.

Settings

EMA Length:
This sets the calculation period of the Exponential Moving Average.

EMA Source:
This sets the data source of the Exponential Moving Average.


Pine Script Basics Course
Pine Script Mastery Course

Source Code

// Created by Matthew J. Slabosz
// www.zenandtheartoftrading.com
// @version=3
study(title = "MJS - Colored EMA", shorttitle="EMA+", overlay = true)

// Strategy settings
emaLength = input(50, minval=1, title="EMA Length")
emaSource = input(close, title="EMA Source")

// Get EMA and plot it
ema = ema(emaSource, emaLength)
plot(ema, color=close[1] > ema and close > ema ? green : red, linewidth=2)

Last Updated: 21st March, 2019


Free Premium Charts!

5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments