ChrisMoody

Example of Code for Moving Average Cross - Changing Colors

Famous 7 Time World Trading Champion Chuck Hughes found the 50 and 100 EMA to be the best Signal for a Change in Trend. Through extensive back-testing he found these EMA’s to give the earliest signal that also resulted in a Long-Term Change in Trend.

Dotted Line represents Long-Term EMA. The 100 EMA in this example.
Solid line represents the Short-Term EMA. The 50 EMA in this example.

If Short-Term EMA is ABOVE Long-Term EMA...Color = Green.
If Short-Term EMA is BELOW Long-Term EMA...Color = Red.

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?
//Created by user ChrisMoody
//Long EMA = Dots, Short EMA = Line
//If Short EMA is ABOVE Long EMA = Lime Color, If Short EMA is BELOW Long EMA = Red Color
study(title="_CM_Double EMA Trend Color", shorttitle="_CM-2EMA-Trend", overlay=true)
src = close, len = input(50, minval=1, title="Short EMA")
src2 = close, len2 = input(100, minval=1, title="Long EMA")
emaShort = ema(src, len)
emaLong = ema(src2, len2)

spanColor = emaShort>=emaLong ? lime : red

p1 = plot(emaShort, title="EMA Short", style=line, linewidth=4, color=spanColor)
p2 = plot(emaLong, title="EMA Long", style=circles, linewidth=3, color=spanColor)

fill(p1, p2, color=silver, transp=40, title="Fill")

//If you do not want the Fill gradient between the EMA's follow the steps below.

//Erase the p1 = in line 12 and 13 so plot is at the far left
//Erase line 15 or put two forward slashes infront of the word fill, just like the two forward slashes at the beginning of this line.