Indicator · Pine Script v4 · Own pane

Simple EMA Candle

by minaecer

This indicator plots colored candles on the price chart using three Exponential Moving Averages.

View on GitHub

GitHub stars2on the repository
Pine versionv4older, still runs
Lines of code39
Settings6inputs
LicenceMPL-2.0
Last update4 years ago27 Jun 2022

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

39 lines of Pine Script v4 from simpleemacandle.pinescript, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

simpleemacandle.pinescript
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © minaecer
study("Simple EMA Candle")
//length
flen = input(30, title="1st Length")
slen = input(15, title="2st Length")
tlen = input(10, title="3nd Length")
src = input(close, title="Source")
barcl = input(true, title="Bar Color")
//ema
fema = ema(src, flen)
sema = ema(src, slen)
tema = ema(src, tlen)
//color
wcolor = tema > fema ? tema > sema ? color.green : color.orange : 
   tema > sema ? color.orange : color.red

eba = input(false, title="Enable colors")

barcolor(eba ? wcolor : na, title="Bar Colours")
//plot
plotcandle(fema, sema, tema, close, title='Title', color=wcolor, wickcolor=color.black)
avg_1 = avg(tema, fema)
plotshape(tema >= fema ? avg_1 : na, style=shape.triangleup, size=size.large, color=color.green, location=location.abovebar, show_last=1)
avg_2 = avg(tema, fema)
plotshape(fema >= tema ? avg_2 : na, style=shape.triangledown, size=size.large, color=color.red, location=location.abovebar, show_last=1)


avg_3 = avg(tema, fema)
alertcondition(tema >= fema ? avg_3 : na, title='Alert on Green Bar', message='Green Bar!')
avg_4 = avg(tema, fema)
alertcondition(fema >= fema ? avg_4 : na, title='Alert on Red Bar', message='Red Bar!')

var testTable = table.new(position=position.top_right, columns=1, rows=1, bgcolor=color.yellow, border_width=1)


if barstate.islast
    table.cell(table_id=testTable, column=0, row=0, text='EMA    ' + tostring(fema))

Overview

The 30-period EMA serves as the open, the 15-period EMA as the high, and the 10-period EMA as the low, with the original close value. Bar colors change based on comparisons between the 10-period EMA and the 30-period EMA, and optionally the 15-period EMA. Upward and downward triangular markers appear above the bars to signal when the 10-period EMA crosses above or below the 30-period EMA. Settings allow adjustment of the three EMA lengths, selection of data source, and toggling of bar color display. A table shows the current 30-period EMA value at the top right of the chart.

Details

Published by

minaecer on GitHub

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pinescriptpinescript-indicatorstrades

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
1st Lengthint30flen
2st Lengthint15slen
3nd Lengthint10tlen
Sourcesourceclosesrc
Bar Colorbooltruebarcl
Enable colorsboolfalseeba
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Cerebr Bloop

by jerryinyang
5 stars

Cerebr Bloop is a momentum oscillator calculated by applying Heikin-Ashi candle logic to a zero-centered Relative Strength Index (RSI). Displayed in a separate pane, it visualizes smoothed RSI momentum candles alongside customizable overbought and oversold thr

Indicator v4 Oscillators & momentumCandlestick patterns
Updated 2 years ago · None stated GitHub repository of Cerebr Bloop
3 stars

This indicator plots a 20 period simple moving average of the closing price on the chart. The test_val input sets the number of last bars to show for the plot. It draws in a separate pane using price action principles and a moving average. No buy or sell signa

Indicator v5 Moving averagesCandlestick patterns
Updated 5 months ago · None stated GitHub repository of Price Action Candles
1 stars

This indicator plots detrended candlesticks in a separate pane relative to a chosen baseline to highlight market cycles around a zero line. Users can switch the baseline mode between a moving average and high/low extremes. In moving average mode, it subtracts

Indicator v5 Moving averagesOscillators & momentum
Updated 7 weeks ago · None stated GitHub repository of Detrended Candles (Switchable)
285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers