Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////// INDICATOR 1 SSL HYBRID /////////
- //@version=4
- //By Mihkel00
- // This script is designed for the NNFX Method, so it is recommended for Daily charts only.
- // Tried to implement a few VP NNFX Rules
- // This script has a SSL / Baseline (you can choose between the SSL or MA), a secondary SSL for continiuation trades and a third SSL for exit trades.
- // Alerts added for Baseline entries, SSL2 continuations, Exits.
- // Baseline has a Keltner Channel setting for "in zone" Gray Candles
- // Added "Candle Size > 1 ATR" Diamonds from my old script with the criteria of being within Baseline ATR range.
- // Credits
- // Strategy causecelebre https://www.tradingview.com/u/causecelebre/
- // SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
- // Moving Averages jiehonglim https://www.tradingview.com/u/jiehonglim/
- // Moving Averages everget https://www.tradingview.com/u/everget/
- // "Many Moving Averages" script Fractured https://www.tradingview.com/u/Fractured/
- study("SSL Hybrid", overlay=true)
- show_Baseline = input(title="Show Baseline", type=input.bool, defval=true)
- show_SSL1 = input(title="Show SSL1", type=input.bool, defval=false)
- show_atr = input(title="Show ATR bands", type=input.bool, defval=true)
- //ATR
- atrlen = input(14, "ATR Period")
- mult = input(1, "ATR Multi", step=0.1)
- smoothing = input(title="ATR Smoothing", defval="WMA", options=["RMA", "SMA", "EMA", "WMA"])
- ma_function(source, atrlen) =>
- if smoothing == "RMA"
- rma(source, atrlen)
- else
- if smoothing == "SMA"
- sma(source, atrlen)
- else
- if smoothing == "EMA"
- ema(source, atrlen)
- else
- wma(source, atrlen)
- atr_slen = ma_function(tr(true), atrlen)
- ////ATR Up/Low Bands
- upper_band = atr_slen * mult + close
- lower_band = close - atr_slen * mult
- ////BASELINE / SSL1 / SSL2 / EXIT MOVING AVERAGE VALUES
- maType = input(title="SSL1 / Baseline Type", type=input.string, defval="HMA", options=["SMA","EMA","DEMA","TEMA","LSMA","WMA","MF","VAMA","TMA","HMA", "JMA", "Kijun v2", "EDSMA","McGinley"])
- len = input(title="SSL1 / Baseline Length", defval=60)
- SSL2Type = input(title="SSL2 / Continuation Type", type=input.string, defval="JMA", options=["SMA","EMA","DEMA","TEMA","WMA","MF","VAMA","TMA","HMA", "JMA","McGinley"])
- len2 = input(title="SSL 2 Length", defval=5)
- //
- SSL3Type = input(title="EXIT Type", type=input.string, defval="HMA", options=["DEMA","TEMA","LSMA","VAMA","TMA","HMA","JMA", "Kijun v2", "McGinley", "MF"])
- len3 = input(title="EXIT Length", defval=15)
- src = input(title="Source", type=input.source, defval=close)
- //
- tema(src, len) =>
- ema1 = ema(src, len)
- ema2 = ema(ema1, len)
- ema3 = ema(ema2, len)
- (3 * ema1) - (3 * ema2) + ema3
- kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")
- jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=3)
- jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=1)
- volatility_lookback = input(10, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")
- //MF
- beta = input(0.8,minval=0,maxval=1,step=0.1, title="Modular Filter, General Filter Only - Beta")
- feedback = input(false, title="Modular Filter Only - Feedback")
- z = input(0.5,title="Modular Filter Only - Feedback Weighting",step=0.1, minval=0, maxval=1)
- //EDSMA
- ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)
- ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])
- //----
- //EDSMA
- get2PoleSSF(src, length) =>
- PI = 2 * asin(1)
- arg = sqrt(2) * PI / length
- a1 = exp(-arg)
- b1 = 2 * a1 * cos(arg)
- c2 = b1
- c3 = -pow(a1, 2)
- c1 = 1 - c2 - c3
- ssf = 0.0
- ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])
- get3PoleSSF(src, length) =>
- PI = 2 * asin(1)
- arg = PI / length
- a1 = exp(-arg)
- b1 = 2 * a1 * cos(1.738 * arg)
- c1 = pow(a1, 2)
- coef2 = b1 + c1
- coef3 = -(c1 + b1 * c1)
- coef4 = pow(c1, 2)
- coef1 = 1 - coef2 - coef3 - coef4
- ssf = 0.0
- ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])
- ma(type, src, len) =>
- float result = 0
- if type=="TMA"
- result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
- if type=="MF"
- ts=0.,b=0.,c=0.,os=0.
- //----
- alpha = 2/(len+1)
- a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
- //----
- b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
- c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
- os := a == b ? 1 : a == c ? 0 : os[1]
- //----
- upper = beta*b+(1-beta)*c
- lower = beta*c+(1-beta)*b
- ts := os*upper+(1-os)*lower
- result := ts
- if type=="LSMA"
- result := linreg(src, len, 0)
- if type=="SMA" // Simple
- result := sma(src, len)
- if type=="EMA" // Exponential
- result := ema(src, len)
- if type=="DEMA" // Double Exponential
- e = ema(src, len)
- result := 2 * e - ema(e, len)
- if type=="TEMA" // Triple Exponential
- e = ema(src, len)
- result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
- if type=="WMA" // Weighted
- result := wma(src, len)
- if type=="VAMA" // Volatility Adjusted
- /// Copyright © 2019 to present, Joris Duyck (JD)
- mid=ema(src,len)
- dev=src-mid
- vol_up=highest(dev,volatility_lookback)
- vol_down=lowest(dev,volatility_lookback)
- result := mid+avg(vol_up,vol_down)
- if type=="HMA" // Hull
- result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
- if type=="JMA" // Jurik
- /// Copyright © 2018 Alex Orekhov (everget)
- /// Copyright © 2017 Jurik Research and Consulting.
- phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5
- beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
- alpha = pow(beta, jurik_power)
- jma = 0.0
- e0 = 0.0
- e0 := (1 - alpha) * src + alpha * nz(e0[1])
- e1 = 0.0
- e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
- e2 = 0.0
- e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
- jma := e2 + nz(jma[1])
- result := jma
- if type=="Kijun v2"
- kijun = avg(lowest(len), highest(len))//, (open + close)/2)
- conversionLine = avg(lowest(len/kidiv), highest(len/kidiv))
- delta = (kijun + conversionLine)/2
- result :=delta
- if type=="McGinley"
- mg = 0.0
- mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
- result :=mg
- if type=="EDSMA"
- zeros = src - nz(src[2])
- avgZeros = (zeros + zeros[1]) / 2
- // Ehlers Super Smoother Filter
- ssf = ssfPoles == 2
- ? get2PoleSSF(avgZeros, ssfLength)
- : get3PoleSSF(avgZeros, ssfLength)
- // Rescale filter in terms of Standard Deviations
- stdev = stdev(ssf, len)
- scaledFilter = stdev != 0
- ? ssf / stdev
- : 0
- alpha = 5 * abs(scaledFilter) / len
- edsma = 0.0
- edsma := alpha * src + (1 - alpha) * nz(edsma[1])
- result := edsma
- result
- ///SSL 1 and SSL2
- emaHigh = ma(maType, high, len)
- emaLow = ma(maType, low, len)
- maHigh = ma(SSL2Type, high, len2)
- maLow = ma(SSL2Type, low, len2)
- ///EXIT
- ExitHigh = ma(SSL3Type, high, len3)
- ExitLow = ma(SSL3Type, low, len3)
- ///Keltner Baseline Channel
- BBMC = ma(maType, close, len)
- useTrueRange = input(true)
- multy = input(0.2, step=0.05, title="Base Channel Multiplier")
- Keltma = ma(maType, src, len)
- range = useTrueRange ? tr : high - low
- rangema = ema(range, len)
- upperk =Keltma + rangema * multy
- lowerk = Keltma - rangema * multy
- //Baseline Violation Candle
- open_pos = open*1
- close_pos = close*1
- difference = abs(close_pos-open_pos)
- atr_violation = difference > atr_slen
- InRange = upper_band > BBMC and lower_band < BBMC
- candlesize_violation = atr_violation and InRange
- plotshape(candlesize_violation, color=color.white, size=size.tiny,style=shape.diamond, location=location.top, transp=0,title="Candle Size > 1xATR")
- //SSL1 VALUES
- Hlv = int(na)
- Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
- sslDown = Hlv < 0 ? emaHigh : emaLow
- //SSL2 VALUES
- Hlv2 = int(na)
- Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
- sslDown2 = Hlv2 < 0 ? maHigh : maLow
- //EXIT VALUES
- Hlv3 = int(na)
- Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
- sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
- base_cross_Long = crossover(close, sslExit)
- base_cross_Short = crossover(sslExit, close)
- codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na
- //COLORS
- show_color_bar = input(title="Color Bars", type=input.bool, defval=true)
- color_bar = close > upperk ? #00c3ff : close < lowerk ? #ff0062 : color.gray
- color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na
- //PLOTS
- plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows", transp=20, maxheight=20, offset=0)
- p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4,transp=0, title='MA Baseline')
- DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3, color=color_ssl1, transp=10)
- barcolor(show_color_bar ? color_bar : na)
- up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline Upper Channel")
- low_channel = plot(show_Baseline ? lowerk : na, color=color_bar, title="Basiline Lower Channel")
- fill(up_channel, low_channel, color=color_bar, transp=90)
- ////SSL2 Continiuation from ATR
- atr_crit = input(0.9, step=0.1, title="Continuation ATR Criteria")
- upper_half = atr_slen * atr_crit + close
- lower_half = close - atr_slen * atr_crit
- buy_inatr = lower_half < sslDown2
- sell_inatr = upper_half > sslDown2
- sell_cont = close < BBMC and close < sslDown2
- buy_cont = close > BBMC and close > sslDown2
- sell_atr = sell_inatr and sell_cont
- buy_atr = buy_inatr and buy_cont
- atr_fill = buy_atr ? color.green : sell_atr ? color.purple : color.white
- LongPlot = plot(sslDown2, title="SSL2", linewidth=2, color=atr_fill, style=plot.style_circles, transp=0)
- u = plot(show_atr ? upper_band : na, "+ATR", color=color.white, transp=80)
- l = plot(show_atr ? lower_band : na, "-ATR", color=color.white, transp=80)
- //ALERTS
- alertcondition(crossover(close, sslDown), title='SSL Cross Alert', message='SSL1 has crossed.')
- alertcondition(crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2 has crossed.')
- alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
- alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
- alertcondition(crossover(close, sslExit), title='Exit Sell', message='Exit Sell Alert.')
- alertcondition(crossover(sslExit, close), title='Exit Buy', message='Exit Buy Alert.')
- alertcondition(crossover(close, upperk ), title='Baseline Buy Entry', message='Base Buy Alert.')
- alertcondition(crossover(lowerk, close ), title='Baseline Sell Entry', message='Base Sell Alert.')
- //////// INDICATOR 2 TOP BOTTOMS ////////////
- //@version=4
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © ceyhun
- per = input(14, title="Bottom Period")
- loc = low < lowest(low[1], per) and low <= lowest(low[per], per)
- bottom = barssince(loc)
- per2 = input(14, title="Top Period")
- loc2 = high > highest(high[1], per2) and high >= highest(high[per2], per2)
- top = barssince(loc2)
- /////BUY-SELL/////
- Buy = crossover(bottom, top)
- Sell = crossunder(bottom, top)
- plotshape(Buy,"BUY", shape.labelup, location.belowbar, color.green, text="BUY",textcolor=color.black)
- plotshape(Sell,"SELL", shape.labeldown, location.abovebar, color.red, text="SELL",textcolor=color.black)
- alertcondition(Buy, title="Buy Signal", message="Buy")
- alertcondition(Sell, title="Sell Signal", message="Sell")
- /////////////// INDICATOR 3 PULL BACK STRATEGY SIGNAL //////////
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © PriyankaAgarwal
- //@version=4
- sma20 = sma(close,20)
- ema34 = ema(close,34)
- ema60 = ema(close,60)
- ema5 = ema(close,5)
- ma200=sma(close,200)
- ma100=sma(close,100)
- var1 = high
- var2 = low
- var3 = open
- var4 = close
- candlerange = abs(high - low)
- bodyrange = abs(open - close)
- ucloserange = abs(low - close)
- lcloserange = abs(high - close)
- bodytocandleper = (bodyrange/candlerange)*100
- ucandlecloseper = (lcloserange/candlerange)*100
- lcandlecloseper = (ucloserange/candlerange)*100
- C_WhiteBody = open < close
- C_BlackBody = open > close
- buy = C_WhiteBody and (bodytocandleper>=80 or ucandlecloseper <=15) and high < ema5 and sma20 > ema34 and ema34 > ema60
- sell = C_BlackBody and (bodytocandleper>=80 or lcandlecloseper <=15) and low > ema5 and sma20 < ema34 and ema34 < ema60
- plot(sma20, title="Simple Moving Avg 20",color=color.red, linewidth=1)
- plot(ema34, title="Exp Moving Avg 34",color=color.blue, linewidth=1)
- plot(ema60, title="Exp Moving Avg 60",color=color.green, linewidth=1)
- plot(ema5, title="Exp Moving Avg 5",color=color.orange, linewidth=2)
- plot(ma100,color=color.purple,linewidth=2)
- plot(ma200,color=color.olive,linewidth=2)
- plotshape(buy, "Up Arrow", shape.triangleup, location.belowbar, color.green , 0,0,"Buy", color.green, true,size.tiny)
- plotshape(sell, "Down Arrow", shape.triangledown, location.abovebar, color.red , 0,0,"Sell", color.red, true,size.tiny)
- ///////// INDICATOR 3 SUPPORT RESİSTANCE ///////
- // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
- // © LuxAlgo
- //@version = 4
- //
- toggleBreaks = input(true, title = "Show Breaks" )
- leftBars = input(15, title = "Left Bars ")
- rightBars = input(15, title = "Right Bars")
- volumeThresh = input(20, title = "Volume Threshold")
- //
- highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1])
- lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1])
- r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance")
- s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support")
- //Volume %
- short = ema(volume, 5)
- long = ema(volume, 10)
- osc = 100 * (short - long) / long
- //For breaks with volume
- plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'Buy', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)
- plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'Sell', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)
- //For bull / bear wicks
- plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny)
- plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny)
- alertcondition(crossunder(close,lowUsePivot) and osc > volumeThresh , title = "Support Broken" , message = "Support Broken")
- alertcondition(crossover(close,highUsePivot) and osc > volumeThresh, title = "Resistance Broken" , message = "Resistance Broken")
- ////////////// INDICATOR 4 WELLES WILDER MA //////////
- Period = input(14, title="Period", minval=1)
- src5 = input(close, title="Source")
- alpha = 1/ Period
- WM = 0.0
- WM := alpha*src + (1-alpha)*nz(WM[1])
- color1= WM>WM[1]
- colorx = color1 ? color.lime : color.yellow
- plot(WM, style=plot.style_circles, color=colorx, linewidth=2, title="WM", transp=0)
- //////////// INDICATOR 5 ABCD /////////////////
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © rathiabhi
- //@version=4
- length = input(5)
- up1 = pivothigh(high,length,length)
- dn1 = pivotlow(low,length,length)
- upcount = barssince(not na(up1))
- dncount = barssince(not na(dn1))
- ppp = (not na(dn1) and dncount[1]>upcount[1]) ? dn1 : (not na(up1) and dncount[1]<upcount[1]) ? up1 : na
- up = (not na(up1) and dncount[1]<upcount[1]) ? up1 : na
- dn = (not na(dn1) and dncount[1]>upcount[1]) ? dn1 : na
- plot(up,title="pivot high",offset=-length)
- plot(dn,title="pivot low",offset=-length)
- plot(ppp,title="pivot line",offset=-length)
- n = bar_index
- a = valuewhen(not na(ppp),n,2)
- b = valuewhen(not na(ppp),n,1)
- c = valuewhen(not na(ppp),n,0)
- av = valuewhen(not na(ppp),ppp,2)
- bv = valuewhen(not na(ppp),ppp,1)
- cv = valuewhen(not na(ppp),ppp,0)
- //bullish AB=CD pattern
- ABCD_bear = av<bv and (bv-cv)<=(0.89*(bv-av)) and (bv-cv)>=(0.38*(bv-av))
- ABCD_bear1 = (high-cv)>=(bv-av) and ABCD_bear
- label1 = ABCD_bear1 and not(ABCD_bear1[1]) ? label.new(bar_index,high,text="Bearish AB=CD",color=color.red,style=label.style_arrowdown,yloc=yloc.abovebar,
- textcolor=color.red,size=size.normal) : na
- //buearish AB=CD pattern
- ABCD_bull = av>bv and (cv-bv)<=(0.89*(av-bv)) and (cv-bv)>=(0.38*(av-bv))
- ABCD_bull1 = (cv-low)>=(av-bv) and ABCD_bull
- label2 = ABCD_bull1 and not(ABCD_bull1[1]) ? label.new(bar_index,low,text="Bullish AB=CD",color=color.green,style=label.style_arrowup,yloc=yloc.belowbar,
- textcolor=color.green,size=size.normal) : na
- ////////// INDICATOR TOP AND BOTTOM CYCLE //////////
- //Thresholds
- psma_length = input(200, title="Price SMA Length")
- threshold = input(2.4, title="Threshold",step=0.1)
- optimalbuy = input(0.7, title="Optimal Buy",step=0.1)
- optimalsell = input(3.5, title="Optimal Sell",step=0.1)
- ma6 = sma(close, psma_length)
- multiple = close / ma6
- //Color
- opt_sell_signal = multiple > optimalsell
- s_signal = multiple[1] > optimalsell and multiple < optimalsell
- opt_buy_signal = multiple < optimalbuy
- b_signal = multiple[1] < optimalbuy and multiple > optimalbuy
- sell_signal = multiple > threshold
- //Plots
- plotshape(s_signal, style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small)
- plotshape(sell_signal, style = shape.triangledown, location = location.abovebar, color = color.yellow)
- plotshape(opt_buy_signal, style = shape.triangleup, location = location.belowbar, color = color.aqua)
- plotshape(b_signal, style = shape.triangleup, location = location.belowbar, color = color.green, size = size.small)
- //////////////// INDICATOR RSI TOP BOTTOM //////////
- //Inputs
- inputW = input(14,title="Length", type=input.integer, minval=1)
- resW=input("W", type=input.resolution, title="Resolution")
- outW = rsi(close,inputW)
- thresholdT = input(88,title="Top")
- thresholdB = input(30,title="Bottom")
- //Security
- securityW = security(syminfo.tickerid, resW, outW)
- //Threshold
- bottom5 = crossover(thresholdB, securityW) == 1 ? true : false
- top5= crossover(thresholdT, securityW) == 1 ? true : false
- //Plots
- plotshape(bottom5, style = shape.arrowup, location = location.belowbar, color = color.green, size = size.small, text="BOTTOM")
- plotshape(top, style = shape.arrowdown, location = location.abovebar, color = color.red, size = size.small, text="TOP")
- //////////// INDICATOR HACIM ////////////
- //Source
- src7 = input(close, title="Source")
- //Inputs ////////////
- ShowDL = input(true, "Show Volume Detail Label?")
- ShowVV = input(true, "Show Volume Values?")
- ShowRV = input(true, "Show Relative Volume?")
- RVLength = input(21, "Volume MA Length", minval=1)
- ShowRVBars = input(true, "Paint High Relative Volume Bars?")
- RValue = input(3, "Relative Volume for Bars?")
- LabelS = input(title = "Label Size", defval = "Normal", type = input.string, options = ['Tiny', 'Small', 'Normal', 'Large', 'Huge'])
- label_size = LabelS == 'Tiny' ? size.tiny : LabelS == 'Small' ? size.small : LabelS == 'Normal' ? size.normal : LabelS == 'Large' ? size.large : LabelS == 'Huge' ? size.huge : size.normal
- string Bstr = ""
- string DPBstr = ""
- string Sstr = ""
- string DPSstr = ""
- string TVol = ""
- string RVolTB = ""
- string RVolTS = ""
- //Buy - Sell Volume
- BuyVol = nz(round(iff((high==low), 0, volume*(close-low)/(high-low))))
- SellVol = nz(round(iff((high==low), 0, volume*(high-close)/(high-low))))
- //Buy-Sell Volume Percent Calculation ////////////
- BuyVolumePercent = nz(100 * BuyVol/(BuyVol+SellVol))
- SellVolumePercent = nz(100 * SellVol/(BuyVol+SellVol))
- //Total Volume Calculation ////////////
- if(str.length(tostring(volume)) >= 10 and str.length(tostring(volume)) <= 12)
- TVol := tostring(volume / 1000000000, "###.###") + "B"
- if(str.length(tostring(volume)) >= 7 and str.length(tostring(volume)) <= 9)
- TVol := tostring(volume / 1000000, "###.###") + "M"
- if(str.length(tostring(volume)) < 7)
- TVol := tostring(volume / 1000) + "K"
- if(str.length(tostring(volume)) < 4)
- TVol := tostring(volume)
- //Buy-Sell Volume Calculation ////////////
- //Buy Volume Billions Calculation
- if BuyVolumePercent > 0 and str.length(tostring(BuyVol)) >= 10 and str.length(tostring(SellVol)) <= 12 and ShowVV
- Bstr := " - " + tostring(BuyVol / 1000000000, "###.###") + "B"
- DPBstr := tostring(BuyVol / 1000000000, "###.###") + "B"
- //Sell Volume Billions Calculation
- if SellVolumePercent > 0 and str.length(tostring(SellVol)) >= 10 and str.length(tostring(SellVol)) <= 12 and ShowVV
- Sstr := " - " + tostring(SellVol / 1000000000, "###.###") + "B"
- DPSstr := tostring(SellVol / 1000000000, "###.###") + "B"
- //Buy Volume Millions Calculation
- if BuyVolumePercent > 0 and str.length(tostring(BuyVol)) >= 7 and str.length(tostring(SellVol)) <= 9 and ShowVV
- Bstr := " - " + tostring(BuyVol / 1000000, "###.###") + "M"
- DPBstr := tostring(BuyVol / 1000000, "###.###") + "M"
- //Sell Volume Millions Calculation
- if SellVolumePercent > 0 and str.length(tostring(SellVol)) >= 7 and str.length(tostring(SellVol)) <= 9 and ShowVV
- Sstr := " - " + tostring(SellVol / 1000000, "###.###") + "M"
- DPSstr := tostring(SellVol / 1000000, "###.###") + "M"
- //Buy Volume Thousands Calculation
- if BuyVolumePercent > 0 and str.length(tostring(BuyVol)) < 7 and ShowVV
- Bstr := " - " + tostring(BuyVol / 1000) + "K"
- DPBstr := tostring(BuyVol / 1000) + "K"
- //Sell Thousands Calculation
- if SellVolumePercent > 0 and str.length(tostring(SellVol)) < 7 and ShowVV
- Sstr := " - " + tostring(SellVol / 1000) + "K"
- DPSstr := tostring(SellVol / 1000) + "K"
- //Buy Volume less than a thousand
- if BuyVolumePercent > 0 and str.length(tostring(BuyVol)) < 4 and ShowVV
- Bstr := " - " + tostring(BuyVol)
- DPBstr := tostring(BuyVol)
- //Sell Volume less than a thousand
- if SellVolumePercent > 0 and str.length(tostring(SellVol)) < 4 and ShowVV
- Sstr := " - " + tostring(SellVol)
- DPSstr := tostring(SellVol)
- if BuyVolumePercent == 0 and ShowVV
- DPBstr := "0"
- if SellVolumePercent == 0 and ShowVV
- DPSstr := "0"
- //Relative Volume Calculation ////////////
- AVol = sma(volume, RVLength)
- RVol = volume/AVol
- //Relative Volume Label Value ////////////
- if(ShowDL)
- RVolTB := ShowRV and close > open ? tostring(RVol, "##.#") : na
- RVolTS := ShowRV and close < open ? tostring(RVol, "##.#") : na
- else
- RVolTB := ShowRV and close > open ? tostring(RVol, "##.#") + " - " : na
- RVolTS := ShowRV and close < open ? tostring(RVol, "##.#") + " - " : na
- //Labels ////////////////////////
- if(ShowDL)
- //Detail Labels //////////////////////////
- l = label.new(bar_index, na, (close > open and round(RVol) > 0 ? "Relative Volume : " + RVolTB + "\n" : na) + "Buy Percent : %" + tostring(BuyVolumePercent, "##") + "\n" + "Buy Volume : " + DPBstr + "\n" + "Total Volume : " + TVol, color=color.green, textcolor=color.white, textalign=text.align_left, style=label.style_label_lower_left, size=label_size, yloc=yloc.abovebar)
- label.delete(l[1])
- r = label.new(bar_index, na, (close < open and round(RVol) > 0 ? "Relative Volume : " + RVolTS + "\n" : na) + "Sell Percent : %" + tostring(SellVolumePercent, "##") + "\n" + "Sell Volume : " + DPSstr, color=color.red, textcolor=color.white, textalign=text.align_left, style=label.style_label_upper_left, size=label_size, yloc=yloc.belowbar)
- label.delete(r[1])
- else
- //Small Labels /////////////////////////
- l = label.new(bar_index, na, (round(RVol) > 0 ? RVolTB : na) + '%' + tostring(BuyVolumePercent, "##") + Bstr, color=color.green, textcolor=color.white, style=label.style_label_lower_left, size=label_size, yloc=yloc.abovebar)
- label.delete(l[1])
- r = label.new(bar_index, na, (round(RVol) > 0 ? RVolTS : na) + '%' + tostring(SellVolumePercent, "##") + Sstr, color=color.red, textcolor=color.white, style=label.style_label_upper_left, size=label_size, yloc=yloc.belowbar)
- label.delete(r[1])
- //If the relative volume value is greater than the value(Relative Volume for bars) we specify, paint those bars.
- barcolor(title="Relative Volume Candles", color= ShowRVBars and close > open and RVol > RValue ? color.blue : na)
Advertisement
Add Comment
Please, Sign In to add comment