Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator('KTS 1.2', overlay=true)
- //checkboxes
- daily = input(false, 'Daily support and resistance')
- hourly = input(false, 'Hourly support and resistance')
- rsar = input(false, 'General support and resistance')
- renko = input(false, 'Renko Bar Overlay')
- renkot = input('D', 'Renko Overlay Timeframe')
- //renkoverlay=input(false, "Renko Signal")
- //renkots=input("D", "Renko Signal Timeframe")
- altsentiment = input(false, 'Altcoin Sentiment')
- witchb = input(false, 'Support Cloud')
- witchc = input(false, 'Resistance Cloud')
- goldencross = input(false, 'Golden Cross Signal')
- fma = input(false, 'FastMA')
- gc1 = input(50, 'FastMA Periods')
- slma = input(false, 'SlowMA')
- gc2 = input(200, 'SlowMA')
- dbs = input(false, 'Overtrend Cloud')
- ichi = input(false, 'Ichimokou Cloud')
- ichi2 = input(false, 'Secondary Ichimokou Cloud')
- rsioverlay = false //input(false, "RSI Signal")
- weakh = input(false, 'Weak Hands Signal')
- predlev = input(false, 'Prediction Levels')
- semiashi = input(false, 'Half Heiken Ashi Candles')
- wmoverlay = input(false, 'Whale Movement Overlay')
- wmpinger = input(false, 'Whale Movement Hint Overlay')
- bolband = input(false, 'Bollinger Bands')
- keltch = input(false, 'Keltner Channel')
- countSignal = input(false, '13-9 Signal')
- //math
- //common constants
- GreaterValue(a, b) =>
- a > b ? a : b
- LesserValue(a, b) =>
- a < b ? a : b
- IsInRange(value, a, b) =>
- value >= LesserValue(a, b) and value <= GreaterValue(a, b)
- TrueLow(barsBack) =>
- LesserValue(low[barsBack], close[barsBack + 1])
- TrueHigh(barsBack) =>
- GreaterValue(high[barsBack], close[barsBack + 1])
- BuyPressure = close - TrueLow(0)
- SellPressure = TrueHigh(0) - close
- //bollinger bands
- bblength = 18
- bbmult = 2
- bbbasis = ta.ema(close, bblength)
- dev = bbmult * ta.stdev(close, bblength)
- upper = bbbasis + dev
- lower = bbbasis - dev
- //keltner channel
- ma = ta.ema(close, 14)
- rangema = ta.ema(ta.tr, 14)
- kcupper = ma + rangema * 2
- kclower = ma - rangema * 2
- c = color.red
- //whale movement
- fff = true
- //overtrend cloud
- otpd = 20
- //SARs
- x = 24
- y = 21
- ctf = 'D'
- cth = '60'
- //Renkos
- atrLen = 10
- renko_close = request.security(ticker.renko(syminfo.tickerid, 'ATR', atrLen), renkot, close)
- renko_open = request.security(ticker.renko(syminfo.tickerid, 'ATR', atrLen), renkot, open)
- //Altcoin Sentiment
- dogesauce = request.security('BITTREX:DOGEBTC', 'D', close)
- //witchcraft
- Factor10 = 10
- Factor = 1
- Pd = 8
- //overtrend
- otbase = request.security(syminfo.tickerid, 'D', ta.sma(close * 2, otpd))
- otlbase = request.security(syminfo.tickerid, 'D', ta.sma(close * 2, math.round(otpd * 1.618)))
- otlma = otlbase * 0.382
- othma = otbase * 0.618
- otc = otlma + (otlma + othma) / 2
- otf = otlma + (otlma - othma) / 2
- otm = (otlma + othma) / 2
- //ichimokou
- conversionPeriods = 34
- basePeriods = 68
- laggingSpan2Periods = 136
- displacement = 68
- //DailySAR
- //dsar=security(tickerid,ctf,lowest(close,x))+security(tickerid,ctf,highest(close,x))-security(tickerid,ctf,lowest(close,x))*abs((security(tickerid,ctf,close)>security(tickerid,ctf,ema(close,y))?0:1)-0.618)
- dsar = ta.lowest(request.security(syminfo.tickerid, ctf, close), x) + (ta.highest(request.security(syminfo.tickerid, ctf, close), x) - ta.lowest(request.security(syminfo.tickerid, ctf, close), x)) * math.abs((request.security(syminfo.tickerid, ctf, close) > ta.ema(request.security(syminfo.tickerid, ctf, close), y) ? 0 : 1) - 0.618)
- //HourlySAR
- hsar = ta.lowest(request.security(syminfo.tickerid, cth, close), x) + (ta.highest(request.security(syminfo.tickerid, cth, close), x) - ta.lowest(request.security(syminfo.tickerid, cth, close), x)) * math.abs((request.security(syminfo.tickerid, cth, close) > ta.ema(request.security(syminfo.tickerid, cth, close), y) ? 0 : 1) - 0.618)
- //RSAR
- hmid = ta.lowest(x) + (ta.highest(x) - ta.lowest(x)) * 0.382
- hmid3 = ta.lowest(x) + (ta.highest(x) - ta.lowest(x)) * 0.618
- //Alt Sentiment
- cp = ta.sma(dogesauce, 2)
- lp = ta.sma(dogesauce, 50)
- dx = ta.sma(ta.change(cp - lp), 13)
- //witchcraft
- lowline(tp) =>
- ll = ta.lowest(low, Pd * tp)
- myl = ta.sma(hlc3, Pd * tp) * 0.5 + ll * 0.5
- low1 = myl - Factor * tp * ta.atr(3)
- low1f = low1
- low1f := hlc3 > low1f[1] ? math.max(low1, low1f[1]) : low1
- low1f
- highline(tp) =>
- he = ta.highest(high, Pd * tp)
- myh = ta.sma(hlc3, Pd * tp) * 0.5 + he * 0.5
- h1 = myh + Factor * tp * ta.atr(3)
- h1f = h1
- h1f := hlc3 < h1f[1] ? math.min(h1, h1f[1]) : h1
- h1f
- tran = 100
- h1 = highline(1)
- h2 = highline(2)
- h3 = highline(4)
- low1 = lowline(1)
- low2 = lowline(2)
- low3 = lowline(4)
- //MAs
- slowma = ta.sma(close, gc2)
- fastma = ta.sma(close, gc1)
- //ichimokou
- donchian(len) =>
- math.avg(ta.lowest(len), ta.highest(len))
- conversionLine = donchian(conversionPeriods)
- baseLine = donchian(basePeriods)
- leadLine1 = math.avg(conversionLine, baseLine)
- leadLine2 = donchian(laggingSpan2Periods)
- //RSI announce
- r = ta.rsi(close, 14)
- rsi30 = ta.sma(r, 30)
- rsi20 = ta.sma(r, 20)
- //weak
- //INPUTS
- per = 24 //input(24, type=integer, minval=15, maxval=60)
- preunit = 'atr' //input('atr', title="prediction in atr or percent", options=['atr', 'percent'])
- preamount = 1 //input(1, title="added amount of prediction", type=float, minval=0, maxval=6)
- //CHANNEL
- hb = ta.highest(high, per) //High Border
- lb = ta.lowest(low, per) //Low Border
- dist = hb - lb //range of the channel
- med = (hb + lb) / 2 //median of the channel
- hf = hb - dist * 0.236 //Highest Fib
- chf = hb - dist * 0.382 //Center High Fib
- clf = hb - dist * 0.618 //Center Low Fib
- lf = hb - dist * 0.764 //Lowest Fib
- //PULL BACK LEVELS
- //initialise mutatables
- leh = hb
- lel = lb
- hbtrue = true
- evpup = high > hb[1] //push up event
- evhbstart = hb[3] == hb[2] and hb[2] == hb[1] and evpup //horizontal then up, part of evhb calculation
- evpdown = low < lb[1] //push down event
- evlbstart = lb[3] == lb[2] and lb[2] == lb[1] and evpdown //horizontal then down, part of evlb calculation
- //two levels will be merged in the plot
- evhb = evhbstart or high[1] == hb //event with high border
- leh := evhb ? hf : leh[1] //level high mutatable set to highest fib on event or kept on value
- evlb = evlbstart or low[1] == lb //event with low border
- lel := evlb ? lf : lel[1] //level low mutatable set to lowest fib on event or kept on value
- hbtrue := evhb ? true : evlb ? false : hbtrue[1] //last event mutatable
- //ENTRY MARKERS
- tol = ta.atr(per) * 0.2 //tolerance for placing triangles and prediction candles at borders
- //initialise mutatables
- hftrue = true
- lftrue = true
- cftrue = true
- evupin = ta.crossover(close, hf) //market enters up trend
- evupout = ta.crossunder(close, hf) //market leaves up trend
- hftrue := evupin ? true : evupout ? false : hftrue[1] //mutatable true if in up trend
- evdownin = ta.crossunder(close, lf) //market enters down trend
- evdownout = ta.crossover(close, lf) //market leaves down trend
- lftrue := evdownin ? true : evdownout ? false : lftrue[1] //mutatable true if in down trend
- cftrue := not hftrue and not lftrue ? true : false //mutatable true if instrument is ranging
- //IDENTIFY LAST BAR
- last = barstate.islast
- last := barstate.isrealtime and timeframe.isintraday ? not barstate.isconfirmed : barstate.islast
- //barstate.islast works also when all bars are confirmed and are history. However in real time and intradaycharts bars never lose this state.
- //In that situation 'not barstate.isconfirmed' (like not ishistory) is the better alternative. if you use intraday charts after closing time of
- //the markets "barstate.isrealtime and isintraday" will be false and the script will use barstate.islast.
- //SITUATION
- hbdtrue = last and hftrue //up trend
- lbdtrue = last and lftrue //down trend
- chfdtrue = last and cftrue and hbtrue //high ranging
- clfdtrue = last and cftrue and not hbtrue //low ranging
- //expected levels
- schigh = hb
- schigh := hbdtrue ? hb : lbdtrue ? lf : chfdtrue ? hf : clfdtrue ? chf : na //situation candle high
- sclow = lb
- sclow := hbdtrue ? hf : lbdtrue ? lb : chfdtrue ? clf : clfdtrue ? lf : na //situation candle low
- //prediction levels
- atr_1 = ta.atr(per)
- pred = preunit == 'atr' ? preamount * atr_1 : preunit == 'percent' ? preamount * close / 100 : 0
- prcahigh = med
- prcahigh := hbdtrue and (evpup or evpup[1]) ? hb + pred : na //prediction level higher than high border
- prcalow = med
- prcalow := lbdtrue and (evpdown or evpdown[1]) ? lb - pred : na //prediction level lower than low border
- //HULL MOVING AVERAGE
- hma = ta.wma(2 * ta.wma(close, per / 2) - ta.wma(close, per), math.round(math.sqrt(per)))
- //Semi Ashi
- grnma = ta.sma(close, 2)
- redma = ta.sma(open, 2)
- //WM
- bbr = (close - (ta.sma(close, 20) - 2 * ta.stdev(close, 20))) / (ta.sma(close, 20) + 2 * ta.stdev(close, 20) - (ta.sma(close, 20) - 2 * ta.stdev(close, 20)))
- //bollinger band position
- acc = 100 - ta.rsi((ta.sma(close, 20) + 2 * ta.stdev(close, 20) - (ta.sma(close, 20) - 2 * ta.stdev(close, 20))) / ta.sma(close, 20), 14)
- //expected volatility
- change_1 = ta.change(volume)
- rma_1 = ta.rma(math.max(change_1, 0), 14)
- change_2 = ta.change(volume)
- rma_2 = ta.rma(math.max(change_2, 0), 14)
- change_3 = ta.change(volume)
- rma_3 = ta.rma(-math.min(change_3, 0), 14)
- mfg = ta.rma(-math.min(ta.change(volume), 0), 14) == 0 ? 100 : rma_1 == 0 ? 0 : 100 - 100 / (1 + rma_2 / rma_3)
- //rsi of volume
- bigmove = bbr > 1
- gc = mfg > 50 and mfg[1] > 50
- xx = ta.roc(acc, 1)
- b = xx > 0
- b2 = xx < 0
- valid = gc and not bigmove or not fff
- sbull = close > ta.ema(close, 5)
- buysignal = valid and not sbull and b
- sellsignal = valid and sbull and b2
- // Setups
- camoBuy = close < close[1] and close > open and low < TrueLow(1)
- camoSell = close > close[1] and close < open and high > TrueHigh(1)
- clopBuy = open < LesserValue(close[1], open[1]) and high > GreaterValue(close[1], open[1])
- clopSell = open > GreaterValue(close[1], open[1]) and low < LesserValue(close[1], open[1])
- clopwinBuy = IsInRange(close, close[1], open[1]) and IsInRange(open, close[1], open[1]) and close > close[1]
- clopwinSell = IsInRange(close, close[1], open[1]) and IsInRange(open, close[1], open[1]) and close < close[1]
- openBuy = open < low[1] and close > low[1]
- openSell = open > high[1] and close < high[1]
- trapBuy = IsInRange(open, low[1], high[1]) and high > high[1]
- trapSell = IsInRange(open, low[1], high[1]) and low < low[1]
- diffUp = close < close[1] and close[1] < close[2] and BuyPressure > BuyPressure[1] and SellPressure < SellPressure[1]
- diffDown = close > close[1] and close[1] > close[2] and BuyPressure < BuyPressure[1] and SellPressure > SellPressure[1]
- reverseDiffUp = close > close[1] and close[1] > close[2] and BuyPressure > BuyPressure[1] and SellPressure < SellPressure[1]
- reverseDiffDown = close < close[1] and close[1] < close[2] and BuyPressure < BuyPressure[1] and SellPressure > SellPressure[1]
- antiDiffUp = close < close[1] and close[1] > close[2] and close[2] < close[3]
- antiDiffDown = close > close[1] and close[1] < close[2] and close[2] > close[3]
- anyBullSetup = camoBuy or clopBuy or clopwinBuy or openBuy or trapBuy or diffUp or reverseDiffUp or antiDiffUp
- anyBearSetup = camoSell or clopSell or clopwinSell or openSell or trapSell or diffDown or reverseDiffDown or antiDiffDown
- // Sequential
- bullCount = 0
- bullCountCondition = close > close[4]
- bullCount := bullCountCondition ? nz(bullCount[1]) == 0 ? 1 : bullCount[1] == 1 ? 2 : bullCount[1] == 2 ? 3 : bullCount[1] == 3 ? 4 : bullCount[1] == 4 ? 5 : bullCount[1] == 5 ? 6 : bullCount[1] == 6 ? 7 : bullCount[1] == 7 ? 8 : bullCount[1] == 8 ? 9 : 0 : 0
- bearCount = 0
- bearCountCondition = close < close[4]
- bearCount := bearCountCondition ? nz(bearCount[1]) == 0 ? 1 : bearCount[1] == 1 ? 2 : bearCount[1] == 2 ? 3 : bearCount[1] == 3 ? 4 : bearCount[1] == 4 ? 5 : bearCount[1] == 5 ? 6 : bearCount[1] == 6 ? 7 : bearCount[1] == 7 ? 8 : bearCount[1] == 8 ? 9 : 0 : 0
- // Signal
- bullConditionCount = close > close[1] and bullCount > 1 and bullCount < 9 or bearCount == 9
- bearConditionCount = close < close[1] and bearCount > 1 and bearCount < 9 or bullCount == 9
- /////////
- //PLOTS//
- /////////
- pink = #ff3b83
- //ReversalSAR
- reversal = plot(rsar ? hmid : na, 'Reversal Line', color=color.new(color.red, 0), linewidth=2, offset=1)
- sar = plot(rsar ? hmid3 : na, 'SAR Line', linewidth=2, color=color.new(color.green, 0), offset=1)
- fill(sar, reversal, color=color.new(color.gray, 80))
- //Daily SAR
- plot(daily ? dsar : na, 'Daily SAR Line', linewidth=4, color=close > dsar ? color.green : pink)
- //Hourly SAR
- plot(hourly ? hsar : na, 'Hourly SAR Line', close > hsar ? color.green : pink, 4, plot.style_circles)
- //Renko overlay
- plot1 = plot(renko ? renko_close : na, style=plot.style_linebr, linewidth=4, color=color.new(color.black, 0))
- plot2 = plot(renko ? renko_open : na, style=plot.style_linebr, linewidth=4, color=color.new(color.black, 0))
- fill(plot1, plot2, color=renko_close < renko_open ? pink : color.green, transp=50)
- //Alt Sentiment
- plotshape(ta.crossover(dx, 0) and altsentiment, 'Alt Sentiment Switch Bullish', location=location.belowbar, color=color.new(color.green, 0), style=shape.triangleup, text='A\nL\nT')
- plotshape(ta.crossunder(dx, 0) and altsentiment, 'Alt Sentiment Switch Bearish', location=location.abovebar, color=color.new(pink, 0), style=shape.triangledown, text='A\nL\nT')
- //witchcraft//
- cx = plot(witchb ? low1 : na, color=color.green, offset=1, title='sell 1 red', linewidth=0, transp=tran)
- cy = plot(witchb ? low2 : na, color=color.green, offset=1, title='sell 2 green', linewidth=0, transp=tran)
- cz = plot(witchb ? low3 : na, color=color.green, offset=1, title='sell 3 blue', linewidth=0, transp=tran)
- ax = plot(witchc ? h1 : na, color=pink, offset=1, title='buy 1 red', linewidth=0, transp=tran)
- ay = plot(witchc ? h2 : na, color=pink, offset=1, title='buy 2 green', linewidth=0, transp=tran)
- az = plot(witchc ? h3 : na, color=pink, offset=1, title='buy 3 blue', linewidth=0, transp=tran)
- fill(ax, ay, color=color.new(pink, 80))
- fill(ay, az, color=color.new(pink, 70))
- fill(cx, cy, color=color.new(color.green, 90))
- fill(cy, cz, color=color.new(color.green, 80))
- //overtrend
- otlo = plot(dbs ? otlma : na, color=color.new(color.black, 0), linewidth=0)
- othi = plot(dbs ? othma : na, color=color.new(color.black, 0), linewidth=0)
- otceil = plot(dbs ? otc : na, color=color.new(color.black, 0), linewidth=0)
- otfloor = plot(dbs ? otf : na, color=color.new(color.black, 0), linewidth=0)
- otmid = plot(dbs ? otm : na, color=color.new(color.white, 0), linewidth=4)
- fill(othi, otceil, color=color.new(color.red, 85))
- fill(otfloor, otlo, color=color.new(color.green, 85))
- //MAs
- ugold = ta.crossover(fastma, slowma)
- dgold = ta.crossover(slowma, fastma)
- plot(fma ? fastma : na, color=color.new(color.green, 0), linewidth=4)
- plot(slma ? slowma : na, color=color.new(pink, 0), linewidth=4)
- plotshape(dgold and goldencross, style=shape.triangledown, location=location.belowbar, color=color.new(pink, 0), text='G\nC')
- plotshape(ugold and goldencross, style=shape.triangleup, location=location.abovebar, color=color.new(color.green, 0), text='G\nC')
- //ichi
- c1 = plot(ichi2 ? conversionLine : na, color=color.new(#0496ff, 0), title='Conversion Line', linewidth=2)
- c2 = plot(ichi2 ? baseLine : na, color=color.new(#991515, 0), title='Base Line', linewidth=2)
- p1 = plot(ichi ? leadLine1 : na, offset=displacement, color=color.new(color.black, 0), title='Lead 1', linewidth=4)
- p2 = plot(ichi ? leadLine2 : na, offset=displacement, color=color.new(pink, 0), title='Lead 2', linewidth=4)
- fill(p1, p2, color=leadLine1 > leadLine2 ? color.green : pink, transp=60)
- fill(c1, c2, color=conversionLine > baseLine ? #003333 : color.maroon, transp=70)
- //rsi
- crossover_1 = ta.crossover(rsi30, rsi20)
- plotshape(rsioverlay ? crossover_1 : na, style=shape.triangledown, color=color.new(pink, 0), location=location.belowbar, text='R\nS\nI')
- crossunder_1 = ta.crossunder(rsi30, rsi20)
- plotshape(rsioverlay ? crossunder_1 : na, style=shape.triangleup, color=color.new(color.green, 0), location=location.abovebar, text='R\nS\nI')
- //weak hands
- //plot entry markers
- plotshape(weakh ? evupin ? hb + tol : na : na, style=shape.triangleup, location=location.absolute, color=color.new(color.blue, 0), size=size.tiny)
- plotshape(weakh ? evupout ? hb + tol : na : na, style=shape.xcross, location=location.absolute, color=color.new(color.gray, 0), size=size.tiny)
- plotshape(weakh ? evdownin ? lb - tol : na : na, style=shape.triangledown, location=location.absolute, color=color.new(pink, 0), size=size.tiny)
- plotshape(weakh ? evdownout ? lb - tol : na : na, style=shape.xcross, location=location.absolute, color=color.new(color.gray, 0), size=size.tiny)
- //plot future circle markers
- plotshape(predlev ? hbdtrue ? hb : na : na, style=shape.circle, location=location.absolute, color=color.new(color.blue, 0), offset=1, size=size.tiny)
- plotshape(predlev ? lbdtrue ? lb : na : na, style=shape.circle, location=location.absolute, color=color.new(pink, 0), offset=1, size=size.tiny)
- plotshape(predlev ? chfdtrue ? chf : na : na, style=shape.circle, location=location.absolute, color=color.new(color.green, 0), offset=1, size=size.tiny)
- plotshape(predlev ? clfdtrue ? clf : na : na, style=shape.circle, location=location.absolute, color=color.new(color.maroon, 0), offset=1, size=size.tiny)
- //plot prediction levels
- plot(last and predlev and (evpup or evpup[1]) and preamount > 0 ? prcahigh : na, style=plot.style_cross, title=' predict', linewidth=5, color=color.new(color.blue, 0), offset=3)
- plot(last and predlev and (evpdown or evpdown[1]) and preamount > 0 ? prcalow : na, style=plot.style_cross, title=' predict', linewidth=5, color=color.new(pink, 0), offset=3)
- //plot predictionmarkers
- plotshape(hbdtrue and predlev and (evpup or evpup[1]) ? hb + tol : na, style=shape.diamond, location=location.absolute, color=color.new(color.blue, 0), size=size.tiny, offset=3)
- plotshape(lbdtrue and predlev and (evpdown or evpdown[1]) ? lb - tol : na, style=shape.diamond, location=location.absolute, color=color.new(pink, 0), size=size.tiny, offset=3)
- //semi ashi
- barcolor(semiashi ? grnma > redma ? color.green : pink : na)
- //whale
- plotshape(wmpinger and buysignal, 'Up Arrow', style=shape.arrowup, location=location.abovebar, color=color.new(color.green, 0))
- plotshape(wmpinger and sellsignal, 'Down Arrow', style=shape.arrowdown, location=location.abovebar, color=color.new(color.red, 0))
- barcolor(wmoverlay ? gc ? acc < 50 ? acc < 20 ? gc ? color.blue : color.black : gc ? color.yellow : color.black : gc ? bbr > 1 ? color.black : color.red : color.black : na : na)
- //plot(gc?acc:0, color=acc<50?acc<20?gc?blue:black:gc?yellow:black:gc?bbr>1?black:red:black,linewidth=4,style=columns)
- //boll
- plot(bolband ? bbbasis : na, offset=1, color=close > bbbasis ? color.green : pink)
- bolbot = plot(bolband ? upper : na, offset=1, color=high > upper ? color.red : color.blue)
- boltop = plot(bolband ? lower : na, offset=1, color=low < lower ? color.red : color.blue)
- fill(bolbot, boltop, transp=90)
- //KC
- u = plot(keltch ? kcupper : na, color=color.new(c, 0), title='Upper Keltner Channel Band')
- plot(keltch ? ma : na, color=color.new(c, 0), title='Keltner Channel Basis')
- l = plot(keltch ? kclower : na, color=color.new(c, 0), title='Lower Keltner Channel Band')
- fill(u, l, color=color.new(c, 90))
- // Signal
- plotshape(bullConditionCount and anyBullSetup and countSignal, style=shape.arrowup, color=color.new(color.green, 0), location=location.belowbar, text='T\nD')
- plotshape(bearConditionCount and anyBearSetup and countSignal, style=shape.arrowdown, color=color.new(pink, 0), location=location.abovebar, text='T\nD')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement