TradingView
yerb
7 mar 2014 14:57

4x MA cross script, i need some help 

Descrizione

I would like to have a yellow dot on all crosses. Please share it if you add the feature. Thanx.
Commenti
LazyBear
With configurable EMA lengths

//----------- start copying here -----------------------------------------------------------------
study(title="4x MA Cross", overlay=true)
ma1_p=input(8, title="EMA1 Length")
ma2_p=input(20, title="EMA2 Length")
ma3_p=input(50, title="EMA3 Length")
ma4_p=input(200, title="EMA4 Length")
ma1 = ema(close, ma1_p)
ma2 = sma(close, ma2_p)
ma3 = sma(close, ma3_p)
ma4 = sma(close, ma4_p)
plot(ma1, color = #00ffff, linewidth = 2)
plot(ma2, color = #ff9800, linewidth = 2)
plot(ma3, color = #cc4125, linewidth = 2)
plot(ma4, color = #00ff00, linewidth = 2)
plot(cross(ma1, ma2) or cross(ma1, ma3) or cross(ma1, ma4) ? ma1 : na, style = circles, linewidth = 4 , color = #ffaa00)
plot(cross(ma2, ma3) or cross(ma2, ma4) ? ma2 : na, style = circles, linewidth = 4 , color = lime)
plot(cross(ma3, ma4) ? ma3 : na, style = circles, linewidth = 4 , color = aqua)
//--------------------- end_copy ------------------------------------------------------------------
LazyBear
Try this.

study(title="4x MA Cross", overlay=true)
ma1 = ema(close, 8)
ma2 = sma(close, 20)
ma3 = sma(close, 50)
ma4 = sma(close, 200)
plot(ma1, color = #00ffff, linewidth = 2)
plot(ma2, color = #ff9800, linewidth = 2)
plot(ma3, color = #cc4125, linewidth = 2)
plot(ma4, color = #00ff00, linewidth = 2)
plot(cross(ma1, ma2) or cross(ma1, ma3) or cross(ma1, ma4) ? ma1 : na, style = circles, linewidth = 4 , color = #ffaa00)
plot(cross(ma2, ma3) or cross(ma2, ma4) ? ma2 : na, style = circles, linewidth = 4 , color = lime)
plot(cross(ma3, ma4) ? ma3 : na, style = circles, linewidth = 4 , color = aqua)
Altro