Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study(title='EMAs', overlay=true)
- show_labels = input(true, title='SHOW LABELS')
- show_daily = input(false, title='SHOW DAILY')
- hide_normal = input(false, title='HIDE NORMAL')
- show_slope = input(false, title='SHOW SLOPE')
- show_gdx = input(true, title='SHOW G/D X')
- show_x_emas = input(false, title='SHOW X EMAS')
- hide_normal_1 = hide_normal == false and show_slope == false or hide_normal == true and show_slope == false
- hide_normal_2 = show_labels == true and show_daily == true and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_3 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_4 = show_labels == false and show_daily == true and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_5 = show_labels == false and show_daily == true and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_6 = show_labels == true and show_daily == true and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_7 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_8 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_9 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_10 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_11 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- hide_normal_12 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_13 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- hide_normal_0 = hide_normal_1 or hide_normal_2 or hide_normal_3 or hide_normal_4 or hide_normal_5 or hide_normal_6 or hide_normal_7 or hide_normal_8 or hide_normal_9 or hide_normal_10 or hide_normal_11 or hide_normal_12 or hide_normal_13
- show_daily_1 = show_daily == true
- show_daily_2 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == false
- show_daily_3 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_daily_4 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == false
- show_daily_5 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- show_daily_6 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_daily_7 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- show_daily_8 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- show_daily_9 = show_labels == false and show_daily == false and hide_normal == true and show_slope == false and show_gdx == true and show_x_emas == true
- show_daily_10 = show_labels == true and show_daily == false and hide_normal == true and show_slope == false and show_gdx == true and show_x_emas == true
- show_daily_11 = show_labels == true and show_daily == false and hide_normal == true and show_slope == false and show_gdx == false and show_x_emas == true
- show_daily_12 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- show_daily_13 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == false
- show_daily_14 = show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == false
- show_daily_0 = show_daily_1 or show_daily_2 or show_daily_3 or show_daily_4 or show_daily_5 or show_daily_6 or show_daily_7 or show_daily_8 or show_daily_9 or show_daily_10 or show_daily_11 or show_daily_12 or show_daily_13 or show_daily_14
- show_slope_1 = show_daily == true and show_x_emas == false or show_daily == true and show_x_emas == true and hide_normal == true and show_slope == true
- show_slope_2 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == false
- show_slope_3 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_4 = show_labels == false and show_daily == true and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_5 = show_labels == false and show_daily == true and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_6 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_7 = show_labels == true and show_daily == true and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_8 = show_labels == false and show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_9 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_10 = show_labels == true and show_daily == true and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_11 = show_labels == true and show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_12 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == false and show_x_emas == true
- show_slope_13 = show_labels == false and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_14 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == true
- show_slope_15 = show_labels == true and show_daily == false and hide_normal == true and show_slope == true and show_gdx == true and show_x_emas == false
- show_slope_16 = show_daily == false and hide_normal == false and show_slope == true and show_gdx == false and show_x_emas == false
- show_slope_17 = show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == false
- show_slope_0 = show_slope_1 or show_slope_2 or show_slope_3 or show_slope_4 or show_slope_5 or show_slope_6 or show_slope_7 or show_slope_8 or show_slope_9 or show_slope_10 or show_slope_11 or show_slope_12 or show_slope_13 or show_slope_14 or show_slope_15 or show_slope_16 or show_slope_17
- show_x_emas_1 = show_labels == false and show_daily == false and hide_normal == false and show_slope == false and show_gdx == false and show_x_emas == true
- show_x_emas_2 = show_labels == true and show_daily == false and hide_normal == false and show_slope == false and show_gdx == false and show_x_emas == true
- show_x_emas_3 = show_daily == false and hide_normal == false and show_slope == false and show_gdx == false and show_x_emas == true
- show_x_emas_4 = show_daily == false and hide_normal == false and show_slope == false and show_gdx == true and show_x_emas == true
- show_x_emas_5 = show_daily == false and hide_normal == false and show_slope == true and show_gdx == true and show_x_emas == true
- show_x_emas_0 = show_x_emas_1 or show_x_emas_2 or show_x_emas_3 or show_x_emas_4 or show_x_emas_5
- sma10 = sma(close, 10)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? sma10:na, color=red, transp=0, linewidth=1, title='10')
- ema21 = ema(close, 21)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema21:na, color=yellow, transp=0, linewidth=2, title='21')
- ema50 = ema(close, 50)
- plot(hide_normal_0 ? ema50:na, color=lime, transp=0, linewidth=2, title='50')
- ema89 = ema(close, 89)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema89:na, color=white, transp=0, linewidth=2, title='89')
- ema100 = ema(close, 100)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema100:na, color=aqua, transp=0, linewidth=2, title='100')
- ema144 = ema(close, 144)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema144:na, color=#1976d2, transp=0, linewidth=2, title='144')
- ema200 = ema(close, 200)
- plot(hide_normal_0 ? ema200:na, color=fuchsia, transp=0, linewidth=2, title='200')
- sma200 = sma(close, 200)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? sma200:na, color=red, transp=0, linewidth=2, title='200')
- ema377 = ema(close, 377)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema377:na, color=maroon, transp=0, linewidth=2, title='377')
- ema886 = ema(close, 886)
- plot(hide_normal == false and show_slope == false and show_x_emas == false ? ema886:na, color=white, transp=0, linewidth=2, title='886')
- sma10_m = security(tickerid, 'M', sma10)
- ema21_w = security(tickerid, 'W', ema21)
- ema21_m = security(tickerid, 'M', ema21)
- ema50_w = security(tickerid, 'W', ema50)
- ema89_w = security(tickerid, 'W', ema89)
- sma200_w = security(tickerid, 'W', sma200)
- daily_only = not isweekly and not ismonthly
- plot(daily_only ? sma10_m:na, style=line, linewidth=2, show_last=1, color=red, transp=0, title='10 M')
- plot(daily_only ? ema21_w:na, style=line, linewidth=2, show_last=1, color=yellow, transp=0, title='21 W')
- plot(daily_only ? ema21_m:na, style=line, linewidth=2, show_last=1, color=yellow, transp=0, title='21 M')
- plot(daily_only ? ema50_w:na, style=line, linewidth=2, show_last=1, color=lime, transp=0, title='50 W')
- plot(daily_only ? ema89_w:na, style=line, linewidth=2, show_last=1, color=white, transp=0, title='89 W')
- plot(daily_only ? sma200_w:na, style=line, linewidth=2, show_last=1, color=red, transp=0, title='200 W')
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? sma10:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='10', title='10', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema21:na, style=shape.diamond, location=location.absolute, show_last=1, color=yellow, transp=0, text='21', title='21', offset=4)
- plotshape(show_labels == true and hide_normal_0 ? ema50:na, style=shape.diamond, location=location.absolute, show_last=1, color=lime, transp=0, text='50', title='50', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema89:na, style=shape.diamond, location=location.absolute, show_last=1, color=white, transp=0, text='89', title='89', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema100:na, style=shape.diamond, location=location.absolute, show_last=1, color=aqua, transp=0, text='100', title='100', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema144:na, style=shape.diamond, location=location.absolute, show_last=1, color=#1976d2, transp=0, text='144', title='144', offset=4)
- plotshape(show_labels == true and hide_normal_0 ? ema200:na, style=shape.diamond, location=location.absolute, show_last=1, color=fuchsia, transp=0, text='200', title='200', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? sma200:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='200', title='200', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema377:na, style=shape.diamond, location=location.absolute, show_last=1, color=maroon, transp=0, text='377', title='377', offset=4)
- plotshape(show_labels == true and hide_normal == false and show_slope == false and show_x_emas == false ? ema886:na, style=shape.diamond, location=location.absolute, show_last=1, color=white, transp=0, text='886', title='886', offset=4)
- sma10_1d = security(tickerid, 'D', sma10)
- plot(show_daily_0 or show_x_emas_0 ? sma10_1d:na, color=red, transp=0, linewidth=1, title='10 D')
- ema21_1d = security(tickerid, 'D', ema21)
- plot(show_daily_0 or show_x_emas_0 ? ema21_1d:na, color=yellow, transp=0, linewidth=2, title='21 D')
- sma30 = sma(close, 30)
- sma30_1d = security(tickerid, 'D', sma30)
- plot(show_slope_0 ? sma30_1d:na, color=blue, transp=0, linewidth=3, title='30 D')
- ema50_1d = security(tickerid, 'D', ema50)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema50_1d:na, color=lime, transp=0, linewidth=2, title='50 D')
- ema89_1d = security(tickerid, 'D', ema89)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema89_1d:na, color=white, transp=0, linewidth=2, title='89 D')
- ema100_1d = security(tickerid, 'D', ema100)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema100_1d:na, color=aqua, transp=0, linewidth=2, title='100 D')
- ema144_1d = security(tickerid, 'D', ema144)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema144_1d:na, color=#1976d2, transp=0, linewidth=2, title='144 D')
- ema200_1d = security(tickerid, 'D', ema200)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema200_1d:na, color=fuchsia, transp=0, linewidth=2, title='200 D')
- sma200_1d = security(tickerid, 'D', sma200)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? sma200_1d:na, color=red, transp=0, linewidth=2, title='200 D')
- ema377_1d = security(tickerid, 'D', ema377)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema377_1d:na, color=maroon, transp=0, linewidth=2, title='377 D')
- ema886_1d = security(tickerid, 'D', ema886)
- plot(show_daily == true and show_slope == false and show_x_emas == false ? ema886_1d:na, color=white, transp=0, linewidth=2, title='886 D')
- plotshape(show_labels == true and show_daily_0 or show_labels == true and show_x_emas_0 ? sma10_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='10 D', title='10 D', offset=8)
- plotshape(show_labels == true and show_daily_0 or show_labels == true and show_x_emas_0 ? ema21_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=yellow, transp=0, text='21 D', title='21 D', offset=8)
- plotshape(show_labels == true and show_slope_0 ? sma30_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=blue, transp=0, text='30 D', title='30 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema50_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=lime, transp=0, text='50 D', title='50 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema89_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=white, transp=0, text='89 D', title='89 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema100_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=aqua, transp=0, text='100 D', title='100 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema144_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=#1976d2, transp=0, text='144 D', title='144 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema200_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=fuchsia, transp=0, text='200 D', title='200 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? sma200_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='200 D', title='200 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema377_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=maroon, transp=0, text='377 D', title='377 D', offset=8)
- plotshape(show_labels == true and show_daily == true and show_slope == false and show_x_emas == false ? ema886_1d:na, style=shape.diamond, location=location.absolute, show_last=1, color=white, transp=0, text='886 D', title='886 D', offset=8)
- plotshape(daily_only ? sma10_m:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='10 M', title='10 M', offset=8)
- plotshape(daily_only ? ema21_w:na, style=shape.diamond, location=location.absolute, show_last=1, color=yellow, transp=0, text='21 W', title='21 W', offset=8)
- plotshape(daily_only ? ema21_m:na, style=shape.diamond, location=location.absolute, show_last=1, color=yellow, transp=0, text='21 M', title='21 M', offset=8)
- plotshape(daily_only ? ema50_w:na, style=shape.diamond, location=location.absolute, show_last=1, color=lime, transp=0, text='50 W', title='50 W', offset=8)
- plotshape(daily_only ? ema89_w:na, style=shape.diamond, location=location.absolute, show_last=1, color=white, transp=0, text='89 W', title='89 W', offset=8)
- plotshape(daily_only ? sma200_w:na, style=shape.diamond, location=location.absolute, show_last=1, color=red, transp=0, text='200 W', title='200 W', offset=8)
- ema50_3h = security(tickerid, '180', ema50)
- ema200_3h = security(tickerid, '180', ema200)
- ema50_4h = security(tickerid, '240', ema50)
- ema200_4h = security(tickerid, '240', ema200)
- goldenx_3h = crossover(ema50_3h, ema200_3h) and daily_only
- alertcondition(goldenx_3h, title='3H GOLDEN X', message='3H GOLDEN X')
- plotshape(show_gdx == true ? goldenx_3h:na, style=shape.xcross, location=location.belowbar, color=yellow, transp=0, text='3H G', title='3H GOLDEN X', show_last=50, size=size.small)
- deathx_3h = crossunder(ema50_3h, ema200_3h) and daily_only
- alertcondition(deathx_3h, title='3H DEATH X', message='3H DEATH X')
- plotshape(show_gdx == true ? deathx_3h:na, style=shape.xcross, location=location.abovebar, color=red, transp=0, text='3H D', title='3H DEATH X', show_last=50, size=size.small)
- goldenx_4h = crossover(ema50_4h, ema200_4h) and daily_only
- alertcondition(goldenx_4h, title='4H GOLDEN X', message='4H GOLDEN X')
- plotshape(show_gdx == true ? goldenx_4h:na, style=shape.xcross, location=location.belowbar, color=yellow, transp=0, text='4H G', title='4H GOLDEN X', show_last=50, size=size.small)
- deathx_4h = crossunder(ema50_4h, ema200_4h) and daily_only
- alertcondition(deathx_4h, title='4H DEATH X', message='4H DEATH X')
- plotshape(show_gdx == true ? deathx_4h:na, style=shape.xcross, location=location.abovebar, color=red, transp=0, text='4H D', title='4H DEATH X', show_last=50, size=size.small)
- goldenx_1d = crossover(ema50_1d, ema200_1d) and daily_only
- alertcondition(goldenx_1d, title='1D GOLDEN X', message='1D GOLDEN X')
- plotshape(show_gdx == true ? goldenx_1d:na, style=shape.xcross, location=location.belowbar, color=yellow, transp=0, text='1D GOLDEN', title='1D GOLDEN X', show_last=100, size=size.huge)
- deathx_1d = crossunder(ema50_1d, ema200_1d) and daily_only
- alertcondition(deathx_1d, title='1D DEATH X', message='1D DEATH X')
- plotshape(show_gdx == true ? deathx_1d:na, style=shape.xcross, location=location.abovebar, color=red, transp=0, text='1D DEATH', title='1D DEATH X', show_last=100, size=size.huge)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement