Skip to content

Instantly share code, notes, and snippets.

@glenndavy
Created May 21, 2019 08:48
Show Gist options
  • Save glenndavy/edcab7798267e6a38dd97e8f13517d2d to your computer and use it in GitHub Desktop.
Save glenndavy/edcab7798267e6a38dd97e8f13517d2d to your computer and use it in GitHub Desktop.
pine script to put Emas from other timeframes on your current timeframe
//@version=3
study("Daily EMAs", overlay=true)
sw1 = input(true, title="Show Daily EMA")
sw2 = input(true, title="Show Weekly EMA")
sw3 = input(true, title="Show Monthly EMA")
D1 =security(tickerid, "D", ema(close,50), barmerge.gaps_off, barmerge.lookahead_on)
D2 =security(tickerid, "D", ema(close,200), barmerge.gaps_off, barmerge.lookahead_on)
W1 =security(tickerid, "W", ema(close,50), barmerge.gaps_off, barmerge.lookahead_on)
W2 =security(tickerid, "W", ema(close,200), barmerge.gaps_off, barmerge.lookahead_on)
M1 =security(tickerid, "M", ema(close,50), barmerge.gaps_off, barmerge.lookahead_on)
M2 =security(tickerid, "M", ema(close,200), barmerge.gaps_off, barmerge.lookahead_on)
plotshape(sw1 ? D1 : na, color= red , style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw1 ? D1 : na, color= red , style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw1 ? D1 : na, color= red , style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="D50")
plotshape(sw1 ? D1 : na, color= red , style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw1 ? D2 : na, color= aqua , style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw1 ? D2 : na, color= aqua , style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw1 ? D2 : na, color= aqua , style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="D200")
plotshape(sw1 ? D2 : na, color= aqua , style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2 ? W1 : na, color= red , style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2 ? W1 : na, color= red , style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2 ? W1 : na, color= red , style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="W50")
plotshape(sw2 ? W1 : na, color= red , style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2? W2 : na, color= aqua, style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2? W2 : na, color= aqua, style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw2? W2 : na, color= aqua, style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="W200")
plotshape(sw2? W2 : na, color= aqua, style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3 ? M1 : na, color= red , style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3 ? M1 : na, color= red , style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3 ? M1 : na, color= red , style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="M50")
plotshape(sw3 ? M1 : na, color= red , style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3? M2 : na, color= aqua, style=shape.cross, transp=10, offset=2 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3? M2 : na, color= aqua, style=shape.cross, transp=10, offset=3 , show_last=1, size=size.auto,location=location.absolute)
plotshape(sw3? M2 : na, color= aqua, style=shape.cross, transp=10, offset=4 , show_last=1, size=size.auto,location=location.absolute, text="M200")
plotshape(sw3? M2 : na, color= aqua, style=shape.cross, transp=10, offset=5 , show_last=1, size=size.auto,location=location.absolute)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment