Request: Multi-EMA, with Settings

drizzla

Member
I currently have 5 different EMAs on a couple of my charts, a 9, 20, 50, 100, 200. I would love to be able to combine these all into one single multi-EMA indicator, and I would love to have the individual indicator settings available in the customizations page (color, width, change EMA length, etc.). I am capable of doing some basic design edits to the actual script too, if need be, but not functional edits per se.

Here is a similar TradingView example: https://www.tradingview.com/script/lFGM42Wi-Multiple-EMA/

Sorry if this is a bit of lazy request, haha. Please feel free to link me to any existing indicators like this. Thank you!

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Salemselva
//@version=4

study(title="Multiple EMA", shorttitle="5EMA by SelNach", overlay=true)

len1 = input(10, minval=1, title="Length")
src1 = input(close, title="Source")
ema10 = ema(src1, len1)
plot(ema10, color=#f00b0b, transp=50, style=plot.style_line, linewidth=2, title="EMA(10)")

len2 = input(20, minval=1, title="Length")
src2 = input(close, title="Source")
ema20 = ema(src2, len2)
plot(ema20, color=#80ff33, transp=50, style=plot.style_line, linewidth=2, title="EMA(20)")

len3 = input(50, minval=1, title="Length")
src3 = input(close, title="Source")
ema50 = ema(src3, len3)
plot(ema50, color=#337dff, transp=50, style=plot.style_line, linewidth=2, title="EMA(50)")

len4 = input(100, minval=1, title="Length")
src4 = input(close, title="Source")
ema100 = ema(src4, len4)
plot(ema100, color=#af11aa, transp=50, style=plot.style_line, linewidth=2, title="EMA(100)")

len5 = input(200, minval=1, title="Length")
src5 = input(close, title="Source")
ema200 = ema(src5, len5)
plot(ema200, color=#f3ed16, transp=50, style=plot.style_line, linewidth=2, title="EMA(200)")

Here is my current EMA chart for reference:



OWZlwPS
 
Solution
@drizzla You may need to change the colors
Code:
input ma1 = 9;
input ma2 = 20;
input ma3 = 50;
input ma4 = 100;
input ma5 = 200;
input offset = 0;

def c = close;
def n = double.nan;

plot ema1 = if !isnan(c) then expaverage(c,ma1)[offset] else n;
ema1.setdefaultcolor(color.cyan);
ema1.hidebubble();
plot ema2 = if !isnan(c) then expaverage(c,ma2)[offset] else n;
ema2.setdefaultcolor(createcolor(0,51,51));
ema2.hidebubble();
plot ema3 = if !isnan(c) then expaverage(c,ma3)[offset] else n;
ema3.setdefaultcolor(color.magenta);
ema3.hidebubble();
plot ema4 = if !isnan(c) then expaverage(c,ma4)[offset] else n;
ema4.setdefaultcolor(createcolor(0,34,34));
ema4.hidebubble();
plot ema5 = if !isnan(c) then expaverage(c,ma5)[offset] else n...
@drizzla You may need to change the colors
Code:
input ma1 = 9;
input ma2 = 20;
input ma3 = 50;
input ma4 = 100;
input ma5 = 200;
input offset = 0;

def c = close;
def n = double.nan;

plot ema1 = if !isnan(c) then expaverage(c,ma1)[offset] else n;
ema1.setdefaultcolor(color.cyan);
ema1.hidebubble();
plot ema2 = if !isnan(c) then expaverage(c,ma2)[offset] else n;
ema2.setdefaultcolor(createcolor(0,51,51));
ema2.hidebubble();
plot ema3 = if !isnan(c) then expaverage(c,ma3)[offset] else n;
ema3.setdefaultcolor(color.magenta);
ema3.hidebubble();
plot ema4 = if !isnan(c) then expaverage(c,ma4)[offset] else n;
ema4.setdefaultcolor(createcolor(0,34,34));
ema4.hidebubble();
plot ema5 = if !isnan(c) then expaverage(c,ma5)[offset] else n;
ema5.setdefaultcolor(createcolor(0,34,34));
ema5.hidebubble();
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
184 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top