ChrisMoody

Example Of How To Code Triple EMA’s - Colors Based On Trend!!!

FX:AUDUSD   Australian Dollar/U.S. Dollar
2731 30 40
Example of Triple EMA Changing Color To Show Trend.Currently You Can Only Have 2 Plots That Change Colors and have Fills Between The Plots.So I Created 2 Separate Indicators with Same RulesRules:If Slow EMA is Less Than Medium EMA, AND Medium EMA is Less Than Fast EMAColor = Red Showing Down TrendIf Slow EMA is Greater Than Medium EMA, AND Medium EMA is Greater Than Fast EMAColor = Green Showing Up TrendIf Both of the Above Rules are False then:Color = Yellow Showing No Trend. Consolidation Area.Lower StudyUses the Same Rules as the Upper Studies With the 3 EMA’sPlots Red in Down Trend, Green in Up Trend, Yellow = No TrendHistogram Shows The Difference Between the Short and Long EMA's*****Code is pasted below...Sometimes When I Copy and Paste the Code For Some Reason It Doesn't Come Through Correctly. *****You Can Click On The White Arrow At The Top Right Of The Chart And Then You Have Access To The Chart. On The Indicators Click On The Brackets To The Left Of the X And You Will See The Source Code. Just Re Name It If you Want and Click Save And The Indicator Will Be In Your Indicators List Under "Custom Scripts"Let Me Know If You Have Any Requests For Any Indicators.....I Enjoy Coding...
ChrisMoody PRO
3 years ago
For Some Reason the Annotations On The Chart Didn't Show Up....Sorry..
Reply
admin PRO ChrisMoody
3 years ago
Fixed. We'll look into what went wrong.
Reply
ChrisMoody PRO
3 years ago
Fast and Medium EMA Code - Upper Study

// Created By User ChrisMoody
// This Indicator plots the Fast and Medium EMA
// As of 1-14-2014 you can only use two Plots so this indicator is used with the Medium and Fast EMA Trend Indicator
// Rules = Iff EMAFast>=EmaMedium and EMA Medium>= EMA Slow THEN Color = Lime - Showing Up Trend
// Rules = Iff EMAFast < EmaMedium and EMA Medium < EMA Slow THEN Color = Fuchsia - Showing Down Trend
// If Rules Are Not True then Color = Yellow Showing NO TREND

study(title = "CM-TrippleEMA-TrendColor-Fast-Medium EMA’s", shorttitle="CM-TripEma-TrendColor-Fast-Medium", overlay=true)

src = close, len = input(8, minval=1, title="Fast EMA")
src2 = close, len2 = input(21, minval=1, title="Medium EMA")
src3 = close, len3 = input(34, minval=1, title="Slow EMA")

emaFast = ema(src, len)
emaMedium = ema(src2, len2)
emaSlow = ema(src3, len3)

plot_color = emaFast >= emaMedium and emaMedium >= emaSlow ? lime : emaFast < emaMedium and emaMedium < emaSlow ? fuchsia : yellow

p1 = plot(emaFast, title="EMA Fastt", style=line, linewidth=4, color = plot_color)
p2 = plot(emaMedium, title="EMA Medium", style=line, linewidth=3, color = plot_color)

fill(p1, p2, color=silver, transp=60, title="Fill")
Reply
ChrisMoody PRO
3 years ago
Slow and Medium EMA Code - Upper Study

// Created By User ChrisMoody
// This Study Plots the Slow and Medium EMA's
// As of 1-14-2014 you can only use two Plots so this indicator is used with the Medium and Fast EMA Trend Indicator
// Rules = Iff EMAFast>=EmaMedium and EMA Medium>= EMA Slow THEN Color = Lime - Showing Up Trend
// Rules = Iff EMAFast < EmaMedium and EMA Medium < EMA Slow THEN Color = Red - Showing Down Trend
// If Rules Are Not True then Color = Yellow Showing NO TREND

study(title = "CM-TrippleEMA-TrendColor-Medium-Slow EMA's", shorttitle="CM-TripEma-TrendColor-Medium-Slow", overlay=true)

src = close, len = input(8, minval=1, title="Fast EMA")
src2 = close, len2 = input(21, minval=1, title="Medium EMA")
src3 = close, len3 = input(34, minval=1, title="Slow EMA")

emaFast = ema(src, len)
emaMedium = ema(src2, len2)
emaSlow = ema(src3, len3)

plot_color = emaFast >= emaMedium and emaMedium >= emaSlow ? green : emaFast < emaMedium and emaMedium < emaSlow ? red : yellow

p1 = plot(emaMedium, title="EMA Medium", style=line, linewidth=4, color = plot_color)
p2 = plot(emaSlow, title="EMA Slow", style=line, linewidth=4, color = plot_color)

fill(p1, p2, color=white, transp=40, title="Fill")
+1 Reply
ChrisMoody PRO
3 years ago
Lower Histogram Indicator That Plots Same Colors As Upper Studies. Same Rules Using the 3 EMA's

// Created By User ChrisMoody
// Study uses 3 EMA's plotted in Histogram Format,
// Histogram is created by taking Fast EMA - Slow EMA
// Rules are IFF Fast EMA > Medium EMA > Slow EMA color = Lime Green.
// IFF Fast EMA < Medium EMA < Slow EMA Color = Red....ELSE Color = Yellow
study(title = "CM_Lower Tripple EMA Histogram", shorttitle="Trip EMA Histogram")

src = close, len = input(8, minval=1, title="Fast EMA")
src2 = close, len2 = input(21, minval=1, title="Medium EMA")
src3 = close, len3 = input(34, minval=1, title="Slow EMA")

emaFast = ema(src, len)
emaMedium = ema(src2, len2)
emaSlow = ema(src3, len3)

emaHistogram = emaFast-emaSlow
ma = sma(emaHistogram, 1)

plot_color = emaFast > emaMedium and emaMedium > emaSlow ? lime : emaFast < emaMedium and emaMedium < emaSlow ? red : yellow

plot(emaHistogram, title="EMA Histogram", style=histogram, linewidth=3, color = plot_color)
plot(ma, title="Outer Line", style=line, linewidth=4, color=white)
hline(0, title="O Line", linestyle=solid, linewidth=3, color=white)
Reply
marketscjr
3 years ago
Chris - very cool! Tried copying and pasting code into new script and got a series of errors:
Error: Undeclared identifier `emaFast`;
Error: Undeclared identifier `plot_color`;
Error: Undeclared identifier `emaMedium`;
Error: Undeclared identifier `p1`;
Error: Undeclared identifier `p2`
Are there variables missing in the script?
+1 Reply
ChrisMoody PRO marketscjr
3 years ago

Once Again I Placed the correct code in and when it saves it takes several of the lines out..Follow the directions Below......


*****You Can Click On The White Arrow At The Top Right Of The Chart And Then You Have Access To The Chart. On The Indicators Click On The Brackets To The Left Of the X And You Will See The Source Code. Just Re Name It If you Want and Click Save And The Indicator Will Be In Your Indicators List Under "Custom Scripts"
Reply
ChrisMoody PRO ChrisMoody
3 years ago
It did it again...when you click on the white arrow then select MAKE IT MINE...and follow the rest of the instructions above....
Reply
Chris, I think the best way would be for people to use the white 'Share' arrow to the top right of the chart, click the 'make it mine' button and then grab the code by clicking on the settings button for the indicator and going to 'source code'.
Reply
ChrisMoody PRO optionsnewbie
3 years ago
Your Correct...This is the second time I've posted code and I verify it is correct...then when I save post it takes out complete lines....That will be my instructions from now on....
Reply
Dear Chris Moody, These recent PINE Script Editor posts have been so helpful to me! Thank you so much, Sincerely, Beauty
Reply
ChrisMoody PRO BitcoinMedusa
3 years ago
Thank You....I enjoy finding the limitations that are currently in the Pine Script and finding ways to make it work the way I want it to....I've got some great codes coming....
Reply
marketscjr
3 years ago
Thanks - that worked! What are the 3 EMA's being used here?
Reply
ChrisMoody PRO marketscjr
3 years ago
You can see at the top left of the screen it gives the indicator inputs. 8, 21, 34 EMA's...you can click on the format icon and change the EMA's or any of the colors etc...like any other indicator...Just make sure if you change the EMA's The Slow EMA has to be less than the Medium EMA etc...or the colors will not follow the rules
Reply
pascal.hamel.779
3 years ago
Wow very visual and will be be very helpful for my trading !!!! Thanks !
Reply
ChrisMoody PRO pascal.hamel.779
3 years ago
Thanks...I've been slammed but I have much more to come as far as Indicators in the next couple of weeks...If you haven't seen my other posts I've shown some other custom indicators
Reply
sublimares2
3 years ago
Absolute great code and so nice for sharing it. My question would be: is it possible to draw a horizontal line (a short segment) right at the cross point of the EMAs?
Reply
ChrisMoody PRO sublimares2
3 years ago
I'll play around with it...my initial thoughts are no....the only line we can draw is a hline which requires a value or price...might be possible to treat the value of the line based on a criteria, like a MA cross, but if that would work I think it would make a horizontal line going across the screen. If I haven't responded in a couple of days feel free to remind me.
Reply
Algokid PRO
3 years ago
This is really fantastic Chris. You doing us all a big favor by sharing your codes. I'm still trying to find time to learn and start coding, but your codes will definitely reduce my learning curve. Again ,thank you for sharing this and keep up the great work :)
Reply
ChrisMoody PRO Algokid
3 years ago
Thanks Algokid....I've got plenty more coming once I can create the time. Let me know if you want anything in particular. I'm doing my best to learn this code so I can create what I want. I've paid more money than I want to say over the years to coders on the different platforms I own.

I can tell you from experience that it is much easier if you dive in now while the code is basic. If you learn it now as it gets more advanced it's easy to understand the more complex capabilities they will integrate to allow us to create more advanced codes. If you start two years from now you'll end up hiring a programmer.

The first two codes I created I could't have done without emailing support several times. Now I've got the changing the color of lines based on a certain criteria down. I'll move on to something else...Just start knowing it will take you days to complete your first code b/c you'll get stuck and have to email support. This coding language is pretty simple but you just have to learn it. Right now you could learn it in two weeks. Once they give us the ability to create paint bars and signals etc... If you don't know the basics those will seem overwhelming...but if you learn the basics now every time they add a new feature you can pick it up in a day or two and all of a sudden people will think your a genius programmer...
Reply
fcha PRO
3 years ago
Chris, I could not reach Ross, what is wrong with the number, I try to call many times.
Thanks

Freesia
Reply
ChrisMoody PRO fcha
3 years ago
Fcha...I'm not sure what number you called b/c he only has email on his Web site. We need to talk...I have a feeling TV will be releasing the Private Chat feature Soon...We will talk then
Reply
Kautilya PRO
3 years ago
Chris, This is awesome. Thanks for sharing your code.
Reply
ChrisMoody PRO Kautilya
3 years ago
Thanks...Have a lot more coming...if you haven't seen them I've posted several other codes...
Reply
Kautilya PRO ChrisMoody
3 years ago
Thanks Chris.. I got greedy :-) went through all your code and have saved charts as ChrisMoody - CCI, ChrisMoody-moon phases, etc.
Reply
ChrisMoody PRO
3 years ago
Version 2 of Code Released:

With update to Pine Script now the Upper Indicator just needs to be 1 Indicator instead of two.

Here is a Link to the New Code:
http://pastebin.com/C17gvh9d


New Video Showing How To Install Code From Link Above:
Video Titled: Importing Custom Indicators In TradingView Charts

Link To New Video:
http://vimeopro.com/user14689865/tradingviewcom-how-to-videos
Reply
Awesome indicator, TY
Reply
onemanatatime
2 years ago
genius
Reply
ChrisMoody PRO onemanatatime
2 years ago
Genius might be a overstatement but I do appreciate it. Just make sure you saw the post right above yours from me with updated code...Instead of getting the code from the chart...
Reply
sublimares2
2 years ago
Any idea why all of a sudden the "Fill" argument in the script is not displaying anymore?
Reply
Ideas Scripts Chart
United States
United Kingdom
India
España
France
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Account and Billing Sign Out