Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © mildSnail31034
- // Part of this code is copied from Lazy Bear-Range Identifier indicator, Schaff Trend Cycle from everget and OverAtr Bar highlight by
- // Jim8080.
- // I made this indicator for my use initially, but it could be useful to others as well. This being said, I want to thank the original authors
- // for their work and if there are any issues with this, please let me know.
- //@version=5
- indicator("EMA MTF Plus",overlay=true)
- Length=input(12,group="Wicks")
- src = input.source(close,group="Wicks")
- volf = input.bool(title="Volume filter",defval=true,group="Wicks")
- lenvolma = input.int(title="Volume MA",defval=20,group="Wicks")
- atrlen = input.int(title="ATR length" , defval=14,group="Strong bars")
- atrmult = input.float(title="Body ratio",defval=0.8,group="Strong bars")
- macdopt = input.bool(title="Macd filter for triangles",defval=true,group="MACD")
- fastLength = input(title='MACD Fast Length', defval=23,group="MACD")
- slowLength = input(title='MACD Slow Length', defval=50,group="MACD")
- cycleLength = input(title='Cycle Length', defval=10,group="MACD")
- d1Length = input(title='1st %D Length', defval=3,group="MACD")
- d2Length = input(title='2nd %D Length', defval=3,group="MACD")
- macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
- k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
- d = ta.ema(k, d1Length)
- kd = nz(fixnan(ta.stoch(d, d, d, cycleLength)))
- stc = ta.ema(kd, d2Length)
- stc := math.max(math.min(stc, 100), 0)
- bullmacd = stc[0]>99.6?true:false
- bearmacd = stc[0]<0.4?true:false
- bullm = macdopt?bullmacd:true
- bearm = macdopt?bearmacd:true
- atrvover= atrmult*ta.atr(atrlen)+open
- atrvunder= open-ta.atr(atrlen)*atrmult
- isover() => close > atrvover
- isunder() => close < atrvunder
- barcolor(isover() ? color.yellow: isunder() ? color.fuchsia : na)
- volma = ta.ema(volume,lenvolma)
- volcond = volume>volma?true:false
- volfilter=volf?volcond:true
- wickup=open>close?high-open:high-close
- wickdown=open<close?open-low:close-low
- wicks = wickup>wickdown?wickup:wickdown
- wicksma=ta.ema(wicks,Length)
- hh = high==ta.highest(Length) and ta.highest(high-src,Length) and wickup>wicksma and volfilter and bullm
- ll = low==ta.lowest(Length) and ta.highest(src-low,Length) and wickdown>wicksma and volfilter and bearm
- plotshape(hh, style=shape.triangledown, size=size.small,color=color.red)
- plotshape(ll,style=shape.triangleup, size=size.small , color=color.green, location=location.belowbar)
- connectRanges=input(false, title="Connect Ranges",group="Ranges")
- showMidLine=input(true, title="Show MidLine",group="Ranges")
- hc=input(true, title="Highlight Consolidation",group="Ranges")
- showEMA=input(true, title="Signal EMA",group="EMAs")
- lengthEMA=input(20, title="EMA Length",group="EMAs")
- showEMAm=input(true, title="Mid EMA",group="EMAs")
- lengthEMAm=input(120, title="EMA Length",group="EMAs")
- showEMAb=input(true, title="Base EMA",group="EMAs")
- lengthEMAb=input(200, title="EMA Length",group="EMAs")
- e=ta.ema(close,lengthEMA)
- em=ta.ema(close,lengthEMAm)
- eb=ta.ema(close,lengthEMAb)
- var up = close
- var down = close
- down := close<nz(up[1]) and close>down[1] ? nz(down[1]) : low
- up := close<nz(up[1]) and close>down[1] ? nz(up[1]) : high
- mid = math.avg(up,down)
- ul=plot(connectRanges?up:up==nz(up[1])?up:na, color=color.gray, linewidth=2, style=plot.style_linebr, title="Up")
- llz=plot(connectRanges?down:down==nz(down[1])?down:na, color=color.gray, linewidth=2, style=plot.style_linebr, title="Down")
- dummy=plot(hc?close>e?down:up:na, color=color.gray, style=plot.style_circles, linewidth=0, title="Dummy")
- fill(ul,dummy, color=#acfa8745)
- fill(dummy,llz, color=#faac8745)
- plot(showMidLine?mid:na, color=color.gray, linewidth=1, title="Mid")
- plot(showEMA?e:na, title="EMA", color=color.black, linewidth=2)
- ebcol = ta.rising(eb,1)?color.green:color.red
- emcol = ta.rising(em,1)?color.blue:color.orange
- plot(showEMAm?em:na, title="EMA", color=emcol, linewidth=3)
- plot(showEMAb?eb:na, title="EMA", color=ebcol, linewidth=4)
- fast = input(20,inline="period",group="HTF EMA tracker")
- slow = input(200,inline="period",group="HTF EMA tracker")
- tf1sw = input.bool(title="5min fast",defval=true,inline="tf1",group="HTF EMA tracker")
- tf2sw = input.bool(title="15min fast",defval=true,inline="tf2",group="HTF EMA tracker")
- tf3sw = input.bool(title="1hr fast",defval=true,inline="tf3",group="HTF EMA tracker")
- tf4sw = input.bool(title="4hr fast",defval=true,inline="tf4",group="HTF EMA tracker")
- tf5sw = input.bool(title="D fast",defval=true,inline="tf5",group="HTF EMA tracker")
- tf6sw = input.bool(title="W fast",defval=true,inline="tf6",group="HTF EMA tracker")
- tf1sws = input.bool(title="5min slow",defval=true,inline="tf1",group="HTF EMA tracker")
- tf2sws = input.bool(title="15min slow",defval=true,inline="tf2",group="HTF EMA tracker")
- tf3sws = input.bool(title="1hr slow",defval=true,inline="tf3",group="HTF EMA tracker")
- tf4sws = input.bool(title="4hr slow",defval=true,inline="tf4",group="HTF EMA tracker")
- tf5sws = input.bool(title="D slow",defval=true,inline="tf5",group="HTF EMA tracker")
- tf6sws = input.bool(title="W slow",defval=true,inline="tf6",group="HTF EMA tracker")
- tf1src = input.source(title="",defval=close,inline="tf1",group="HTF EMA tracker")
- tf2src = input.source(title="",defval=close,inline="tf2",group="HTF EMA tracker")
- tf3src = input.source(title="",defval=close,inline="tf3",group="HTF EMA tracker")
- tf4src = input.source(title="",defval=close,inline="tf4",group="HTF EMA tracker")
- tf5src = input.source(title="",defval=close,inline="tf5",group="HTF EMA tracker")
- tf6src = input.source(title="",defval=close,inline="tf6",group="HTF EMA tracker")
- e1f= request.security(syminfo.tickerid,"5",ta.ema(tf1src,fast))
- e1s= request.security(syminfo.tickerid,"5",ta.ema(tf1src,slow))
- e2f= request.security(syminfo.tickerid,"15",ta.ema(tf2src,fast))
- e2s= request.security(syminfo.tickerid,"15",ta.ema(tf2src,slow))
- e3f= request.security(syminfo.tickerid,"60",ta.ema(tf3src,fast))
- e3s= request.security(syminfo.tickerid,"60",ta.ema(tf3src,slow))
- e4f= request.security(syminfo.tickerid,"240",ta.ema(tf4src,fast))
- e4s= request.security(syminfo.tickerid,"240",ta.ema(tf4src,slow))
- e5f= request.security(syminfo.tickerid,"D",ta.ema(tf5src,fast))
- e5s= request.security(syminfo.tickerid,"D",ta.ema(tf5src,slow))
- e6f= request.security(syminfo.tickerid,"W",ta.ema(tf6src,fast))
- e6s= request.security(syminfo.tickerid,"W",ta.ema(tf6src,slow))
- supcol = input.color(title="Support",defval=color.green,inline="col",group="HTF EMA tracker")
- rescol = input.color(title="Resistance",defval=color.red,inline="col",group="HTF EMA tracker")
- e1fcol = close>e1f?supcol:rescol
- e1scol = close>e1s?supcol:rescol
- e2fcol = close>e2f?supcol:rescol
- e2scol = close>e2s?supcol:rescol
- e3fcol = close>e3f?supcol:rescol
- e3scol = close>e3s?supcol:rescol
- e4fcol = close>e4f?supcol:rescol
- e4scol = close>e4s?supcol:rescol
- e5fcol = close>e5f?supcol:rescol
- e5scol = close>e5s?supcol:rescol
- e6fcol = close>e6f?supcol:rescol
- e6scol = close>e6s?supcol:rescol
- plot(tf1sw?e1f:na,color=e1fcol,show_last=1,trackprice=true,linewidth=2,title="5m F")
- plot(tf1sws?e1s:na,color=e1scol,show_last=1,trackprice=true,linewidth=3,title="5m S")
- plot(tf2sw?e2f:na,color=e2fcol,show_last=1,trackprice=true,linewidth=2,title="15m F")
- plot(tf2sws?e2s:na,color=e2scol,show_last=1,trackprice=true,linewidth=3,title="15m S")
- plot(tf3sw?e3f:na,color=e3fcol,show_last=1,trackprice=true,linewidth=2,title="1h F")
- plot(tf3sws?e3s:na,color=e3scol,show_last=1,trackprice=true,linewidth=3,title="1h S")
- plot(tf4sw?e4f:na,color=e4fcol,show_last=1,trackprice=true,linewidth=2,title="4h F")
- plot(tf4sws?e4s:na,color=e4scol,show_last=1,trackprice=true,linewidth=3,title="4h S")
- plot(tf5sw?e5f:na,color=e5fcol,show_last=1,trackprice=true,linewidth=2,title="Daily F")
- plot(tf5sws?e5s:na,color=e5scol,show_last=1,trackprice=true,linewidth=3,title="Daily S")
- plot(tf6sw?e6f:na,color=e6fcol,show_last=1,trackprice=true,linewidth=2,title="Weekly F")
- plot(tf6sws?e6s:na,color=e6scol,show_last=1,trackprice=true,linewidth=3,title="Weekly S")
- Offset = input(3,group="HTF EMA tracker")
- plotshape(tf1sw?e1f:na,style=shape.cross,color=e1fcol,show_last=1,text="5m F",location=location.absolute, offset=Offset)
- plotshape(tf1sws?e1s:na,style=shape.cross,color=e1scol,show_last=1,text="5m S",location=location.absolute, offset=Offset)
- plotshape(tf2sw?e2f:na,style=shape.cross,color=e2fcol,show_last=1,text="15m F",location=location.absolute, offset=Offset)
- plotshape(tf2sws?e2s:na,style=shape.cross,color=e2scol,show_last=1,text="15m S",location=location.absolute, offset=Offset)
- plotshape(tf3sw?e3f:na,style=shape.cross,color=e3fcol,show_last=1,text="1h F",location=location.absolute, offset=Offset)
- plotshape(tf3sws?e3s:na,style=shape.cross,color=e3scol,show_last=1,text="1h S",location=location.absolute, offset=Offset)
- plotshape(tf4sw?e4f:na,style=shape.cross,color=e4fcol,show_last=1,text="4h F",location=location.absolute, offset=Offset)
- plotshape(tf4sws?e4s:na,style=shape.cross,color=e4scol,show_last=1,text="4h S",location=location.absolute, offset=Offset)
- plotshape(tf5sw?e5f:na,style=shape.cross,color=e5fcol,show_last=1,text="D F",location=location.absolute, offset=Offset)
- plotshape(tf5sws?e5s:na,style=shape.cross,color=e5scol,show_last=1,text="D S",location=location.absolute, offset=Offset)
- plotshape(tf6sw?e6f:na,style=shape.cross,color=e6fcol,show_last=1,text="W F",location=location.absolute, offset=Offset)
- plotshape(tf6sws?e6s:na,style=shape.cross,color=e6scol,show_last=1,text="W S",location=location.absolute, offset=Offset)
Advertisement
Add Comment
Please, Sign In to add comment