Advertisement
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/
- //@version=5
- indicator("TD lite • Yata",
- overlay = true,
- timeframe = "")
- // -----------------------------------
- groupTD = ""
- // -----------------------------------
- lastN = input.string("6 to 9", title="Show", options=["6 to 9", "7, 8 and 9", "8 and 9", "Only 9", "None"], inline="TD1", group=groupTD)
- showSR = input(false, title="Show Support and Resistance", inline="TD", group=groupTD)
- Count13 = input(true, title="Countd. 13 |", inline="TD1", group=groupTD)
- CountdA13 = input(true, title="Aggr. 13", inline="TD1", group=groupTD)
- locB = input.string("Below", title="Label: Buy" , options=["Above", "Below"], inline="TD5", group=groupTD)
- locA = input.string("Above", title="Sell" , options=["Above", "Below"], inline="TD5", group=groupTD)
- locBc = locB == "Above" ? location.abovebar : locB == "Below" ? location.belowbar : na
- locAc = locA == "Above" ? location.abovebar : locA == "Below" ? location.belowbar : na
- // -----------------------------------
- i_style0 = "Label"
- i_style1 = "Arrow"
- i_style2 = "Triangle"
- i_style3 = "Circle"
- i_style4 = "Cross"
- Bstyle = input.string(i_style0, title="Style: Buy" , options=[i_style0, i_style1, i_style2, i_style3, i_style4], inline="TD6", group=groupTD)
- Sstyle = input.string(i_style0, title="Sell" , options=[i_style0, i_style1, i_style2, i_style3, i_style4], inline="TD6", group=groupTD)
- f_getStyleB(_inputStyle) =>
- _return = _inputStyle == i_style1 ? shape.arrowup :
- _inputStyle == i_style2 ? shape.triangleup :
- _inputStyle == i_style3 ? shape.circle :
- _inputStyle == i_style4 ? shape.cross : shape.labelup
- _return
- f_getStyleS(_inputStyle) =>
- _return = _inputStyle == i_style1 ? shape.arrowdown :
- _inputStyle == i_style2 ? shape.triangledown :
- _inputStyle == i_style3 ? shape.circle :
- _inputStyle == i_style4 ? shape.xcross : shape.labeldown
- _return
- // -----------------------------------
- sellSet = 0
- sellSet := close > close[4] ? sellSet[1] == 9 ? 1 : sellSet[1] + 1 : 0
- buySet = 0
- buySet := close < close[4] ? buySet[1] == 9 ? 1 : buySet[1] + 1 : 0
- // -----------------------------------
- highest9 = ta.highest(9)
- highTrendLine = 0.0
- highTrendLine := buySet == 9 ? highest9 : close > highTrendLine[1] ? 0 : highTrendLine[1]
- lowest9 = ta.lowest(9)
- lowTrendLine = 0.0
- lowTrendLine := sellSet == 9 ? lowest9 : close < lowTrendLine[1] ? 0 : lowTrendLine[1]
- S_color = input.color(color.new(#90EE90, 25), title="|", inline="TD", group=groupTD)
- R_color = input.color(color.new(#E21B22, 25), title="", inline="TD", group=groupTD)
- plot(showSR and lowTrendLine > 0 ? lowTrendLine : na, style=plot.style_circles, linewidth=1, color=S_color, title="Support")
- plot(showSR and highTrendLine > 0 ? highTrendLine : na, style=plot.style_circles, linewidth=1, color=R_color, title="Resistance")
- // -----------------------------------
- buyCountd = 0.0
- buyCountd8Close = 0.0
- isBuyCountd = close < low[2]
- nonQBuy13 = isBuyCountd and math.abs(buyCountd[1]) == 12 and low > buyCountd8Close[1]
- buyCountd := buySet == 9 ? isBuyCountd ? 1 : 0 : sellSet == 9 or highTrendLine == 0 ? 14 : nonQBuy13 ? -12 : isBuyCountd ? math.abs(buyCountd[1]) + 1 : -math.abs(buyCountd[1])
- nonQBuy13 := nonQBuy13 and buyCountd == -12
- buyCountd8Close := buyCountd == 8 ? close : buyCountd8Close[1]
- sellCountd = 0.0
- sellCountd8Close = 0.0
- isSellCountd = close > high[2]
- nonQSell13 = isSellCountd and math.abs(sellCountd[1]) == 12 and high < sellCountd8Close[1]
- sellCountd := sellSet == 9 ? isSellCountd ? 1 : 0 : buySet == 9 or lowTrendLine == 0 ? 14 : nonQSell13 ? -12 : isSellCountd ? math.abs(sellCountd[1]) + 1 : -math.abs(sellCountd[1])
- nonQSell13 := nonQSell13 and sellCountd == -12
- sellCountd8Close := sellCountd == 8 ? close : sellCountd8Close[1]
- isAggressiveBuy = low < low[2]
- aggressiveBuy = 0.0
- aggressiveBuy := buySet == 9 ? isAggressiveBuy ? 1 : 0 : sellSet == 9 or highTrendLine == 0 ? 14 : isAggressiveBuy ? math.abs(aggressiveBuy[1]) + 1 : -math.abs(aggressiveBuy[1])
- isAggressiveSell = high > high[2]
- aggressiveSell = 0.0
- aggressiveSell := sellSet == 9 ? isAggressiveSell ? 1 : 0 : buySet == 9 or lowTrendLine == 0 ? 14 : isAggressiveSell ? math.abs(aggressiveSell[1]) + 1 : -math.abs(aggressiveSell[1])
- // -----------------------------------
- color_btext = input.color(color.new(color.white , 0), title="Colors: Buy", inline="C", group=groupTD)
- color_stext = input.color(color.new(color.white , 0), title="Sell", inline="C", group=groupTD)
- color_b6 = input.color(color.new(#77F1B0 , 0), title="6", inline="CB", group=groupTD)
- color_b7 = input.color(color.new(#00ADAD , 0), title="7", inline="CB", group=groupTD)
- color_b8 = input.color(color.new(#0067FF , 0), title="8", inline="CB", group=groupTD)
- color_b9 = input.color(color.new(#0014C4 , 0), title="9", inline="CB", group=groupTD)
- color_s6 = input.color(color.new(color.yellow , 0), title="6", inline="CS", group=groupTD)
- color_s7 = input.color(color.new(color.orange , 0), title="7", inline="CS", group=groupTD)
- color_s8 = input.color(color.new(color.red , 0), title="8", inline="CS", group=groupTD)
- color_s9 = input.color(color.new(color.maroon , 0), title="9", inline="CS", group=groupTD)
- color_b13 = input.color(color.new(color.blue , 0), title="13", inline="CB", group=groupTD)
- color_s13 = input.color(color.new(#d69d00 , 0), title="13", inline="CS", group=groupTD)
- color_bA13 = input.color(color.new(#6400d6 , 0), title="A13", inline="CB", group=groupTD)
- color_sA13 = input.color(color.new(#ff8629 , 0), title="A13", inline="CS", group=groupTD)
- // -----------------------------------
- plotshape(lastN == "6 to 9" ?
- buySet == 6 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_b6, text="", title="lb6", textcolor=color_btext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" ?
- buySet == 7 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_b7, text="", title="lb7", textcolor=color_btext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" or lastN == "8 and 9" ?
- buySet == 8 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_b8, text="", title="lb8", textcolor=color_btext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" or lastN == "8 and 9" or lastN == "Only 9" ?
- buySet == 9 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_b9, text="9", title="lb9", textcolor=color_btext)
- plotshape(lastN == "6 to 9" ?
- sellSet == 6 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_s6, text="", title="ls6", textcolor=color_stext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" ?
- sellSet == 7 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_s7, text="", title="ls7", textcolor=color_stext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" or lastN == "8 and 9" ?
- sellSet == 8 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_s8, text="", title="ls8", textcolor=color_stext)
- plotshape(lastN == "6 to 9" or lastN == "7, 8 and 9" or lastN == "8 and 9" or lastN == "Only 9" ?
- sellSet == 9 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_s9, text="9", title="ls9", textcolor=color_stext)
- plotshape(Count13 ?
- sellCountd == 13 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_s13, text="13", title="lsc13", textcolor=color_stext)
- plotshape(Count13 ?
- buyCountd == 13 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_b13, text="13", title="lbc13", textcolor=color_btext)
- plotshape(CountdA13 ?
- aggressiveBuy == 13 : na, location=locBc, style=f_getStyleB(Bstyle), size=size.auto, color=color_bA13, text="a13", title="lbc13", textcolor=color_btext)
- plotshape(CountdA13 ?
- aggressiveSell == 13 : na, location=locAc, style=f_getStyleS(Sstyle), size=size.auto, color=color_sA13, text="a13", title="lsc13", textcolor=color_stext)
- // -----------------------------------
- count9 = buySet == 9 or sellSet == 9
- count13 = buyCountd == 13 or sellCountd == 13
- counta13 = aggressiveBuy == 13 or aggressiveSell == 13
- count913 = count9 or count13
- alertcondition(count9 , title="TD 9 Alert" , message="TD Seq: 9 \n\nTicker: {{ticker}}\nTime: {{time}}\nPrice: {{close}}")
- alertcondition(count13 , title="TD 13 Alert" , message="TD Seq: 13 \n\nTicker: {{ticker}}\nTime: {{time}}\nPrice: {{close}}")
- alertcondition(counta13 , title="TD a13 Alert" , message="TD Seq: a13 \n\nTicker: {{ticker}}\nTime: {{time}}\nPrice: {{close}}")
- alertcondition(count913 , title="TD 9 and 13 Alert" , message="TD Seq: 9, 13 \n\nTicker: {{ticker}}\nTime: {{time}}\nPrice: {{close}}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement