Indicator · Pine Script v4 · On the chart

5 EMAs

by hirawatt· code credited to yesgoods

5 EMAs calculates and plots five Exponential Moving Averages derived from five configurable timeframes directly onto the main price chart.

View on GitHub

Repaints

GitHub stars11on the repository
Pine versionv4older, still runs
Lines of code49
Settings12inputs
LicenceMIT
Last update2 years ago11 Dec 2023

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

49 lines of Pine Script v4 from indicator/5MA.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

5MA.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © yesgoods

//@version=4
study(title="5 EMAs", shorttitle="5MA", overlay=true)

// Variables {
src = input(title="Source", type=input.source, defval=hlc3)

timeFrame  = input(title="Time Frame", type=input.resolution, defval="180")
timeFrame1 = input(title="Time Frame 1", type=input.resolution, defval="5")
timeFrame2 = input(title="Time Frame 2", type=input.resolution, defval="15")
timeFrame3 = input(title="Time Frame 3", type=input.resolution, defval="30")
timeFrame4 = input(title="Time Frame 4", type=input.resolution, defval="120")
timeFrame5 = input(title="Time Frame 5", type=input.resolution, defval="D")

ema1Len = input(title="MA 1 Length", type=input.integer, defval=1)
ema2Len = input(title="MA 2 Length", type=input.integer, defval=5)
ema3Len = input(title="MA 3 Length", type=input.integer, defval=10)
ema4Len = input(title="MA 4 Length", type=input.integer, defval=21)
ema5Len = input(title="MA 5 Length", type=input.integer, defval=55)

ema1 = ema(security(syminfo.tickerid, timeFrame1, src), ema1Len)
ema2 = ema(security(syminfo.tickerid, timeFrame2, src), ema2Len)
ema3 = ema(security(syminfo.tickerid, timeFrame3, src), ema3Len)
ema4 = ema(security(syminfo.tickerid, timeFrame4, src), ema4Len)
ema5 = ema(security(syminfo.tickerid, timeFrame5, src), ema5Len)
//}

// Design {
p_1 = plot(ema1, title="MA1", color=color.blue)
p_2 = plot(ema2, title="MA2", color=color.green)
p_3 = plot(ema3, title="MA3", color=color.yellow)
p_4 = plot(ema4, title="MA4", color=color.orange)
p_5 = plot(ema5, title="MA5", color=color.red)

symbolHigh = security(syminfo.tickerid, timeFrame, high)
symbolLow  = security(syminfo.tickerid, timeFrame, low)

plot(symbolHigh, color=color.green)
plot(symbolLow, color=color.red)

bars = tostring(bar_index)

var table t = table.new(position.top_right, 1, 2, bgcolor = color.rgb(255, 0, 0, 50))
table.cell_set_text(t, row = 0, column = 0, text = "Bars")
table.cell(t, 0, 1, text = bars, bgcolor = color.rgb(255, 255, 0, 50))

//}

Overview

5 EMAs also plots the high and low lines fetched from an additional custom timeframe, accompanied by a small on-screen table showing the total bar index count. Traders can adjust the calculation source, moving average lengths, and individual timeframe resolutions. Because the script references higher-timeframe data via security calls without lookahead restrictions, calculated values on historical and live higher-timeframe bars may repaint.

Details

Published by

hirawatt on GitHub

Code credit

yesgoods, as written in the script's header

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Moving averages, Trend, Support & resistance, Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Topics

pinescriptpinescript-indicatorspinescript-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Sourcesourcehlc3src
Time Frametimeframe180timeFrame
Time Frame 1timeframe5timeFrame1
Time Frame 2timeframe15timeFrame2
Time Frame 3timeframe30timeFrame3
Time Frame 4timeframe120timeFrame4
Time Frame 5timeframeDtimeFrame5
MA 1 Lengthint1ema1Len
MA 2 Lengthint5ema2Len
MA 3 Lengthint10ema3Len
MA 4 Lengthint21ema4Len
MA 5 Lengthint55ema5Len
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

Market Monitor - 1m

by chris-c-thomas
14 stars

Market Monitor - 1m is an overlay indicator designed for multi-chart monitoring and directional bias assessment. It plots a fast, mid, and slow EMA ribbon with a fill cloud, session VWAP with standard deviation bands, and previous day key levels. It evaluates

Indicator v6 TrendMoving averages Repaints
Updated 6 months ago · MIT GitHub repository of Market Monitor - 1m
257 stars

This indicator analyzes short-term price action on index futures and options charts by applying Rational Quadratic kernel smoothing to detect sideways consolidation ranges and potential breakouts. It processes pivot highs and lows over customizable loopback pe

Indicator v5 Support & resistanceTrend Repaints
Updated 6 weeks ago · None stated GitHub repository of SPX 30M - Trading Chart

Ichimoku Cloud

by harryguiacorn
219 stars

This indicator plots Ichimoku Cloud elements on the price chart, including Tenkan-sen, Kijun-sen, Senkou Span A and B lines with optional Chikou Span. It signals trend changes via Tenkan-sen and Kijun-sen crosses and places arrows at Kijun-sen direction shifts

Indicator v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ichimoku Cloud
218 stars

TradersPost Trading Checklist is an overlay indicator that evaluates a suite of popular technical conditions for long and short trade setups. It checks session-anchored VWAP, fast and slow EMA alignments and crosses, 200 SMA, RSI overbought or oversold conditi

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of TradersPost Trading Checklist

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers