Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Multi Indicator by SKB & Kasparovabi
- // RSI Label by scarf
- // Pivot Prices by BacktestRookies
- // Volume-based S/R Levels by wugamlo
- // Monthly & Weekly Levels by scarf
- // ZigZag with Fibonacci Levels by LonesomeTheBlue
- // Engulfing Scanner v1 by TsanYouJun
- // Pivots High Low (HH/HL/LH/LL)/Trend by Mohamed3nan
- //@version=4
- study(title="SKB/KASPAROVABI Multi Indicator", overlay=true)
- srcrsi = close
- len = input(15, minval=1, title="RSI Length")
- show_ext = input(title="Show RSI Extremes", type=input.bool, defval=true)
- show_mid = input(title="Show RSI Mid Range", type=input.bool, defval=true)
- show_low = input(title="Show RSI Low Range", type=input.bool, defval=true)
- up = rma(max(change(srcrsi), 0), len)
- down = rma(-min(change(srcrsi), 0), len)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
- //plotchar(rsi, char="", location=location.bottom)
- rsi_high = rsi >= 70 or rsi[1] >= 70
- rsi_mid = rsi < 50 and rsi > 30
- rsi_low = rsi <= 30 or rsi[1] <= 30
- plotshape(show_ext and rsi_high ? close : na, style=shape.triangledown, location=location.top, color=color.red, textcolor=color.new(color.gray, 0), text="H", transp=10, title="RSI High")
- plotshape(show_mid and rsi_mid ? close : na, style=shape.flag, location=location.absolute, color=color.red, textcolor=color.new(color.gray, 0), show_last=1, text="RSI Mid", offset=5, transp=80, title="RSI Mid")
- plotshape(show_low and rsi_low ? close : na, style=shape.triangleup, location=location.bottom, color=color.red, textcolor=color.new(color.gray, 0), text="L", offset=0, transp=80, title="RSI Low")
- offset_val = input(title="Monthly/Weekly Offset", type=input.integer, defval=25)
- showlabels = input(title="Monthly/Weekly", type=input.bool, defval=true)
- monthH = security(syminfo.tickerid, 'M', high)[1]
- monthL = security(syminfo.tickerid, 'M', low)[1]
- weekH = security(syminfo.tickerid, 'W', high)[1]
- weekL = security(syminfo.tickerid, 'W', low)[1]
- plot(monthH, title="Monthly High Line", style=plot.style_line, linewidth=1, color=color.red, show_last=1, trackprice=true, offset=offset_val)
- plot(monthL, title="Monthly Low Line", style=plot.style_line, linewidth=1, color=color.red, show_last=1, trackprice=true, offset=offset_val)
- plotshape(showlabels ? monthH : na, style=shape.labeldown, title="Monthly High", location=location.absolute, color=color.red, textcolor=color.new(color.white, 0), show_last=1, text="Month High", offset=offset_val, transp=20)
- plotshape(showlabels ? monthL : na, style=shape.labelup, title="Monthly Low", location=location.absolute, color=color.red, textcolor=color.new(color.white, 0), show_last=1, text="Month Low", offset=offset_val, transp=20)
- plot(weekH, title="Weekly High Line", style=plot.style_line, linewidth=1, color=color.blue, show_last=1, trackprice=true, offset=offset_val)
- plot(weekL, title="Weekly Low Line", style=plot.style_line, linewidth=1, color=color.blue, show_last=1, trackprice=true, offset=offset_val)
- plotshape(showlabels ? weekH : na, style=shape.labeldown, title="Weekly High", location=location.absolute, color=color.blue, textcolor=color.new(color.white, 0), show_last=1, text="Week High", offset=offset_val, transp=20)
- plotshape(showlabels ? weekL : na, style=shape.labelup, title="Weekly High", location=location.absolute, color=color.blue, textcolor=color.new(color.white, 0), show_last=1, text="Week Low", offset=offset_val, transp=20)
- //support
- volMALength = input(20, title = "STDDEV: Volume MA Length")
- stdevLength = input(20, title = "STDDEV: Length")
- stdevHigh = input(2.50, title = "STDDEV: Threshold High")
- stdevExtreme = input(3.00, title = "STDDEV: Threshold Extreme")
- wickminimum = input(75.00, title = "Minimum Wick Length [% of Body]")
- linelength = input(200, title = "Length of Lines (No of Candles)")
- colorstrength = input(title = "Line Color Intensity", defval="STRONG", options=["STRONG", "WEAK"])
- display = input(title = "Display Support/Resistance", defval="ALL", options=["RESISTANCE", "SUPPORT", "ALL"])
- display2 = input(title = "Display High/Extreme Volume", defval="ALL", options=["HIGH", "EXTREME", "ALL"])
- display3 = input(title = "Display WICK / WICK Range", defval="WICK", options=["RANGE", "WICK"])
- //signals = input(false, title = "Show Signal Triangles?")
- // Calculation
- volumeVal = volume
- volumeMA = sma(volumeVal, volMALength)
- stdevValue = stdev(volumeVal, stdevLength)
- extremeVol = volumeMA + (stdevExtreme * stdevValue) // Extreme Volume Threshold
- highVol = volumeMA + (stdevHigh * stdevValue) // High Volume Threshold
- bullcandle = close >= open
- bearcandle = close < open
- bodylength = abs(open-close)
- wicklength = bearcandle? abs(low-close) : abs(high-close)
- wickratio = (wicklength / bodylength) * 100
- rel_wick = wickratio >= wickminimum // Relevant Wick?
- vol_above_limit1 = volumeVal > highVol and volumeVal < extremeVol and rel_wick
- vol_above_limit2 = volumeVal >= extremeVol and rel_wick
- // Strong Colors
- Scol_green1 = color.new(color.green, 40) // Weak Green
- Scol_green2 = color.new(color.green, 10) // Strong Green
- Scol_red1 = color.new(color.red, 40) // Weak Red
- Scol_red2 = color.new(color.red, 10) // Strong Red
- // Weak Colors
- Wcol_green1 = color.new(color.green, 80) // Weak Green
- Wcol_green2 = color.new(color.green, 50) // Strong Green
- Wcol_red1 = color.new(color.red, 80) // Weak Red
- Wcol_red2 = color.new(color.red, 50) // Strong Red
- col_green1 = colorstrength == "STRONG"? Scol_green1 : Wcol_green1
- col_green2 = colorstrength == "STRONG"? Scol_green2 : Wcol_green2
- col_red1 = colorstrength == "STRONG"? Scol_red1 : Wcol_red1
- col_red2 = colorstrength == "STRONG"? Scol_red2 : Wcol_red2
- plotshape(vol_above_limit1 and bullcandle? close : na, title="Resistance - Volume above Threshold", style = shape.triangledown, location=location.abovebar, color=col_red2, size = size.tiny)
- plotshape(vol_above_limit2 and bullcandle? close : na, title="Resistance - Volume above Threshold x 2", style = shape.triangledown, location=location.abovebar, color=col_red1, size = size.tiny)
- plotshape(vol_above_limit1 and bearcandle? close : na, title="Support - Volume above Threshold", style = shape.triangleup, location=location.belowbar, color=col_green2, size = size.tiny)
- plotshape(vol_above_limit2 and bearcandle? close : na, title="Support - Volume above Threshold x 2", style = shape.triangleup, location=location.belowbar, color=col_green1, size = size.tiny)
- chper = time - time[1]
- chper := change(chper) > 0 ? chper[1] : chper
- if vol_above_limit1 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "HIGH") and display3 == "RANGE"
- bull1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 1)
- bull2 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 1)
- bull3 = line.new(time, (high+close)/2, time + chper * linelength, (high+close)/2, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 2)
- if vol_above_limit1 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "HIGH") and display3 == "WICK"
- bull4 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red1, style = line.style_solid, width = 2)
- if vol_above_limit2 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "RANGE"
- bull1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 1)
- bull2 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 1)
- bull3 = line.new(time, (high+close)/2, time + chper * linelength, (high+close)/2, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 2)
- if vol_above_limit2 and bullcandle and (display == "ALL" or display == "RESISTANCE") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "WICK"
- bull4 = line.new(time, high, time + chper * linelength, high, xloc = xloc.bar_time, color = col_red2, style = line.style_solid, width = 2)
- if vol_above_limit1 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "HIGH") and display3 == "RANGE"
- bear1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 1)
- bear2 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 1)
- bear3 = line.new(time, (low+close)/2, time + chper * linelength, (low+close)/2, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 2)
- if vol_above_limit1 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "HIGH") and display3 == "WICK"
- bear4 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green1, style = line.style_solid, width = 2)
- if vol_above_limit2 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "RANGE"
- bear1 = line.new(time, close, time + chper * linelength, close, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 1)
- bear2 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 1)
- bear3 = line.new(time, (low+close)/2, time + chper * linelength, (low+close)/2, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 2)
- if vol_above_limit2 and bearcandle and (display == "ALL" or display == "SUPPORT") and (display2 == "ALL" or display2 == "EXTREME") and display3 == "WICK"
- bear4 = line.new(time, low, time + chper * linelength, low, xloc = xloc.bar_time, color = col_green2, style = line.style_solid, width = 2)
- //------------------------------------------------------------------------------||
- leftbars = input(50, minval=1, title='High Price')
- rightbars = input(25, minval=1, title='Low Price')
- phigh = pivothigh(high, leftbars, rightbars)
- plow = pivotlow(low, leftbars, rightbars)
- if phigh
- label1 = label.new(bar_index[rightbars], high[rightbars], text=tostring(high[rightbars]), style=label.style_labeldown, color=color.orange)
- if plow
- label2 = label.new(bar_index[rightbars], low[rightbars], text=tostring(low[rightbars]), style=label.style_labelup, color=color.green)
- //////////////////
- prd = input(defval = 15, title="ZigZag Period", minval = 2, maxval = 50)
- showzigzag = input(defval = false, title = "Show Zig Zag")
- showfibo = input(defval = false, title = "Show Fibonacci Ratios")
- labelcol = input(defval = color.blue, title = "Fibonacci Text Color")
- fibolinecol = input(defval = color.lime, title = "Fibonacci Line Color")
- upcol = input(defval = color.lime, title = "Zigzag Up Color")
- dncol = input(defval = color.red, title = "Zigzag Down Color")
- labelloc = input(defval = "Right", title = "Fibonacci Location", options = ["Left", "Right"])
- enable14 = input(defval = true, title = "Enable Level 0.14")
- enable236 = input(defval = true, title = "Enable Level 0.236")
- enable382 = input(defval = true, title = "Enable Level 0.382")
- enable500 = input(defval = true, title = "Enable Level 0.500")
- enable618 = input(defval = true, title = "Enable Level 0.618")
- enable786 = input(defval = true, title = "Enable Level 0.786")
- var fibo_ratios = array.new_float(0)
- var shownlevels = 1
- if barstate.isfirst
- array.push(fibo_ratios, 0.000)
- if enable14
- array.push(fibo_ratios, 0.14)
- shownlevels := shownlevels + 1
- if enable236
- array.push(fibo_ratios, 0.236)
- shownlevels := shownlevels + 1
- if enable382
- array.push(fibo_ratios, 0.382)
- shownlevels := shownlevels + 1
- if enable500
- array.push(fibo_ratios, 0.500)
- shownlevels := shownlevels + 1
- if enable618
- array.push(fibo_ratios, 0.618)
- shownlevels := shownlevels + 1
- if enable786
- array.push(fibo_ratios, 0.786)
- shownlevels := shownlevels + 1
- for x = 1 to 5
- array.push(fibo_ratios, x)
- array.push(fibo_ratios, x + 0.272)
- array.push(fibo_ratios, x + 0.414)
- array.push(fibo_ratios, x + 0.618)
- float ph = highestbars(high, prd) == 0 ? high : na
- float pl = lowestbars(low, prd) == 0 ? low : na
- var dir = 0
- dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir))
- var max_array_size = 10
- var zigzag = array.new_float(0)
- add_to_zigzag(value, bindex)=>
- array.unshift(zigzag, bindex)
- array.unshift(zigzag, value)
- if array.size(zigzag) > max_array_size
- array.pop(zigzag)
- array.pop(zigzag)
- update_zigzag(value, bindex)=>
- if array.size(zigzag) == 0
- add_to_zigzag(value, bindex)
- else
- if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0))
- array.set(zigzag, 0, value)
- array.set(zigzag, 1, bindex)
- 0.
- Round_it(value)=> round(value / syminfo.mintick) * syminfo.mintick
- dirchanged = change(dir)
- if ph or pl
- if dirchanged
- add_to_zigzag(dir == 1 ? ph : pl, bar_index)
- else
- update_zigzag(dir == 1 ? ph : pl, bar_index)
- if showzigzag and array.size(zigzag) >= 4
- var line zzline = na
- float val = array.get(zigzag, 0)
- int point = round(array.get(zigzag, 1))
- if change(val) or change(point)
- float val1 = array.get(zigzag, 2)
- int point1 = round(array.get(zigzag, 3))
- if change(val1) == 0 and change(point1) == 0
- line.delete(zzline)
- zzline := line.new(x1 = point, y1 = val, x2 = point1, y2 = val1, color = dir == 1 ? upcol : dncol, width = 2)
- var fibolines = array.new_line(0)
- var fibolabels = array.new_label(0)
- if showfibo and array.size(zigzag) >= 6 and barstate.islast
- if array.size(fibolines) > 0
- for x = 0 to array.size(fibolines) - 1
- line.delete(array.get(fibolines, x))
- label.delete(array.get(fibolabels, x))
- diff = array.get(zigzag, 4) - array.get(zigzag, 2)
- stopit = false
- for x = 0 to array.size(fibo_ratios) - 1
- if stopit and x > shownlevels
- break
- array.unshift(fibolines,
- line.new(x1 = round(array.get(zigzag, 5)),
- y1 = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
- x2 = bar_index,
- y2 = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
- color = fibolinecol,
- extend = extend.right))
- label_x_loc = labelloc == "Left" ? time[bar_index - (round(array.get(zigzag, 5)) - 1)] : time + 15 * (time - time[1])
- array.unshift(fibolabels,
- label.new( x = label_x_loc,
- y = array.get(zigzag, 2) + diff * array.get(fibo_ratios, x),
- text = tostring(array.get(fibo_ratios, x), '#.###') + "(" + tostring(Round_it(array.get(zigzag, 2) + diff * array.get(fibo_ratios, x))) + ")",
- xloc = xloc.bar_time,
- textcolor = labelcol,
- style = label.style_none))
- if (dir == 1 and array.get(zigzag, 2) + diff * array.get(fibo_ratios, x) > array.get(zigzag, 0)) or
- (dir == -1 and array.get(zigzag, 2) + diff * array.get(fibo_ratios, x) < array.get(zigzag, 0))
- stopit := true
- bullEnHeight = input(title="BullEn, Height (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=10, confirm=false)
- bullEnAbove = input(title="BullEn Above (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=3, confirm=false)
- bullEnBelow = input(title="BullEn, Below (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=1, confirm=false)
- bearEnHeight = input(title="BearEn, Height (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=10, confirm=false)
- bearEnAbove = input(title="BearEn Above (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=3, confirm=false)
- bearEnBelow = input(title="BearEn, Below (Pips)", type=input.integer, minval=1, maxval=100, step=1, defval=1, confirm=false)
- //bullish engulfing
- bullEngulfing = (open[1] - close[1]) / syminfo.mintick >= bullEnHeight and close > open and
- (close - open[1]) / syminfo.mintick >= bullEnAbove and
- (close[1] - open) / syminfo.mintick >= bullEnBelow
- //bearish candle
- bearEngulfing = (close[1] - open[1]) / syminfo.mintick >= bearEnHeight and close < open and
- (open - close[1]) / syminfo.mintick >= bearEnAbove and
- (open[1] - close) / syminfo.mintick >= bearEnBelow
- //add long here
- plotshape(bullEngulfing, style=shape.cross, location=location.abovebar, color=color.green, text='', title="bullEngulfing", offset=-1)
- //close all longs
- plotshape(bearEngulfing, style=shape.xcross, location=location.belowbar, color=color.red, text='', title="bearEngulfing", offset=-1)
- //HH/HL/LH/LL
- // - INPUTS
- ShowPivots = input(true, title="Show Pivot Points")
- ShowHHLL = input(true, title="Show HH,LL,LH,HL markers on Pivots Points")
- lefthh = input(5, minval=1, title="Pivot Length lefthh Hand Side")
- righthh = input(5, minval=1, title="Pivot Length righthh Hand Side")
- ShowSRLevels = input(true, title="Show S/R Level Extensions")
- maxLvlLen = input(0, minval=0, title="Maximum S/R Level Extension Length (0 = Max)")
- //
- ShowFB = input(true, title="Show Buy/Sell Signal")
- // Determine pivots
- pvtLenL = lefthh
- pvtLenR = righthh
- // Get High and Low Pivot Points
- pvthi_ = pivothigh(high, pvtLenL, pvtLenR)
- pvtlo_ = pivotlow(low, pvtLenL, pvtLenR)
- // Force Pivot completion before plotting.
- pvthi = pvthi_
- pvtlo = pvtlo_
- // ||-----------------------------------------------------------------------------------------------------||
- // ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------||
- valuewhen_1 = valuewhen(pvthi, high[pvtLenR], 1)
- valuewhen_2 = valuewhen(pvthi, high[pvtLenR], 0)
- higherhigh = na(pvthi) ? na : valuewhen_1 < valuewhen_2 ? pvthi : na
- valuewhen_3 = valuewhen(pvthi, high[pvtLenR], 1)
- valuewhen_4 = valuewhen(pvthi, high[pvtLenR], 0)
- lowerhigh = na(pvthi) ? na : valuewhen_3 > valuewhen_4 ? pvthi : na
- valuewhen_5 = valuewhen(pvtlo, low[pvtLenR], 1)
- valuewhen_6 = valuewhen(pvtlo, low[pvtLenR ], 0)
- higherlow = na(pvtlo) ? na : valuewhen_5 < valuewhen_6 ? pvtlo : na
- valuewhen_7 = valuewhen(pvtlo, low[pvtLenR], 1)
- valuewhen_8 = valuewhen(pvtlo, low[pvtLenR ], 0)
- lowerlow = na(pvtlo) ? na : valuewhen_7 > valuewhen_8 ? pvtlo : na
- // If selected Display the HH/LL above/below candle.
- plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.triangledown, location=location.abovebar, color=color.new(color.green,50), text="HH", offset=-pvtLenR)
- plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.triangleup, location=location.belowbar, color=color.new(color.green,50), text="HL", offset=-pvtLenR)
- plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.triangledown, location=location.abovebar, color=color.new(color.red,50), text="LH", offset=-pvtLenR)
- plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.triangleup, location=location.belowbar, color=color.new(color.red,50), text="LL", offset=-pvtLenR)
- plot(ShowPivots and not ShowHHLL ? pvthi : na, title='High Pivot', style=plot.style_circles, join=false, color=color.green, offset=-pvtLenR, linewidth=3)
- plot(ShowPivots and not ShowHHLL ? pvtlo : na, title='Low Pivot', style=plot.style_circles, join=false, color=color.red, offset=-pvtLenR, linewidth=3)
- //Count How many candles for current Pivot Level, If new reset.
- counthi = 0
- countlo = 0
- counthi := na(pvthi) ? nz(counthi[1]) + 1 : 0
- countlo := na(pvtlo) ? nz(countlo[1]) + 1 : 0
- pvthis = 0.0
- pvtlos = 0.0
- pvthis := na(pvthi) ? pvthis[1] : high[pvtLenR]
- pvtlos := na(pvtlo) ? pvtlos[1] : low[pvtLenR]
- hipc = pvthis != pvthis[1] ? na : color.new(color.red,50)
- lopc = pvtlos != pvtlos[1] ? na : color.new(color.green,50)
- // // Add Optional Fractal Break Alerts
- buy = false
- sell = false
- buy := close>pvthis and open<=pvthis
- sell := close<pvtlos and open>=pvtlos
- // //
- plotshape(ShowFB and buy?1:na, title="BUY Signal", color=color.green, style=shape.diamond,location =location.belowbar)
- plotshape(ShowFB and sell?-1:na, title="SELL Signal", color=color.red, style=shape.diamond,location =location.abovebar)
- // Alerts//
- alertcondition(buy or sell,title="Fractal Break Arrow",message="Alert")
- alertcondition(buy,title="Fractal Break Long",message="Long")
- alertcondition(sell,title="Fractal Break Short",message="Short")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement