name
stringlengths
1
64
url
stringlengths
44
135
author
stringlengths
3
30
author_url
stringlengths
34
61
likes_count
int64
0
33.2k
kind
stringclasses
3 values
pine_version
int64
1
5
license
stringclasses
3 values
source
stringlengths
177
279k
T.O/REG/Gauss Line
https://www.tradingview.com/script/Shev3v1v-T-O-REG-Gauss-Line/
shakibsharifian
https://www.tradingview.com/u/shakibsharifian/
54
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shakibsharifian //@version=5 indicator("T.O/REG/Gauss Line") vline(BarIndex, Color, LineStyle, LineWidth) => // Verticle Line, 54 lines maximum allowable per indicator barindx=bar_index-BarIndex _return = line.new(barindx, ta.highest(high,10), barindx, ta.lowest(low,10), xloc.bar_index, extend.both, Color, LineStyle, LineWidth) linearREGslope(x,y,length)=> //y=a*bx sumX=math.sum(x,length) sumY=math.sum(y,length) sumXY=math.sum(x*y,length) sumX2=math.sum(math.pow(x,2),length) Pow2SumX=math.pow((math.sum(x,length)),2) b=((length*sumXY)-(sumX*sumY))/((length*sumX2)-Pow2SumX) b linearREGbias(x,y,length)=> //y=a*bx sumX=math.sum(x,length) sumY=math.sum(y,length) sumXY=math.sum(x*y,length) sumX2=math.sum(math.pow(x,2),length) Pow2SumX=math.pow((math.sum(x,length)),2) a=((sumY*sumX2)-(sumX*sumXY))/((length*sumX2)-Pow2SumX) a //REGRESSION regLINE(src,length)=> b=linearREGslope(bar_index,src,length) a=linearREGbias(bar_index,src,length) x=bar_index y=b*(x)+a y gaussianMEAN(src,length,mult)=> float sum=0 for int _i=0 to length-1 sum:=sum+src[_i] _mean=sum/length sum:=0 for int _i=0 to length-1 sum:=sum+(math.pow((_mean-src[_i]),2)) _variance=sum/length _std=mult*math.sqrt(_variance) sum:=0 float coefSum=0 for int _i=0 to length-1 _coef=(1/(_std*math.sqrt(2*3.1415)))*math.exp(-.5*math.pow(((src[_i]-_mean)/_std),2)) sum:=sum+(_coef*src[_i]) coefSum:=coefSum+_coef _gaussMean=sum/coefSum _gaussMean srcIni = input.source(low, title='SOURCE',group='GENERAL',inline='a') bkw = input.int(200, minval=1, title='Backward',group='GENERAL',inline='b') mult = input.float(1, title='GAUSS MULT.',group='GENERAL',inline='c',step=0.1) supL = input.int(9, minval=1, title='BACKWARD',group='SUPER TREND',inline='a') fact = input.int(3, minval=1, title='FACTOR',group='SUPER TREND',inline='a') [_sup,_]=ta.supertrend(fact, supL) regSup=regLINE(_sup,bkw) ausw=ta.rma(gaussianMEAN(gaussianMEAN(srcIni,bkw,mult),bkw,mult),bkw) plot(ausw,color=color.new(#ed37db,0),linewidth=4,title='T.O Line') plot(gaussianMEAN(srcIni,bkw,mult),color=color.new(#fcba03,0),linewidth=3,title='GAUSS LINE') plot(regLINE(srcIni,bkw),color=color.new(#03cafc,0),linewidth=2,title='REG. LINE') plot(regSup,color=color.new(#90f0b0,0),linewidth=2,title='SUPREG. LINE')
FUNCTION: Limited Historical Data Workaround
https://www.tradingview.com/script/jOv7PBMz-FUNCTION-Limited-Historical-Data-Workaround/
theheirophant
https://www.tradingview.com/u/theheirophant/
38
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theheirophant //@version=5 indicator("FUNCTION: Limited Historical Data Workaround") // an SMA function that accepts series as a length Sma(src,p) => a = ta.cum(src) ret = (a - a[p]) / p limit(length) => lengthR = length if bar_index < length lengthR := bar_index lengthR plot(ta.sma(close, 200), color=color.red, linewidth=3) plot(Sma(close, limit(200)), color=color.lime)
Crypto Force Index
https://www.tradingview.com/script/3rNgQRJk/
Francesco_Guidotti
https://www.tradingview.com/u/Francesco_Guidotti/
34
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Francesco_Guidotti //@version=5 indicator("Crypto Force Index", overlay=true, shorttitle="CFI") // Inputs rsiSourceInput = input(close, "Source", group = "Configurazione RSI") rsiPeriodInput = input(14, "Length", group = "Configurazione RSI") signalInputRsi40_50 = input(false, "Segnale attivo se: RSI <= 50 and RSI >= 40", group = "Debolezza") signalInputRsi40_30 = input(false, "Segnale attivo se: RSI <= 40 and RSI >= 30", group = "Debolezza") signalInputRsi30_20 = input(true, "Segnale attivo se: RSI <= 30 and RSI >= 20", group = "Debolezza") signalInputRsi20_10 = input(true, "Segnale attivo se: RSI <= 20 and RSI >= 10", group = "Debolezza") signalInputRsi10_0 = input(true, "Segnale attivo se: RSI <= 10 and RSI >= 0", group = "Debolezza") signalInputRsi50_60 = input(false, "Segnale attivo se: RSI >= 50 and RSI <= 60", group = "Forza") signalInputRsi60_70 = input(false, "Segnale attivo se: RSI >= 60 and RSI <= 70", group = "Forza") signalInputRsi70_80 = input(false, "Segnale attivo se: RSI >= 70 and RSI <= 80", group = "Forza") signalInputRsi80_90 = input(true, "Segnale attivo se: RSI >= 80 and RSI <= 90", group = "Forza") signalInputRsi90_100 = input(true, "Segnale attivo se: RSI >= 90 and RSI <= 100", group = "Forza") // Configuration rsi = ta.rsi(rsiSourceInput, rsiPeriodInput) location = location.bottom size = size.tiny color = color.green signal = false percentualeRata = "0%" // Iper venduto if rsi <= 50 and rsi >= 40 color := color.new(color.red, 80) signal := signalInputRsi40_50 percentualeRata := "100%" else if rsi <= 40 and rsi >= 30 color := color.new(color.red, 60) signal := signalInputRsi40_30 percentualeRata := "100%" else if rsi <= 30 and rsi >= 20 color := color.new(color.red, 40) signal := signalInputRsi30_20 percentualeRata := "100%" else if rsi <= 20 and rsi >= 10 color := color.new(color.red, 20) signal := signalInputRsi20_10 percentualeRata := "100%" else if rsi <= 10 and rsi >= 0 color := color.new(color.red, 0) signal := signalInputRsi10_0 percentualeRata := "100%" // Iper comprato else if rsi >= 50 and rsi <= 60 color := color.new(color.green, 80) signal := signalInputRsi50_60 else if rsi >= 60 and rsi <= 70 color := color.new(color.green, 60) signal := signalInputRsi60_70 else if rsi >= 70 and rsi <= 80 color := color.new(color.green, 40) signal := signalInputRsi70_80 else if rsi >= 80 and rsi <= 90 color := color.new(color.green, 20) signal := signalInputRsi80_90 else if rsi >= 90 and rsi <= 100 color := color.new(color.green, 0) signal := signalInputRsi90_100 // Plots bgcolor(color.new(color, 95)) plotshape(rsi, style=shape.square, location=location, color=color, size=size) plotshape(signal, style=shape.circle, location=location.belowbar, color=color, size=size) if signal label.new(bar_index, high, text=percentualeRata, style=label.style_none)
Cup & Handle
https://www.tradingview.com/script/ZxTnUrDh-Cup-Handle/
fikira
https://www.tradingview.com/u/fikira/
1,528
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fikira //@version=5 indicator('Cup & Handle Final', max_lines_count=500, max_labels_count=500, max_bars_back=5000, overlay=true) // v82 v109 v233 // –––––––[ input ]––––––– calcs = 'Flattens the lines, \nthis has no effect \n   on calculations \n-> just for visuals' mHigh = 'maximum highs breaking through the top line\n (% of bars between left & right point)' mLow = 'maximum lows breaking through the bottom line\n (% of bars between left & right point)' cupLin = 'shows maximum difference \n         (-> "% angle") \n between the 2 top points \n of the latest cup pattern' cupLab = 'shows left & right top points of the latest cup pattern' cupHist = 'shows position of cup pattern in history' left = input.int ( 3 , title='left' , maxval= 50, minval= 1 ) right = input.int ( 1 , title='right' , maxval= 50, minval= 1 ) ZZback = input.int ( 50 , title='PP back' , maxval= 50, minval= 4 ) prcAngle = input.float( 22., title='% angle' , step= 0.1, minval= 0, group='Top line' ) / 100 prcOfCupT = input.float( 22., title='% cup Height Top' , maxval=100, minval= 0, group='Top line' ) / 100 maxHighs = input.float( 20., title='max % breaks' , tooltip= mHigh , maxval= 30, minval= 0, group='Top line' ) / 100 flatTop = input.bool ( true, title='Flatten' , tooltip= calcs , group='Top line' ) i_shTlin = input.bool ( false, title='  show test-lines' , tooltip= cupLin , group='Top line' ) i_shTlab = input.bool ( false, title='  show test-labels', tooltip= cupLab , group='Top line' ) prcOfCupB = input.float( 22., title='% cup Height Bot' , maxval=100, minval= 0, group='Bottom line') / 100 maxLows = input.float( 20., title='max % breaks' , tooltip= mLow , maxval= 30, minval= 0, group='Bottom line') / 100 flatBot = input.bool ( true, title='Flatten' , tooltip= calcs , group='Bottom line') i_CupLab = input.bool ( false, title='  show Cup labels' , tooltip= cupHist ) c_cup = input.color(color.new(color.yellow, 87), title='fill' , group='colors' ) c_bord = input.color(color.new(color.aqua , 75), title='border' , group='colors' ) c_retr = input.color(color.new( #FF0000 , 80), title='retrace' , group='colors' ) // –––––––[ function ]––––––– clearFill(fl) => while array.size(fl) > 0 lineF = array.pop(fl) line.delete(linefill.get_line1(lineF)) line.delete(linefill.get_line2(lineF)) linefill.delete(lineF) // –––––––[ variables ]––––––– var aP = array.new <float> () var aB = array.new <int> () var aLbCup = array.new <label> () var aLnFill = array.new <linefill>() var line l1 = line.new (bar_index, close, bar_index, close) var line l2 = line.new (bar_index, close, bar_index, close) var label b1 = label.new(bar_index, close, color=color.red, style=label.style_label_right, size= size.tiny ) var label b2 = label.new(bar_index, close, color=color.red, style=label.style_label_left , size= size.tiny ) var box bx = box.new (bar_index, close, bar_index, close, border_color= c_bord, bgcolor= na ) var box bx_ = box.new (bar_index, close, bar_index, close, border_color= c_cup , bgcolor= na, border_width= 7) var box bx2 = box.new (bar_index, close, bar_index, close, border_color= na , bgcolor= c_retr ) // –––––––[ clean ]––––––– if array.size(aP) > 50 array.pop(aP) array.pop(aB) if array.size(aLbCup ) > 500 label.delete(array.pop(aLbCup)) if array.size(aLnFill) > 500 lineF = array.pop(aLnFill) line.delete(linefill.get_line1(lineF)) line.delete(linefill.get_line2(lineF)) linefill.delete(lineF) // –––––––[ calcs ]––––––– ph = ta.pivothigh(left, right) // –––––––[ math.cos( 0 ) = 1 ]––––––– // –––––––[ math.cos(math.pi / 2) = 0 ]––––––– // –––––––[ math.cos(math.pi ) = -1 ]––––––– // –––––––[ => cos(0 -> pi) => 1 -> -1 ]––––––– if ph lwset = 0., cupH1 = 0., cupH2 = 0. if array.size(aP) > 4 // loopieloopie a{ for a = 4 to math.min(ZZback, array.size(aP)) -1 broken = false brTop = 0 brBot = 0 // –––––––[ get points -> x, y ]––––––– x1 = array.get(aB, a) , y1 = array.get(aP, a) x2 = bar_index - right, y2 = ph // cupW = x2 - x1 // width 'cup' lo = low // loopieloopie c{ for c = 0 to cupW if low[c] < lo lo := low[c] // –––––––[ if 'angle' per bar between y2 & y1 is smaller than x% of difference ]––––––– if y2 > y1 and y1 > y2 - ((y2 - lo) * prcAngle) and bar_index - x1 < 3000 // –––––––[ draw line ]––––––– testline = line.new(x1, y1, x2, y2) // loopieloopie b{ for b = right to bar_index - x1 // –––––––[ if a close between breaks the line -> stop ]––––––– if close[b] > line.get_price(testline, bar_index - b) broken := true break //} if broken == false // if not broken // // –––––––[ A) first check if there is no break above/below upper/lower line ]––––––– // aPPT = array.new<float>(), aPPB = array.new<float>() aPBT = array.new<int> (), aPBB = array.new<int> () // //cupW = x2 - x1 // width 'cup' //lo = low //// loopieloopie c{ //for c = 0 to cupW // if low[c] < lo // lo := low[c] //} lwset := lo // lowest point cupH1 := y2 - lwset // height 'cup' (y2 - lowest) cupH2 := y1 - lwset // height 'cup' (y1 - lowest) plus = cupH1 * prcOfCupT // percentage of difference between highest point and lowest of cup min = cupH2 * prcOfCupB // percentage of difference between other high point and lowest of cup brT = math.round(cupW * maxHighs) brB = math.round(cupW * maxLows ) // // loopieloopie d{ for d = 0 to cupW cos = math.cos (math.pi / cupW * d ) // 1 -> -1 nxt = math.sqrt( 1 - cos * cos) // -> 1 -> 0 -> 1 // math.abs(cos) , -math.abs(cos), cos clcT = y2 - ( cupH1 * nxt) + plus clcB = y1 - ( cupH2 * nxt) - min // // [ check for break ] if brTop > brT or brBot > brB break if high[d] > math.min(clcT , y2 ) brTop += 1 if low [d] < math.max(lwset, clcB) brBot += 1 // array.unshift(aPPT, flatTop ? math.min(y2 , clcT ) : clcT) array.unshift(aPPB, flatBot ? math.max(lwset, clcB ) : clcB) array.unshift(aPBT, x2 - d) , array.unshift(aPBB , x2 - d) //} // –––––––[ B) if no break -> draw everything ]––––––– // if brTop < brT and brBot < brB clearFill(aLnFill) // delete previous linefill drawings if i_CupLab array.unshift(aLbCup, label.new (x2, y2, color=color.new(color.blue , 75), textcolor=color.yellow, text='Cup', size=size.small)) // loopieloopie e{ for e = array.size(aPPT) -2 to 0 array.unshift(aLnFill, linefill.new( line.new(array.get(aPBT, e ), array.get(aPPT, e ), array.get(aPBT, e + 1), array.get(aPPT, e + 1), color=c_bord), line.new(array.get(aPBB, e ), array.get(aPPB, e ), array.get(aPBB, e + 1), array.get(aPPB, e + 1), color=c_bord), c_cup)) //} // –––––––[ draw box ]––––––– box.set_lefttop (bx , x2 , y2 ) box.set_rightbottom (bx , x2 + cupW / 3, y2 - (cupH1 * 0.5 )) box.set_lefttop (bx_, x2 , y2 ) box.set_rightbottom (bx_, x2 + cupW / 3, y2 - (cupH1 * 0.5 )) box.set_lefttop (bx2, x2 , y2 - (cupH1 * 0.33)) box.set_rightbottom (bx2, x2 + cupW / 3, y2 - (cupH1 * 0.5 )) // –––––––[ draw test labels ]––––––– if i_shTlab label.set_xy(b1, x1, y1) label.set_xy(b2, x2, y2) // –––––––[ draw test lines ]––––––– if i_shTlin line.set_xy1(l1, x1, y2 ) line.set_xy2(l1, x2, y2 ) line.set_xy1(l2, x1, y2 - ((y2 - lo) * prcAngle)) line.set_xy2(l2, x2, y2 - ((y2 - lo) * prcAngle)) // line.delete(testline) //} // array.unshift(aP, ph) array.unshift(aB, bar_index - right) //plot(array.size(line.all)) //-------------------------------------------------------
J_TPO Velocity Variation
https://www.tradingview.com/script/uCQTLlHO-J-TPO-Velocity-Variation/
ThiagoSchmitz
https://www.tradingview.com/u/ThiagoSchmitz/
89
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ThiagoSchmitz //@version=5 indicator("J_TPO Velocity Variation", "J_TPO", precision=5) int length = input.int(40, "Length", inline="core") int emaLength = input.int(200, "EMA Length", inline="core") float src = input.source(close, "Source", inline="core") bool colorbars = input.bool(true, "Color Bars", inline="display", group="Display") bool showFirstCross = input.bool(true, "Kicking Middle Cross", inline="display", group="Display") bool showCross = input.bool(true, "Middle Crosses", inline="display", group="Display") bool useTrendFilter = input.bool(true, "Trend Filter", inline="display", group="Display") color colorUp1 = input.color(#43A047, "Higher", inline="colors", group="Colors") color colorUp2 = input.color(#A5D6A7, "High", inline="colors", group="Colors") color colorDown1 = input.color(#E53935, "Lower", inline="colors", group="Colors") color colorDown2 = input.color(#EF9A9A, "Low", inline="colors", group="Colors") var bool crossedUp = false var float normalization = 12 / (length * (length - 1) * (length + 1)) var float Lenp1half = (length + 1) * 0.5 getRange() => float H = ta.highest(length) float L = ta.lowest(length) H - L getValue() => float[] arr1 = array.new_float(length + 2, 0) float[] arr2 = array.new_float(length + 2, 0) float[] arr3 = array.new_float(length + 2, 0) float accum = 0.0 int m = 1 for int i = 1 to length array.set(arr2, i, i) array.set(arr3, i, i) array.set(arr1, i, src[length - i]) for int i = 1 to length - 1 float maxval = array.get(arr1, i) int maxloc = i for j = i + 1 to length if array.get(arr1, j) < maxval maxval := array.get(arr1, j) maxloc := j float tmp1 = array.get(arr1, i) array.set(arr1, i, array.get(arr1, maxloc)) array.set(arr1, maxloc, tmp1) float tmp2 = array.get(arr2, i) array.set(arr2, i, array.get(arr2, maxloc)) array.set(arr2, maxloc, tmp2) while m < length - 1 int j = m + 1 bool flag = true accum := array.get(arr3, m) while flag if array.get(arr1, m) != array.get(arr1, j) if j - m > 1 accum := accum / (j - m) for int n = m to j - 1 array.set(arr3, n, accum) flag := false else accum := accum + array.get(arr3, j) j := j + 1 if j >= array.size(arr1) - 1 flag := false m := j accum := 0.0 for int i = 1 to length accum := accum + (array.get(arr3, m) - Lenp1half) * (array.get(arr2, m) - Lenp1half) accum float j_tpo = (normalization * getValue()) * getRange() / length float ema = ta.ema(j_tpo, emaLength) bool conditionBelow = (useTrendFilter and ema < 0) and j_tpo < 0 bool conditionAbove = (useTrendFilter and ema > 0) and j_tpo > 0 color conditionColor = conditionBelow ? j_tpo < j_tpo[1] ? colorDown1 : colorDown2 : conditionAbove ? j_tpo > j_tpo[1] ? colorUp1 : colorUp2 : color.gray crossedUp := conditionBelow and j_tpo[1] >= 0 ? false : conditionAbove and j_tpo[1] <= 0 ? true : crossedUp hline(0) barcolor(colorbars ? conditionColor : na) plot(j_tpo, "J_TPO", conditionColor, 1, plot.style_columns) plot(ema, "EMA Baseline", color.yellow, 2) plotshape(showFirstCross ? crossedUp and not nz(crossedUp[1], false) : false, "Kicking Cross Up", shape.triangleup, location.bottom, colorUp1, size=size.small) plotshape(showFirstCross ? not crossedUp and nz(crossedUp[1], false) : false, "Kicking Cross Down", shape.triangledown, location.top, colorDown1, size=size.small) plotshape(showCross ? conditionBelow and j_tpo[1] >= 0 : false, "Cross Down", shape.diamond, location.top, colorDown1, size=size.tiny) plotshape(showCross ? conditionAbove and j_tpo[1] <= 0 : false, "Cross Up", shape.diamond, location.bottom, colorUp1, size=size.tiny)
Blockchain Fundamentals: 200 Week MA Heatmap [CR]
https://www.tradingview.com/script/jTgpQFMI-Blockchain-Fundamentals-200-Week-MA-Heatmap-CR/
theheirophant
https://www.tradingview.com/u/theheirophant/
214
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theheirophant //@version=5 indicator("Blockchain Fundamentals: 200 Week MA Heatmap [CR]", overlay=true) //choose MA function. we need the no nbuilt ins so they can take a series as length. Sma(src,p) => a = ta.cum(src) ret = (a - a[p]) / ta.max(p) Ema(src,p) => ema = 0. sf = 2/(p+1) ema := nz(ema[1] + sf*(src - ema[1]),src) Wma(src,p) => mp = math.max(p,0) denom = mp*(mp+1)/2 a = ta.cum(src), (mp*a - math.sum(a[1],p))/denom getMA(src, length, maSelect) => ma = 0.0 if maSelect == "EMA" ma := Ema(src, length) ma if maSelect == "SMA" ma := Sma(src, length) ma if maSelect == "WMA" ma := Wma(src, length) ma ma //a function to return a length which will give a result even if there is not enough historical data. requires custom functions that will allow series as length. limit(length) => lengthR = length if bar_index < length lengthR := bar_index lengthR //are you naughty traders on the daily chart or not? daily = timeframe.isdaily if not daily runtime.error("USE DAILY CHART =)") //inputs maSelect = input.session(title="Choose Weekly MA type (SMA is default)", defval="SMA", options=["EMA", "SMA", "WMA"], group = "MA Settings") length = input.int(200, minval=2, title='Weekly MA Length (200 is default)', group = "MA Settings") * 7 //if you dont want legend just turn in off in style tab > uncheck "Tables" //legendSelect = input.bool(true, "Display Legend?", inline="a", group="Legend") Y = input.string("middle", " Position: ", inline = "a", options = ["top", "middle", "bottom"], group="Legend") X = input.string("right", "", inline = "a", options = ["left", "center", "right"], group="Legend") hmLocation = input.string("top", "Heatmap Location", options = ["top", "bottom"], group="Heatmap") hmShape = input.string("circle", "Heatmap Shape", options = ["square", "circle"], group="Heatmap") //data price = request.security('BNC:BLX', 'W', open) //ma200 = request.security('BNC:BLX', 'W', getMA(close , length, maSelect)) maLen = limit(length) ma200v2 = getMA(close, maLen, maSelect) //calculation SMA = 0.0 pSMA = 0.0 weekChange = ta.change(price) ? true : false SMA := weekChange ? ma200v2 : SMA[1] pSMA := weekChange ? SMA[1] : pSMA[1] diff = ta.valuewhen(weekChange, (SMA - pSMA) / SMA * 100, 0) diff2 = ta.valuewhen(weekChange, (SMA - pSMA) / SMA * 100, 1) diff3 = ta.valuewhen(weekChange, (SMA - pSMA) / SMA * 100, 2) diff4 = ta.valuewhen(weekChange, (SMA - pSMA) / SMA * 100, 3) heatmap = diff + diff2 + diff3 + diff4 //colors colorY = color.from_gradient(heatmap, -20, 0, color.black, color.purple) colorX = color.from_gradient(heatmap, 16, 40, color.maroon, color.red) red = #FF5252 orange = #FFA500 maroon = #880E4F yellow = #FFEB3B lime = #00E676 green = #4CAF50 aqua = #09EBEE blue = #28ACEA navy = #3D76E0 purple = #9C27B0 black = #000000 white = #FFFFFF colorz = heatmap >= 16 ? colorX : heatmap >= 14 ? maroon : heatmap >= 12 ? orange : heatmap >= 10 ? yellow : heatmap >= 8 ? lime : heatmap >= 6 ? aqua : heatmap >= 4 ? blue : heatmap >= 2 ? navy : heatmap >= 0 ? purple : heatmap < 0 ? colorY : white //plots plotshape(weekChange ? close : na, title="200W MA Heatmap", color = colorz, style=hmShape == "circle" ? shape.circle : shape.square, location= hmLocation == "top" ? location.top : location.bottom, size=size.small) plot(ma200v2, "200 Week MA", color=colorz, linewidth=2) //legend / table legend = table.new(Y + "_" + X, columns = 2, rows = 11, border_width = 2, border_color = color.black, frame_width = 1, frame_color = color.white, bgcolor=color.silver) table.cell(table_id = legend, column = 0, row = 0, text = "Color",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 1, row = 0, text = "Cum. 4 week % Δ",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 1, text = "■",text_size = size.normal,text_color = red) table.cell(table_id = legend, column = 1, row = 1, text = "16+ % Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 2, text = "■",text_size = size.normal,text_color = maroon) table.cell(table_id = legend, column = 1, row = 2, text = "14 - 16% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 3, text = "■",text_size = size.normal,text_color = orange) table.cell(table_id = legend, column = 1, row = 3, text = "12 - 14% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 4, text = "■",text_size = size.normal,text_color = yellow) table.cell(table_id = legend, column = 1, row = 4, text = "10 - 12% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 5, text = "■",text_size = size.normal,text_color = lime) table.cell(table_id = legend, column = 1, row = 5, text = "8 - 10% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 6, text = "■",text_size = size.normal,text_color = aqua) table.cell(table_id = legend, column = 1, row = 6, text = "6 - 8% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 7, text = "■",text_size = size.normal,text_color = blue) table.cell(table_id = legend, column = 1, row = 7, text = "4 - 6% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 8, text = "■",text_size = size.normal,text_color = navy) table.cell(table_id = legend, column = 1, row = 8, text = "2 - 4% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 9, text = "■",text_size = size.normal,text_color = purple) table.cell(table_id = legend, column = 1, row = 9, text = "0 - 2% Gain",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 0, row = 10, text = "■",text_size = size.normal,text_color = color.black) table.cell(table_id = legend, column = 1, row = 10, text = "< 0% Gain",text_size = size.normal,text_color = color.black)
Jay Multi SMA
https://www.tradingview.com/script/77haH3dZ-Jay-Multi-SMA/
Jay_king
https://www.tradingview.com/u/Jay_king/
3
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Jay_king //@version=5 indicator("Jay Multi SMA", overlay = true) Lenghtsma1 = input.int(title = "SMA1", defval = 30, minval = 1, maxval = 200) Lenghtsma2 = input.int(title = "SMA2", defval = 40, minval = 1, maxval = 200) Lenghtsma3 = input.int(title = "SMA3", defval = 50, minval = 1, maxval = 200) Lenghtsma4 = input.int(title = "SMA4", defval = 60, minval = 1, maxval = 200) Lenghtsma5 = input.int(title = "SMA5", defval = 200, minval = 1, maxval = 200) // SMA INDICATOR SMA1 = ta.sma(close,Lenghtsma1) SMA2 = ta.sma(close,Lenghtsma2) SMA3 = ta.sma(close,Lenghtsma3) SMA4 = ta.sma(close,Lenghtsma4) SMA5 = ta.sma(close,Lenghtsma5) //PLOT plot(SMA1, color = color.new(color.green,0)) plot(SMA2, color = color.new(color.yellow,0)) plot(SMA3, color = color.new(color.white,0)) plot(SMA4, color = color.new(color.red,0)) plot(SMA5, color = color.new(color.fuchsia,0))
Multiple EMAs
https://www.tradingview.com/script/HcEzNkjf-Multiple-EMAs/
Swing-Trades
https://www.tradingview.com/u/Swing-Trades/
1
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Syed.Shahbaaz.Quadri //@version=5 indicator("Multiple EMAs", overlay=true) //length1 = input.int(50, "Fast SMA") source1 = close //FastSMA=ta.sma(source1, length1) //plot(FastSMA, color=color.new(color.red,20),title="FastSMA") length2 = input.int(100, "Slow SMA") source2 = close SlowSMA=ta.sma(source2, length2) plot(SlowSMA, color=color.new(color.green,20),title="SlowSMA") //length3 = input.int(50, "Fast EMA") //source3 = close //FastEMA=ta.ema(source3, length3) //FastEMA=ta.ema(close, 50) //plot(FastSMA, color=color.new(color.yellow,20),title="FastEMA") //length4 = input.int(100, "Slow EMA") //source4 = close //SlowEMA=ta.ema(source4, length4) //SlowEMA=ta.ema(close, 100) //plot(SlowSMA, color=color.new(color.blue,20),title="SlowEMA") //FastEMA=ta.ema(close, 50) //SlowEMA=ta.ema(close, 100) plot(ta.ema(close,20),title="20 EMA",color = color.new(color.white, 20)) plot(ta.ema(close,50),title="50 EMA",color = color.new(color.yellow, 20)) plot(ta.ema(close,100),title="100 EMA",color =color.new(color.blue, 20)) plot(ta.ema(close,200), title="200 EMA",color=color.new(color.red,20))
Percent above or Below Moving Average Candle colour
https://www.tradingview.com/script/yCYmGuVy-Percent-above-or-Below-Moving-Average-Candle-colour/
Amit_001
https://www.tradingview.com/u/Amit_001/
86
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Amit_001 //@version=5 indicator("percent above or Below Moving Average", overlay=true, shorttitle = "percent_MA_X") maLevel = input(title="Moving Average", defval=20) percentage = input(title = "%above/Below", defval = 50) typeMA = input.string(title = "Select type", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "DEMA"]) src = input(close, title="Source") MASource = ta.sma(src, maLevel) if typeMA == "EMA" MASource := ta.ema(src, maLevel) else if typeMA == "SMMA (RMA)" MASource := ta.rma(src, maLevel) else if typeMA == "VWMA" MASource := ta.vwma(src, maLevel) else if typeMA == "WMA" MASource := ta.wma(src, maLevel) else if typeMA == "DEMA" MASource := 2* ta.ema(src, maLevel) - ta.ema(ta.ema(src, maLevel), maLevel) plot(MASource, color = color.new(color.orange,0)) barcolor((close>open) and (high-MASource) > ((high-low)*(percentage/100))? color.new(color.blue, 0) : na) barcolor((close<open) and (MASource-low) > ((high-low)*(percentage/100))? color.new(color.yellow, 0) : na)
MAP Money Management
https://www.tradingview.com/script/ibAsuEy3-MAP-Money-Management/
manipoursadegh
https://www.tradingview.com/u/manipoursadegh/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mani Poursadegh //@version=5 indicator("MAP", overlay = true) // ---------- INPUTS ---------- ////// var GRP1 = "تنظیمات حجم معاملات" portfolio_size = input.float(1000.00, "حجم معامله", group = GRP1) risk_sel = input.float(1, "درصد ریسک", minval = 0.1, maxval = 100, step = 0.1, group = GRP1) var GRP2 = "TRADE INPUTS" entry_price = input.float(0, "قیمت ورود به معامله", minval = 0, group = GRP2) stop_price = input.float(0, "قیمت استاپ لاس", minval = 0, group = GRP2) exit_price = input.float(0, "قیمت خروج از معامله", minval = 0, group = GRP2) levrage_price = input.float(1, "اهرم", minval =0, maxval = 100, group = GRP2) var GRP3 = "PLOT SELECTION" show_table = input(true, "Show Table", group = GRP3) show_labels = input(true, title='Show Trade Labels', group = GRP3) _offset = input(15, "Line offset", group = GRP3) transp_label = input.int(0, "Label Transparency", minval = 0, maxval = 100, group = GRP3) // ---------- CALCS ---------- //// current_price = close long = entry_price > stop_price risk_amount = portfolio_size * (risk_sel/100) // Risk amount stop_per = long ? 100 - ((stop_price / entry_price) * 100) : (100 - ((stop_price / entry_price) * 100)) * -1 position_size = risk_amount / (stop_per / 100) asset_quantity = position_size / entry_price risk = (entry_price - stop_price) / entry_price reward = ((exit_price - entry_price) / entry_price) rr = math.round(reward / risk, 2) levrage = math.round(position_size / levrage_price, 2) // ---------- PLOTS ---------- // // Plot Lines _offsettime = timenow + math.round(ta.change(time)*_offset) if show_labels and entry_price > 0 _entry = label.new(_offsettime, entry_price,"______________________________ورود", xloc = xloc.bar_time, textcolor = color.new(color.black, transp_label), style = label.style_none, size = size.normal) _stop = label.new(_offsettime, stop_price, "_____________________________استاپ", xloc = xloc.bar_time, textcolor = color.new(color.red, transp_label), style = label.style_none, size = size.normal) _exit = label.new(_offsettime, exit_price, "_____________________________خروج", xloc = xloc.bar_time, textcolor = color.new(color.green, transp_label), style = label.style_none, size = size.normal) label.delete(_entry[1]) label.delete(_stop[1]) label.delete(_exit[1]) // Plot Table text_col = color.white b_col = color.black col_trade = color.new(color.black, 50) col_risk = color.new(color.black, 50) col_position = color.new(color.black, 50) var table RiskTable = table.new(position.bottom_right, 2, 12, frame_color=color.new(color.red, 50), frame_width=1, border_width=1, border_color=color.new(color.red, 50)) if barstate.islast // Headings if show_table table.cell(RiskTable, 0, 0, 'اطلاعات', text_color = color.black, text_size = size.normal, bgcolor = color.new(color.olive,50)) table.cell(RiskTable, 1, 0, 'حجم', text_color = color.black, text_size = size.normal, bgcolor = color.new(color.olive,50)) if (show_table) table.cell(RiskTable, 0, 1, "قیمت کنونی", text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 1, 1, '$' + str.tostring(math.round(current_price, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 2, "حجم دارایی شما", text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 1, 2, '$' + str.tostring(portfolio_size), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 3, "درصد ریسک", text_color = text_col, text_size = size.normal, bgcolor = col_risk) table.cell(RiskTable, 1, 3, str.tostring(risk_sel) + '%', text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 4, "مدیریت ریسک", text_color = text_col, text_size = size.normal, bgcolor = col_risk) table.cell(RiskTable, 1, 4, '$' + str.tostring(math.round(risk_amount, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 5, "قیمت ورود", text_color = text_col, text_size = size.normal, bgcolor = col_trade) table.cell(RiskTable, 1, 5, str.tostring(math.round(entry_price, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 6, "قیمت استاپ", text_color = text_col, text_size = size.normal, bgcolor = col_trade) table.cell(RiskTable, 1, 6, str.tostring(math.round(stop_price, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 7, "قیمت خروج", text_color = text_col, text_size = size.normal, bgcolor = col_trade) table.cell(RiskTable, 1, 7, str.tostring(math.round(exit_price, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 8, "درصد استاپ", text_color = text_col, text_size = size.normal, bgcolor = col_risk) table.cell(RiskTable, 1, 8, str.tostring(math.round(stop_per, 2)) + '%', text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 9, "Risk / Reward", text_color = text_col, text_size = size.normal, bgcolor = col_risk) table.cell(RiskTable, 1, 9, str.tostring(rr), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 10, "حجم ورود به معامله", text_color = text_col, text_size = size.normal, bgcolor = col_position) table.cell(RiskTable, 1, 10, '$' + str.tostring(math.round(position_size, 2)), text_color = text_col, text_size = size.normal, bgcolor = b_col) table.cell(RiskTable, 0, 11, "قیمت با اهرم", text_color = text_col, text_size = size.normal, bgcolor = col_trade) table.cell(RiskTable, 1, 11, '$' + str.tostring(levrage), text_color = text_col, text_size = size.normal, bgcolor = b_col) // table.cell(RiskTable, 0, 12, "حجم ارز", text_color = text_col, text_size = size.normal, bgcolor = col_position) //table.cell(RiskTable, 1, 12, str.tostring(math.round(asset_quantity, 5)), text_color = text_col, text_size = size.normal, bgcolor = b_col)
Dividend Yield
https://www.tradingview.com/script/9JVuv3H6-Dividend-Yield/
Ronald_Ryninger
https://www.tradingview.com/u/Ronald_Ryninger/
49
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Ron_C //@version=5 indicator("Dividend Yield") //----- Inputs { dividendSchedule = input.string("Annual", title="Dividend Payment Frequency",options=["Annual","Semi-Annual", "Quarterly", "Monthly"]) desiredYieldPercent = input.float(7.5, title="Desired Yield %", step=0.1) //} //----- Variables { var dividendFrequency = 0 dividend = request.dividends(syminfo.tickerid) var resultsTable = table.new(position = position.top_right, columns = 2, rows = 2) var divFreqNum = int(na) var annualIncome = float(na) var annualYield = float(na) //} //----- Converting Percent into Decmial { desiredYield = desiredYieldPercent/100 //} //----- Determining Number Annual Dividends { if dividendSchedule == "Annual" dividendFrequency := 1 else if dividendSchedule == "Semi-Annual" dividendFrequency := 2 else if dividendSchedule == "Quarterly" dividendFrequency := 4 else dividendFrequency := 12 //} //----- Determining Stock Price Required for Desired Yield { stockPrice = dividend * dividendFrequency / desiredYield //} //----- Plot Stock Price { plot(stockPrice, title="Required Price for Desired Yield") //} //-------- Determining Annual Yield { annualIncome := dividend * dividendFrequency annualYield := math.round((annualIncome / close) * 100, 2) annualYieldString = str.tostring(annualYield) //} //-------- Display Results Table { table.cell(resultsTable, column = 0, row = 0, text = "") table.cell(resultsTable, column = 0, row = 1, bgcolor = color.white, text = "Current Yield") table.cell(resultsTable, column = 1, row = 1, bgcolor = color.white, text = annualYieldString + "%") //}
Intraday Background Time Ranges
https://www.tradingview.com/script/s6IWPyEH-Intraday-Background-Time-Ranges/
valpatrad
https://www.tradingview.com/u/valpatrad/
97
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © valpatrad //@version=5 indicator('Intraday Background Time Ranges', 'Time Ranges', true) if not timeframe.isintraday runtime.error('The indicator works on intraday charts only.') //////////////////////////// // // // Menu // // // //////////////////////////// ant = input.bool(true, 'Anticipate') //Range 1 show_1 = input.bool(true, '  1', inline='1.1') col_1 = input.color(color.new(#2962FF, 90), '', inline='1.1') note_1 = input.string('', '    -  Table ', inline='1.1') txt_col_1 = input.color(#FFFFFF, '', inline='1.1', tooltip='Leave the text field empty to remove the table slot.') start_hour_1 = input.int(9, '', 0, 24, inline='1.2') start_min_1 = input.int(30, '-', 0, 59, inline='1.2') end_hour_1 = input.int(9, '/', 0, 24, inline='1.2') end_min_1 = input.int(43, '-', 0, 59, inline='1.2', tooltip='Starting Time: Hour - Minutes / Ending Time: Hour - Minutes') //Range 2 show_2 = input.bool(true, '  2', inline='2.1') col_2 = input.color(color.new(#FFFFFF, 90), '', inline='2.1') note_2 = input.string('', '    -  Table ', inline='2.1') txt_col_2 = input.color(#000000, '', inline='2.1') start_hour_2 = input.int(9, '', 0, 24, inline='2.2') start_min_2 = input.int(43, '-', 0, 59, inline='2.2') end_hour_2 = input.int(9, '/', 0, 24, inline='2.2') end_min_2 = input.int(56, '-', 0, 59, inline='2.2') //Range 3 show_3 = input.bool(true, '  3', inline='3.1') col_3 = input.color(color.new(#880E4F, 90), '', inline='3.1') note_3 = input.string('', '    -  Table ', inline='3.1') txt_col_3 = input.color(#FFFFFF, '', inline='3.1') start_hour_3 = input.int(9, '', 0, 24, inline='3.2') start_min_3 = input.int(56, '-', 0, 59, inline='3.2') end_hour_3 = input.int(10, '/', 0, 24, inline='3.2') end_min_3 = input.int(9, '-', 0, 59, inline='3.2') //Range 4 show_4 = input.bool(true, '  4', inline='4.1') col_4 = input.color(color.new(#00BCD4, 90), '', inline='4.1') note_4 = input.string('', '    -  Table ', inline='4.1') txt_col_4 = input.color(#000000, '', inline='4.1') start_hour_4 = input.int(10, '', 0, 24, inline='4.2') start_min_4 = input.int(9, '-', 0, 59, inline='4.2') end_hour_4 = input.int(10, '/', 0, 24, inline='4.2') end_min_4 = input.int(22, '-', 0, 59, inline='4.2') //Range 5 show_5 = input.bool(true, '  5', inline='5.1') col_5 = input.color(color.new(#FFEB3B, 90), '', inline='5.1') note_5 = input.string('', '    -  Table ', inline='5.1') txt_col_5 = input.color(#000000, '', inline='5.1') start_hour_5 = input.int(10, '', 0, 24, inline='5.2') start_min_5 = input.int(22, '-', 0, 59, inline='5.2') end_hour_5 = input.int(10, '/', 0, 24, inline='5.2') end_min_5 = input.int(35, '-', 0, 59, inline='5.2') //Range 6 show_6 = input.bool(true, '  6', inline='6.1') col_6 = input.color(color.new(#FF5252, 90), '', inline='6.1') note_6 = input.string('', '    -  Table ', inline='6.1') txt_col_6 = input.color(#000000, '', inline='6.1') start_hour_6 = input.int(10, '', 0, 24, inline='6.2') start_min_6 = input.int(35, '-', 0, 59, inline='6.2') end_hour_6 = input.int(10, '/', 0, 24, inline='6.2') end_min_6 = input.int(48, '-', 0, 59, inline='6.2') //Range 7 show_7 = input.bool(false, '  7', inline='7.1') col_7 = input.color(color.new(#81C784, 90), '', inline='7.1') note_7 = input.string('', '    -  Table ', inline='7.1') txt_col_7 = input.color(#000000, '', inline='7.1') start_hour_7 = input.int(10, '', 0, 24, inline='7.2') start_min_7 = input.int(48, '-', 0, 59, inline='7.2') end_hour_7 = input.int(11, '/', 0, 24, inline='7.2') end_min_7 = input.int(1, '-', 0, 59, inline='7.2') //Range 8 show_8 = input.bool(false, '  8', inline='8.1') col_8 = input.color(color.new(#CE93D8, 90), '', inline='8.1') note_8 = input.string('', '    -  Table ', inline='8.1') txt_col_8 = input.color(#000000, '', inline='8.1') start_hour_8 = input.int(11, '', 0, 24, inline='8.2') start_min_8 = input.int(1, '-', 0, 59, inline='8.2') end_hour_8 = input.int(11, '/', 0, 24, inline='8.2') end_min_8 = input.int(14, '-', 0, 59, inline='8.2') //Range 9 show_9 = input.bool(false, '  9', inline='9.1') col_9 = input.color(color.new(#808000, 90), '', inline='9.1') note_9 = input.string('', '    -  Table ', inline='9.1') txt_col_9 = input.color(#FFFFFF, '', inline='9.1') start_hour_9 = input.int(11, '', 0, 24, inline='9.2') start_min_9 = input.int(14, '-', 0, 59, inline='9.2') end_hour_9 = input.int(11, '/', 0, 24, inline='9.2') end_min_9 = input.int(27, '-', 0, 59, inline='9.2') //Range 10 show_10 = input.bool(false, '10', inline='10.1') col_10 = input.color(color.new(#9C27B0, 90), '', inline='10.1') note_10 = input.string('', '    -  Table ', inline='10.1') txt_col_10 = input.color(#FFFFFF, '', inline='10.1') start_hour_10 = input.int(11, '', 0, 24, inline='10.2') start_min_10 = input.int(27, '-', 0, 59, inline='10.2') end_hour_10 = input.int(11, '/', 0, 24, inline='10.2') end_min_10 = input.int(40, '-', 0, 59, inline='10.2') //Range 11 show_11 = input.bool(false, '11', inline='11.1') col_11 = input.color(color.new(#00FF0C, 90), '', inline='11.1') note_11 = input.string('', '    -  Table ', inline='11.1') txt_col_11 = input.color(#000000, '', inline='11.1') start_hour_11 = input.int(11, '', 0, 24, inline='11.2') start_min_11 = input.int(40, '-', 0, 59, inline='11.2') end_hour_11 = input.int(11, '/', 0, 24, inline='11.2') end_min_11 = input.int(53, '-', 0, 59, inline='11.2') //Range 12 show_12 = input.bool(false, '12', inline='12.1') col_12 = input.color(color.new(#F57F17, 90), '', inline='12.1') note_12 = input.string('', '    -  Table ', inline='12.1') txt_col_12 = input.color(#000000, '', inline='12.1') start_hour_12 = input.int(11, '', 0, 24, inline='12.2') start_min_12 = input.int(53, '-', 0, 59, inline='12.2') end_hour_12 = input.int(12, '/', 0, 24, inline='12.2') end_min_12 = input.int(6, '-', 0, 59, inline='12.2') //Range 13 show_13 = input.bool(false, '13', inline='13.1') col_13 = input.color(color.new(#006064, 90), '', inline='13.1') note_13 = input.string('', '    -  Table ', inline='13.1') txt_col_13 = input.color(#FFFFFF, '', inline='13.1') start_hour_13 = input.int(12, '', 0, 24, inline='13.2') start_min_13 = input.int(6, '-', 0, 59, inline='13.2') end_hour_13 = input.int(12, '/', 0, 24, inline='13.2') end_min_13 = input.int(19, '-', 0, 59, inline='13.2') //Range 14 show_14 = input.bool(false, '14', inline='14.1') col_14 = input.color(color.new(#FF1493, 90), '', inline='14.1') note_14 = input.string('', '    -  Table ', inline='14.1') txt_col_14 = input.color(#FFFFFF, '', inline='14.1') start_hour_14 = input.int(12, '', 0, 24, inline='14.2') start_min_14 = input.int(19, '-', 0, 59, inline='14.2') end_hour_14 = input.int(12, '/', 0, 24, inline='14.2') end_min_14 = input.int(32, '-', 0, 59, inline='14.2') //Range 15 show_15 = input.bool(false, '15', inline='15.1') col_15 = input.color(color.new(#00FFFF, 90), '', inline='15.1') note_15 = input.string('', '    -  Table ', inline='15.1') txt_col_15 = input.color(#FFFFFF, '', inline='15.1') start_hour_15 = input.int(12, '', 0, 24, inline='15.2') start_min_15 = input.int(32, '-', 0, 59, inline='15.2') end_hour_15 = input.int(12, '/', 0, 24, inline='15.2') end_min_15 = input.int(45, '-', 0, 59, inline='15.2') //Range 16 show_16 = input.bool(false, '16', inline='16.1') col_16 = input.color(color.new(#FF8C00, 90), '', inline='16.1') note_16 = input.string('', '    -  Table ', inline='16.1') txt_col_16 = input.color(#FFFFFF, '', inline='16.1') start_hour_16 = input.int(12, '', 0, 24, inline='16.2') start_min_16 = input.int(45, '-', 0, 59, inline='16.2') end_hour_16 = input.int(12, '/', 0, 24, inline='16.2') end_min_16 = input.int(58, '-', 0, 59, inline='16.2') //Range 17 show_17 = input.bool(false, '17', inline='17.1') col_17 = input.color(color.new(#7B68EE, 90), '', inline='17.1') note_17 = input.string('', '    -  Table ', inline='17.1') txt_col_17 = input.color(#FFFFFF, '', inline='17.1') start_hour_17 = input.int(12, '', 0, 24, inline='17.2') start_min_17 = input.int(58, '-', 0, 59, inline='17.2') end_hour_17 = input.int(13, '/', 0, 24, inline='17.2') end_min_17 = input.int(11, '-', 0, 59, inline='17.2') //Range 18 show_18 = input.bool(false, '18', inline='18.1') col_18 = input.color(color.new(#32CD32, 90), '', inline='18.1') note_18 = input.string('', '    -  Table ', inline='18.1') txt_col_18 = input.color(#FFFFFF, '', inline='18.1') start_hour_18 = input.int(13, '', 0, 24, inline='18.2') start_min_18 = input.int(11, '-', 0, 59, inline='18.2') end_hour_18 = input.int(13, '/', 0, 24, inline='18.2') end_min_18 = input.int(24, '-', 0, 59, inline='18.2') //Range 19 show_19 = input.bool(false, '19', inline='19.1') col_19 = input.color(color.new(#9370DB, 90), '', inline='19.1') note_19 = input.string('', '    -  Table ', inline='19.1') txt_col_19 = input.color(#FFFFFF, '', inline='19.1') start_hour_19 = input.int(13, '', 0, 24, inline='19.2') start_min_19 = input.int(24, '-', 0, 59, inline='19.2') end_hour_19 = input.int(13, '/', 0, 24, inline='19.2') end_min_19 = input.int(37, '-', 0, 59, inline='19.2') //Range 20 show_20 = input.bool(false, '20', inline='20.1') col_20 = input.color(color.new(#FFD700, 90), '', inline='20.1') note_20 = input.string('', '    -  Table ', inline='20.1') txt_col_20 = input.color(#FFFFFF, '', inline='20.1') start_hour_20 = input.int(13, '', 0, 24, inline='20.2') start_min_20 = input.int(37, '-', 0, 59, inline='20.2') end_hour_20 = input.int(13, '/', 0, 24, inline='20.2') end_min_20 = input.int(50, '-', 0, 59, inline='20.2') //Range 21 show_21 = input.bool(false, '21', inline='21.1') col_21 = input.color(color.new(#3CB371, 90), '', inline='21.1') note_21 = input.string('', '    -  Table ', inline='21.1') txt_col_21 = input.color(#FFFFFF, '', inline='21.1') start_hour_21 = input.int(13, '', 0, 24, inline='21.2') start_min_21 = input.int(50, '-', 0, 59, inline='21.2') end_hour_21 = input.int(14, '/', 0, 24, inline='21.2') end_min_21 = input.int(3, '-', 0, 59, inline='21.2') //Range 22 show_22 = input.bool(false, '22', inline='22.1') col_22 = input.color(color.new(#BA55D3, 90), '', inline='22.1') note_22 = input.string('', '    -  Table ', inline='22.1') txt_col_22 = input.color(#FFFFFF, '', inline='22.1') start_hour_22 = input.int(14, '', 0, 24, inline='22.2') start_min_22 = input.int(3, '-', 0, 59, inline='22.2') end_hour_22 = input.int(14, '/', 0, 24, inline='22.2') end_min_22 = input.int(16, '-', 0, 59, inline='22.2') //Range 23 show_23 = input.bool(false, '23', inline='23.1') col_23 = input.color(color.new(#FFA500, 90), '', inline='23.1') note_23 = input.string('', '    -  Table ', inline='23.1') txt_col_23 = input.color(#FFFFFF, '', inline='23.1') start_hour_23 = input.int(14, '', 0, 24, inline='23.2') start_min_23 = input.int(16, '-', 0, 59, inline='23.2') end_hour_23 = input.int(14, '/', 0, 24, inline='23.2') end_min_23 = input.int(29, '-', 0, 59, inline='23.2') //Range 24 show_24 = input.bool(false, '24', inline='24.1') col_24 = input.color(color.new(#66CDAA, 90), '', inline='24.1') note_24 = input.string('', '    -  Table ', inline='24.1') txt_col_24 = input.color(#FFFFFF, '', inline='24.1') start_hour_24 = input.int(14, '', 0, 24, inline='24.2') start_min_24 = input.int(29, '-', 0, 59, inline='24.2') end_hour_24 = input.int(14, '/', 0, 24, inline='24.2') end_min_24 = input.int(42, '-', 0, 59, inline='24.2') //Range 25 show_25 = input.bool(false, '25', inline='25.1') col_25 = input.color(color.new(#8B4513, 90), '', inline='25.1') note_25 = input.string('', '    -  Table ', inline='25.1') txt_col_25 = input.color(#FFFFFF, '', inline='25.1') start_hour_25 = input.int(14, '', 0, 24, inline='25.2') start_min_25 = input.int(42, '-', 0, 59, inline='25.2') end_hour_25 = input.int(14, '/', 0, 24, inline='25.2') end_min_25 = input.int(55, '-', 0, 59, inline='25.2') //Range 26 show_26 = input.bool(false, '26', inline='26.1') col_26 = input.color(color.new(#FF69B4, 90), '', inline='26.1') note_26 = input.string('', '    -  Table ', inline='26.1') txt_col_26 = input.color(#FFFFFF, '', inline='26.1') start_hour_26 = input.int(14, '', 0, 24, inline='26.2') start_min_26 = input.int(55, '-', 0, 59, inline='26.2') end_hour_26 = input.int(15, '/', 0, 24, inline='26.2') end_min_26 = input.int(8, '-', 0, 59, inline='26.2') //Range 27 show_27 = input.bool(false, '27', inline='27.1') col_27 = input.color(color.new(#1E90FF, 90), '', inline='27.1') note_27 = input.string('', '    -  Table ', inline='27.1') txt_col_27 = input.color(#FFFFFF, '', inline='27.1') start_hour_27 = input.int(15, '', 0, 24, inline='27.2') start_min_27 = input.int(8, '-', 0, 59, inline='27.2') end_hour_27 = input.int(15, '/', 0, 24, inline='27.2') end_min_27 = input.int(21, '-', 0, 59, inline='27.2') //Range 28 show_28 = input.bool(false, '28', inline='28.1') col_28 = input.color(color.new(#FFDAB9, 90), '', inline='28.1') note_28 = input.string('', '    -  Table ', inline='28.1') txt_col_28 = input.color(#FFFFFF, '', inline='28.1') start_hour_28 = input.int(15, '', 0, 24, inline='28.2') start_min_28 = input.int(21, '-', 0, 59, inline='28.2') end_hour_28 = input.int(15, '/', 0, 24, inline='28.2') end_min_28 = input.int(34, '-', 0, 59, inline='28.2') //Range 29 show_29 = input.bool(false, '29', inline='29.1') col_29 = input.color(color.new(#8A2BE2, 90), '', inline='29.1') note_29 = input.string('', '    -  Table ', inline='29.1') txt_col_29 = input.color(#FFFFFF, '', inline='29.1') start_hour_29 = input.int(15, '', 0, 24, inline='29.2') start_min_29 = input.int(34, '-', 0, 59, inline='29.2') end_hour_29 = input.int(15, '/', 0, 24, inline='29.2') end_min_29 = input.int(47, '-', 0, 59, inline='29.2') //Range 30 show_30 = input.bool(false, '30', inline='30.1') col_30 = input.color(color.new(#FFFF00, 90), '', inline='30.1') note_30 = input.string('', '    -  Table ', inline='30.1') txt_col_30 = input.color(#FFFFFF, '', inline='30.1') start_hour_30 = input.int(15, '', 0, 24, inline='30.2') start_min_30 = input.int(47, '-', 0, 59, inline='30.2') end_hour_30 = input.int(16, '/', 0, 24, inline='30.2') end_min_30 = input.int(0, '-', 0, 59, inline='30.2') //Table in_font = input.string('Default', 'Text Font' , ['Default', 'Monospace'], group='Table') font = switch in_font 'Default' => font.family_default 'Monospace' => font.family_monospace show_frame = input.bool(false, 'Frame', group='Table') col_bord = input.color(color.new(#363A45, 100), 'Border Color', group='Table') width_bord = input.int(1, 'Border Width', 0, group='Table') transp = input.int(20, 'Transparency', 0, 100, group='Table') input_tab_size = input.string('Auto', 'Size', group='Table', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge']) tab_size = switch input_tab_size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge input_tab_pos = input.string('Bottom Right', 'Position', group='Table', options=['Top Left', 'Top Center', 'Top Right', 'Middle Left', 'Middle Center', 'Middle Right', 'Bottom Left', 'Bottom Center', 'Bottom Right']) tab_pos = switch input_tab_pos 'Top Left' => position.top_left 'Top Center' => position.top_center 'Top Right' => position.top_right 'Middle Left' => position.middle_left 'Middle Center' => position.middle_center 'Middle Right' => position.middle_right 'Bottom Left' => position.bottom_left 'Bottom Center' => position.bottom_center 'Bottom Right' => position.bottom_right ///////////////////////////// // // // Variables // // // ///////////////////////////// tdy = year(timenow) == year(time) and month(timenow) == month(time) and dayofmonth(timenow) == dayofmonth(time) _bgcond(start_hour, start_min, end_hour, end_min) => start = timestamp(syminfo.timezone, year, month, dayofmonth, start_hour, start_min, 00) end = timestamp(syminfo.timezone, year, month, dayofmonth, end_hour, end_min, 00) (time >= start and time < end and ant and not tdy) or (time >= start and time < end and not ant) _range(show, start_hour, start_min, end_hour, end_min, col) => start = timestamp(syminfo.timezone, year, month, dayofmonth, start_hour, start_min, 00) end = timestamp(syminfo.timezone, year, month, dayofmonth, end_hour, end_min, 00) var line id_1 = na var line id_2 = na if ant and show id_1 := line.new(start, low, start, high, xloc.bar_time, extend.both, na) line.delete(id_1[1]) id_2 := line.new(end, low, end, high, xloc.bar_time, extend.both, na) line.delete(id_2[1]) linefill.new(id_1, id_2, col) //Table tab=table.new(tab_pos, 1, 30, border_color=color.new(col_bord, transp), border_width=width_bord, frame_color=show_frame ? color.new(col_bord, transp) : na, frame_width=show_frame ? width_bord : 0) _n(a, txt, r, txt_col, bgcol) => var row = 0 if a and txt != '' row := r table.cell(tab, 0, row, txt, text_color=txt_col, text_size=tab_size, bgcolor=color.new(bgcol, transp), text_font_family=font) //////////////////////////// // // // Plot // // // //////////////////////////// //Time Ranges bgcolor(show_1 and _bgcond(start_hour_1, start_min_1, end_hour_1, end_min_1) ? col_1 : na, editable=false) bgcolor(show_2 and _bgcond(start_hour_2, start_min_2, end_hour_2, end_min_2) ? col_2 : na, editable=false) bgcolor(show_3 and _bgcond(start_hour_3, start_min_3, end_hour_3, end_min_3) ? col_3 : na, editable=false) bgcolor(show_4 and _bgcond(start_hour_4, start_min_4, end_hour_4, end_min_4) ? col_4 : na, editable=false) bgcolor(show_5 and _bgcond(start_hour_5, start_min_5, end_hour_5, end_min_5) ? col_5 : na, editable=false) bgcolor(show_6 and _bgcond(start_hour_6, start_min_6, end_hour_6, end_min_6) ? col_6 : na, editable=false) bgcolor(show_7 and _bgcond(start_hour_7, start_min_7, end_hour_7, end_min_7) ? col_7 : na, editable=false) bgcolor(show_8 and _bgcond(start_hour_8, start_min_8, end_hour_8, end_min_8) ? col_8 : na, editable=false) bgcolor(show_9 and _bgcond(start_hour_9, start_min_9, end_hour_9, end_min_9) ? col_9 : na, editable=false) bgcolor(show_10 and _bgcond(start_hour_10, start_min_10, end_hour_10, end_min_10) ? col_10 : na, editable=false) bgcolor(show_11 and _bgcond(start_hour_11, start_min_11, end_hour_11, end_min_11) ? col_11 : na, editable=false) bgcolor(show_12 and _bgcond(start_hour_12, start_min_12, end_hour_12, end_min_12) ? col_12 : na, editable=false) bgcolor(show_13 and _bgcond(start_hour_13, start_min_13, end_hour_13, end_min_13) ? col_13 : na, editable=false) bgcolor(show_14 and _bgcond(start_hour_14, start_min_14, end_hour_14, end_min_14) ? col_14 : na, editable=false) bgcolor(show_15 and _bgcond(start_hour_15, start_min_15, end_hour_15, end_min_15) ? col_15 : na, editable=false) bgcolor(show_16 and _bgcond(start_hour_16, start_min_16, end_hour_16, end_min_16) ? col_16 : na, editable=false) bgcolor(show_17 and _bgcond(start_hour_17, start_min_17, end_hour_17, end_min_17) ? col_17 : na, editable=false) bgcolor(show_18 and _bgcond(start_hour_18, start_min_18, end_hour_18, end_min_18) ? col_18 : na, editable=false) bgcolor(show_19 and _bgcond(start_hour_19, start_min_19, end_hour_19, end_min_19) ? col_19 : na, editable=false) bgcolor(show_20 and _bgcond(start_hour_20, start_min_20, end_hour_20, end_min_20) ? col_20 : na, editable=false) bgcolor(show_21 and _bgcond(start_hour_21, start_min_21, end_hour_21, end_min_21) ? col_21 : na, editable=false) bgcolor(show_22 and _bgcond(start_hour_22, start_min_22, end_hour_22, end_min_22) ? col_22 : na, editable=false) bgcolor(show_23 and _bgcond(start_hour_23, start_min_23, end_hour_23, end_min_23) ? col_23 : na, editable=false) bgcolor(show_24 and _bgcond(start_hour_24, start_min_24, end_hour_24, end_min_24) ? col_24 : na, editable=false) bgcolor(show_25 and _bgcond(start_hour_25, start_min_25, end_hour_25, end_min_25) ? col_25 : na, editable=false) bgcolor(show_26 and _bgcond(start_hour_26, start_min_26, end_hour_26, end_min_26) ? col_26 : na, editable=false) bgcolor(show_27 and _bgcond(start_hour_27, start_min_27, end_hour_27, end_min_27) ? col_27 : na, editable=false) bgcolor(show_28 and _bgcond(start_hour_28, start_min_28, end_hour_28, end_min_28) ? col_28 : na, editable=false) bgcolor(show_29 and _bgcond(start_hour_29, start_min_29, end_hour_29, end_min_29) ? col_29 : na, editable=false) bgcolor(show_30 and _bgcond(start_hour_30, start_min_30, end_hour_30, end_min_30) ? col_30 : na, editable=false) //Anticipate _range(show_1, start_hour_1, start_min_1, end_hour_1, end_min_1, col_1) _range(show_2, start_hour_2, start_min_2, end_hour_2, end_min_2, col_2) _range(show_3, start_hour_3, start_min_3, end_hour_3, end_min_3, col_3) _range(show_4, start_hour_4, start_min_4, end_hour_4, end_min_4, col_4) _range(show_5, start_hour_5, start_min_5, end_hour_5, end_min_5, col_5) _range(show_6, start_hour_6, start_min_6, end_hour_6, end_min_6, col_6) _range(show_7, start_hour_7, start_min_7, end_hour_7, end_min_7, col_7) _range(show_8, start_hour_8, start_min_8, end_hour_8, end_min_8, col_8) _range(show_9, start_hour_9, start_min_9, end_hour_9, end_min_9, col_9) _range(show_10, start_hour_10, start_min_10, end_hour_10, end_min_10, col_10) _range(show_11, start_hour_11, start_min_11, end_hour_11, end_min_11, col_11) _range(show_12, start_hour_12, start_min_12, end_hour_12, end_min_12, col_12) _range(show_13, start_hour_13, start_min_13, end_hour_13, end_min_13, col_13) _range(show_14, start_hour_14, start_min_14, end_hour_14, end_min_14, col_14) _range(show_15, start_hour_15, start_min_15, end_hour_15, end_min_15, col_15) _range(show_16, start_hour_16, start_min_16, end_hour_16, end_min_16, col_16) _range(show_17, start_hour_17, start_min_17, end_hour_17, end_min_17, col_17) _range(show_18, start_hour_18, start_min_18, end_hour_18, end_min_18, col_18) _range(show_19, start_hour_19, start_min_19, end_hour_19, end_min_19, col_19) _range(show_20, start_hour_20, start_min_20, end_hour_20, end_min_20, col_20) _range(show_21, start_hour_21, start_min_21, end_hour_21, end_min_21, col_21) _range(show_22, start_hour_22, start_min_22, end_hour_22, end_min_22, col_22) _range(show_23, start_hour_23, start_min_23, end_hour_23, end_min_23, col_23) _range(show_24, start_hour_24, start_min_24, end_hour_24, end_min_24, col_24) _range(show_25, start_hour_25, start_min_25, end_hour_25, end_min_25, col_25) _range(show_26, start_hour_26, start_min_26, end_hour_26, end_min_26, col_26) _range(show_27, start_hour_27, start_min_27, end_hour_27, end_min_27, col_27) _range(show_28, start_hour_28, start_min_28, end_hour_28, end_min_28, col_28) _range(show_29, start_hour_29, start_min_29, end_hour_29, end_min_29, col_29) _range(show_30, start_hour_30, start_min_30, end_hour_30, end_min_30, col_30) //Table _n(show_1, note_1, 0, txt_col_1, col_1) _n(show_2, note_2, 1, txt_col_2, col_2) _n(show_3, note_3, 2, txt_col_3, col_3) _n(show_4, note_4, 3, txt_col_4, col_4) _n(show_5, note_5, 4, txt_col_5, col_5) _n(show_6, note_6, 5, txt_col_6, col_6) _n(show_7, note_7, 6, txt_col_7, col_7) _n(show_8, note_8, 7, txt_col_8, col_8) _n(show_9, note_9, 8, txt_col_9, col_9) _n(show_10, note_10, 9, txt_col_10, col_10) _n(show_11, note_11, 10, txt_col_11, col_11) _n(show_12, note_12, 11, txt_col_12, col_12) _n(show_13, note_13, 12, txt_col_13, col_13) _n(show_14, note_14, 13, txt_col_14, col_14) _n(show_15, note_15, 14, txt_col_15, col_15) _n(show_16, note_16, 15, txt_col_16, col_16) _n(show_17, note_17, 16, txt_col_17, col_17) _n(show_18, note_18, 17, txt_col_18, col_18) _n(show_19, note_19, 18, txt_col_19, col_19) _n(show_20, note_20, 29, txt_col_20, col_20) _n(show_21, note_21, 20, txt_col_21, col_21) _n(show_22, note_22, 21, txt_col_22, col_22) _n(show_23, note_23, 22, txt_col_23, col_23) _n(show_24, note_24, 23, txt_col_24, col_24) _n(show_25, note_25, 24, txt_col_25, col_25) _n(show_26, note_26, 25, txt_col_26, col_26) _n(show_27, note_27, 26, txt_col_27, col_27) _n(show_28, note_28, 27, txt_col_28, col_28) _n(show_29, note_29, 28, txt_col_29, col_29) _n(show_30, note_30, 29, txt_col_30, col_30)
Window Periods
https://www.tradingview.com/script/1IZHetJh-Window-Periods/
rrturtles2
https://www.tradingview.com/u/rrturtles2/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rrturtles2 //@version=5 indicator(title="Window Periods", overlay=true) printTable(txt) => var table t = table.new(position.top_right, 1, 1), table.cell(t, 0, 0, txt, bgcolor = color.yellow) // Work in progress.. visualize event windows // to do: // - assign sector relevance (add opec events and weight more to commodity typed instruments, whereas revenue forecasts of walmart won't be as relevant to commodities) // - create weighting onto macro probability valuators // - create means to store window weight/values in an accessible way so that additional scripts can access this data (post hidden text in window?) or maybe just duplicate arrays elsewhere in additional code (terrible option) // - correct colors to scale within like types of events (opex the same, rebalancing periods the same, political and financial meeting the same color etc..) // - find a way to make transfer the timestamps or date strings as const variables usable within functions. v5 sends as series and cannot be converted back making this an overly complicated case instead of a function/library // - add dates back to 2017 for better referencing // - convert a number of the variables to inputs so they can be controlled in-chart, such as transparancy, and color of each window period? // Window periods // Initialize array of window dates (size with pushes) // - make list of all windows to be initialized // - manually enter dates below var string _drawnext = "vix opex" // first case select to cascade from var _windowsVixOpex = array.new_int(1) var _windowsOpex = array.new_int(1) var _windowsMarketClosures = array.new_int(1) var _windowsEOQ = array.new_int(1) var _windowsERBlackout = array.new_int(1) var _windowsRevForecasts = array.new_int(1) var _windowsGlobalFinancialMeeting = array.new_int(1) var _windowsPoliticalEvents = array.new_int(1) var _windowsCPI = array.new_int(1) var _windowsFOMC = array.new_int(1) var _windowsFOMCminutes = array.new_int(1) var _windowsMajorIPOs = array.new_int(1) // Default variables var _windowsRiskPeriod = array.new_int(1) // initialize generic loop array var _windowText = "" // Displayed text within window var bool _drawingloop = true // condution for when loop var bool _drawwindows = true // condition for case to pass to when loop var int _transparancy = 75 // strength of transparancy // set window colors var color _windowBorderColor = color.rgb(255, 255, 255, 100) // transparency = 100 so no borders var color _windowBGcolor = color.new(color.white, 50) // assigned differently for each window type // Set manually for each type of risk window var int _windowFadeInDays = 1 // high risk trend/chop that diverges from macro trend var int _windowFadeOutDays = 1 // duration of vanna/charm gamma event // fetch vertical positions for the window to span float _highest = ta.highest(high, 120) * 1.05 float _lowest = ta.lowest(low, 120)// * .75 // Set number of milliseconds in a day for future calculations // convert # days to milliseconds for direct use with timestamps var int _millisecondday = 86400000 if barstate.islast while _drawingloop // Defaults to prevent infinite loop _windowsRiskPeriod := array.new_int(0) _drawingloop := false // Case select to compile data // - used in place of function because v5 pinescript does not allow arrays to pass to functions // - and it does not allow for a str.split() to create const strings that can be converted into timestamps // - as of 2022/08/10, don't know any other way to import a list of dates into a function _drawwindows := switch _drawnext "vix opex" => // VIX Opex, source: https://www.macroption.com/vix-expiration-calendar/ _windowText := "VIX Opex" _windowBGcolor := color.new(color.red, _transparancy) // set window colors _windowFadeInDays := 2 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: vix opex typically reverses dramatically (vix lower) 2 days prior and 1-2 days post // - as new hedges are applied, vix often experiences a surge 2-4 days after vix opex // - note: vix expires AM so a 17th expiry last trades on the 16th array.set(_windowsVixOpex, 0, timestamp(2022, 08, 17)) array.push(_windowsVixOpex, timestamp(2022, 09, 21)) array.push(_windowsVixOpex, timestamp(2022, 10, 19)) array.push(_windowsVixOpex, timestamp(2022, 11, 16)) array.push(_windowsVixOpex, timestamp(2022, 12, 21)) array.push(_windowsVixOpex, timestamp(2023, 01, 18)) array.push(_windowsVixOpex, timestamp(2023, 02, 15)) array.push(_windowsVixOpex, timestamp(2023, 03, 22)) array.push(_windowsVixOpex, timestamp(2023, 04, 19)) array.push(_windowsVixOpex, timestamp(2023, 05, 17)) array.push(_windowsVixOpex, timestamp(2023, 06, 21)) array.push(_windowsVixOpex, timestamp(2023, 07, 19)) array.push(_windowsVixOpex, timestamp(2023, 08, 16)) array.push(_windowsVixOpex, timestamp(2023, 09, 20)) array.push(_windowsVixOpex, timestamp(2023, 10, 18)) array.push(_windowsVixOpex, timestamp(2023, 11, 15)) array.push(_windowsVixOpex, timestamp(2023, 12, 20)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsVixOpex) // copy to generic loop array _drawnext := "opex" // set to next case true "opex" => // Opex, source: https://www.marketwatch.com/tools/options-expiration-calendar _windowText := "Opex" _windowBGcolor := color.new(color.fuchsia, _transparancy) // set window colors _windowFadeInDays := 1 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 2 // duration of vanna/charm gamma event // Reason: SPX futures expiry AM, array.set(_windowsOpex, 0, timestamp(2022, 08, 19)) array.push(_windowsOpex, timestamp(2022, 09, 16)) array.push(_windowsOpex, timestamp(2022, 10, 21)) array.push(_windowsOpex, timestamp(2022, 11, 18)) array.push(_windowsOpex, timestamp(2022, 12, 16)) array.push(_windowsOpex, timestamp(2023, 01, 20)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsOpex) // copy to generic loop array _drawnext := "market closures" // set to next case true "market closures" => // Market Closures, source: https://www.nyse.com/markets/hours-calendars _windowText := "Market Closures" _windowBGcolor := color.new(color.gray, _transparancy) // set window colors _windowFadeInDays := 3 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 3 // duration of vanna/charm gamma event // Reason: Risk off of shorts or longs based on macro environment, **plus adjusting for option decay!** and vacations? array.set(_windowsMarketClosures, 0, timestamp(2022, 05, 30)) array.push(_windowsMarketClosures, timestamp(2022, 07, 04)) array.push(_windowsMarketClosures, timestamp(2022, 09, 05)) array.push(_windowsMarketClosures, timestamp(2022, 09, 05)) array.push(_windowsMarketClosures, timestamp(2022, 09, 05)) array.push(_windowsMarketClosures, timestamp(2022, 10, 10)) array.push(_windowsMarketClosures, timestamp(2022, 11, 24)) array.push(_windowsMarketClosures, timestamp(2022, 12, 26)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsMarketClosures) // copy to generic loop array _drawnext := "end of quarter" // set to next case true "end of quarter" => // Quarterly ER blackout periods, source: none _windowText := "EOQ" _windowBGcolor := color.new(color.purple, _transparancy) // set window colors _windowFadeInDays := 0 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 3 // duration of vanna/charm gamma event // Reason: Major rebalancing with in-flows prior to/at EOQ array.set(_windowsEOQ, 0, timestamp(2022, 03, 31)) array.push(_windowsEOQ, timestamp(2022, 06, 30)) array.push(_windowsEOQ, timestamp(2022, 09, 30)) array.push(_windowsEOQ, timestamp(2022, 12, 30)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsEOQ) // copy to generic loop array _drawnext := "er blackout" // set to next case true "er blackout" => // Quarterly ER blackout periods, source: none _windowText := "ER Blackout" _windowBGcolor := color.new(color.olive, _transparancy) // set window colors _windowFadeInDays := 0 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 20 // duration of vanna/charm gamma event // Reason: Majority of S&P companies in ER blackout from buybacks and news leads to increased opportunity to front-run expectations array.set(_windowsERBlackout, 0, timestamp(2022, 04, 15)) array.push(_windowsERBlackout, timestamp(2022, 07, 15)) array.push(_windowsERBlackout, timestamp(2022, 10, 15)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsERBlackout) // copy to generic loop array _drawnext := "revenue forecasts" // set to next case true "revenue forecasts" => // Mega Cap revenue forecast updates, source: none _windowText := "Rev forecast" _windowBGcolor := color.new(color.maroon, _transparancy) // set window colors _windowFadeInDays := 1 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: front-running may occur, and if it does then vix / gamma can be chased as it reverts (vix collapse, gamma squeeze up) array.set(_windowsRevForecasts, 0, timestamp(2022, 07, 25)) // WMT Walmart (retail, tgt etc..) array.push(_windowsRevForecasts, timestamp(2022, 08, 09)) // MU Micron (semis) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsRevForecasts) // copy to generic loop array _drawnext := "global financial meeting" // set to next case true "global financial meeting" => // Global Financial Meeting, source: none _windowText := "Global Financial Meeting" _windowBGcolor := color.new(color.orange, _transparancy) // set window colors _windowFadeInDays := 3 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: no way the market melts down during billionaire / political gathering / WEF array.set(_windowsGlobalFinancialMeeting, 0, timestamp(2022, 08, 27)) // Jackson Hole //array.push(_windowsGlobalFinancialMeeting, timestamp(2022, 08, 27)) // name or details... // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsGlobalFinancialMeeting) // copy to generic loop array _drawnext := "political events" // set to next case true "political events" => // Political Events, source: none _windowText := "Political Event" _windowBGcolor := color.new(color.orange, _transparancy) // set window colors _windowFadeInDays := 3 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: front-running may occur, and if it does then vix / gamma can be chased as it reverts (vix collapse, gamma squeeze up) array.set(_windowsPoliticalEvents, 0, timestamp(2022, 11, 08)) // US congress election // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsPoliticalEvents) // copy to generic loop array _drawnext := "cpi release" // set to next case true "cpi release" => // CPI release, source: https://www.bls.gov/schedule/news_release/cpi.htm _windowText := "CPI" _windowBGcolor := color.new(color.orange, _transparancy) // set window colors _windowFadeInDays := 2 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: front-running may occur, and if it does then vix / gamma can be chased as it reverts (vix collapse, gamma squeeze up) array.set(_windowsCPI, 0, timestamp(2022, 09, 13)) array.push(_windowsCPI, timestamp(2022, 10, 13)) array.push(_windowsCPI, timestamp(2022, 11, 10)) array.push(_windowsCPI, timestamp(2022, 12, 13)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsCPI) // copy to generic loop array _drawnext := "fomc meeting" // set to next case true "fomc meeting" => // FOMC meeting, source: https://www.federalreserve.gov/monetarypolicy/fomccalendars.htm _windowText := "FOMC meeting" _windowBGcolor := color.new(color.aqua, _transparancy) // set window colors _windowFadeInDays := 2 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: front-running may occur, and if it does then vix / gamma can be chased as it reverts (vix collapse, gamma squeeze up) array.set(_windowsFOMC, 0, timestamp(2022, 07, 26)) array.push(_windowsFOMC, timestamp(2022, 09, 20)) array.push(_windowsFOMC, timestamp(2022, 11, 01)) array.push(_windowsFOMC, timestamp(2022, 12, 13)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsFOMC) // copy to generic loop array _drawnext := "fomc minutes" // set to next case true "fomc minutes" => // FOMC minutes, source: https://www.federalreserve.gov/newsevents/calendar.htm _windowText := "FOMC minutes" _windowBGcolor := color.new(color.aqua, _transparancy) // set window colors _windowFadeInDays := 1 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: front-running may occur, and if it does then vix / gamma can be chased as it reverts (vix collapse, gamma squeeze up) array.set(_windowsFOMCminutes, 0, timestamp(2022, 07, 06)) array.push(_windowsFOMCminutes, timestamp(2022, 08, 17)) // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsFOMCminutes) // copy to generic loop array _drawnext := "major ipos" // set to next case true "major ipos" => // Major IPOs, source: https://www.nasdaq.com/market-activity/ipos _windowText := "Major IPOs" _windowBGcolor := color.new(color.green, _transparancy) // set window colors _windowFadeInDays := 1 // high risk trend/chop that diverges from macro trend _windowFadeOutDays := 1 // duration of vanna/charm gamma event // Reason: When notable IPOs enter the market, these can withdraw liqudity and trader activity just before // - and just after IPO. The broad market can suffer a dullness as algos place effort on the option free single trade // array.set(_windowsMajorIPOs, 0, timestamp(2021, 09, 03)) //DWACU Digital World Acquisition Corp. // array.push(_windowsMajorIPOs, timestamp(2022, 07, 15)) // HKD AMTD Digital Inc. // REQURED at end of case _windowsRiskPeriod := array.copy(_windowsMajorIPOs) // copy to generic loop array _drawnext := "" // set to next case true "" => _windowsRiskPeriod := array.new_int(0) false for i = 0 to (array.size(_windowsRiskPeriod) == 0 ? na : array.size(_windowsRiskPeriod) -1) box.new(text=_windowText, text_color=color.white, left=array.get(_windowsRiskPeriod, i) - (_millisecondday * _windowFadeInDays), top=_highest, right=array.get(_windowsRiskPeriod, i) + (_millisecondday * _windowFadeOutDays), bottom=_lowest, border_color=_windowBorderColor, border_width=1, border_style=line.style_solid, extend=extend.none, xloc=xloc.bar_time, bgcolor=_windowBGcolor) _drawingloop := _drawwindows
QQE of Parabolic-Weighted Velocity [Loxx]
https://www.tradingview.com/script/6fv0iOzY-QQE-of-Parabolic-Weighted-Velocity-Loxx/
loxx
https://www.tradingview.com/u/loxx/
97
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © loxx //@version=5 indicator('QQE of Parabolic-Weighted Velocity [Loxx]', shorttitle = "QQEPWV [Loxx]", overlay = false, timeframe="", timeframe_gaps = true) import loxx/loxxexpandedsourcetypes/4 greencolor = #2DD204 redcolor = #D2042D darkGreenColor = #1B7E02 darkRedColor = #93021F SM02 = 'Zero Cross' SM03 = 'Fast Trend Cross' SM04 = 'Slow Trend Cross' _ivelocity(src, period, power)=> suma = 0., sumwa=0. sumb = 0., sumwb=0. velWork = src for k = 0 to period - 1 weight = math.pow((period-k), power) suma += nz(velWork[k]) * weight sumb += nz(velWork[k]) * weight * weight sumwa += weight sumwb += math.pow(weight, 2) out = sumb/sumwb-suma/sumwa out smthtype = input.string("Kaufman", "Heikin-Ashi Better Caculation Type", options = ["AMA", "T3", "Kaufman"], group = "Source Settings") srcin = input.string("Close", "Source", group= "Source Settings", options = ["Close", "Open", "High", "Low", "Median", "Typical", "Weighted", "Average", "Average Median Body", "Trend Biased", "Trend Biased (Extreme)", "HA Close", "HA Open", "HA High", "HA Low", "HA Median", "HA Typical", "HA Weighted", "HA Average", "HA Average Median Body", "HA Trend Biased", "HA Trend Biased (Extreme)", "HAB Close", "HAB Open", "HAB High", "HAB Low", "HAB Median", "HAB Typical", "HAB Weighted", "HAB Average", "HAB Average Median Body", "HAB Trend Biased", "HAB Trend Biased (Extreme)"]) type = input.string("EMA", "QQE/DSS Smoothing Type", options = ["EMA", "WMA", "RMA", "SMA"], group = "Basic Settings") velper = input.int(50, "Velocity Period", group = "Basic Settings") velpow = input.float(2, "Velocity Power", group = "Basic Settings") MAPeriod = input.int(5, "Velocity Smoothing Factor", group = "Basic Settings") wpFast = input.float(2.618, "WP Fast Coeffient", group = "Basic Settings") wpSlow = input.float(4.236, "WP Slow Coeffient", group = "Basic Settings") sigtype = input.string(SM04, "Signal type", options = [SM02, SM03, SM04], group = "Signal Settings") colorbars = input.bool(true, "Color bars?", group = "UI Options") showSigs = input.bool(true, "Show signals?", group = "UI Options") kfl=input.float(0.666, title="* Kaufman's Adaptive MA (KAMA) Only - Fast End", group = "Moving Average Inputs") ksl=input.float(0.0645, title="* Kaufman's Adaptive MA (KAMA) Only - Slow End", group = "Moving Average Inputs") amafl = input.int(2, title="* Adaptive Moving Average (AMA) Only - Fast", group = "Moving Average Inputs") amasl = input.int(30, title="* Adaptive Moving Average (AMA) Only - Slow", group = "Moving Average Inputs") haclose = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close) haopen = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, open) hahigh = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, high) halow = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low) hamedian = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hl2) hatypical = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlc3) haweighted = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, hlcc4) haaverage = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, ohlc4) src = switch srcin "Close" => loxxexpandedsourcetypes.rclose() "Open" => loxxexpandedsourcetypes.ropen() "High" => loxxexpandedsourcetypes.rhigh() "Low" => loxxexpandedsourcetypes.rlow() "Median" => loxxexpandedsourcetypes.rmedian() "Typical" => loxxexpandedsourcetypes.rtypical() "Weighted" => loxxexpandedsourcetypes.rweighted() "Average" => loxxexpandedsourcetypes.raverage() "Average Median Body" => loxxexpandedsourcetypes.ravemedbody() "Trend Biased" => loxxexpandedsourcetypes.rtrendb() "Trend Biased (Extreme)" => loxxexpandedsourcetypes.rtrendbext() "HA Close" => loxxexpandedsourcetypes.haclose(haclose) "HA Open" => loxxexpandedsourcetypes.haopen(haopen) "HA High" => loxxexpandedsourcetypes.hahigh(hahigh) "HA Low" => loxxexpandedsourcetypes.halow(halow) "HA Median" => loxxexpandedsourcetypes.hamedian(hamedian) "HA Typical" => loxxexpandedsourcetypes.hatypical(hatypical) "HA Weighted" => loxxexpandedsourcetypes.haweighted(haweighted) "HA Average" => loxxexpandedsourcetypes.haaverage(haaverage) "HA Average Median Body" => loxxexpandedsourcetypes.haavemedbody(haclose, haopen) "HA Trend Biased" => loxxexpandedsourcetypes.hatrendb(haclose, haopen, hahigh, halow) "HA Trend Biased (Extreme)" => loxxexpandedsourcetypes.hatrendbext(haclose, haopen, hahigh, halow) "HAB Close" => loxxexpandedsourcetypes.habclose(smthtype, amafl, amasl, kfl, ksl) "HAB Open" => loxxexpandedsourcetypes.habopen(smthtype, amafl, amasl, kfl, ksl) "HAB High" => loxxexpandedsourcetypes.habhigh(smthtype, amafl, amasl, kfl, ksl) "HAB Low" => loxxexpandedsourcetypes.hablow(smthtype, amafl, amasl, kfl, ksl) "HAB Median" => loxxexpandedsourcetypes.habmedian(smthtype, amafl, amasl, kfl, ksl) "HAB Typical" => loxxexpandedsourcetypes.habtypical(smthtype, amafl, amasl, kfl, ksl) "HAB Weighted" => loxxexpandedsourcetypes.habweighted(smthtype, amafl, amasl, kfl, ksl) "HAB Average" => loxxexpandedsourcetypes.habaverage(smthtype, amafl, amasl, kfl, ksl) "HAB Average Median Body" => loxxexpandedsourcetypes.habavemedbody(smthtype, amafl, amasl, kfl, ksl) "HAB Trend Biased" => loxxexpandedsourcetypes.habtrendb(smthtype, amafl, amasl, kfl, ksl) "HAB Trend Biased (Extreme)" => loxxexpandedsourcetypes.habtrendbext(smthtype, amafl, amasl, kfl, ksl) => haclose variant(type, src, len) => sig = 0.0 if type == "SMA" sig := ta.sma(src, len) else if type == "EMA" sig := ta.ema(src, len) else if type == "WMA" sig := ta.wma(src, len) else if type == "RMA" sig := ta.rma(src, len) sig qqe = 0. trend1 = 0. trend2 = 0. velout = _ivelocity(src, velper, velpow) velma = variant(type, velout, MAPeriod) mavel = variant(type, math.abs(nz(velma[1]) - velma), velper) outer = variant(type, mavel, velper) emas = outer * wpSlow emaf = outer * wpFast TrendSlow = 0.0 tr = nz(TrendSlow[1]) dv = tr if (velma < tr) tr := velma + emas if ((nz(velma[1]) < dv and tr > dv)) tr := dv if (velma > tr) tr := velma - emas if ((nz(velma[1]) > dv) and (tr < dv)) tr := dv TrendSlow := tr TrendFast = 0.0 tr := nz(TrendFast[1]) dv := tr if (velma < tr) tr := velma + emaf if ((nz(velma[1]) < dv and tr > dv)) tr := dv if (velma > tr) tr := velma - emaf if ((nz(velma[1]) > dv) and (tr < dv)) tr := dv TrendFast := tr mid = 0 colorout = sigtype == SM02 ? velma > mid ? greencolor : velma < mid ? redcolor : color.gray : sigtype == SM03 ? velma > TrendFast ? greencolor : velma < TrendFast ? redcolor : color.gray : velma > TrendSlow ? greencolor : velma < TrendSlow ? redcolor : color.gray plot(velma,"Parabolic-Weighted Velocity MA", color = colorout, linewidth = 3) plot(mid, color=color.new(color.gray, 30), linewidth=1, style=plot.style_circles, title = "Zero line") plot(TrendFast, "Fast Trend", color=color.new(color.white, 0), linewidth = 1) plot(TrendSlow, "Slow Trend", color=color.new(color.yellow, 0), linewidth = 1) barcolor(colorbars ? colorout : na) goLong = sigtype == SM02 ? ta.crossover(velma, mid) : sigtype == SM03 ? ta.crossover(velma, TrendFast) : ta.crossover(velma, TrendSlow) goShort = sigtype == SM02 ? ta.crossunder(velma, mid) : sigtype == SM03 ? ta.crossunder(velma, TrendFast) : ta.crossunder(velma, TrendSlow) plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.bottom, size = size.auto) plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.top, size = size.auto) alertcondition(goLong, title="Long", message="QQE of Parabolic-Weighted Velocity [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}") alertcondition(goShort, title="Short", message="QQE of Parabolic-Weighted Velocity [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}")
Linear Average Price
https://www.tradingview.com/script/Z3tQRrcc/
faytterro
https://www.tradingview.com/u/faytterro/
149
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © faytterro //@version=5 indicator("Linear Average Price", overlay=true) len=input.int(200,title="lenght") src=input(hlc3, title="source") sum1=0.0 sum2=0.0 for i=0 to len-1 sum2+=src[i]/len for i=0 to len-2 sum1+=(len-1)*(src[i+1]-src[i])/(2*len-2) x1=last_bar_index-len+1 x2=last_bar_index y1=sum2+sum1 y2=sum2-sum1 dev=ta.stdev(src,len) ldev=input.float(1, title="range", step=0.1, minval=0.5, maxval=2) linreg=line.new(x1, y1, x2, y2, color= y1<y2? color.rgb(76, 175, 79, 20) : color.rgb(255, 82, 82, 20), extend=extend.right, width=2) line.delete(linreg[1]) linregtop=line.new(x1, y1+dev*ldev, x2, y2+dev*ldev, color= color.rgb(255, 82, 82, 100), extend=extend.right, width=1) line.delete(linregtop[1]) linregbot=line.new(x1, y1-dev*ldev, x2, y2-dev*ldev, color=color.rgb(76, 175, 79, 100) , extend=extend.right, width=1) line.delete(linregbot[1]) linregtop2=line.new(x1, y1+dev*ldev*2, x2, y2+dev*ldev*2, color= color.rgb(255, 82, 82, 100), extend=extend.right, width=1) line.delete(linregtop2[1]) linregbot2=line.new(x1, y1-dev*ldev*2, x2, y2-dev*ldev*2, color=color.rgb(76, 175, 79, 100) , extend=extend.right, width=1) line.delete(linregbot2[1]) linregtop3=line.new(x1, y1+dev*ldev*4, x2, y2+dev*ldev*4, color= color.rgb(255, 82, 82, 100), extend=extend.right, width=1) line.delete(linregtop3[1]) linregbot3=line.new(x1, y1-dev*ldev*4, x2, y2-dev*ldev*4, color=color.rgb(76, 175, 79, 100) , extend=extend.right, width=1) line.delete(linregbot3[1]) linregtop4=line.new(x1, y1+dev*ldev*0.5, x2, y2+dev*ldev*0.5, color= color.rgb(255, 82, 82, 100), extend=extend.right, width=1) line.delete(linregtop4[1]) linregbot4=line.new(x1, y1-dev*ldev*0.5, x2, y2-dev*ldev*0.5, color=color.rgb(76, 175, 79, 100) , extend=extend.right, width=1) line.delete(linregbot4[1]) linefill.new(linregbot2, linregbot, color=color.rgb(76, 175, 79, 80)) linefill.new(linregtop2, linregtop, color=color.rgb(255, 82, 82, 80)) linefill.new(linregbot2, linregbot3, color=color.rgb(76, 175, 79, 70)) linefill.new(linregtop2, linregtop3, color=color.rgb(255, 82, 82, 70)) linefill.new(linregbot4, linregbot, color=color.rgb(76, 175, 79, 90)) linefill.new(linregtop4, linregtop, color=color.rgb(255, 82, 82, 90))
OHLC Moving Average
https://www.tradingview.com/script/mvCJnR5o/
FX365_Thailand
https://www.tradingview.com/u/FX365_Thailand/
82
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FX365_Thailand //Revision history //v31.0 First release //v32.0 Added two options; // 1. Gradation // 2. MA Color Change //@version=5 //Define indicator name indicator('OHLC Moving Average', 'OHLC MA', timeframe='', timeframe_gaps=true, overlay=true) //User inputs ma_len = input(title='Length', defval=20) ma_type = input.string(title='MA Type', options=['SMA', 'EMA'], defval='SMA') ma_offset = input(title='Offset', defval=0) i_fill = input(true, title='Fill MA') i_grad = input(true, title='Gradation') i_macolor = input(true, title='MA Color Change') //Function to calculate MA ma_f(ma_type, src, ma_len) => ma_type == 'EMA' ? ta.ema(src, ma_len) : ta.sma(src, ma_len) //Calculate MA ma1 = ma_f(ma_type, open, ma_len) ma2 = ma_f(ma_type, high, ma_len) ma3 = ma_f(ma_type, low, ma_len) ma4 = ma_f(ma_type, close, ma_len) //Plot MA bull = ma1 > ma1[1] and ma2 > ma2[1] and ma3 > ma3[1] and ma4 > ma4[1] bear = ma1 < ma1[1] and ma2 < ma2[1] and ma3 < ma3[1] and ma4 < ma4[1] a = plot(ma1, color=(i_macolor and bull) ? color.new(color.green, 0) : (i_macolor and bear) ? color.new(color.red,0) : color.new(color.gray,0), offset=ma_offset, title='Open MA') b = plot(ma2, color=(i_macolor and bull) ? color.new(color.green, 0) : (i_macolor and bear) ? color.new(color.red,0) : color.new(color.gray,0), offset=ma_offset, title='High MA') c = plot(ma3, color=(i_macolor and bull) ? color.new(color.green, 0) : (i_macolor and bear) ? color.new(color.red,0) : color.new(color.gray,0), offset=ma_offset, title='Low MA') d = plot(ma4, color=(i_macolor and bull) ? color.new(color.green, 0) : (i_macolor and bear) ? color.new(color.red,0) : color.new(color.gray,0), offset=ma_offset, title='Close MA') //Fill fill(b, c, i_fill ? color.red : na, title='Fill MA', transp=90) //Gradation fill(c, b, top_value = ma2, bottom_value= ma3, top_color = (i_grad and bull) ? color.new(color.green,80) : (i_grad and bear) ? color.new(color.red,20) : (i_grad) ? color.new(color.gray,20) : na, bottom_color = (i_grad and bull) ? color.new(color.green,20) : (i_grad and bear) ? color.new(color.red,80) : (i_grad) ? color.new(color.gray,80) : na, title="Gradation color")
Multiple RSI
https://www.tradingview.com/script/wNzVzwzb-Multiple-RSI/
SirDrBroclawEsq
https://www.tradingview.com/u/SirDrBroclawEsq/
27
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SirDrBroclawEsq //@version=4 study("Multiple RSI") rsi1length = input(defval=21, title="RSI 1 Length", minval=1, type=input.integer, group="RSI 1 Settings") rsi1source = input(defval=close, title="RSI 1 Source", type=input.source, group="RSI 1 Settings") rsi1set = rsi(rsi1source, rsi1length) rsi2length = input(defval=14, title="RSI 2 Length", minval=1, type=input.integer, group="RSI 2 Settings") rsi2source = input(defval=close, title="RSI 2 Source", type=input.source, group="RSI 2 Settings") rsi2set = rsi(rsi2source, rsi2length) rsi3length = input(defval=30, title="RSI 3 Length", minval=1, type=input.integer, group="RSI 3 Settings") rsi3source = input(defval=close, title="RSI 3 Source", type=input.source, group="RSI 3 Settings") rsi3set = rsi(rsi3source, rsi3length) rsi4length = input(defval=14, title="RSI 4 Length", minval=1, type=input.integer, group="RSI 4 Settings") rsi4source = input(defval=close, title="RSI 4 Source", type=input.source, group="RSI 4 Settings") rsi4set = rsi(rsi4source, rsi4length) rsi5length = input(defval=14, title="RSI 5 Length", minval=1, type=input.integer, group="RSI 5 Settings") rsi5source = input(defval=close, title="RSI 5 Source", type=input.source, group="RSI 5 Settings") rsi5set = rsi(rsi5source, rsi5length) rsi1 = security(syminfo.tickerid, "5", rsi1set) rsi2 = security(syminfo.tickerid, "15", rsi2set) rsi3 = security(syminfo.tickerid, "30", rsi3set) rsi4 = security(syminfo.tickerid, "60", rsi4set) rsi5 = security(syminfo.tickerid, "240", rsi5set) plot(rsi1, color=color.aqua) plot(rsi2, color=color.navy) plot(rsi3, color=color.black) plot(rsi4, color=color.green) plot(rsi5, color=color.yellow)
Sessions
https://www.tradingview.com/script/sfaCWSjD-Sessions/
jokersxsd
https://www.tradingview.com/u/jokersxsd/
4
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © YarRunming //@version=5 indicator("Sessions", overlay=true) sess_in = input.session("1500-2300:1234567", "Session") timezone=input.string("GMT+8","Timezone") sess = na(time(timeframe.period, sess_in,timezone))?na:color.new(color.blue,transp=50) // plot(asia) // sess = na(sess) ? na : color.blue bgcolor(sess, title="Session")
Crypto Portfolio Management
https://www.tradingview.com/script/rn1wxDqQ-Crypto-Portfolio-Management/
farzinsabbagh
https://www.tradingview.com/u/farzinsabbagh/
19
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © farzinsabbagh //@version=5 indicator(title = "Crypto Portfolio Management", shorttitle = "CPM", overlay = true) // ---- Inputs ---- tickerid_02 = input.symbol("BITSTAMP:ETHUSD", "Second Asset") tickerid_03 = input.symbol("POLONIEX:DASHUSDT","Third Asset") tickerid_04 = input.symbol("BITSTAMP:XRPUSD", "Forth Asset") tickerid_05 = input.symbol("BITFINEX:LTCUSD", "Fifth Asset") tickerid_06 = input.symbol("BITFINEX:XMRUSD", "Sixth Asset") tickerid_07 = input.symbol("POLONIEX:DOGEUSD", "Seventh Asset") tickerid_08 = input.symbol("KRAKEN:ADAUSD", "Eighth Asset") RiskFreeRate = input.float(title = "Risk Free Rate", defval = 2) cell_height = input.int(title = "Cell Size height", defval = 6) cell_width = input.int(title = "Cell Size Width", defval = 10) // ---- Variables ---- var tbl = table.new(position = position.middle_center, columns = 8, rows = 9) var buff = array.new_float(0) var BTC_Yearly_Open = array.new_float(0) var BTC_Yearly_Returns = array.new_float(0) var BTC_Monthly_open = array.new_float(0) var BTC_Monthly_return = array.new_float(0) var ath_BTC = 0.0 var second_asset_yearly_open = array.new_float(0) var second_asset_yearly_returns = array.new_float(0) var second_asset_monthly_open = array.new_float(0) var second_asset_monthly_returns = array.new_float(0) var ath_second_asset = 0.0 var third_asset_yearly_open = array.new_float(0) var third_asset_yearly_returns = array.new_float(0) var third_asset_monthly_open = array.new_float(0) var third_asset_monthly_returns = array.new_float(0) var ath_third_asset = 0.0 var forth_asset_yearly_open = array.new_float(0) var forth_asset_yearly_returns = array.new_float(0) var forth_asset_monthly_open = array.new_float(0) var forth_asset_monthly_returns = array.new_float(0) var ath_forth_asset = 0.0 var fifth_asset_yearly_open = array.new_float(0) var fifth_asset_yearly_returns = array.new_float(0) var fifth_asset_monthly_open = array.new_float(0) var fifth_asset_monthly_returns = array.new_float(0) var ath_fifth_asset = 0.0 var sixth_asset_yearly_open = array.new_float(0) var sixth_asset_yearly_returns = array.new_float(0) var sixth_asset_monthly_open = array.new_float(0) var sixth_asset_monthly_returns = array.new_float(0) var ath_sixth_asset = 0.0 var seventh_asset_yearly_open = array.new_float(0) var seventh_asset_yearly_returns = array.new_float(0) var seventh_asset_monthly_open = array.new_float(0) var seventh_asset_monthly_returns = array.new_float(0) var ath_seventh_asset = 0.0 var eighth_asset_yearly_open = array.new_float(0) var eighth_asset_yearly_returns = array.new_float(0) var eighth_asset_monthly_open = array.new_float(0) var eighth_asset_monthly_returns = array.new_float(0) var ath_eighth_asset = 0.0 var buff2 = 0.0 var buff3 = 0.0 tbl_col = color.rgb(239,215,174,0) // ---- Functions ---- get_each_year_open_price(_ser, _target_array) => if((year-year[1]) != 0) array.push(_target_array,_ser) get_each_month_open_price(_ser, _target_array) => if((month-month[1]) !=0) array.push(_target_array,_ser) make_sizes_equal(_array_1, _array_2) => _array_1_size = array.size(_array_1) _array_2_size = array.size(_array_2) if(_array_1_size < _array_2_size) _num_ind_to_remove = _array_2_size - _array_1_size for i = 0 to (_num_ind_to_remove - 1) array.remove(_array_2, i) if(_array_2_size < _array_1_size) _num_ind_to_remove = _array_1_size - _array_2_size for i = 0 to (_num_ind_to_remove - 1) array.remove(_array_1, i) calculate_return(_open, _target) => for i = 1 to (array.size(_open)-1) array.push(_target, ((array.get(_open,i) - array.get(_open,i-1))/ array.get(_open,i-1))*100) // ---- Requests ---- [BTC_Daily, BTC_High] = request.security("BITSTAMP:BTCUSD", "D", [open, high]) [second_asset_daily, second_asset_high] = request.security(tickerid_02, "D", [open, high]) [third_asset_daily, third_asset_high] = request.security(tickerid_03, "D", [open, high]) [forth_asset_daily, forth_asset_high] = request.security(tickerid_04, "D", [open, high]) [fifth_asset_daily, fifth_asset_high] = request.security(tickerid_05, "D", [open, high]) [sixth_asset_daily, sixth_asset_high] = request.security(tickerid_06, "D", [open, high]) [seventh_asset_daily, seventh_asset_high] = request.security(tickerid_07, "D", [open, high]) [eighth_asset_daily, eighth_asset_high] = request.security(tickerid_08, "D", [open, high]) get_each_year_open_price(BTC_Daily, BTC_Yearly_Open) get_each_month_open_price(BTC_Daily, BTC_Monthly_open) get_each_year_open_price(second_asset_daily, second_asset_yearly_open) get_each_month_open_price(second_asset_daily, second_asset_monthly_open) get_each_year_open_price(third_asset_daily, third_asset_yearly_open) get_each_month_open_price(third_asset_daily, third_asset_monthly_open) get_each_year_open_price(forth_asset_daily, forth_asset_yearly_open) get_each_month_open_price(forth_asset_daily, forth_asset_monthly_open) get_each_year_open_price(fifth_asset_daily, fifth_asset_yearly_open) get_each_month_open_price(fifth_asset_daily, fifth_asset_monthly_open) get_each_year_open_price(sixth_asset_daily, sixth_asset_yearly_open) get_each_month_open_price(sixth_asset_daily, sixth_asset_monthly_open) get_each_year_open_price(seventh_asset_daily, seventh_asset_yearly_open) get_each_month_open_price(seventh_asset_daily, seventh_asset_monthly_open) get_each_year_open_price(eighth_asset_daily, eighth_asset_yearly_open) get_each_month_open_price(eighth_asset_daily, eighth_asset_monthly_open) // ---- Main Code ---- if (BTC_High > ath_BTC) ath_BTC := BTC_High if (second_asset_high > ath_second_asset) ath_second_asset := second_asset_high if (third_asset_high > ath_third_asset) ath_third_asset := third_asset_high if (forth_asset_high > ath_forth_asset) ath_forth_asset := forth_asset_high if (fifth_asset_high > ath_fifth_asset) ath_fifth_asset := fifth_asset_high if (sixth_asset_high > ath_sixth_asset) ath_sixth_asset := sixth_asset_high if (seventh_asset_high > ath_seventh_asset) ath_seventh_asset := seventh_asset_high if (eighth_asset_high > ath_eighth_asset) ath_eighth_asset := eighth_asset_high if (barstate.islast) // BTC yealy return calculation calculate_return(BTC_Yearly_Open,BTC_Yearly_Returns) // BTC monthly return calculation calculate_return(BTC_Monthly_open,BTC_Monthly_return) // Second asset yearly return calculate_return(second_asset_yearly_open,second_asset_yearly_returns) // Second asset monthly return calculate_return(second_asset_monthly_open,second_asset_monthly_returns) // Third asset yearly return calculate_return(third_asset_yearly_open,third_asset_yearly_returns) // Third asset monthly return calculate_return(third_asset_monthly_open,third_asset_monthly_returns) // Forth asset yearly return calculate_return(forth_asset_yearly_open,forth_asset_yearly_returns) // Forth asset monthly return calculate_return(forth_asset_monthly_open,forth_asset_monthly_returns) // Fifth asset yearly return calculate_return(fifth_asset_yearly_open,fifth_asset_yearly_returns) // Fifth asset monthly return calculate_return(fifth_asset_monthly_open,fifth_asset_monthly_returns) // Sixth asset yearly return calculate_return(sixth_asset_yearly_open,sixth_asset_yearly_returns) // Sixth asset monthly return calculate_return(sixth_asset_monthly_open,sixth_asset_monthly_returns) // Seventh asset yearly return calculate_return(seventh_asset_yearly_open,seventh_asset_yearly_returns) // Seventh asset monthly return calculate_return(seventh_asset_monthly_open,seventh_asset_monthly_returns) // eighth asset yearly return calculate_return(eighth_asset_yearly_open,eighth_asset_yearly_returns) // Eighth asset monthly return calculate_return(eighth_asset_monthly_open,eighth_asset_monthly_returns) table.set_border_color(tbl,color.black) table.set_border_width(tbl,2) // Col 0 table.cell(tbl, 0, 0, "Pair", width = cell_width+5, height = cell_height , bgcolor = color.orange) table.cell(tbl, 0, 1, "BITSTAMP:BTCUSD", bgcolor = color.white, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 2, tickerid_02, bgcolor = tbl_col, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 3, tickerid_03, bgcolor = color.white, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 4, tickerid_04, bgcolor = tbl_col, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 5, tickerid_05, bgcolor = color.white, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 6, tickerid_06, bgcolor = tbl_col, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 7, tickerid_07, bgcolor = color.white, width = cell_width+5, height = cell_height) table.cell(tbl, 0, 8, tickerid_08, bgcolor = tbl_col, width = cell_width+5, height = cell_height) // Col 1 table.cell(tbl, 1, 0, "Y-Exp", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round(array.avg(BTC_Yearly_Returns),2) table.cell(tbl, 1, 1, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(second_asset_yearly_returns),2) table.cell(tbl, 1, 2, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(third_asset_yearly_returns),2) table.cell(tbl, 1, 3, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(forth_asset_yearly_returns),2) table.cell(tbl, 1, 4, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(fifth_asset_yearly_returns),2) table.cell(tbl, 1, 5, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(sixth_asset_yearly_returns),2) table.cell(tbl, 1, 6, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(seventh_asset_yearly_returns),2) table.cell(tbl, 1, 7, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(eighth_asset_yearly_returns),2) table.cell(tbl, 1, 8, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 2 table.cell(tbl, 2, 0, "Y-SDev", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round(array.stdev(BTC_Yearly_Returns),2) table.cell(tbl, 2, 1, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(second_asset_yearly_returns),2) table.cell(tbl, 2, 2, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(third_asset_yearly_returns),2) table.cell(tbl, 2, 3, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(forth_asset_yearly_returns),2) table.cell(tbl, 2, 4, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(fifth_asset_yearly_returns),2) table.cell(tbl, 2, 5, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(sixth_asset_yearly_returns),2) table.cell(tbl, 2, 6, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(seventh_asset_yearly_returns),2) table.cell(tbl, 2, 7, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(eighth_asset_yearly_returns),2) table.cell(tbl, 2, 8, str.tostring(buff2)+"%", bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 3 table.cell(tbl, 3, 0, "M-Exp", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round(array.avg(BTC_Monthly_return),2) table.cell(tbl, 3, 1, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(second_asset_monthly_returns),2) table.cell(tbl, 3, 2, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(third_asset_monthly_returns),2) table.cell(tbl, 3, 3, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(forth_asset_monthly_returns),2) table.cell(tbl, 3, 4, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(fifth_asset_monthly_returns),2) table.cell(tbl, 3, 5, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(sixth_asset_monthly_returns),2) table.cell(tbl, 3, 6, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.avg(seventh_asset_monthly_returns),2) table.cell(tbl, 3, 7, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.avg(eighth_asset_monthly_returns),2) table.cell(tbl, 3, 8, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 4 table.cell(tbl, 4, 0, "M-SDev", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round(array.stdev(BTC_Monthly_return),2) table.cell(tbl, 4, 1, str.tostring(buff2)+"%", bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(second_asset_monthly_returns),2) table.cell(tbl, 4, 2, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(third_asset_monthly_returns),2) table.cell(tbl, 4, 3, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(forth_asset_monthly_returns),2) table.cell(tbl, 4, 4, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(fifth_asset_monthly_returns),2) table.cell(tbl, 4, 5, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(sixth_asset_monthly_returns),2) table.cell(tbl, 4, 6, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(seventh_asset_monthly_returns),2) table.cell(tbl, 4, 7, str.tostring(buff2)+"%",bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round(array.stdev(eighth_asset_monthly_returns),2) table.cell(tbl, 4, 8, str.tostring(buff2)+"%",bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 5 table.cell(tbl, 5, 0, "CorToBTC", width = cell_width, height = cell_height , bgcolor = color.orange) table.cell(tbl, 5, 1, "1",bgcolor = color.white, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,second_asset_monthly_returns) buff2 := math.round(array.covariance(buff,second_asset_monthly_returns) / (array.stdev(buff) * array.stdev(second_asset_monthly_returns)),2) table.cell(tbl, 5, 2, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,third_asset_monthly_returns) buff2 := math.round(array.covariance(buff,third_asset_monthly_returns) / (array.stdev(buff) * array.stdev(third_asset_monthly_returns)),2) table.cell(tbl, 5, 3, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,forth_asset_monthly_returns) buff2 := math.round(array.covariance(buff,forth_asset_monthly_returns) / (array.stdev(buff) * array.stdev(forth_asset_monthly_returns)),2) table.cell(tbl, 5, 4, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,fifth_asset_monthly_returns) buff2 := math.round(array.covariance(buff,fifth_asset_monthly_returns) / (array.stdev(buff) * array.stdev(fifth_asset_monthly_returns)),2) table.cell(tbl, 5, 5, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,sixth_asset_monthly_returns) buff2 := math.round(array.covariance(buff,sixth_asset_monthly_returns) / (array.stdev(buff) * array.stdev(sixth_asset_monthly_returns)),2) table.cell(tbl, 5, 6, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,seventh_asset_monthly_returns) buff2 := math.round(array.covariance(buff,seventh_asset_monthly_returns) / (array.stdev(buff) * array.stdev(seventh_asset_monthly_returns)),2) table.cell(tbl, 5, 7, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff := array.copy(BTC_Monthly_return) make_sizes_equal(buff,eighth_asset_monthly_returns) buff2 := math.round(array.covariance(buff,eighth_asset_monthly_returns) / (array.stdev(buff) * array.stdev(eighth_asset_monthly_returns)),2) table.cell(tbl, 5, 8, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 6 table.cell(tbl, 6, 0, "SR Y/M", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round((array.avg(BTC_Monthly_return) - RiskFreeRate)/ array.stdev(BTC_Monthly_return),2) buff3 := math.round((array.avg(BTC_Yearly_Returns) - RiskFreeRate)/ array.stdev(BTC_Yearly_Returns),2) table.cell(tbl, 6, 1, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round((array.avg(second_asset_monthly_returns)-RiskFreeRate)/ array.stdev(second_asset_monthly_returns),2) buff3 := math.round((array.avg(second_asset_yearly_returns) - RiskFreeRate)/ array.stdev(second_asset_yearly_returns),2) table.cell(tbl, 6, 2, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round((array.avg(third_asset_monthly_returns)-RiskFreeRate)/ array.stdev(third_asset_monthly_returns),2) buff3 := math.round((array.avg(third_asset_yearly_returns) - RiskFreeRate)/ array.stdev(third_asset_yearly_returns),2) table.cell(tbl, 6, 3, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round((array.avg(forth_asset_monthly_returns)-RiskFreeRate)/ array.stdev(forth_asset_monthly_returns),2) buff3 := math.round((array.avg(forth_asset_yearly_returns) - RiskFreeRate)/ array.stdev(forth_asset_yearly_returns),2) table.cell(tbl, 6, 4, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round((array.avg(fifth_asset_monthly_returns)-RiskFreeRate)/ array.stdev(fifth_asset_monthly_returns),2) buff3 := math.round((array.avg(fifth_asset_yearly_returns) - RiskFreeRate)/ array.stdev(fifth_asset_yearly_returns),2) table.cell(tbl, 6, 5, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round((array.avg(sixth_asset_monthly_returns)-RiskFreeRate)/ array.stdev(sixth_asset_monthly_returns),2) buff3 := math.round((array.avg(sixth_asset_yearly_returns) - RiskFreeRate)/ array.stdev(sixth_asset_yearly_returns),2) table.cell(tbl, 6, 6, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) buff2 := math.round((array.avg(seventh_asset_monthly_returns)-RiskFreeRate)/ array.stdev(seventh_asset_monthly_returns),2) buff3 := math.round((array.avg(seventh_asset_yearly_returns) - RiskFreeRate)/ array.stdev(seventh_asset_yearly_returns),2) table.cell(tbl, 6, 7, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height) buff2 := math.round((array.avg(eighth_asset_monthly_returns)-RiskFreeRate)/ array.stdev(eighth_asset_monthly_returns),2) buff3 := math.round((array.avg(eighth_asset_yearly_returns) - RiskFreeRate)/ array.stdev(eighth_asset_yearly_returns),2) table.cell(tbl, 6, 8, str.tostring(buff3)+"/"+str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height) // Col 7 table.cell(tbl, 7, 0, "DownFrom ATH %", width = cell_width, height = cell_height, bgcolor = color.orange) buff2 := math.round(((BTC_Daily-ath_BTC)/ath_BTC)*100,2) table.cell(tbl, 7, 1, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height ) buff2 := math.round(((second_asset_daily - ath_second_asset)/ ath_second_asset)*100,2) table.cell(tbl, 7, 2, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height ) buff2 := math.round(((third_asset_daily - ath_third_asset)/ ath_third_asset)*100,2) table.cell(tbl, 7, 3, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height ) buff2 :=math.round(((forth_asset_daily - ath_forth_asset)/ ath_forth_asset)*100,2) table.cell(tbl, 7, 4, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height ) buff2 :=math.round(((fifth_asset_daily - ath_fifth_asset)/ ath_fifth_asset)*100,2) table.cell(tbl, 7, 5, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height ) buff2 :=math.round(((sixth_asset_daily - ath_sixth_asset)/ ath_sixth_asset)*100,2) table.cell(tbl, 7, 6, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height ) buff2 :=math.round(((seventh_asset_daily - ath_seventh_asset)/ ath_seventh_asset)*100,2) table.cell(tbl, 7, 7, str.tostring(buff2), bgcolor = color.white, width = cell_width, height = cell_height ) buff2 :=math.round(((eighth_asset_daily - ath_eighth_asset)/ ath_eighth_asset)*100,2) table.cell(tbl, 7, 8, str.tostring(buff2), bgcolor = tbl_col, width = cell_width, height = cell_height )
Consolidation and Breakout (Inside Bars)
https://www.tradingview.com/script/8ivF6HJP-Consolidation-and-Breakout-Inside-Bars/
Vulnerable_human_x
https://www.tradingview.com/u/Vulnerable_human_x/
356
study
5
MPL-2.0
// 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('Consolidation and Breakout (Inside Bars)', overlay=true) markbreakout = input(true, 'Mark Breaker Candle') var bubreaker = input(color.green, title="Bullish Break Color", inline="2") var bebreaker = input(color.red, title="Bearish Break Color", inline="2") colorinside = input(true, 'Colorize inside bars') var insidecolor = input(#000000, title="Inside Bar(s) Color") minbars = 1 maxbars = 250 var highlowcolor = input(#e91e63, title="Candle H/L Line Color", tooltip="Set transparency to 0 to make high and low invisible") var hllinewidth = input(2, title="High/Low Line Width") up = high down = low childup = open > close ? open : close childdown = open > close ? close : open var mainIndex = 0 upControl = childup > up[bar_index - mainIndex] and bar_index - mainIndex > minbars and bar_index - mainIndex <= maxbars ? true : na downControl = childdown < down[bar_index - mainIndex] and bar_index - mainIndex > minbars and bar_index - mainIndex <= maxbars ? true : na //marking candles that closed above/below the zone plotshape(markbreakout == true and upControl ? 1 : na, style=shape.triangleup, location=location.belowbar, color=bubreaker) plotshape(markbreakout == true and downControl ? -1 : na, style=shape.triangledown, location=location.abovebar, color=bebreaker) mainIndex := childdown <= up[bar_index - mainIndex] and childdown >= down[bar_index - mainIndex] and childup <= up[bar_index - mainIndex] and childup >= down[bar_index - mainIndex] and bar_index > 1 ? mainIndex[1] : bar_index //plotting high and low of the main candle plot(mainIndex == mainIndex[1] ? up[bar_index - mainIndex] : na, color=highlowcolor, style=plot.style_linebr, linewidth=hllinewidth) plot(mainIndex == mainIndex[1] ? down[bar_index - mainIndex] : na, color=highlowcolor, style=plot.style_linebr, linewidth=hllinewidth) barcolor(colorinside == true and bar_index - mainIndex > 0 ? insidecolor : na)
[GTH] Relative Strength, Sectors
https://www.tradingview.com/script/06Ji3OpZ-GTH-Relative-Strength-Sectors/
gehteha
https://www.tradingview.com/u/gehteha/
25
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © gehteha //@version=5 indicator(title="[GTH] Relative Strength, Sector", overlay= false) sector = input.string(defval="SPX", title="Sector", options=["SPX", "NDX", "XLB", "XLC", "XLE", "XLF", "XLI", "XLK", "XLP", "XLRE", "XLU", "XLV", "XLY", "XBI", "XHE", "XPH", "XHS", "XOP", "XES", "XRT", "XHB", "XSD", "XSW", "XTL", "XTN", "XAR", "KIE", "CIBR", "SPYG", "SPYV"]) switch_os = input.bool(title="Use this symbol instead", defval=false, inline="1") other_sym = input.symbol("", title="", inline="1") per = input.int(title="Smoothing Period", defval=21, minval=1) org_sym = request.security(syminfo.tickerid, timeframe.period, close) comp_sym = switch_os == true ? other_sym : sector s = request.security(comp_sym, timeframe.period, close) plot(ta.linreg(org_sym/s, per, 0), linewidth=2, color=#ff00df)
Improved Z-Score
https://www.tradingview.com/script/rYUMIFJC-Improved-Z-Score/
jlb05013
https://www.tradingview.com/u/jlb05013/
154
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jlb05013 //@version=5 indicator("Improved Z-Score") z_score_type = input.string(defval='Close', title='Ticker Type', options=['Open', 'High', 'Low', 'Close', 'OHLC4']) z_score_smooth = input.bool(defval=false, title='Ticker Smoothing?', tooltip='Whether or not you would like the ticker raw data to be smoothened or not by a particular period. Sometimes 3 or 5 period smoothing helps filter noise.') z_score_smooth_period = input.int(defval=3, title='Ticker Smoothing Period', tooltip='This is the smoothing period for the ticker if "Ticker Smoothing?" is set to True. I recommend using 3 or 5 period smoothing to filter noise.') z_score_ma_type = input.string(defval='SMA', title='Z-Score Type', options=['SMA', 'EMA']) z_score_ma_period = input.int(defval=21, title='Moving Average Period', tooltip='The length (in bars) for normalizing with a moving average. Standard is 21 (one month of trading days) but is customizable.') z_score_stdev_period = input.int(defval=252, title='Standard Deviation Period', tooltip='The length of time (in bars) for calculating standard deviation. Standard is 252 for use on Daily chart (1 trading year)') ticker_raw_data = z_score_type == 'Close' ? close : z_score_type == 'Open' ? open : z_score_type == 'High' ? high : z_score_type == 'Low' ? low : z_score_type == 'OHLC4' ? ohlc4 : na ticker_smooth = z_score_smooth ? ta.ema(ticker_raw_data, z_score_smooth_period) : ticker_raw_data ticker_ma = z_score_ma_type == 'SMA' ? ta.sma(ticker_raw_data, z_score_ma_period) : z_score_ma_type == 'EMA' ? ta.ema(ticker_raw_data, z_score_ma_period) : na ticker_stdev = ta.stdev(ticker_raw_data, z_score_stdev_period) final_zscore = (ticker_smooth - ticker_ma) / ticker_stdev plot(final_zscore, title='Z-Score', color=color.new(color.red, 30), style=plot.style_area)
Gann Square of 144
https://www.tradingview.com/script/7KmrAB2f-Gann-Square-of-144/
ThiagoSchmitz
https://www.tradingview.com/u/ThiagoSchmitz/
1,682
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ThiagoSchmitz //@version=5 indicator("Gann Square of 144", overlay=true, max_lines_count=500, max_labels_count=500) // ***************************************************************************** // ********************************* Constants ********************************* // ***************************************************************************** string groupInlineXYLabels = "X-Axis and Y-Axis Labels" string groupInlineExtraLines = "Extra Lines" string groupInlineColors = "colors" string groupInlineSquare = "squarecolors" int squares = 144 int barIndex = bar_index float barHigh = high float barLow = low string lineDashed = line.style_dashed string lineDotted = line.style_dotted string lineSolid = line.style_solid string lineNone = label.style_none bool barstateIsNew = barstate.isnew bool barstateIsLast = barstate.islast color colorRed = color.red color colorWhite = color.white // ***************************************************************************** // ********************************* Inputs ************************************ // ***************************************************************************** var int startDate = input.time(timestamp("2022-11-01"), "Starting Date") var float maxPrice = input.float(69198.0, "Manual Max Price") var float minPrice = input.float(17595.0, "Manual Min Price") var bool autoPricesAndBar = input.bool(true, "Set Upper/Lower Prices and Start Bar Automatically") var bool updateNewBar = input.bool(true, "Update at new bar") var int candlesPerDivision = input.int(1, "Candles per division", minval=1) var bool showTopXAxis = input.bool(false, "Top X-Axis", inline=groupInlineXYLabels, group=groupInlineXYLabels) var bool showBottomXAxis = input.bool(true, "Bottom X-Axis", inline=groupInlineXYLabels, group=groupInlineXYLabels) var bool showLeftYAxis = input.bool(false, "Left Y-Axis", inline=groupInlineXYLabels, group=groupInlineXYLabels) var bool showRightYAxis = input.bool(true, "Right Y-Axis", inline=groupInlineXYLabels, group=groupInlineXYLabels) var bool showPrices = input.bool(true, "Show Prices on the Right Y-Axis", inline=groupInlineXYLabels, group=groupInlineXYLabels) var bool showDivisions = input.bool(true, "Show Vertical Divisions", inline=groupInlineExtraLines, group=groupInlineExtraLines) var bool showExtraLines = input.bool(true, "Show Extra Lines", inline=groupInlineExtraLines, group=groupInlineExtraLines) var bool showGrid = input.bool(true, "Show Grid", inline=groupInlineExtraLines, group=groupInlineExtraLines) var bool showBackground = input.bool(true, "Show Background", inline=groupInlineExtraLines, group=groupInlineExtraLines) var string patterns = input.string("None", "Line Patterns", options=["None", "Arrow", "Star", "36, 72, and 108", "Arrow Cross", "Corners and Cross", "Master"], group="patterns") var color labelColor = input.color(color.green, "Numbers Color", inline=groupInlineColors, group=groupInlineColors) var color divisionsColor = input.color(color.blue, "Vertical Lines Color", inline=groupInlineColors, group=groupInlineColors) var color gridColor = input.color(color.gray, "Grid Color", inline=groupInlineColors, group=groupInlineColors) var color TLSColor = input.color(color.new(color.green, 80), "Top Left Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color TMSColor = input.color(color.new(color.red, 80), "Top Middle Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color TRSColor = input.color(color.new(color.green, 80), "Top Right Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color CLSColor = input.color(color.new(color.green, 80), "Center Left Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color CMSColor = input.color(color.new(color.red, 80), "Center Middle Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color CRSColor = input.color(color.new(color.green, 80), "Center Right Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color BLSColor = input.color(color.new(color.green, 80), "Bottom Left Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color BMSColor = input.color(color.new(color.red, 80), "Bottom Middle Square Color", inline=groupInlineSquare, group=groupInlineSquare) var color BRSColor = input.color(color.new(color.green, 80), "Bottom Right Square Color", inline=groupInlineSquare, group=groupInlineSquare) var int dateBarIndex = 0 if time == startDate dateBarIndex := barIndex // ***************************************************************************** // ******************************** Variables ********************************** // ***************************************************************************** int startBarIndex = autoPricesAndBar ? barIndex - math.floor(squares * candlesPerDivision / 2) : dateBarIndex int endBarIndex = startBarIndex + squares * candlesPerDivision int middleBarIndex = startBarIndex + squares * candlesPerDivision / 2 int onethirdPriceBar = (endBarIndex - startBarIndex) / 3 int barDiff = squares - math.abs(endBarIndex - barIndex) int barIndexDiff = barDiff <= 0 ? 1 : barDiff float atr = ta.atr(5) float highest = ta.highest(math.floor(squares * candlesPerDivision / 2) + 1) float lowest = ta.lowest(math.floor(squares * candlesPerDivision/ 2) + 1) float lowerPrice = autoPricesAndBar ? lowest : minPrice float upperPrice = autoPricesAndBar ? highest : maxPrice float middlePrice = lowerPrice + (upperPrice - lowerPrice) / 2 float onethirdPrice = (upperPrice - lowerPrice) / 3 // ***************************************************************************** // *************************** One-Time Variables ****************************** // ***************************************************************************** var box squareLines = box.new(barIndex, barHigh, barIndex, barLow, color.new(colorWhite, 50), 2, bgcolor=na) var bool buildSquareDone = false var bool buildInputsDone = false var bool[] dashedLineStyles = array.new_bool() var bool[] extendLines = array.new_bool() var bool[] showGroup = array.new_bool() var color[] lineColors = array.new_color() var label[] bottomXAxisArray = array.new_label() var label[] leftYAxisArray = array.new_label() var label[] rightYAxisArray = array.new_label() var label[] topXAxisArray = array.new_label() var line[] BLRArray = array.new_line() var line[] BLTArray = array.new_line() var line[] BRLArray = array.new_line() var line[] BRTArray = array.new_line() var line[] TLBArray = array.new_line() var line[] TLRArray = array.new_line() var line[] TRBArray = array.new_line() var line[] TRLArray = array.new_line() var line[] divisionsArray = array.new_line() var line[] extraArray = array.new_line() var line[] gridArray = array.new_line() var box back1Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=TLSColor) var box back2Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=TMSColor) var box back3Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=TRSColor) var box back4Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=CLSColor) var box back5Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=CMSColor) var box back6Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=CRSColor) var box back7Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=BLSColor) var box back8Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=BMSColor) var box back9Square = box.new(barIndex, barHigh, barIndex, barLow, na, 0, bgcolor=BRSColor) // ***************************************************************************** // ******************************** Fucntions ********************************** // ***************************************************************************** // ============================================================================= // * This function will update the box that goes on the edge of the Gann's // * square // ============================================================================= updateBox() => box.set_left(squareLines, startBarIndex) box.set_top(squareLines, upperPrice) box.set_right(squareLines, endBarIndex) box.set_bottom(squareLines, lowerPrice) // ============================================================================= // * This function will update the background of the Gann's square // ============================================================================= updateBackgrounds() => s1 = startBarIndex s2 = startBarIndex + ((squares / 3) * candlesPerDivision) s3 = startBarIndex + ((squares / 3) * 2 * candlesPerDivision) s4 = endBarIndex t1 = upperPrice t2 = upperPrice - ((upperPrice - lowerPrice) / 3) t3 = upperPrice - ((upperPrice - lowerPrice) / 3) * 2 t4 = lowerPrice box.set_left(back1Square, s1) box.set_right(back1Square, s2) box.set_top(back1Square, t1) box.set_bottom(back1Square, t2) box.set_left(back2Square, s2) box.set_right(back2Square, s3) box.set_top(back2Square, t1) box.set_bottom(back2Square, t2) box.set_left(back3Square, s3) box.set_right(back3Square, s4) box.set_top(back3Square, t1) box.set_bottom(back3Square, t2) box.set_left(back4Square, s1) box.set_right(back4Square, s2) box.set_top(back4Square, t2) box.set_bottom(back4Square, t3) box.set_left(back5Square, s2) box.set_right(back5Square, s3) box.set_top(back5Square, t2) box.set_bottom(back5Square, t3) box.set_left(back6Square, s3) box.set_right(back6Square, s4) box.set_top(back6Square, t2) box.set_bottom(back6Square, t3) box.set_left(back7Square, s1) box.set_right(back7Square, s2) box.set_top(back7Square, t3) box.set_bottom(back7Square, t4) box.set_left(back8Square, s2) box.set_right(back8Square, s3) box.set_top(back8Square, t3) box.set_bottom(back8Square, t4) box.set_left(back9Square, s3) box.set_right(back9Square, s4) box.set_top(back9Square, t3) box.set_bottom(back9Square, t4) // ============================================================================= // * Build both X-Axis and y-Axis labels // * It will use the topXAxisArray, bottomXAxisArray, rightYAxisArray, and // * leftYAxisArray arrays to store each label, if they are enabled to be shown // ============================================================================= buildAxis() => for int j = 0 to squares by 6 if showTopXAxis array.push(topXAxisArray, label.new(startBarIndex + j * candlesPerDivision, upperPrice + atr / 4, str.tostring(j), style=lineNone, textcolor=labelColor)) if showBottomXAxis array.push(bottomXAxisArray, label.new(startBarIndex + j * candlesPerDivision, lowerPrice - atr / 2, str.tostring(j), style=lineNone, textcolor=labelColor)) if showRightYAxis price = upperPrice - (upperPrice - lowerPrice) / squares * j t = str.tostring(j) + (showPrices ? " (" + str.tostring(math.round_to_mintick(price)) + ")" : "") array.push(rightYAxisArray, label.new(endBarIndex + 8 * candlesPerDivision, price, t, style=lineNone, textcolor=labelColor)) if showLeftYAxis array.push(leftYAxisArray, label.new(startBarIndex - 3, upperPrice - (upperPrice - lowerPrice) / squares * j, str.tostring(j), style=lineNone, textcolor=labelColor)) // ============================================================================= // * Update both X-Axis and y-Axis labels // ============================================================================= updateAxis() => for int j = 0 to squares - 1 by 6 if showTopXAxis label.set_x(array.get(topXAxisArray, j / 6), startBarIndex + j * candlesPerDivision) label.set_y(array.get(topXAxisArray, j / 6), upperPrice + atr / 4) if showBottomXAxis label.set_x(array.get(bottomXAxisArray, j / 6), startBarIndex + j * candlesPerDivision) label.set_y(array.get(bottomXAxisArray, j / 6), lowerPrice - atr / 2) if showRightYAxis label.set_x(array.get(rightYAxisArray, j / 6), endBarIndex + 8 * candlesPerDivision) label.set_y(array.get(rightYAxisArray, j / 6), upperPrice - (upperPrice - lowerPrice) / squares * j) if showLeftYAxis label.set_x(array.get(rightYAxisArray, j / 6), startBarIndex - 3) label.set_y(array.get(rightYAxisArray, j / 6), upperPrice - (upperPrice - lowerPrice) / squares * j) // ============================================================================= // * Build the vertical divisions to divide the square in 9 smaller squares // ============================================================================= buildDivisions() => array.push(divisionsArray, line.new(startBarIndex, lowerPrice + onethirdPrice, endBarIndex, lowerPrice + onethirdPrice, color=divisionsColor, style=lineDashed)) array.push(divisionsArray, line.new(startBarIndex, lowerPrice + onethirdPrice * 2, endBarIndex, lowerPrice + onethirdPrice * 2, color=divisionsColor, style=lineDashed)) array.push(divisionsArray, line.new(startBarIndex + onethirdPriceBar, upperPrice, startBarIndex + onethirdPriceBar, lowerPrice, color=divisionsColor, style=lineDashed)) array.push(divisionsArray, line.new(startBarIndex + onethirdPriceBar * 2, upperPrice, startBarIndex + onethirdPriceBar * 2, lowerPrice, color=divisionsColor, style=lineDashed)) // ============================================================================= // * Update the vertical divisions // ============================================================================= updateDivisions() => line.set_xy1(array.get(divisionsArray, 0), startBarIndex, lowerPrice + onethirdPrice) line.set_xy2(array.get(divisionsArray, 0), endBarIndex, lowerPrice + onethirdPrice) line.set_xy1(array.get(divisionsArray, 1), startBarIndex, lowerPrice + onethirdPrice * 2) line.set_xy2(array.get(divisionsArray, 1), endBarIndex, lowerPrice + onethirdPrice * 2) line.set_xy1(array.get(divisionsArray, 2), startBarIndex + onethirdPriceBar, upperPrice) line.set_xy2(array.get(divisionsArray, 2), startBarIndex + onethirdPriceBar, lowerPrice) line.set_xy1(array.get(divisionsArray, 3), startBarIndex + onethirdPriceBar * 2, upperPrice) line.set_xy2(array.get(divisionsArray, 3), startBarIndex + onethirdPriceBar * 2, lowerPrice) // ============================================================================= // * Build the Gann's square. It will create lines based on the inputs and store // * them in some arrays. It will use the showGroup array to check if the line // * needs to be created or not. If showExtraLines is enabled, it will create // * specific lines to provide the original Gann's Square format // ============================================================================= buildSquare() => for int i = 0 to (squares / 6) - 1 int endIndex = startBarIndex + 6 * (i + 1) * candlesPerDivision float endPrice = upperPrice - ((upperPrice - lowerPrice) / squares) * 6 * (i + 1) string style = array.get(dashedLineStyles, i) ? lineDashed : lineSolid string extend = array.get(extendLines, i) ? extend.both : extend.none if array.get(showGroup, i * 8) // Top Left Bottom array.push(TLBArray, line.new(startBarIndex, upperPrice, endIndex, lowerPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 1) // Top Left Right array.push(TLRArray, line.new(startBarIndex, upperPrice, endBarIndex, endPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 2) // Bottom Left Top array.push(BLTArray, line.new(startBarIndex, lowerPrice, endIndex, upperPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 3) // Bottom Left Right array.push(BLRArray, line.new(startBarIndex, lowerPrice, endBarIndex, endPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 4) // Top Right Bottom array.push(TRBArray, line.new(endBarIndex, upperPrice, endIndex, lowerPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 5) // Top Right Left array.push(TRLArray, line.new(endBarIndex, upperPrice, startBarIndex, endPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 6) // Bottom Right Top array.push(BRTArray, line.new(endBarIndex, lowerPrice, endIndex, upperPrice, color=array.get(lineColors, i), style=style, extend=extend)) if array.get(showGroup, i * 8 + 7) // Bottom Right Left array.push(BRLArray, line.new(endBarIndex, lowerPrice, startBarIndex, endPrice, color=array.get(lineColors, i), style=style, extend=extend)) if showExtraLines array.push(extraArray, line.new(middleBarIndex, upperPrice, startBarIndex, upperPrice - ((upperPrice - lowerPrice) / squares) * 36, color=colorRed, style=lineDashed)) array.push(extraArray, line.new(middleBarIndex, upperPrice, endBarIndex, upperPrice - ((upperPrice - lowerPrice) / squares) * 36, color=colorRed, style=lineDashed)) array.push(extraArray, line.new(middleBarIndex, lowerPrice, startBarIndex, upperPrice - ((upperPrice - lowerPrice) / squares) * 108, color=colorRed, style=lineDashed)) array.push(extraArray, line.new(middleBarIndex, lowerPrice, endBarIndex, upperPrice - ((upperPrice - lowerPrice) / squares) * 108, color=colorRed, style=lineDashed)) // ============================================================================= // * Update each line created for the Gann's square // ============================================================================= updateSquare() => if array.size(TLBArray) == (squares / 6) - 1 and array.size(TLRArray) == (squares / 6) - 1 and array.size(BLTArray) == (squares / 6) - 1 for int i = 0 to (squares / 6) - 1 int endIndex = startBarIndex + 6 * i * candlesPerDivision float endPrice = upperPrice - ((upperPrice - lowerPrice) / squares) * 6 * i if array.get(showGroup, i * 8) // Top Left Bottom line.set_xy1(array.get(TLBArray, i), startBarIndex, upperPrice) line.set_xy2(array.get(TLBArray, i), endIndex, lowerPrice) if array.get(showGroup, i * 8 + 1) // Top Left Right line.set_xy1(array.get(TLRArray, i), startBarIndex, upperPrice) line.set_xy2(array.get(TLRArray, i), endBarIndex, endPrice) if array.get(showGroup, i * 8 + 2) // Bottom Left Top line.set_xy1(array.get(BLTArray, i), startBarIndex, lowerPrice) line.set_xy2(array.get(BLTArray, i), endIndex, upperPrice) if array.get(showGroup, i * 8 + 3) // Bottom Left Right line.set_xy1(array.get(BLRArray, i), startBarIndex, lowerPrice) line.set_xy2(array.get(BLRArray, i), endBarIndex, endPrice) if array.get(showGroup, i * 8 + 4) // Top Right Bottom line.set_xy1(array.get(TRBArray, i), endBarIndex, upperPrice) line.set_xy2(array.get(TRBArray, i), endIndex, lowerPrice) if array.get(showGroup, i * 8 + 5) // Top Right Left line.set_xy1(array.get(TRLArray, i), endBarIndex, upperPrice) line.set_xy2(array.get(TRLArray, i), startBarIndex, endPrice) if array.get(showGroup, i * 8 + 6) // Bottom Right Top line.set_xy1(array.get(BRTArray, i), endBarIndex, lowerPrice) line.set_xy2(array.get(BRTArray, i), endIndex, upperPrice) if array.get(showGroup, i * 8 + 7) // Bottom Right Left line.set_xy1(array.get(BRLArray, i), endBarIndex, lowerPrice) line.set_xy2(array.get(BRLArray, i), startBarIndex, endPrice) // ============================================================================= // * Create the grid lines for reference // ============================================================================= buildGrid() => for int i = 0 to 23 index = startBarIndex + 6 * (i + 1) * candlesPerDivision price = upperPrice - ((upperPrice - lowerPrice) / squares) * 6 * (i + 1) array.push(gridArray, line.new(index, upperPrice, index, lowerPrice, color=gridColor, style=lineDotted)) array.push(gridArray, line.new(startBarIndex, price, endBarIndex, price, color=gridColor, style=lineDotted)) // ============================================================================= // * Update the grid lines // ============================================================================= updateGrid() => for int i = 0 to 23 index = startBarIndex + 6 * (i + 1) * candlesPerDivision price = upperPrice - ((upperPrice - lowerPrice) / squares) * 6 * (i + 1) line.set_xy1(array.get(gridArray, i * 2), index, upperPrice) line.set_xy2(array.get(gridArray, i * 2), index, lowerPrice) line.set_xy1(array.get(gridArray, i * 2 + 1), startBarIndex, price) line.set_xy2(array.get(gridArray, i * 2 + 1), endBarIndex, price) // ============================================================================= // * Set lines pattern to override the parameters input of each division. When an // * option besides None is selected, it will ignore the selections of each line // ============================================================================= setPattern() => if patterns != "None" for int i = 0 to array.size(showGroup) - 1 array.set(showGroup, i, false) if patterns == "Arrow" array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 else if patterns == "Star" array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 array.set(showGroup, 92, true) // Top Right to Bottom 72 array.set(showGroup, 93, true) // Top Right to Left 72 array.set(showGroup, 94, true) // Bottom Right to Top 72 array.set(showGroup, 95, true) // Bottom Right to Left 72 else if patterns == "36, 72, and 108" array.set(showGroup, 40, true) // Top Left to Bottom 36 array.set(showGroup, 41, true) // Top Left to Right 36 array.set(showGroup, 42, true) // Bottom Left to Top 36 array.set(showGroup, 45, true) // Top Right to Left 36 array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 array.set(showGroup, 92, true) // Top Right to Bottom 72 array.set(showGroup, 93, true) // Top Right to Left 72 array.set(showGroup, 94, true) // Bottom Right to Top 72 array.set(showGroup, 95, true) // Bottom Right to Left 72 array.set(showGroup, 139, true) // Bottom Left to Right 108 array.set(showGroup, 140, true) // Top Right to Bottom 108 array.set(showGroup, 142, true) // Bottom Right to Top 108 array.set(showGroup, 143, true) // Bottom Right to Left 108 array.set(showGroup, 184, true) // Top Left to Corner 144 array.set(showGroup, 186, true) // Top Right to Corner 144 else if patterns == "Arrow Cross" array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 array.set(showGroup, 184, true) // Top Left to Corner 144 array.set(showGroup, 186, true) // Top Right to Corner 144 else if patterns == "Corners and Cross" array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 array.set(showGroup, 92, true) // Top Right to Bottom 72 array.set(showGroup, 93, true) // Top Right to Left 72 array.set(showGroup, 94, true) // Bottom Right to Top 72 array.set(showGroup, 95, true) // Bottom Right to Left 72 array.set(showGroup, 184, true) // Top Left to Corner 144 array.set(showGroup, 186, true) // Top Right to Corner 144 else if patterns == "Master" array.set(showGroup, 42, true) // Bottom Left to Top 36 array.set(showGroup, 43, true) // Bottom Left to Right 36 array.set(showGroup, 88, true) // Top Left to Bottom 72 array.set(showGroup, 89, true) // Top Left to Right 72 array.set(showGroup, 90, true) // Bottom Left to Top 72 array.set(showGroup, 91, true) // Bottom Left to Right 72 array.set(showGroup, 138, true) // Bottom Left to Top 108 array.set(showGroup, 139, true) // Bottom Left to Right 108 array.set(showGroup, 184, true) // Top Left to Corner 144 array.set(showGroup, 186, true) // Top Right to Corner 144 // ***************************************************************************** // ************************** Run On Every Tick ******************************** // ***************************************************************************** if updateNewBar and buildSquareDone and barstateIsNew and autoPricesAndBar updateSquare() updateAxis() updateBox() if showDivisions updateDivisions() if showGrid updateGrid() // if showBackground // updateBackgrounds() // ***************************************************************************** // ****************************** Run Once ************************************* // ***************************************************************************** if buildInputsDone if time == startDate startBarIndex := barIndex if barstateIsLast and not buildSquareDone setPattern() updateBox() buildSquare() buildAxis() if showDivisions buildDivisions() if showGrid buildGrid() if showBackground updateBackgrounds() buildSquareDone := true // ============================================================================= // * Create all the lines inputs, together with the color of each one, line style and // * extend type. The default values are those originally found in W.D. Gann's book. // * The order of each line matters for the comparison inside the functions // ============================================================================= if not buildInputsDone buildInputsDone := true lineColors := array.concat(lineColors, array.from( input.color(color.green, "Line Color", inline="line", group="Connections from corners to 6"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 12"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 18"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 24"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 30"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 36"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 42"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 48"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 54"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 60"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 66"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 72"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 78"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 84"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 90"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 96"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 102"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 108"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 114"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 120"), input.color(color.red, "Line Color", inline="line", group="Connections from corners to 126"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 132"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 138"), input.color(color.green, "Line Color", inline="line", group="Connections from corners to 144"))) extendLines := array.concat(extendLines, array.from( input.bool(false, "Extend Line", inline="line", group="Connections from corners to 6"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 12"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 18"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 24"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 30"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 36"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 42"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 48"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 54"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 60"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 66"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 72"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 78"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 84"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 90"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 96"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 102"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 108"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 114"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 120"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 126"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 132"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 138"), input.bool(false, "Extend Line", inline="line", group="Connections from corners to 144"))) dashedLineStyles := array.concat(dashedLineStyles, array.from( input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 6"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 12"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 18"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 24"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 30"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 36"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 42"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 48"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 54"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 60"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 66"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 72"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 78"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 84"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 90"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 96"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 102"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 108"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 114"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 120"), input.bool(true, "Dashed Line", inline="line", group="Connections from corners to 126"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 132"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 138"), input.bool(false, "Dashed Line", inline="line", group="Connections from corners to 144"))) showGroup := array.concat(showGroup, array.from( input.bool(false, "┏ ↓", inline="6", group="Connections from corners to 6"), input.bool(false, "┏ →", inline="6", group="Connections from corners to 6"), input.bool(false, "┗ ↑", inline="6", group="Connections from corners to 6"), input.bool(false, "┗ →", inline="6", group="Connections from corners to 6"), input.bool(false, "┓ ←", inline="6", group="Connections from corners to 6"), input.bool(false, "┓ ↓", inline="6", group="Connections from corners to 6"), input.bool(false, "┛ ←", inline="6", group="Connections from corners to 6"), input.bool(false, "┛ ↑", inline="6", group="Connections from corners to 6"), input.bool(false, "┏ ↓", inline="12", group="Connections from corners to 12"), input.bool(false, "┏ →", inline="12", group="Connections from corners to 12"), input.bool(false, "┗ ↑", inline="12", group="Connections from corners to 12"), input.bool(false, "┗ →", inline="12", group="Connections from corners to 12"), input.bool(false, "┓ ←", inline="12", group="Connections from corners to 12"), input.bool(false, "┓ ↓", inline="12", group="Connections from corners to 12"), input.bool(false, "┛ ←", inline="12", group="Connections from corners to 12"), input.bool(false, "┛ ↑", inline="12", group="Connections from corners to 12"), input.bool(true, "┏ ↓", inline="18", group="Connections from corners to 18"), input.bool(true, "┏ →", inline="18", group="Connections from corners to 18"), input.bool(true, "┗ ↑", inline="18", group="Connections from corners to 18"), input.bool(false, "┗ →", inline="18", group="Connections from corners to 18"), input.bool(false, "┓ ←", inline="18", group="Connections from corners to 18"), input.bool(false, "┓ ↓", inline="18", group="Connections from corners to 18"), input.bool(false, "┛ ←", inline="18", group="Connections from corners to 18"), input.bool(false, "┛ ↑", inline="18", group="Connections from corners to 18"), input.bool(false, "┏ ↓", inline="24", group="Connections from corners to 24"), input.bool(false, "┏ →", inline="24", group="Connections from corners to 24"), input.bool(false, "┗ ↑", inline="24", group="Connections from corners to 24"), input.bool(false, "┗ →", inline="24", group="Connections from corners to 24"), input.bool(false, "┓ ←", inline="24", group="Connections from corners to 24"), input.bool(false, "┓ ↓", inline="24", group="Connections from corners to 24"), input.bool(false, "┛ ←", inline="24", group="Connections from corners to 24"), input.bool(false, "┛ ↑", inline="24", group="Connections from corners to 24"), input.bool(false, "┏ ↓", inline="30", group="Connections from corners to 30"), input.bool(false, "┏ →", inline="30", group="Connections from corners to 30"), input.bool(false, "┗ ↑", inline="30", group="Connections from corners to 30"), input.bool(false, "┗ →", inline="30", group="Connections from corners to 30"), input.bool(false, "┓ ←", inline="30", group="Connections from corners to 30"), input.bool(false, "┓ ↓", inline="30", group="Connections from corners to 30"), input.bool(false, "┛ ←", inline="30", group="Connections from corners to 30"), input.bool(false, "┛ ↑", inline="30", group="Connections from corners to 30"), input.bool(true, "┏ ↓", inline="36", group="Connections from corners to 36"), input.bool(true, "┏ →", inline="36", group="Connections from corners to 36"), input.bool(true, "┗ ↑", inline="36", group="Connections from corners to 36"), input.bool(false, "┗ →", inline="36", group="Connections from corners to 36"), input.bool(false, "┓ ←", inline="36", group="Connections from corners to 36"), input.bool(false, "┓ ↓", inline="36", group="Connections from corners to 36"), input.bool(false, "┛ ←", inline="36", group="Connections from corners to 36"), input.bool(false, "┛ ↑", inline="36", group="Connections from corners to 36"), input.bool(false, "┏ ↓", inline="42", group="Connections from corners to 42"), input.bool(false, "┏ →", inline="42", group="Connections from corners to 42"), input.bool(false, "┗ ↑", inline="42", group="Connections from corners to 42"), input.bool(false, "┗ →", inline="42", group="Connections from corners to 42"), input.bool(false, "┓ ←", inline="42", group="Connections from corners to 42"), input.bool(false, "┓ ↓", inline="42", group="Connections from corners to 42"), input.bool(false, "┛ ←", inline="42", group="Connections from corners to 42"), input.bool(false, "┛ ↑", inline="42", group="Connections from corners to 42"), input.bool(true, "┏ ↓", inline="48", group="Connections from corners to 48"), input.bool(true, "┏ →", inline="48", group="Connections from corners to 48"), input.bool(true, "┗ ↑", inline="48", group="Connections from corners to 48"), input.bool(false, "┗ →", inline="48", group="Connections from corners to 48"), input.bool(false, "┓ ←", inline="48", group="Connections from corners to 48"), input.bool(false, "┓ ↓", inline="48", group="Connections from corners to 48"), input.bool(false, "┛ ←", inline="48", group="Connections from corners to 48"), input.bool(false, "┛ ↑", inline="48", group="Connections from corners to 48"), input.bool(false, "┏ ↓", inline="54", group="Connections from corners to 54"), input.bool(false, "┏ →", inline="54", group="Connections from corners to 54"), input.bool(false, "┗ ↑", inline="54", group="Connections from corners to 54"), input.bool(false, "┗ →", inline="54", group="Connections from corners to 54"), input.bool(false, "┓ ←", inline="54", group="Connections from corners to 54"), input.bool(false, "┓ ↓", inline="54", group="Connections from corners to 54"), input.bool(false, "┛ ←", inline="54", group="Connections from corners to 54"), input.bool(false, "┛ ↑", inline="54", group="Connections from corners to 54"), input.bool(false, "┏ ↓", inline="60", group="Connections from corners to 60"), input.bool(false, "┏ →", inline="60", group="Connections from corners to 60"), input.bool(false, "┗ ↑", inline="60", group="Connections from corners to 60"), input.bool(false, "┗ →", inline="60", group="Connections from corners to 60"), input.bool(false, "┓ ←", inline="60", group="Connections from corners to 60"), input.bool(false, "┓ ↓", inline="60", group="Connections from corners to 60"), input.bool(false, "┛ ←", inline="60", group="Connections from corners to 60"), input.bool(false, "┛ ↑", inline="60", group="Connections from corners to 60"), input.bool(false, "┏ ↓", inline="66", group="Connections from corners to 66"), input.bool(false, "┏ →", inline="66", group="Connections from corners to 66"), input.bool(false, "┗ ↑", inline="66", group="Connections from corners to 66"), input.bool(false, "┗ →", inline="66", group="Connections from corners to 66"), input.bool(false, "┓ ←", inline="66", group="Connections from corners to 66"), input.bool(false, "┓ ↓", inline="66", group="Connections from corners to 66"), input.bool(false, "┛ ←", inline="66", group="Connections from corners to 66"), input.bool(false, "┛ ↑", inline="66", group="Connections from corners to 66"), input.bool(true, "┏ ↓", inline="72", group="Connections from corners to 72"), input.bool(true, "┏ →", inline="72", group="Connections from corners to 72"), input.bool(true, "┗ ↑", inline="72", group="Connections from corners to 72"), input.bool(true, "┗ →", inline="72", group="Connections from corners to 72"), input.bool(true, "┓ ←", inline="72", group="Connections from corners to 72"), input.bool(true, "┓ ↓", inline="72", group="Connections from corners to 72"), input.bool(true, "┛ ←", inline="72", group="Connections from corners to 72"), input.bool(true, "┛ ↑", inline="72", group="Connections from corners to 72"), input.bool(false, "┏ ↓", inline="78", group="Connections from corners to 78"), input.bool(false, "┏ →", inline="78", group="Connections from corners to 78"), input.bool(false, "┗ ↑", inline="78", group="Connections from corners to 78"), input.bool(false, "┗ →", inline="78", group="Connections from corners to 78"), input.bool(false, "┓ ←", inline="78", group="Connections from corners to 78"), input.bool(false, "┓ ↓", inline="78", group="Connections from corners to 78"), input.bool(false, "┛ ←", inline="78", group="Connections from corners to 78"), input.bool(false, "┛ ↑", inline="78", group="Connections from corners to 78"), input.bool(false, "┏ ↓", inline="84", group="Connections from corners to 84"), input.bool(false, "┏ →", inline="84", group="Connections from corners to 84"), input.bool(false, "┗ ↑", inline="84", group="Connections from corners to 84"), input.bool(false, "┗ →", inline="84", group="Connections from corners to 84"), input.bool(false, "┓ ←", inline="84", group="Connections from corners to 84"), input.bool(false, "┓ ↓", inline="84", group="Connections from corners to 84"), input.bool(false, "┛ ←", inline="84", group="Connections from corners to 84"), input.bool(false, "┛ ↑", inline="84", group="Connections from corners to 84"), input.bool(false, "┏ ↓", inline="90", group="Connections from corners to 90"), input.bool(false, "┏ →", inline="90", group="Connections from corners to 90"), input.bool(false, "┗ ↑", inline="90", group="Connections from corners to 90"), input.bool(false, "┗ →", inline="90", group="Connections from corners to 90"), input.bool(false, "┓ ←", inline="90", group="Connections from corners to 90"), input.bool(false, "┓ ↓", inline="90", group="Connections from corners to 90"), input.bool(false, "┛ ←", inline="90", group="Connections from corners to 90"), input.bool(false, "┛ ↑", inline="90", group="Connections from corners to 90"), input.bool(false, "┏ ↓", inline="96", group="Connections from corners to 96"), input.bool(false, "┏ →", inline="96", group="Connections from corners to 96"), input.bool(false, "┗ ↑", inline="96", group="Connections from corners to 96"), input.bool(true, "┗ →", inline="96", group="Connections from corners to 96"), input.bool(false, "┓ ←", inline="96", group="Connections from corners to 96"), input.bool(false, "┓ ↓", inline="96", group="Connections from corners to 96"), input.bool(false, "┛ ←", inline="96", group="Connections from corners to 96"), input.bool(false, "┛ ↑", inline="96", group="Connections from corners to 96"), input.bool(false, "┏ ↓", inline="102", group="Connections from corners to 102"), input.bool(false, "┏ →", inline="102", group="Connections from corners to 102"), input.bool(false, "┗ ↑", inline="102", group="Connections from corners to 102"), input.bool(false, "┗ →", inline="102", group="Connections from corners to 102"), input.bool(false, "┓ ←", inline="102", group="Connections from corners to 102"), input.bool(false, "┓ ↓", inline="102", group="Connections from corners to 102"), input.bool(false, "┛ ←", inline="102", group="Connections from corners to 102"), input.bool(false, "┛ ↑", inline="102", group="Connections from corners to 102"), input.bool(false, "┏ ↓", inline="108", group="Connections from corners to 108"), input.bool(false, "┏ →", inline="108", group="Connections from corners to 108"), input.bool(false, "┗ ↑", inline="108", group="Connections from corners to 108"), input.bool(true, "┗ →", inline="108", group="Connections from corners to 108"), input.bool(false, "┓ ←", inline="108", group="Connections from corners to 108"), input.bool(false, "┓ ↓", inline="108", group="Connections from corners to 108"), input.bool(false, "┛ ←", inline="108", group="Connections from corners to 108"), input.bool(false, "┛ ↑", inline="108", group="Connections from corners to 108"), input.bool(false, "┏ ↓", inline="114", group="Connections from corners to 114"), input.bool(false, "┏ →", inline="114", group="Connections from corners to 114"), input.bool(false, "┗ ↑", inline="114", group="Connections from corners to 114"), input.bool(false, "┗ →", inline="114", group="Connections from corners to 114"), input.bool(false, "┓ ←", inline="114", group="Connections from corners to 114"), input.bool(false, "┓ ↓", inline="114", group="Connections from corners to 114"), input.bool(false, "┛ ←", inline="114", group="Connections from corners to 114"), input.bool(false, "┛ ↑", inline="114", group="Connections from corners to 114"), input.bool(false, "┏ ↓", inline="120", group="Connections from corners to 120"), input.bool(false, "┏ →", inline="120", group="Connections from corners to 120"), input.bool(false, "┗ ↑", inline="120", group="Connections from corners to 120"), input.bool(false, "┗ →", inline="120", group="Connections from corners to 120"), input.bool(false, "┓ ←", inline="120", group="Connections from corners to 120"), input.bool(false, "┓ ↓", inline="120", group="Connections from corners to 120"), input.bool(false, "┛ ←", inline="120", group="Connections from corners to 120"), input.bool(false, "┛ ↑", inline="120", group="Connections from corners to 120"), input.bool(false, "┏ ↓", inline="126", group="Connections from corners to 126"), input.bool(false, "┏ →", inline="126", group="Connections from corners to 126"), input.bool(false, "┗ ↑", inline="126", group="Connections from corners to 126"), input.bool(true, "┗ →", inline="126", group="Connections from corners to 126"), input.bool(false, "┓ ←", inline="126", group="Connections from corners to 126"), input.bool(false, "┓ ↓", inline="126", group="Connections from corners to 126"), input.bool(false, "┛ ←", inline="126", group="Connections from corners to 126"), input.bool(false, "┛ ↑", inline="126", group="Connections from corners to 126"), input.bool(false, "┏ ↓", inline="132", group="Connections from corners to 132"), input.bool(false, "┏ →", inline="132", group="Connections from corners to 132"), input.bool(false, "┗ ↑", inline="132", group="Connections from corners to 132"), input.bool(false, "┗ →", inline="132", group="Connections from corners to 132"), input.bool(false, "┓ ←", inline="132", group="Connections from corners to 132"), input.bool(false, "┓ ↓", inline="132", group="Connections from corners to 132"), input.bool(false, "┛ ←", inline="132", group="Connections from corners to 132"), input.bool(false, "┛ ↑", inline="132", group="Connections from corners to 132"), input.bool(false, "┏ ↓", inline="138", group="Connections from corners to 138"), input.bool(false, "┏ →", inline="138", group="Connections from corners to 138"), input.bool(false, "┗ ↑", inline="138", group="Connections from corners to 138"), input.bool(false, "┗ →", inline="138", group="Connections from corners to 138"), input.bool(false, "┓ ←", inline="138", group="Connections from corners to 138"), input.bool(false, "┓ ↓", inline="138", group="Connections from corners to 138"), input.bool(false, "┛ ←", inline="138", group="Connections from corners to 138"), input.bool(false, "┛ ↑", inline="138", group="Connections from corners to 138"), input.bool(true, "┏ ↓", inline="144", group="Connections from corners to 144"), input.bool(true, "┏ →", inline="144", group="Connections from corners to 144"), input.bool(true, "┗ ↑", inline="144", group="Connections from corners to 144"), input.bool(true, "┗ →", inline="144", group="Connections from corners to 144"), input.bool(false, "┓ ←", inline="144", group="Connections from corners to 144"), input.bool(false, "┓ ↓", inline="144", group="Connections from corners to 144"), input.bool(false, "┛ ←", inline="144", group="Connections from corners to 144"), input.bool(false, "┛ ↑", inline="144", group="Connections from corners to 144")))
Yasir Hameed Advance RSI Indicator
https://www.tradingview.com/script/E6peALmz-Yasir-Hameed-Advance-RSI-Indicator/
Yasir_Hameed
https://www.tradingview.com/u/Yasir_Hameed/
200
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Yasir_Hameed // //@version=5 // indicator("My script") // plot(close) // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HamidBox //@version=4 study("RSI Signals", overlay=true, shorttitle="Yasir Hameed Advanced RSI") //Inputs rsiL = input(title="RSI Length", type=input.integer, defval=7) rsiOBI = input(title="RSI Overbought", type=input.integer, defval=70) rsiOSI = input(title="RSI Oversold", type=input.integer, defval=30) fibLevel = input(title="Hammer Body Size", type=input.float, defval=0.333, step=0.01) BullBearEngulf = input(title="Bullish Bearish Engulfing", type=input.bool, defval=true) hammerShooting = input(title="Hammer Shooting Bar", type=input.bool, defval=false) twoBullBearBar = input(title="Two Bull Bear Bar", type=input.bool, defval=false) //RSI VALUE myRsi = rsi(close , rsiL) //RSI OVERBOUGHT / OVERSOLD rsiOB = myRsi >= rsiOBI rsiOS = myRsi <= rsiOSI ///////////=Hammer & Shooting star=///////////// bullFib = (low - high) * fibLevel + high bearFib = (high - low) * fibLevel + low // Determine which price source closses or open highest/lowest bearCandle = close < open ? close : open bullCandle = close > open ? close : open // Determine if we have a valid hammer or shooting star hammer = (bearCandle >= bullFib) and rsiOS shooting = (bullCandle <= bearFib) and rsiOB twoGreenBars = (close > open and close[1] > open[1]) and rsiOS twoRedBars = (close < open and close[1] < open[1]) and rsiOB ///////////////////////////////////////////// // Engulfing candles bullE = (close > open[1] and close[1] < open[1]) //or hammer or twoGreenBars bearE = close < open[1] and close[1] > open[1] //or shooting or twoRedBars /////////////////////////////////////////// // ((x) y) farmula defination is: X is gona be executed before Y, TradeSignal = ((rsiOS or rsiOS[1]) and bullE) or ((rsiOB or rsiOB[1]) and bearE) if (TradeSignal and bearE and BullBearEngulf) label.new(x= bar_index, y= na, text="Exit", yloc= yloc.abovebar,color= color.maroon, textcolor= color.white, style= label.style_label_down, size=size.normal) plotshape(TradeSignal and bearE and BullBearEngulf, title="Overbought", location=location.abovebar, color=color.orange, style=shape.triangleup, size=size.auto, text="") if (TradeSignal and bullE and BullBearEngulf) label.new(x= bar_index, y= na, text="Buy", yloc= yloc.belowbar,color= color.green, textcolor= color.white, style= label.style_label_up, size=size.normal) plotshape(TradeSignal and bullE and BullBearEngulf, title="Oversold", location=location.belowbar, color=color.lime, style=shape.triangleup, size=size.auto, text="") ////////////////////////////// if (shooting and hammerShooting) label.new(x= bar_index, y= na, text="SS", yloc= yloc.abovebar,color= color.purple, textcolor= color.white, style= label.style_label_down, size=size.normal) plotshape(shooting and hammerShooting, title="Overbought + hammer/shooting", location=location.abovebar, color=color.purple, style=shape.triangledown, size=size.auto, text="") if (hammer and hammerShooting) label.new(x= bar_index, y= na, text="HMR", yloc= yloc.belowbar,color= color.blue, textcolor= color.white, style= label.style_label_up, size=size.normal) plotshape(hammer and hammerShooting, title="Oversold + hammer/shooting", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="") /////////////////////////// if (twoGreenBars and twoBullBearBar) label.new(x= bar_index, y= na, text="2Bull", yloc= yloc.belowbar,color= color.olive, textcolor= color.white, style= label.style_label_up, size=size.normal) plotshape(twoGreenBars and twoBullBearBar, title="Oversold + 2bulls", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="") if (twoRedBars and twoBullBearBar) label.new(x= bar_index, y= na, text="2Bear", yloc= yloc.abovebar,color= color.red, textcolor= color.white, style= label.style_label_down, size=size.normal) plotshape(twoRedBars and twoBullBearBar, title="Overbought + 2bears", location=location.abovebar, color=color.blue, style=shape.triangledown, size=size.auto, text="") // Send Alert if Candle meets our condition alertcondition(TradeSignal, title="RSI SIGNAL", message="RSI Signal Detected fot {{ticker}}")
Nur MA_ADEO
https://www.tradingview.com/script/DHBlbPNJ-Nur-MA-ADEO/
adityadeokule
https://www.tradingview.com/u/adityadeokule/
3
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © adityadeokule //@version=4 study("Nur MA", overlay=true) //MA strategy ma8 = ema(close,8) ma13 = ema(close,13) ma55 = wma(close,55) ma34 = ema(close,34) ma21 = ema(close,21) ma200 =ema(close,200) plot(ma21,color=color.blue, offset=+1) plot(ma34,color=color.black, offset=+1) plot(ma200,color=color.red, offset=+1) plot(ma55,color=color.orange, offset=+1) plot(ma8,color=color.green, offset=+1)
Blockchain Fundamentals - Active Address Sentiment Osc. [CR]
https://www.tradingview.com/script/fRA2t8gk-Blockchain-Fundamentals-Active-Address-Sentiment-Osc-CR/
theheirophant
https://www.tradingview.com/u/theheirophant/
347
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theheirophant //@version=5 /////////////////////////////////////////////////////////////////////////////////////////\ ///////////////////////////////////ALERT//////////////////////////////////////////////////\ //use only on DAILY timeframe I did not implement MTF functions for the calculations yet///|> /////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////// indicator("Blockchain Fundamentals: Active Address Sentiment Oscillator [CR]") //choose MA function getMA(src, length, maSelect) => ma = 0.0 if maSelect == "EMA" ma := ta.ema(src, length) ma if maSelect == "SMA" ma := ta.sma(src, length) ma if maSelect == "VWMA" ma := ta.vwma(src, length) ma if maSelect == "WMA" ma := ta.wma(src, length) ma if maSelect == "RMA" ma := ta.rma(src, length) ma if maSelect == "ALMA" ma := ta.alma(src, length, 0.85, 6) ma if maSelect == "SWMA" ma := ta.swma(src) ma if maSelect == "HMA" ma := ta.hma(src, length) ma ma //are you naughty traders on the daily chart or not? daily = timeframe.isdaily if not daily runtime.error("USE DAILY CHART =)") //data numuniqaddr = request.security('quandl:bchain/naddu', 'D', close) pnumuniqaddr = request.security('quandl:bchain/naddu', 'D', close[28]) price = request.security('BNC:BLX', 'D', close) pprice = request.security('BNC:BLX', 'D', close[28]) //inputs maSelect = input.session(title="Standard Deviation Bands MA Type (SMA is default)", defval="SMA", options=["EMA", "SMA", "VWMA", "WMA", "HMA", "RMA", "ALMA", "SWMA"], group = "SD Settings") length2 = input.int(28, minval=2, title='Standard Deviation Bands MA Length (28 is default)', group = "SD Settings") multi = input.float(2, minval=0.1, title='Standard Deviation Bands Multi (2 is default)', group = "SD Settings") //conditionals tru = input.bool(false, "Plot background coloration for over/under valued?", group = "Settings") tru2 = input.bool(false, "Plot candle coloration for over/under valued?", group = "Settings") tru3 = input.bool(true, "Apply smoothing to Price Change plot? (WMA - 3 period)", group = "Settings") //calculation priceMA = tru3 ? ta.wma((price - pprice) / pprice, 3) : (price - pprice) / pprice daa = (numuniqaddr - pnumuniqaddr) / pnumuniqaddr bandU = getMA(daa + (multi * ta.stdev(daa, 20)),length2, maSelect) bandL = getMA(daa - (multi * ta.stdev(daa, 20)),length2, maSelect) colorBG = priceMA > bandU ? color.new(color.lime, 90) : priceMA < bandL ? color.new(color.red,90) : color.new(color.yellow,100) colorBG2 = priceMA > .40 or priceMA < -.30 ? color.new(color.white, 0) : priceMA > bandU ? color.new(color.lime, 0) : priceMA < bandL ? color.new(color.red, 0) : color.new(color.yellow,100) colorBG3 = priceMA > .40 or priceMA < -.30 ? color.new(color.white, 90) : color.new(color.yellow,100) //plots bgcolor(tru ? colorBG : na) bgcolor(tru ? colorBG3 : na) barcolor(tru2 ? colorBG2 : na) plot(daa*100, 'DAA Change', color=color.new(color.gray, 30)) plot(priceMA*100, 'Price Change', color=color.new(color.yellow, 0)) plot(bandU*100, 'Upper Band', color=color.new(color.red, 0)) plot(bandL*100, 'Lower Band', color=color.new(color.lime, 0))
Session backtest tool
https://www.tradingview.com/script/eWoOVxlw-Session-backtest-tool/
CryptoJok3r
https://www.tradingview.com/u/CryptoJok3r/
25
study
5
MPL-2.0
// 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("Session backtest tool", overlay=true, scale=scale.none) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Background Overlay show_daysession = input(title='Show Day Session', defval=true) daysession = input.session(title='Day Session', defval='0700-1400') show_eveningsession = input(title='Show Evening Session', defval=true) eveningsession = input.session(title='Evening Session', defval='1600-2000') daysession_color = color.new(color.green, 86) eveningsession_color = color.new(color.purple, 86) is_session(session) => not na(time(timeframe.period, session)) is_daysession = is_session(daysession) is_eveningsession = is_session(eveningsession) bgcolor(show_daysession and is_daysession ? daysession_color : na) bgcolor(show_eveningsession and is_eveningsession ? eveningsession_color : na) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Days Of The Week bartimeoffset = time - time[1] plotchar(dayofweek == dayofweek.monday, char='M', location=location.bottom, color=color.new(color.green, 0)) plotchar(dayofweek == dayofweek.tuesday, char='T', location=location.bottom, color=color.new(color.green, 0)) plotchar(dayofweek == dayofweek.wednesday, char='W', location=location.bottom, color=color.new(color.green, 0)) plotchar(dayofweek == dayofweek.thursday, char='T', location=location.bottom, color=color.new(color.green, 0)) plotchar(dayofweek == dayofweek.friday, char='F', location=location.bottom, color=color.new(color.green, 0)) plotchar(dayofweek == dayofweek.saturday, char='S', location=location.bottom, color=color.new(color.red, 0)) plotchar(dayofweek == dayofweek.sunday, char='S', location=location.bottom, color=color.new(color.red, 0))
Stopping Volume Finder (Reversals)
https://www.tradingview.com/script/H0DZ6DaF-Stopping-Volume-Finder-Reversals/
Bcullen175
https://www.tradingview.com/u/Bcullen175/
174
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Bcullen175 //@version=5 indicator("Stopping VOL. Module", overlay = true) //This Indicator is designed to be used along side the Traders Reality indicator as well as RSI/TDI // Works Best on 15 and 5 Minute Timeframes //It highlights candles where there has been a stop hunt, this helps to indentify reversals with the use of divergence in for example RSI as well as using past price actions to identify points of intrest. //Legend: //Bullish Reversal: //Green/Purple Arrow //Bearish Reversal: //Red/Blue Arrow //Mixed Signal //Either: //Green & Blue Arrow //Red & Purple Arrow //> A stop hunt has happened both ways and will now likely move to the nearest pool of liquidity // Stopping Volume Candles // Bull SVCs Bull_SVC1 = (open<close) and ((close-open)/(open-low)<0.30) and (volume>(ta.sma(volume,10)*1.49)) plotshape(Bull_SVC1, "SVC", shape.triangledown, location.abovebar, color.lime) Bull_SVC2 = ((open<close) and (close-open)/(high-close)<0.30) and (volume>(ta.sma(volume,10)*1.49)) plotshape(Bull_SVC2, "SVC", shape.triangleup, location.belowbar, color.red) // Bear SVCs Bear_SVC1 = (open>close) and ((open-close)/(high-open)<0.30) and (volume>(ta.sma(volume,10)*1.49)) plotshape(Bear_SVC1, "SVC", shape.triangleup, location.belowbar, color.red) Bear_SVC2 = (open>close) and ((open-close)/(close-low)<0.30) and (volume>(ta.sma(volume,10)*1.49)) plotshape(Bear_SVC2, "SVC", shape.triangledown, location.abovebar, color.lime)
Blockchain Fundamentals: Electricity Cost of BTC [CR]
https://www.tradingview.com/script/WqgcFq9o-Blockchain-Fundamentals-Electricity-Cost-of-BTC-CR/
theheirophant
https://www.tradingview.com/u/theheirophant/
36
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © theheirophant //@version=5 indicator("Blockchain Fundamentals: Electricity Cost of BTC [CR]") //historical windows for halvings start1 = timestamp('1 Jan 2000 00:00 +0000') finish1 = timestamp('27 Nov 2012 23:59 +0000') window1() => time >= start1 and time <= finish1 ? true : false start2 = timestamp('28 Nov 2012 00:00 +0000') finish2 = timestamp('8 Jul 2016 23:59 +0000') window2() => time >= start2 and time <= finish2 ? true : false start3 = timestamp('9 Jul 2016 00:00 +0000') finish3 = timestamp('10 May 2020 23:59 +0000') window3() => time >= start3 and time <= finish3 ? true : false start4 = timestamp('11 May 2020 00:00 +0000') finish4 = timestamp('1 Jun 2024 23:59 +0000') window4() => time >= start4 and time <= finish4 ? true : false //bitcoin block emission rate based on halvings emissionrate = 6.25 emissionrate := window1() == true ? 50 : emissionrate emissionrate := window2() == true ? 25 : emissionrate emissionrate := window3() == true ? 12.5 : emissionrate emissionrate := window4() == true ? 6.25 : emissionrate //inputs terahashes = input.int(110, minval=0, title='Total Mining TH/s?', tooltip="Total TH/s of all Miners") power = input.float(3.1, minval=0, title='Total kWh Used?', tooltip="1000 watts = 1 kWh | 3500 watts = 3.5 kWh etc ") elecprice = input.float(5, minval=0.1, title='Electricity Cost: Cents per kWh?') tru = input.bool(true, title='Also Plot Total Cost?') elecpercent = input.float(80, minval=0.1, maxval=100, title='Total Cost: Electricity accounts for X% of all costs?', tooltip="Studies report 80% is an average value for efficient miners") / 100 //calculation diff = request.security('quandl:bchain/diff', 'D', close) secstomine1block = math.pow(2, 32) * diff / (math.pow(10, 12) * terahashes) daystomine1block = secstomine1block / (24 * 3600) daystomine1btc = daystomine1block / emissionrate //division by 100 to convert cents to dollars costtomine1day = power * elecprice * 24 / 100 costtomine1btc = costtomine1day * daystomine1btc //plots plot(costtomine1btc, 'Cost to mine 1 BTC - Electric Only', color=color.new(color.blue, 0)) plot(costtomine1btc * ((1 - elecpercent) + 1), 'Cost to mine 1 BTC - All Costs', color=tru ? color.new(color.yellow, 0) : color.new(color.yellow, 100))
Background Zones
https://www.tradingview.com/script/HggOddXL-Background-Zones/
PtGambler
https://www.tradingview.com/u/PtGambler/
64
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © PtGambler //@version=5 indicator("Background Zones", overlay=true) bull = input.int(1800, "Bullish Zone") n_upper = input.int(500, "Neutral Zone upper") n_lower = input.int(-500, "Neutral Zone lower") bear = input.int(-1800, "Bearish Zone") top = hline(9999, "Ceiling") bull_line = hline(bull, "Bullish line", color=color.gray, linestyle=hline.style_dashed) n_upper_line = hline(n_upper, "Neutral Upper line", color=color.gray, linestyle=hline.style_dashed) zero = hline(0, "Zero line", color=color.gray, linestyle=hline.style_dashed, linewidth=2) n_lower_line = hline(n_lower, "Neutral Lower line", color=color.gray, linestyle=hline.style_dashed) bear_line = hline(bear, "Bearish line", color=color.gray, linestyle=hline.style_dashed) bottom = hline(-9999, "Floor") fill(top, bull_line,title="Zone 1", color=color.new(color.green,80)) fill(bull_line, n_upper_line,title="Zone 2", color=color.new(color.green,95)) fill(n_upper_line, n_lower_line,title="Zone 3", color=color.new(color.gray,90)) fill(bear_line, n_lower_line,title="Zone 4", color=color.new(color.red,95)) fill(bear_line, bottom,title="Zone 5", color=color.new(color.red,80))
TheATR: Aroon Oscillator.
https://www.tradingview.com/script/ob0R0OoT-TheATR-Aroon-Oscillator/
thealgorithmictrader
https://www.tradingview.com/u/thealgorithmictrader/
32
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © thealgorithmictrader //@version=5 indicator("TheATR: Aroon Oscillator.") //User has to agree to have the indi loading on the chart. //{ var user_consensus = input.string(defval="", title="By typing 'agree' you acknowledge the understanding about the fact 'TheATR: Aroon Oscillator.' doesn't aim and/or intend to provide any financial advice, as of its nature of being an educational tool.\n © TheATR", confirm = true, group="consensus") var valid = false if user_consensus == "agree" valid := true else runtime.error("Type 'agree' first in order to show the algo!") valid := false //} //Fisher Oscillator Settings //{ g_aroon = "Aroon Oscillator" i_ar_sign = input.bool(true, "Entries",group=g_aroon,inline="ar0") i_ar_exit_sign = input.bool(true, "Exits",group=g_aroon,inline="ar0") i_ar_ws = input.bool(true, "Weak Spots Filter",group=g_aroon,inline="ar2") i_ar_src = input.source(close, "|Src",group=g_aroon,inline="ar2") i_ar_l = input.int(21, "Len",group=g_aroon,inline="ar2",minval=2) i_ar_exit_l = input.float(50.0, "Exit Signal Line Level",group=g_aroon,inline="ar2",minval=5, maxval = 95) g_aroon_sty = "Aroon Oscillator Style" i_bull_col = input.color(color.blue, "Colors: Bull", group=g_aroon_sty, inline = "sty0") i_bear_col = input.color(color.purple, "Bear", group=g_aroon_sty, inline = "sty0") i_exit_col = input.color(color.yellow, "Exit Signal Line", group=g_aroon_sty, inline = "sty00") i_ar_alerts = input.bool(true, "Alerts",group=g_aroon_sty,inline="sty1") //} //Aroon Oscillator Calculations And Plots //{ aroon_up = 100* (ta.highestbars(i_ar_src, i_ar_l+1)+i_ar_l)/i_ar_l aroon_dw = 100* (ta.lowestbars(i_ar_src, i_ar_l+1)+i_ar_l)/i_ar_l plot(valid?aroon_up:na, "Aroon Up", aroon_up>aroon_dw? i_bull_col : color.new(i_bull_col,50),style=plot.style_columns) plot(valid?aroon_dw:na, "Aroon Down", aroon_up<=aroon_dw? i_bear_col : color.new(i_bear_col,50),style=plot.style_columns) hline(0, "0 Line", color.gray) hline(100, "100 Line", color.gray) hline(i_ar_exit_l, "Exit Signal Line", i_exit_col, editable = true, linestyle= hline.style_dashed) //} //Aroon Signals Generation //{ var aroon_bull = false var aroon_bear = false var aroon_bull_exit = false var aroon_bear_exit = false var curr_dir = "" aroon_bull := ta.crossover(aroon_up, aroon_dw) and (i_ar_ws? aroon_up>i_ar_exit_l :true) aroon_bear := ta.crossunder(aroon_up, aroon_dw) and (i_ar_ws? aroon_dw>i_ar_exit_l :true) if aroon_bull curr_dir:="LONG" if aroon_bear curr_dir:="SHORT" aroon_bull_exit := ta.crossunder(aroon_up, i_ar_exit_l) and curr_dir == "LONG" aroon_bear_exit := ta.crossunder(aroon_dw, i_ar_exit_l) and curr_dir == "SHORT" //Aroon Signals Plots plotshape(i_ar_sign and aroon_bull and valid, "Aroon Long Signals", shape.circle,location.bottom,i_bull_col,text="Long",textcolor=i_bull_col) plotshape(i_ar_sign and aroon_bear and valid, "Aroon Short Signals", shape.circle,location.top,i_bear_col,text="Short",textcolor=i_bear_col) //Aroon Exit Signals Plots plotshape(i_ar_sign and i_ar_exit_sign and aroon_bull_exit and valid, "Aroon Long Exit Signals", shape.circle,location.bottom,i_bull_col,text="Exit Long",textcolor=i_bull_col) plotshape(i_ar_sign and i_ar_exit_sign and aroon_bear_exit and valid, "Aroon Short Exit Signals", shape.circle,location.top,i_bear_col,text="Exit Short",textcolor=i_bear_col) //Aroon Alerts if i_ar_sign and aroon_bull and valid and i_ar_alerts alert("Aroon Long Alert") if i_ar_sign and aroon_bear and valid and i_ar_alerts alert("Aroon Short Alert") if i_ar_exit_sign and aroon_bull_exit and valid and i_ar_alerts alert("Aroon Exit Long Alert") if i_ar_exit_sign and aroon_bear_exit and valid and i_ar_alerts alert("Aroon Exit Short Alert") //}
Price Convergence Divergence
https://www.tradingview.com/script/EbseMfW6-Price-Convergence-Divergence/
tomahawk3999
https://www.tradingview.com/u/tomahawk3999/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tomahawk3999 //@version=5 indicator("change") l1 = input(10) hist = ta.change(close,1) ma = ta.sma(hist,l1) col = close > open ? color.green : color.red plot(hist,style=plot.style_columns,color=col) plot(ma,color=color.orange)
PB
https://www.tradingview.com/script/fcWDFS4L-PB/
tomahawk3999
https://www.tradingview.com/u/tomahawk3999/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tomahawk3999 //@version=5 indicator("PB",overlay=true) l1 = input(20,"length") a1 = ta.sma(close,l1) * 1.02 a2 = ta.sma(close,l1) * 1.01 a3 = ta.sma(close,l1) * 0.99 a4 = ta.sma(close,l1) * 0.98 p1 = plot(a1,color=color.red) p2 = plot(a2,color=color.red) p3 = plot(a3,color=color.green) p4 = plot(a4,color=color.green) fill(p1,p2,color=color.new(color.red,70)) fill(p3,p4,color=color.new(color.green,70))
RSI Trend
https://www.tradingview.com/script/LvEWCt8I-RSI-Trend/
traderharikrishna
https://www.tradingview.com/u/traderharikrishna/
1,781
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © traderharikrishna //@version=5 indicator("RSITrend") [plus,minus,adx]=ta.dmi(14,14) sw=input.bool(true,'Highlight Ranging/Sideways') showbarcolor=input.bool(true,'Apply Barcolor') show_Baseline=input.bool(true,'Show Hull Trend') rsiLengthInput = input.int(14, minval=1, title="RSI Length1", group="RSI Settings") rsiLengthInput2 = input.int(28, minval=1, title="RSI Length2", group="RSI Settings") trendlen= input(title='Hull Trend Length', defval=30,group='Hull Trend') oversold=input.int(30, minval=1, title="Over Sold", group="RSI Settings") overbought=input.int(70, minval=1, title="Over Bought", group="RSI Settings") BBMC=ta.hma(close,trendlen) MHULL = BBMC[0] SHULL = BBMC[2] hmac=MHULL > SHULL ?color.new(#00c3ff , 0):color.new(#ff0062, 0) buysignal=MHULL > SHULL sellsignal=MHULL < SHULL frsi=ta.hma(ta.rsi(close,rsiLengthInput),10) srsi=ta.hma(ta.rsi(close,rsiLengthInput2),10) hullrsi1=ta.rsi(MHULL,rsiLengthInput) hullrsi2=ta.rsi(SHULL,rsiLengthInput) rsic=frsi>srsi?color.new(#00c3ff , 0):color.new(#ff0062, 0) barcolor(showbarcolor?hmac:na) hu1=plot(show_Baseline?hullrsi1:frsi,title='HMA1',color=color.gray,linewidth=1,display=display.none) hu2=plot(show_Baseline?hullrsi2:srsi,title='HMA2',color=color.gray,linewidth=1,display=display.none) fill(hu1,hu2,title='HULL RSI TREND',color=show_Baseline?hmac:rsic) fill(hu1,hu2,title='HULL with Sideways',color=sw and adx<20?color.gray:na) rsiUpperBand2 = hline(90, "RSI Upper Band(90)", color=color.red,linestyle=hline.style_dotted,display=display.none) rsiUpperBand = hline(overbought, "RSI Upper Band", color=color.red,linestyle=hline.style_dotted,display=display.none) fill(rsiUpperBand2,rsiUpperBand,title='Buy Zone',color=color.red,transp=80) hline(50, "RSI Middle Band", color=color.new(#787B86, 50),linestyle=hline.style_solid) rsiLowerBand = hline(oversold, "RSI Lower Band", color=color.green,linestyle=hline.style_dotted,display=display.none) rsiLowerBand2 = hline(10, "RSI Lower Band(10)", color=color.green,linestyle=hline.style_dotted,display=display.none) fill(rsiLowerBand,rsiLowerBand2,title='Sell Zone',color=color.green,transp=80) plotshape(buysignal and sellsignal[1] ?hullrsi1 :na, title='Buy', style=shape.triangleup, location=location.absolute, color=color.new(color.yellow, 0), size=size.tiny, offset=0) plotshape(sellsignal and buysignal[1] ?hullrsi1 :na, title='Sell', style=shape.triangledown, location=location.absolute, color=color.new(color.red, 0), size=size.tiny, offset=0) alertcondition(buysignal and sellsignal[1] ,title='RSI TREND:Buy Signal',message='RSI TREND: Buy Signal') alertcondition(sellsignal and buysignal[1],title='RSI TREND:Sell Signal',message='RSI TREND: Sell Signal')
MACD Divergences
https://www.tradingview.com/script/WAw80PoL-MACD-Divergences/
undershot
https://www.tradingview.com/u/undershot/
331
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © undershot // Free Trading Movement //@version=5 indicator("MACD Divergences", overlay=false) fast_length = input(title="Fast Length", defval=12) slow_length = input(title="Slow Length", defval=26) src = input(title="Source", defval=close) signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) [macd, macd_s, macd_h] = ta.macd(src, fast_length, slow_length, signal_length) col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD") col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal") col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above") col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above") col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below") col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below") plot(macd, title="MACD", color=col_macd) plot(macd_s, title="Signal", color=col_signal) plot(macd_h, title="Histogram", style=plot.style_columns, color=(macd_h>=0 ? (macd_h[1] < macd_h ? col_grow_above : col_fall_above) : (macd_h[1] < macd_h ? col_grow_below : col_fall_below))) bullish() => price_nearest = 99999.9 macd_nearest = 0.0 macd_nearest_idx = 0 price_furthest = 99999.9 macd_furthest = 0.0 macd_furthest_idx = 0 if (macd_h[1] < 0 and macd_h >= 0) or (macd_h[1] < 0 and barstate.islast) i = 1 if barstate.islast i := 0 while macd_h[i] < 0 price_nearest := math.min(low[i], price_nearest) macd_nearest := math.min(macd_h[i], macd_nearest) if macd_h[i] == macd_nearest macd_nearest_idx := i i += 1 while macd_h[i] >= 0 i += 1 while macd_h[i] < 0 price_furthest := math.min(low[i], price_furthest) macd_furthest := math.min(macd_h[i], macd_furthest) if macd_h[i] == macd_furthest macd_furthest_idx := i i += 1 divergence = 'none' if price_nearest > price_furthest == false and macd_nearest > macd_furthest == true divergence := 'classic' if price_nearest > price_furthest == true and macd_nearest > macd_furthest == false divergence := 'hidden' [divergence, macd_nearest_idx, macd_furthest_idx] bearish() => price_nearest = 0.0 macd_nearest = 0.0 macd_nearest_idx = 0 price_furthest = 0.0 macd_furthest = 0.0 macd_furthest_idx = 0 if (macd_h[1] > 0 and macd_h <= 0) or (macd_h[1] > 0 and barstate.islast) i = 1 if barstate.islast i := 0 while macd_h[i] > 0 price_nearest := math.max(high[i], price_nearest) macd_nearest := math.max(macd_h[i], macd_nearest) if macd_h[i] == macd_nearest macd_nearest_idx := i i += 1 while macd_h[i] <= 0 i += 1 while macd_h[i] > 0 price_furthest := math.max(high[i], price_furthest) macd_furthest := math.max(macd_h[i], macd_furthest) if macd_h[i] == macd_furthest macd_furthest_idx := i i += 1 divergence = 'none' if price_nearest > price_furthest == true and macd_nearest > macd_furthest == false divergence := 'classic' if price_nearest > price_furthest == false and macd_nearest > macd_furthest == true divergence := 'hidden' [divergence, macd_nearest_idx, macd_furthest_idx] [a_divergence, a_idx_1, a_idx_2] = bullish() if a_divergence == 'classic' line.new(x1=bar_index[a_idx_1], y1=macd_h[a_idx_1], x2=bar_index[a_idx_2], y2=macd_h[a_idx_2], color=color.green, width=1) label.new(bar_index[a_idx_2 - (a_idx_2 - a_idx_1)/2], math.max(macd_h[a_idx_1], macd_h[a_idx_2]) - (math.max(macd_h[a_idx_1], macd_h[a_idx_2]) - math.min(macd_h[a_idx_1], macd_h[a_idx_2])) / 2, color=color.green, style=label.style_label_up, text="Classic bullish", size=size.small) if a_divergence == 'hidden' line.new(x1=bar_index[a_idx_1], y1=macd_h[a_idx_1], x2=bar_index[a_idx_2], y2=macd_h[a_idx_2], color=color.red, width=1) label.new(bar_index[a_idx_2 - (a_idx_2 - a_idx_1)/2], math.max(macd_h[a_idx_1], macd_h[a_idx_2]) - (math.max(macd_h[a_idx_1], macd_h[a_idx_2]) - math.min(macd_h[a_idx_1], macd_h[a_idx_2])) / 2, color=color.red, style=label.style_label_up, text="Hidden bullish", size=size.small) [divergence, idx_1, idx_2] = bearish() if divergence == 'hidden' line.new(x1=bar_index[idx_1], y1=macd_h[idx_1], x2=bar_index[idx_2], y2=macd_h[idx_2], color=color.red, width=1) label.new(bar_index[idx_2 - (idx_2 - idx_1)/2], math.max(macd_h[idx_1], macd_h[idx_2]) - (math.max(macd_h[idx_1], macd_h[idx_2]) - math.min(macd_h[idx_1], macd_h[idx_2])) / 2, color=color.red, style=label.style_label_down, text="Hidden bearish", size=size.small) if divergence == 'classic' line.new(x1=bar_index[idx_1], y1=macd_h[idx_1], x2=bar_index[idx_2], y2=macd_h[idx_2], color=color.green, width=1) label.new(bar_index[idx_2 - (idx_2 - idx_1)/2], math.max(macd_h[idx_1], macd_h[idx_2]) - (math.max(macd_h[idx_1], macd_h[idx_2]) - math.min(macd_h[idx_1], macd_h[idx_2])) / 2, color=color.green, style=label.style_label_down, text="Classic bearish", size=size.small) alertcondition(barstate.islast and (macd_h >= 0 and macd_h[1] < 0) and a_divergence == 'classic', title='Classic bullish', message='Classic bullish MACD divergence') alertcondition(barstate.islast and (macd_h >= 0 and macd_h[1] < 0) and a_divergence == 'hidden', title='Hidden bullish', message='Hidden bullish MACD divergence') alertcondition(barstate.islast and (macd_h <= 0 and macd_h[1] > 0) and divergence == 'classic', title='Classic bearish', message='Classic bearish MACD divergence') alertcondition(barstate.islast and (macd_h <= 0 and macd_h[1] > 0) and divergence == 'hidden', title='Hidden bearish', message='Hidden bearish MACD divergence') alertcondition(barstate.islast and ((macd_h >= 0 and macd_h[1] < 0) or (macd_h <= 0 and macd_h[1] > 0)) and (a_divergence == 'classic' or a_divergence == 'hidden' or divergence == 'classic' or divergence == 'hidden'), title='Any divergence', message='MACD divergence')
CL PMA
https://www.tradingview.com/script/Bmgn1fLz-CL-PMA/
Mreg36
https://www.tradingview.com/u/Mreg36/
32
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mreg36 //@version=5 plot(close) indicator("CL PMA", overlay=true) sma1_period = input(title="SMA1 Period", defval=14) sma2_period = input(title="SMA2 Period", defval=30) sma3_period = input(title="SMA3 Period", defval=50) sma1 = ta.sma(hlc3, sma1_period) sma2 = ta.sma(hlc3, sma2_period) sma3 = ta.sma(hlc3, sma3_period) colors1 = color.orange colors2 = color.blue colors3 = color.green sma1_plot = plot(sma1, color=colors1) sma2_plot = plot(sma2, color=colors2) sma3_plot = plot(sma3, color=colors3)
Digital Nivesh: Trend Tracker
https://www.tradingview.com/script/AN5Wcym5-Digital-Nivesh-Trend-Tracker/
digitalnivesh
https://www.tradingview.com/u/digitalnivesh/
125
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © digitalnivesh //@version=4 study("Trend Tracker", shorttitle="TM", overlay=true, format=format.price, precision=2, resolution="") shortTf = input(defval="3",type=input.resolution) AP=input(5,"ATR Period") tr1 = security(syminfo.tickerid, shortTf, sma(tr,AP)) close1 = security(syminfo.tickerid, shortTf, close) low1 = security(syminfo.tickerid, shortTf, low) high1 = security(syminfo.tickerid, shortTf, high) period=input(20,"CCI period") coeff=input(1,"ATR Multiplier") ATR=sma(tr1,AP) rMT = input(title="Resolution", type=input.resolution, defval="5") src=close1//input(close) upT=low1-ATR*coeff downT=high1+ATR*coeff MagicTrend=0.0 MagicTrend := cci(src,period)>=0 ? (upT<nz(MagicTrend[1]) ? nz(MagicTrend[1]) : upT) : (downT>nz(MagicTrend[1]) ? nz(MagicTrend[1]) : downT) color1= cci(src,period)>=0 ? #0022FC : #FC0400 buySignalFirst = crossover(close1,MagicTrend) sellSignalFirst = crossunder(close1,MagicTrend) plot(MagicTrend, color=color1, linewidth=3) // SECOND INDICATOR Periods = input(title="ATR Period", type=input.integer, defval=10) srcSecond = input(hl2, title="Source") Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true) showsignals = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true) highlighting = input(title="Highlighter On/Off ?", type=input.bool, defval=true) atr2 = sma(tr, Periods) atr= changeATR ? atr(Periods) : atr2 up=srcSecond-(Multiplier*atr) up1 = nz(up[1],up) up := close[1] > up1 ? max(up,up1) : up dn=srcSecond+(Multiplier*atr) dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green) buySignal = trend == 1 and trend[1] == -1 dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red) sellSignal = trend == -1 and trend[1] == 1 mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) longFillColor = highlighting ? (trend == 1 ? color.green : color.white) : color.white shortFillColor = highlighting ? (trend == -1 ? color.red : color.white) : color.white fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor) fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor) plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) //plotshape(buySignalFirst and showsignals ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) //plotshape(sellSignalFirst and showsignals ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0)
[FFriZz]Priceline/Ticks
https://www.tradingview.com/script/AjkMsCRw-FFriZz-Priceline-Ticks/
FFriZz
https://www.tradingview.com/u/FFriZz/
94
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla PublicBull License 2.0 at https://mozilla.org/MPL/2.0/ // © FFriZz //@version=5 indicator('[FFriZz]Priceline/Ticks',overlay = true,max_labels_count = 500,max_lines_count = 500) import FFriZz/BoxLine_Lib/8 as XY //inputs// bool usePriceLine = input.bool(true ,'Price Line?',group = 'On/Off') bool usePriceLabel = input.bool(true ,'Chart Label?',group = 'On/Off') bool usePriceTick = input.bool(true ,'Ticks?',group = 'On/Off') bool useTable = input.bool(true ,'Table?',group = 'On/Off') bool useReverse = input.bool(false ,'Reverse Table?',group = 'On/Off') bool useBoxes = input.bool(true ,'S/R Boxes?',group = 'On/Off') // debug = input.bool(true ,'Table?',group = 'On/Off') bool lineColorChange = input.bool(false ,'Change Price Line Colors?',group = 'Price line',inline = 'f',tooltip = 'Defaults to Up Color') color colorUp = input.color(#000000,'Up',group = 'Price line',inline = 'f') color colorDown = input.color(#ff0000,'Down',group = 'Price line',inline = 'f') string extend = input.string('Extend Both','Extend Price line',options = ['Extend Both','Extend None','Extend Right','Extend Left'],group = 'Price line', inline = 'a') int pLineWidth = input.int(1,'Width',group = 'Price line',inline = 'b') string lineStyle = input.string('Dashed','Price line Style',options = ['Solid','Dashed','Dotted','Arrow Right','Arrow Left','Arrow Both'],group = 'Price line', inline = 'c') bool labelPriceColorChange = input.bool(false ,'Change Label Price Colors?',group = 'Price label',inline = 'g',tooltip = 'Defaults to Up Color') color textColorUp = input.color(#000000,'Up',group = 'Price label',inline = 'g') color textColorDown = input.color(#ff0000,'Down',group = 'Price label',inline = 'g') string labelSize = input.string('Normal','label Size',options = ['Auto','Tiny','Small','Normal','Large','Huge'],group = 'Price label', inline = 'e') bool labelTickColorChange = input.bool(true ,'Change Tick Colors?',group = 'Ticks',inline = 'c',tooltip = 'Defaults to Up Color') color priceTickColorUp = input.color(#008000,'Up',group = 'Ticks',inline = 'c') color priceTickColorDown = input.color(#ff0000,'Down',group = 'Ticks',inline = 'c') color boxColorUp = input.color(#00800062,'Up',group = 'Ticks',inline = 'c') color boxColorDown = input.color(#ff00004f,'Down',group = 'Ticks',inline = 'c') int offset = input.int(0,'Offset',group = 'Adjustments', inline = '') int count = input.int(30,'Tick Display Count',group = 'Adjustments',inline = '',minval = 0) int displayBull = input.int(30,'Bull Box Count',group = 'Adjustments',inline = '',minval = 0) int displayBear = input.int(30,'Bear Box Count',group = 'Adjustments',inline = '',minval = 0) //Single Colors// if labelTickColorChange == false priceTickColorDown := priceTickColorUp if labelPriceColorChange == false textColorDown := textColorUp if lineColorChange == false colorDown := colorUp //Switches//{ LineStyle = switch lineStyle 'Solid' => line.style_solid 'Dashed' => line.style_dashed 'Dotted' => line.style_dotted 'Arrow Right' => line.style_arrow_right 'Arrow Left' => line.style_arrow_left 'Arrow Both' => line.style_arrow_both => na Extend = switch extend 'Extend Both' => extend.both 'Extend None' => extend.none 'Extend Right' => extend.right 'Extend Left' => extend.left => na LabelSize = size.large TickSize = size.small switch labelSize 'Tiny' => LabelSize := size.tiny, TickSize := size.tiny 'Small' => LabelSize := size.small, TickSize := size.tiny 'Normal' => LabelSize := size.normal, TickSize := size.small 'Large' => LabelSize := size.large, TickSize := size.normal 'Huge' => LabelSize := size.huge, TickSize := size.normal 'Auto' => LabelSize := size.auto, TickSize := size.auto => na //} //Vars// string mt = str.tostring(syminfo.mintick) string zeros = '0.' while str.length(zeros) < str.length(mt) zeros += '0' varip string[] aTrackUp = array.new_string() varip string[] aTrackDn = array.new_string() int bt = time_close - time varip bool vIP = na varip int ip = 0 varip float ipClose = na bool upcBull = close > open varip aSizeBull = 0 varip aSizeBear = 0 varip trackMovementsUp = 0.0 varip trackMovementsDn = 0.0 // varip debuggerBull = '', varip debuggerBear = '' //ifs// if barstate.islast varip float[] aFVGbullTop = array.new<float>() varip float[] aFVGbullBot = array.new<float>() varip float[] aFVGbearTop = array.new<float>() varip float[] aFVGbearBot = array.new<float>() var box[] aBullBox = array.new<box>() var box[] aBearBox = array.new<box>() varip float[] aOrderUp = array.new<float>() varip float[] aOrderDn = array.new<float>() varip volUp = 0.0 varip volDn = 0.0 varip volDiff = 0.0 varip float volSave = na if volume < volSave volSave := 0 volDn := 0 volUp := 0 varip cBull = 0.0 varip cBull2 = 0.0 varip cBull3 = 0.0 varip BullS = 0 varip cBear = 0.0 varip cBear2 = 0.0 varip cBear3 = 0.0 varip BearS = 0 if na(volSave) volSave := volume if ipClose != close if ipClose > close array.push(aTrackDn,str.tostring(close - ipClose,zeros) + '\n') array.push(aTrackUp,'\n') trackMovementsDn += math.abs(close - ipClose) volDn += volume - volSave if array.size(aTrackUp) > count array.shift(aTrackUp) if array.size(aTrackDn) > count array.shift(aTrackDn) ip := -1 if ipClose < close array.push(aTrackUp,'+' + str.tostring(close - ipClose,zeros) + '\n') array.push(aTrackDn,'\n') trackMovementsUp += math.abs(close - ipClose) volUp += volume - volSave if array.size(aTrackUp) > count array.shift(aTrackUp) if array.size(aTrackDn) > count array.shift(aTrackDn) ip := 1 if volume > volSave if close == ipClose if ip < 0 array.push(aTrackDn,'▼\n') array.push(aTrackUp,'\n') volDn += volume - volSave if ip > 0 array.push(aTrackUp,'▲\n') array.push(aTrackDn,'\n') volUp += volume - volSave if array.size(aTrackUp) > count array.shift(aTrackUp) if array.size(aTrackDn) > count array.shift(aTrackDn) if useBoxes //Bull Tick FVGs{ if close > ipClose and BullS == 0 cBull := close cBull2 := ipClose BullS := 1 if close < cBull and BullS == 1 cBull3 := cBull2 cBull2 := cBull cBull := close BullS := 2 else if close > cBull and BullS == 1 BullS := 0 if close < cBull2 and close > cBull3 and BullS == 2 cBull := close if close < cBull3 and BullS == 2 BullS := 0 if close > cBull2 and BullS == 2 cBull3 := cBull2 cBull2 := cBull cBull := close BullS := 3 if close > cBull3 and BullS == 3 if close < cBull and close > cBull3 cBull2 := cBull cBull := close BullS := 4 else cBull := close if close < cBull3 and (BullS == 4 or BullS == 3) BullS := 0 if close > cBull3 and close < cBull and BullS == 4 cBull := close if close > cBull and BullS == 4 array.unshift(aFVGbullTop,cBull) array.unshift(aFVGbullBot,cBull3) array.unshift(aOrderUp,volUp) // oLabelBull = label.new(time, math.avg(cBull2,array.get(aFVGbull,0)),text = str.tostring(volUp-array.get(aOrderUp,0),'0.000'),xloc = xloc.bar_time, // color = color(na), style = label.style_label_center, textcolor = priceTickColorUp, size = size.auto) BullS := 0 //} //Bear Tick FVGs{ if close < ipClose and BearS == 0 cBear := close cBear2 := ipClose BearS := 1 if close > cBear and BearS == 1 cBear3 := cBear2 cBear2 := cBear cBear := close BearS := 2 else if close < cBear and BearS == 1 BearS := 0 if close > cBear2 and close < cBear3 and BearS == 2 cBear := close if close > cBear3 and BearS == 2 BearS := 0 if close < cBear2 and BearS == 2 cBear3 := cBear2 cBear2 := cBear cBear := close BearS := 3 if close < cBear3 and BearS == 3 if close > cBear and close < cBear3 cBear2 := cBear cBear := close BearS := 4 else cBear := close if close > cBear3 and (BearS == 4 or BearS == 3) BearS := 0 if close < cBear3 and close > cBear and BearS == 4 cBear := close if close < cBear and BearS == 4 array.unshift(aFVGbearTop,cBear3) array.unshift(aFVGbearBot,cBear) array.unshift(aOrderDn,volDn) // oLabelBear = label.new(time, math.avg(cBear2,array.get(aFVGbear,0)),text = '\n' + str.tostring(volDn-array.get(aOrderDn,0),'0.000'),xloc = xloc.bar_time, // color = color(na), style = label.style_label_center, textcolor = priceTickColorDown, size = size.auto) BearS := 0 // atr = ta.atr(1000) // if barstate.islast // var label lbl = na, label.delete(lbl) // lbl := label.new(bar_index + 50, high,'Bear:'+str.tostring(BearS)+'\nBull:'+str.tostring(BullS)) //} volSave := volume //Line Edits if array.size(aFVGbullTop) > displayBull array.pop(aFVGbullTop), array.pop(aFVGbullBot) if array.size(aFVGbearTop) > displayBear array.pop(aFVGbearTop), array.pop(aFVGbearBot) if array.size(aBullBox) > 0 for i = array.size(aBullBox) - 1 to 0 box.delete(array.remove(aBullBox,i)) if array.size(aFVGbullTop) > 0 for i = array.size(aFVGbullTop) - 1 to 0 top = array.get(aFVGbullTop,i) bot = array.get(aFVGbullBot,i) BullBox = box.new(time - bt,top,last_bar_time + bt + bt,bot,xloc = xloc.bar_time,border_color = boxColorUp,bgcolor = boxColorUp) array.unshift(aBullBox,BullBox) // BullBox = line.new(time - bt,y,last_bar_time + bt + bt,y,xloc = xloc.bar_time,color = priceTickColorUp, width = 1) // array.unshift(aBullBox,BullLine) aSizeBull := array.size(aBullBox) if aSizeBull > 0 for i = aSizeBull - 1 to 0 BullBox = array.get(aBullBox,i) [_,top,_,bottom] = XY.BoxXY(BullBox) if close < top box.set_top(BullBox,close) if array.size(aFVGbullTop) > 0 array.set(aFVGbullTop,i,close) if close < bottom box.delete(array.get(aBullBox,i)) array.remove(aFVGbullTop,i), array.remove(aFVGbullBot,i) if array.size(aBearBox) > 0 for i = array.size(aBearBox) - 1 to 0 box.delete(array.remove(aBearBox,i)) if array.size(aFVGbearTop) > 0 for i = array.size(aFVGbearTop) - 1 to 0 top = array.get(aFVGbearTop,i) bot = array.get(aFVGbearBot,i) BearBox = box.new(time - bt,top,last_bar_time + bt + bt,bot,xloc = xloc.bar_time,border_color = boxColorDown,bgcolor = boxColorDown) array.unshift(aBearBox,BearBox) // BullBox = line.new(time - bt,y,last_bar_time + bt + bt,y,xloc = xloc.bar_time,color = priceTickColorUp, width = 1) // array.unshift(aBearBox,BullLine) aSizeBear := array.size(aBearBox) if aSizeBear > 0 for i = aSizeBear - 1 to 0 BearBox = array.get(aBearBox,i) [_,top,_,bottom] = XY.BoxXY(BearBox) if close > bottom box.set_bottom(BearBox,close) if array.size(aFVGbearBot) > 0 array.set(aFVGbearBot,i,close) if close > top box.delete(array.get(aBearBox,i)) array.remove(aFVGbearTop,i), array.remove(aFVGbearBot,i) //Debuggers{ // debuggerBear := str.tostring(array.size(aBearBox)) // debuggerBear += ' ' + str.tostring(array.size(aFVGbear)) // debuggerBull := str.tostring(array.size(aBullBox)) // debuggerBull += ' ' + str.tostring(array.size(aFVGbull)) //} //} ipClose := close priceCount = close - open pricePerc = math.abs(100 - ((close / open) * 100)) //Color Switches//{ if labelPriceColorChange or lineColorChange vIP := ip > 0 color lineColor = lineColorChange ? vIP ? colorUp : colorDown : upcBull ? colorUp : colorDown color priceColor = labelPriceColorChange ? vIP ? textColorUp : textColorDown : upcBull ? textColorUp : textColorDown //} int x = last_bar_time + ((10 + offset) * bt) //Lines and Labels// if usePriceLabel var label label = na, label.delete(label) label := label.new(x, close,xloc = xloc.bar_time, text = str.tostring(close,zeros), color = chart.bg_color, style = label.style_text_outline, textcolor = priceColor, size = LabelSize) var label labelVUp = na, label.delete(labelVUp) labelVUp := label.new(x, close, xloc = xloc.bar_time, text = (volUp > volDn and close < open ? 'D ' : '') + '+' + str.tostring(volUp) + ' | +'+str.tostring(trackMovementsUp), color = color(na), style = label.style_label_up, textcolor = priceTickColorUp, size = TickSize) var label labelC = na, label.delete(labelC) labelC := label.new(x, close, xloc = xloc.bar_time, text = (priceCount > 0 ? '\n+' : '\n') + str.tostring(priceCount) + ' | ' + (priceCount > 0 ? '+' : '-') + str.tostring(pricePerc,'0.00') + '%', color = color(na), style = label.style_label_up, textcolor = priceCount > 0 ? priceTickColorUp : priceCount < 0 ? priceTickColorDown : #000000, size = TickSize) var label labelVDn = na, label.delete(labelVDn) labelVDn := label.new(x, close, xloc = xloc.bar_time, text = (volUp < volDn and close > open ? '\n\nD -' : '\n\n-') + str.tostring(volDn) + ' | -' + str.tostring(trackMovementsDn), color = color(na), style = label.style_label_up, textcolor = priceTickColorDown, size = TickSize) if usePriceTick var label labelUP = na, label.delete(labelUP) labelUP := label.new(x, close,xloc = xloc.bar_time, text = '' + array.join(aTrackUp,''), color = color(na), style = label.style_none, textcolor = priceTickColorUp, size = TickSize) var label labelDN = na, label.delete(labelDN) labelDN := label.new(x, close,xloc = xloc.bar_time, text = '' + array.join(aTrackDn,''), color = color(na), style = label.style_none, textcolor = priceTickColorDown, size = TickSize) if usePriceLine var line line = na, line.delete(line) line := line.new(bar_index, close, 10 + bar_index + offset, close, extend = Extend, color = lineColor, style = LineStyle, width = pLineWidth) if useTable var table Tbl = table.new(position.middle_right,columns = 1,rows = 5, bgcolor = color(na), frame_color = #00000000, frame_width = 1,border_color = #00000000,border_width = 1) strDN = str.replace_all(array.join(str.split(str.replace_all(array.join(useReverse ? aTrackUp : aTrackDn,''),'\n',' '),' '),'\n'),' ','') DN = str.length(strDN) table.cell(Tbl,0,0,strDN,0,0,text_color = useReverse ? priceTickColorUp : priceTickColorDown, bgcolor = color(na),text_size = TickSize) table.cell(Tbl,0,useReverse ? 3 : 1,(volUp < volDn and close > open ? 'D -' : '-') + str.tostring(volDn),0,2, text_color = priceTickColorDown,bgcolor = color(na),text_size = TickSize) table.cell(Tbl,0,2,str.tostring(close,zeros),0,2,text_color = chart.fg_color, bgcolor = color(na),text_size = TickSize) table.cell(Tbl,0,useReverse ? 1 : 3,(volUp > volDn and close < open ? 'D +' : '+') + str.tostring(volUp),0,2, text_color = priceTickColorUp,bgcolor = color(na),text_size = TickSize) array.reverse(useReverse ? aTrackDn : aTrackUp) strUP = str.replace_all(array.join(str.split(str.replace_all(array.join(useReverse ? aTrackDn : aTrackUp,''),'\n',' '),' '),'\n'),' ','') UP = str.length(strUP) table.cell(Tbl,0,4,strUP,0,0,text_color = useReverse ? priceTickColorDown : priceTickColorUp, bgcolor = color(na),text_size = TickSize) array.reverse(useReverse ? aTrackDn : aTrackUp) //DebuggerTable{ // if debug // table.cell(Tbl,0,1, // 'LineAll = ' + str.tostring(array.size(line.all)) + '\n' + // 'BullS = ' + str.tostring(BullS) + // '\ncBull = ' + str.tostring(cBull) + // '\ncBull2 = ' + str.tostring(cBull2) + // '\ncBull3 = ' + str.tostring(cBull3) + '\n' + // BullCon + // '\nBull FVG Confirm = ' + str.tostring(BullBoxCount) + // '\naSizeBull = ' + str.tostring(aSizeBull) + // '\n-------------------\n' + // debuggerBull + // '\n-------------------\nBearS = ' + str.tostring(BearS) + // '\ncBear = ' + str.tostring(cBear) + // '\ncBear2 = ' + str.tostring(cBear2) + // '\ncBear3 = ' + str.tostring(cBear3) + '\n' + // BearCon + '\nBear FVG Confirm = ' + str.tostring(BearBoxCount) + // '\naSizeBear = ' + str.tostring(aSizeBear) + // '\n-------------------\n' + // debuggerBear, // text_halign = text.align_left,text_color = #00ff00,bgcolor = lColor,text_size = size.small) //}
Interactive trendline
https://www.tradingview.com/script/NePmdKgG-Interactive-trendline/
Blockhead305
https://www.tradingview.com/u/Blockhead305/
399
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Blockhead305 //@version=5 indicator("Interactive trendline", overlay = true) x_1 = input.time(defval = 1, title = "X 1", confirm = true) y_1 = input.price(defval = 1, title = "Y 1", confirm = true) x_2 = input.time(defval = 1, title = "X 2", confirm = true) y_2 = input.price(defval = 1, title = "Y 2", confirm = true) run_input = input.int(defval=0, title="run") extend = input.bool(true, title="extnd trendline") var int bar_index_x_1_table = 0 var int bar_index_x_2_table = 0 if time == x_1 bar_index_x_1_table := bar_index if time == x_2 bar_index_x_2_table := bar_index rise = (math.max(y_1, y_2) - math.min(y_1, y_2)) slope = rise / run_input var float plot_line = na var int bar_count = 0 if time == x_1 and barstate.isconfirmed plot_line := y_1 if time > x_1 if y_2 > y_1 plot_line := plot_line + slope else plot_line := plot_line - slope if time <= x_2 bar_count += 1 if time > x_2 and extend == false plot_line := na plot(run_input != 0 ? plot_line : na) if barstate.isconfirmed var table3 = table.new(position = position.top_right, columns = 30, rows = 30, bgcolor = color.yellow, border_width = 1) table.cell(table_id = table3, column = 0, row = 2, text = "run") table.cell(table_id = table3, column = 1, row = 2, text = str.tostring(bar_index_x_2_table - bar_index_x_1_table))
SUPRES
https://www.tradingview.com/script/wk9qQd9Y-SUPRES/
shakibsharifian
https://www.tradingview.com/u/shakibsharifian/
45
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shakibsharifian //@version=5 indicator("SUPRES") roundDec(val,dec)=> ret=math.pow(10,-dec)*(int(val*math.pow(10,dec))) gaussianMEAN(src,length)=> float sum=0 for int _i=0 to length-1 sum:=sum+src[_i] _mean=sum/length sum:=0 for int _i=0 to length-1 sum:=sum+(math.pow((_mean-src[_i]),2)) _variance=sum/length _std=math.sqrt(_variance) sum:=0 float coefSum=0 for int _i=0 to length-1 _coef=(1/(_std*math.sqrt(2*3.1415)))*math.exp(-.5*math.pow(((src[_i]-_mean)/_std),2)) sum:=sum+(_coef*src[_i]) coefSum:=coefSum+_coef _gaussMean=sum/coefSum _gaussMean bcwsma(s,l,m) => _bcwsma=0.00, _bcwsma:= (m*s+(l-m)*nz(_bcwsma[1]))/l, _bcwsma myKDJ(param,fast,ma1,ma2) => h = ta.highest(high, fast) l = ta.lowest(low,fast) RSV = 100*((param-l)/(h-l)) pK = bcwsma(RSV, ma1, 1) pD = bcwsma(pK, ma2, 1) pJ = 3 * pK-2 * pD [pD,pJ] //plot(close,color=color.white,linewidth=2) txtOpt1="Auto" txtOpt2="Tiny" txtOpt3="Small" txtOpt4="Normal" txtOpt5="Large" bk = input.int(30, minval=1, title='BACKWARD',group='SUPPORT/RESISTANCE (SUPRES)',inline='a') memory = input.int(2, minval=1, title='MEMORY',group='SUPPORT/RESISTANCE (SUPRES)',inline='a') LONG = input.int(9, minval=1, title='LENGTH', group='SUPER TREND', inline='k') ma1 = input.int(3, minval=1, title='MA', group='SUPER TREND', inline='k') colTP = input.color(color.purple,title='RISING',group='SUPER TREND',inline='a') colBT = input.color(color.yellow,title='FALLING',group='SUPER TREND',inline='a') src = input.source(close, title='SOURCE',group='T.O',inline='a') dec = input.int(2, title='DECIMAL T.O',group='T.O',inline='a') colTO = input.color(color.new(#ed37db,0),title='',group='T.O',inline='a') string listSize = input.string('Auto',title='TEXT SIZE',options=[txtOpt1,txtOpt2,txtOpt3,txtOpt4,txtOpt5],group='LIST',inline='a') lstSz = switch listSize txtOpt1 => size.auto txtOpt2 => size.tiny txtOpt3 => size.small txtOpt4 => size.normal txtOpt5 => size.large Lkdj = input.int(21, minval=1, title='LENGTH', group='KDJ', inline='k') ma1kdj = input.int(8, minval=1, title='MA1', group='KDJ', inline='k') ma2kdj = input.int(8, minval=1, title='MA2', group='KDJ', inline='k') [_pD,_pJ]=myKDJ(src,Lkdj,ma1kdj,ma2kdj) red_volArr=array.new<float>() green_volArr=array.new<float>() red_PrcArr=array.new<float>() green_PrcArr=array.new<float>() for _i=0 to bk if close[_i]>open[_i] array.push(green_volArr,volume[_i]) array.push(green_PrcArr,math.min(open[_i],close[_i])) else array.push(red_volArr,volume[_i]) array.push(red_PrcArr,math.max(open[_i],close[_i])) redInd=array.sort_indices(red_volArr,order.descending) greenInd=array.sort_indices(green_volArr,order.descending) sliceSup=array.new<float>() sliceRes=array.new<float>() var ag = array.new_line() var ar = array.new_line() if array.size(redInd)>memory and array.size(greenInd)>memory for _k=0 to memory-1 array.push(ag, line.new(bar_index - 1, array.get(green_PrcArr,array.get(greenInd,_k)), bar_index, array.get(green_PrcArr,array.get(greenInd,_k)),extend=extend.right,color=color.aqua)) array.push(ar, line.new(bar_index - 1, array.get(red_PrcArr,array.get(redInd,_k)), bar_index, array.get(red_PrcArr,array.get(redInd,_k)),extend=extend.right,color=color.red)) array.push(sliceSup,array.get(green_PrcArr,array.get(greenInd,_k))) array.push(sliceRes,array.get(red_PrcArr,array.get(redInd,_k))) if array.size(ar) > memory ln = array.shift(ar) line.delete(ln) if array.size(ag) > memory ln = array.shift(ag) line.delete(ln) //SUPER TREND [supertrend, direction] = ta.supertrend(ma1, LONG) stCol=direction <0 ? colTP:colBT stTxtCol=direction <0 ? color.white:color.black plot(direction < 0 ? supertrend : na, "Up direction", color = stCol, style=plot.style_linebr,linewidth=3) plot(direction > 0 ? supertrend : na, "Down direction", color = stCol, style=plot.style_linebr,linewidth=3) stLbl=label.new(bar_index,supertrend,text=str.substring(str.tostring(supertrend),0,8),style=label.style_label_left,size=size.normal,color=stCol,textcolor=stTxtCol) label.delete(stLbl[1]) //T.O Line ausw=ta.rma(gaussianMEAN(gaussianMEAN(src,bk),bk),bk) plot(ausw,color=colTO,linewidth=4,title='T.O Line') //TABLE array.sort(sliceSup,order.ascending) array.sort(sliceRes,order.ascending) prcArr=array.from(src,roundDec(ausw,dec),roundDec(supertrend,dec)) array.concat(prcArr,sliceSup) array.concat(prcArr,sliceRes) colArr=array.from(color.white,colTO,stCol) for int ii=0 to array.size(sliceSup)-1 array.push(colArr,color.aqua) for int ii=0 to array.size(sliceRes)-1 array.push(colArr,color.red) indSrt=array.sort_indices(prcArr,order.descending) var t = table.new(position.middle_right, 2,(memory*2)+5, color.olive) table.cell(t,1, 0,'PRICE',bgcolor=color.new(color.black,0),text_color=color.yellow,text_size=lstSz) table.cell(t,0, 0,'KDJ',bgcolor=0.97*_pJ>_pD?color.new(color.green,0):color.new(color.red,0),text_color=color.black,text_size=lstSz,width=0.5) for int _l=0 to array.size(prcArr)-1 table.cell(t,1, _l+1, str.tostring(array.get(prcArr,array.get(indSrt,_l))),bgcolor=color.new(color.black,0),text_color=array.get(colArr,array.get(indSrt,_l)),text_size=lstSz) table.cell(t,0, _l+1, '',bgcolor=array.get(colArr,array.get(indSrt,_l)),text_color=color.black,text_size=lstSz) array.clear(ar) array.clear(ag) array.clear(sliceSup) array.clear(sliceRes)
Divergence MACD Sign/Alert [MsF]
https://www.tradingview.com/script/NdEKo2ja/
Trader_Morry
https://www.tradingview.com/u/Trader_Morry/
477
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Trader_Morry //@version=4 study(title="Divergence MACD Sign/Alert [MsF]", shorttitle = "DiverMACD_A", format=format.price, overlay=false) //MACD setting src = close fast = input(12) slow = input(26) smooth = input(9) osctype = input(title="Osc Type", type=input.string, defval="MACD", options=["MACD", "SIGNAL", "HISTOGRAM"]) //lbR = input(title="Pivot Lookback Right", defval=8) //lbL = input(title="Pivot Lookback Left", defval=8) lbR = input(title="Lookback Bars", defval=8) lbL = lbR //rangeUpper = input(title="Max of Lookback Range", defval=60) //rangeLower = input(title="Min of Lookback Range", defval=5) rangeUpper = 60 rangeLower = 5 plotBull = input(title="Plot Bullish", defval=true) plotHiddenBull = input(title="Plot Hidden Bullish", defval=true) plotBear = input(title="Plot Bearish", defval=true) plotHiddenBear = input(title="Plot Hidden Bearish", defval=true) bearColor = color.red bullColor = color.navy hiddenBullColor = color.new(color.yellow,50) hiddenBearColor = color.new(color.yellow,50) textColor = color.white noneColor = color.new(color.white, 100) fast_ma = ema(src, fast) slow_ma = ema(src, slow) macd = fast_ma-slow_ma signal = ema(macd, smooth) hist = macd - signal osc = osctype=="MACD" ? macd : (osctype=="SIGNAL" ? signal : hist) //plot(osc, title="macd", linewidth=2, color=color.aqua) //plot(macd, title="macd", linewidth=2, color=color.aqua) plot(osc, color=color.aqua) //plot(hist, style=plot.style_histogram) plFound = na(pivotlow(osc, lbL, lbR)) ? false : true phFound = na(pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) => bars = barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Lower Low priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=2, color=(bullCond ? bullColor : noneColor), transp=0 ) plotshape( bullCond ? osc[lbR] : na, offset=-lbR, title="Regular Bullish Label", text="D", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, transp=0 ) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Higher Low priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond ? hiddenBullColor : noneColor), transp=0 ) plotshape( hiddenBullCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text="H", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, transp=0 ) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? bearColor : noneColor), transp=0 ) plotshape( bearCond ? osc[lbR] : na, offset=-lbR, title="Regular Bearish Label", text="D", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor, transp=0 ) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Lower High priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? hiddenBearColor : noneColor), transp=0 ) plotshape( hiddenBearCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish Label", text="H", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor, transp=0 ) //------------------------------------------------------------------------------ // ALERT alertcondition(bullCond or hiddenBullCond, title="bull_alert", message="↑ {{interval}} Bullish sign appered!! by MACD divergence") alertcondition(bearCond or hiddenBearCond, title="bear_alert", message="↓ {{interval}} Bearish sign appered!! by MACD divergence")
Inside Bar Highlight
https://www.tradingview.com/script/qNuUGrGX-Inside-Bar-Highlight/
HLongTran
https://www.tradingview.com/u/HLongTran/
158
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HLong Tran //@version=4 study("Inside Bar Highlight", overlay = true, max_boxes_count = 500) ZoneColor = input(defval = color.new(color.orange, 80), title = "Background Color") BorderColor = input(defval = color.new(color.orange, 80), title = "Border Color") var aCZ = array.new_float(0) float highest = high[1] float lowest = low[1] if (array.size(aCZ) > 0) highest := array.get(aCZ, 0) lowest := array.get(aCZ, 1) insideBarCondtion = low >= lowest and low <= highest and high >= lowest and high <= highest if ( insideBarCondtion == true ) array.push(aCZ, high[1]) array.push(aCZ, low[1]) if( array.size(aCZ) >= 2 and insideBarCondtion == false ) float maxCZ = array.max(aCZ) float minCZ = array.min(aCZ) box.new(bar_index - (array.size(aCZ) / 2) - 1, maxCZ, bar_index - 1, minCZ, bgcolor = ZoneColor, border_color = BorderColor) array.clear(aCZ)
[GTH] Net Profit Margin (%)
https://www.tradingview.com/script/6MQglchP-GTH-Net-Profit-Margin/
gehteha
https://www.tradingview.com/u/gehteha/
43
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © gehteha //@version=5 indicator(title="[GTH] Net Profit Margin (%)", overlay=false) np = request.financial(syminfo.tickerid, "NET_MARGIN", "FQ") col_p = input.color(title="Positive", defval=color.green, group="Coloring") col_n = input.color(title="Negative", defval=color.red, group="Coloring") col_p_l = input.color(title="Postive Shade", defval=color.rgb(0, 182, 6, 88)) col_n_l = input.color(title="Negative Shade", defval=color.rgb(255, 73, 73, 79)) col_line = input.color(title="Line", defval=color.black, group="Coloring") r1 = np>0 ? 0 : np r2 = np>0 ? np : 0 col = np>0 ? col_p : col_n col_l = np>0 ? col_p_l : col_n_l p1 = plot(np, title="Net Profit Margin", color=col, linewidth=3, style = plot.style_stepline) p2 = plot(0, title="Shade", color=col_l, linewidth=1, style = plot.style_stepline, display = display.none) fill(p1, p2, title="Shade", color=col_l) float diff = np-np[1] perc = np != np[1] ? (np/np[1])-1 : na string form=str.replace(str.tostring(str.format("{0,number,percent}", math.abs(perc))), ",","",0) plot_perc = np != np[1] ? true : false if plot_perc label.new(bar_index, np, form, color = diff>0 ? col_p : col_n, style = diff>0 ? label.style_label_down : label.style_label_up, textcolor=color.white) hline(0, title="Zero Line", color=color.black, linewidth=1, linestyle=hline.style_solid)
TradingCube : Moving Average : Data table
https://www.tradingview.com/script/LKoTfSN8-TradingCube-Moving-Average-Data-table/
tradingcube
https://www.tradingview.com/u/tradingcube/
91
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tradingcube //@version=5 indicator(title='TradingCube : Moving Average : Data table', shorttitle='Moving Average : Data table', overlay=true, precision=1) htf_tf = input.string('Auto', 'Table Timeframe', options=['Auto', '5 Min','10 Min', '15 Min', '1 Hour', '4 Hour', 'Daily', 'Weekly', 'Monthly', 'Quarterly', 'Yearly']) htf = htf_tf == '5 Min' ? '5' : htf_tf == '10 Min' ? '10' : htf_tf == '15 Min' ? '15' : htf_tf == '1 Hour' ? '60' : htf_tf == '4 Hour' ? '240' : htf_tf == 'Daily' ? 'D' : htf_tf == 'Weekly' ? 'W' : htf_tf == 'Monthly' ? 'M' : htf_tf == 'Quarterly' ? '3M' : htf_tf == 'Yearly' ? '12M' : timeframe.isintraday and (timeframe.period == '1' or timeframe.period == '3' or timeframe.period == '5' or timeframe.period == '15') ? 'D' : timeframe.isintraday and (timeframe.period == '30' or timeframe.period == '45' or timeframe.period == '60' or timeframe.period == '120' or timeframe.period == '180' or timeframe.period == '240') ? 'W' : timeframe.isdaily ? 'M' : timeframe.isweekly or timeframe.ismonthly ? '12M' : '3M' timeFrameD = htf source = request.security(syminfo.tickerid, timeFrameD, close, lookahead=barmerge.lookahead_on) ema_enable = input.bool(title='Enable EMA [* Default is SMA]', defval=false) moving_avg = array.new_int(0, 0) moving_avg_data = array.new_float(0, 0.0) moving_avg_show = array.new_bool(0, false) ma_1_show = input.bool(title='', defval=true, inline='cell_1') ma_1 = input.int(title="Data Cell 1", defval=5, inline='cell_1') ma_1_data = ema_enable ? ta.ema(source, ma_1) : ta.sma(source, ma_1) ma_2_show = input.bool(title = '', defval =true, inline = 'cell_2') ma_2 = input.int(title = "Data Cell 2", defval = 8, inline = 'cell_2') ma_2_data = ema_enable ? ta.ema(source, ma_2) : ta.sma(source, ma_2) ma_3_show = input.bool(title = '', defval =true, inline = 'cell_3') ma_3 = input.int(title = "Data Cell 3", defval = 13, inline = 'cell_3') ma_3_data = ema_enable ? ta.ema(source, ma_3) : ta.sma(source, ma_3) ma_4_show = input.bool(title = '', defval =true, inline = 'cell_4') ma_4 = input.int(title = "Data Cell 4", defval = 21, inline = 'cell_4') ma_4_data = ema_enable ? ta.ema(source, ma_4) : ta.sma(source, ma_4) ma_5_show = input.bool(title = '', defval =true, inline = 'cell_5') ma_5 = input.int(title = "Data Cell 5", defval = 34, inline = 'cell_5') ma_5_data = ema_enable ? ta.ema(source, ma_5) : ta.sma(source, ma_5) ma_6_show = input.bool(title = '', defval =true, inline = 'cell_6') ma_6 = input.int(title = "Data Cell 6", defval = 55, inline = 'cell_6') ma_6_data = ema_enable ? ta.ema(source, ma_6) : ta.sma(source, ma_6) ma_7_show = input.bool(title = '', defval = true, inline = 'cell_7') ma_7 = input.int(title = "Data Cell 7", defval = 89, inline = 'cell_7') ma_7_data = ema_enable ? ta.ema(source, ma_7) : ta.sma(source, ma_7) ma_8_show = input.bool(title = '', defval = true, inline = 'cell_8') ma_8 = input.int(title = "Data Cell 8", defval = 100, inline = 'cell_8') ma_8_data = ema_enable ? ta.ema(source, ma_8) : ta.sma(source, ma_8) ma_9_show = input.bool(title = '', defval = true, inline = 'cell_9') ma_9 = input.int(title = "Data Cell 9", defval = 144, inline = 'cell_9') ma_9_data = ema_enable ? ta.ema(source, ma_9) : ta.sma(source, ma_9) ma_10_show = input.bool(title = '', defval = true, inline = 'cell_10') ma_10 = input.int(title = "Data Cell 10", defval = 200, inline = 'cell_10') ma_10_data = ema_enable ? ta.ema(source, ma_10) : ta.sma(source, ma_10) ma_11_show = input.bool(title = '', defval = true, inline = 'cell_11') ma_11 = input.int(title = "Data Cell 11", defval = 233, inline = 'cell_11') ma_11_data = ema_enable ? ta.ema(source, ma_11) : ta.sma(source, ma_11) ma_12_show = input.bool(title = '', defval = true, inline = 'cell_12') ma_12 = input.int(title = "Data Cell 12", defval = 377, inline = 'cell_12') ma_12_data = ema_enable ? ta.ema(source, ma_12) : ta.sma(source, ma_12) ma_13_show = input.bool(title = '', defval = false, inline = 'cell_13') ma_13 = input.int(title = "Data Cell 13", defval = 400, inline = 'cell_13') ma_13_data = ema_enable ? ta.ema(source, ma_13) : ta.sma(source, ma_13) ma_14_show = input.bool(title = '', defval = false, inline = 'cell_14') ma_14 = input.int(title = "Data Cell 14", defval = 10, inline = 'cell_14') ma_14_data = ema_enable ? ta.ema(source, ma_14) : ta.sma(source, ma_14) ma_15_show = input.bool(title = '', defval = false, inline = 'cell_15') ma_15 = input.int(title = "Data Cell 15", defval = 20, inline = 'cell_15') ma_15_data = ema_enable ? ta.ema(source, ma_15) : ta.sma(source, ma_15) ma_16_show = input.bool(title = '', defval = false, inline = 'cell_16') ma_16 = input.int(title = "Data Cell 16", defval = 30, inline = 'cell_16') ma_16_data = ema_enable ? ta.ema(source, ma_16) : ta.sma(source, ma_16) array.push(moving_avg, ma_1) array.push(moving_avg_data, ma_1_data) array.push(moving_avg_show, ma_1_show) array.push(moving_avg, ma_2) array.push(moving_avg_data, ma_2_data) array.push(moving_avg_show, ma_2_show) array.push(moving_avg, ma_3) array.push(moving_avg_data, ma_3_data) array.push(moving_avg_show, ma_3_show) array.push(moving_avg, ma_4) array.push(moving_avg_data, ma_4_data) array.push(moving_avg_show, ma_4_show) array.push(moving_avg, ma_5) array.push(moving_avg_data, ma_5_data) array.push(moving_avg_show, ma_5_show) array.push(moving_avg, ma_6) array.push(moving_avg_data, ma_6_data) array.push(moving_avg_show, ma_6_show) array.push(moving_avg, ma_7) array.push(moving_avg_data, ma_7_data) array.push(moving_avg_show, ma_7_show) array.push(moving_avg, ma_8) array.push(moving_avg_data, ma_8_data) array.push(moving_avg_show, ma_8_show) array.push(moving_avg, ma_9) array.push(moving_avg_data, ma_9_data) array.push(moving_avg_show, ma_9_show) array.push(moving_avg, ma_10) array.push(moving_avg_data, ma_10_data) array.push(moving_avg_show, ma_10_show) array.push(moving_avg, ma_11) array.push(moving_avg_data, ma_11_data) array.push(moving_avg_show, ma_11_show) array.push(moving_avg, ma_12) array.push(moving_avg_data, ma_12_data) array.push(moving_avg_show, ma_12_show) array.push(moving_avg, ma_13) array.push(moving_avg_data, ma_13_data) array.push(moving_avg_show, ma_13_show) array.push(moving_avg, ma_14) array.push(moving_avg_data, ma_14_data) array.push(moving_avg_show, ma_14_show) array.push(moving_avg, ma_15) array.push(moving_avg_data, ma_15_data) array.push(moving_avg_show, ma_15_show) array.push(moving_avg, ma_16) array.push(moving_avg_data, ma_16_data) array.push(moving_avg_show, ma_16_show) //table colors top_row_col = color.new(color.gray, 0) // plot(ltp) var string display_box = 'Display Table Position' string table_position_y = input.string('bottom', 'Panel position', inline='11', options=['top', 'middle', 'bottom'], group=display_box) string table_position_x = input.string('left', '', inline='11', options=['left', 'center', 'right'], group=display_box) //create table var table_panel = table.new(position = table_position_y + '_' + table_position_x, columns = 20, rows = 20, frame_color = color.new(color.black, 0), frame_width = 1, border_color =color.new(color.black, 0), border_width = 1) if barstate.islast table.cell(table_panel, 0, 0, syminfo.ticker, bgcolor = top_row_col, text_color = color.white, text_size = size.tiny) table.cell(table_panel, 0, 0, syminfo.ticker, bgcolor = top_row_col, text_color = color.white, text_size = size.tiny) table.cell(table_panel, 0, 1, str.tostring(close), bgcolor = top_row_col, text_color = color.white, text_size = size.tiny) for i = 0 to 15 by 1 if array.get(moving_avg_show, i) table.cell(table_panel, i+1, 0, str.tostring(array.get(moving_avg, i)), bgcolor = top_row_col, text_color = color.white, text_size = size.tiny) table.cell(table_panel, i+1, 1, str.tostring(array.get(moving_avg_data, i), format.mintick), bgcolor = array.get(moving_avg_data, i) < close ? color.new(color.green, 0) : color.new(color.red, 0), text_color = color.white, text_size = size.tiny)
Fed Funds Rate Projections
https://www.tradingview.com/script/b8ovdU5o-Fed-Funds-Rate-Projections/
barnabygraham
https://www.tradingview.com/u/barnabygraham/
48
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © barnabygraham //@version=5 indicator("Fed Funds Rate Projections",overlay=true,max_boxes_count=500) // measures the x axis in number of candlesticks n = bar_index // defines the starting point of where the projections will be projected from baselineChoice = input.string('Moving Average','Baseline',options=['close','Moving Average'],tooltip='defines the starting point of where the projections will be projected from') maLength = input.int(20,'Moving Average Length',tooltip='length of the moving average when the baseline has been set to "moving average"') base = baselineChoice == 'close' ? close : baselineChoice == 'Moving Average' ? ta.sma(close,maLength) : na // the significance of the change in rates (10 means a 0.25bps change implies a 2.5% lower stock price) multiplier = input.float(10,'Multiplier',tooltip='the significance of the change in rates (10 means a 0.25bps change implies a 2.5% lower stock price)') // the minimum threshold which a change in rates requires to draw a box threshold = input.float(0.2,'Minimum change threshold in bps',tooltip='the minimum threshold which a change in rates requires to draw a box',step=0.1) // the fed funds rate fedRate = request.security("FRED:EFFR", "D", close) // checks if there has been a change in the fed funds rate and calculates the amount it has changed update = not(fedRate==fedRate[1]) change = 0. if update change := ta.change(fedRate*-1) // Turns the change in the fed funds rate into a percentage which we can use to cast projections with multipliedChange = 0.01*(multiplier * change) // the projection's baseline (the vertical middle of the box) projection = base+(multipliedChange*base) // how many candlesticks in the future to project out (the right side of the box from the candlestick on which the box was made) lookForward = input.int(100,'Look forward',tooltip='how many candlesticks in the future to project out (the right side of the box from the candlestick on which the box was made)') // The opacity. Automatically makes boxes brighter for larger changes in rates and makes small rate changes almost invisible opac = 120-(math.abs(change)*100) // box color boxColor = input.color(color.new(color.yellow,0),'Box Color') // box height multiplier boxHeight = input.float(0.03,'Box Height',step=0.01) // draws boxes when there has been a change in the fed funds rate and meet the minimum threshold if update and math.abs(change) >= threshold newLine = box.new(n,projection+(projection*(boxHeight)),n+lookForward,projection-(projection*(boxHeight)),border_color=color.new(color.white,100),bgcolor=color.new(boxColor,opac))
Correlation with Matrix Table
https://www.tradingview.com/script/7m7bAdoW-Correlation-with-Matrix-Table/
valpatrad
https://www.tradingview.com/u/valpatrad/
95
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © valpatrad //@version=5 indicator('Correlation with Matrix Table', 'Correlation', precision=3) if session.ispremarket runtime.error('The indicator only works in regular session.') /////////////////////////// // // // Correlation // // // /////////////////////////// //Menu len = input.int(20, 'Length', 1, group='Correlation') tf = input.timeframe('', 'Timeframe', group='Correlation') gaps = input.bool(true, 'Gaps', group='Correlation', tooltip='If not checked, gaps are filled with the latest available value.') in_style = input.string('Line with breaks', 'Style', options=['Line', 'Line with breaks', 'Step line', 'Step line with diamonds', 'Cross', 'Circles'], group='Correlation') style = switch in_style 'Line' => plot.style_line 'Line with breaks' => plot.style_linebr 'Step line' => plot.style_stepline 'Step line with diamonds' => plot.style_stepline_diamond 'Cross' => plot.style_cross 'Circles' => plot.style_circles show_1 = input.bool(true, '', group='Reference', inline='Line 0') show_2 = input.bool(true, '1', group='Symbols', inline= 'Line 1') show_3 = input.bool(true, '2', group='Symbols', inline= 'Line 2') show_4 = input.bool(true, '3', group='Symbols', inline= 'Line 3') show_5 = input.bool(true, '4', group='Symbols', inline= 'Line 4') show_6 = input.bool(true, '5', group='Symbols', inline= 'Line 5') show_7 = input.bool(true, '6', group='Symbols', inline= 'Line 6') show_8 = input.bool(true, '7', group='Symbols', inline= 'Line 7') show_9 = input.bool(true, '8', group='Symbols', inline= 'Line 8') col_1 = input.color(#FF0000, '  ', group='Reference', inline='Line 0') col_2 = input.color(#2962FF, '', group='Symbols', inline='Line 1') col_3 = input.color(#FFFFFF, '', group='Symbols', inline='Line 2') col_4 = input.color(#880E4F, '', group='Symbols', inline='Line 3') col_5 = input.color(#FA6496, '', group='Symbols', inline='Line 4') col_6 = input.color(#D79B24, '', group='Symbols', inline='Line 5') col_7 = input.color(#787B86, '', group='Symbols', inline='Line 6') col_8 = input.color(#19965A, '', group='Symbols', inline='Line 7') col_9 = input.color(#23AADC, '', group='Symbols', inline='Line 8') line_1 = input.int(1, '', 1, 4, group='Reference', inline='Line 0') line_2 = input.int(1, '', 1, 4, group='Symbols', inline='Line 1') line_3 = input.int(1, '', 1, 4, group='Symbols', inline='Line 2') line_4 = input.int(1, '', 1, 4, group='Symbols', inline='Line 3') line_5 = input.int(1, '', 1, 4, group='Symbols', inline='Line 4') line_6 = input.int(1, '', 1, 4, group='Symbols', inline='Line 5') line_7 = input.int(1, '', 1, 4, group='Symbols', inline='Line 6') line_8 = input.int(1, '', 1, 4, group='Symbols', inline='Line 7') line_9 = input.int(1, '', 1, 4, group='Symbols', inline='Line 8') sym_1 = input.symbol('AMEX:SPY', '', group='Reference', inline='Line 0') sym_2 = input.symbol('NASDAQ:QQQ', '', group='Symbols', inline= 'Line 1') sym_3 = input.symbol('AMEX:DIA', '', group='Symbols', inline= 'Line 2') sym_4 = input.symbol('AMEX:IWM', '', group='Symbols', inline= 'Line 3') sym_5 = input.symbol('AMEX:MDY', '', group='Symbols', inline= 'Line 4') sym_6 = input.symbol('AMEX:GLD', '', group='Symbols', inline= 'Line 5') sym_7 = input.symbol('AMEX:USO', '', group='Symbols', inline= 'Line 6') sym_8 = input.symbol('AMEX:UUP', '', group='Symbols', inline= 'Line 7') sym_9 = input.symbol('NASDAQ:IEF', '', group='Symbols', inline= 'Line 8') //Variables data_1 = request.security(sym_1, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_2 = request.security(sym_2, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_3 = request.security(sym_3, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_4 = request.security(sym_4, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_5 = request.security(sym_5, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_6 = request.security(sym_6, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_7 = request.security(sym_7, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_8 = request.security(sym_8, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_9 = request.security(sym_9, tf, close, gaps ? barmerge.gaps_on : barmerge.gaps_off) c1_1 = ta.correlation(data_1, data_1, len) c1_2 = ta.correlation(data_1, data_2, len) c1_3 = ta.correlation(data_1, data_3, len) c1_4 = ta.correlation(data_1, data_4, len) c1_5 = ta.correlation(data_1, data_5, len) c1_6 = ta.correlation(data_1, data_6, len) c1_7 = ta.correlation(data_1, data_7, len) c1_8 = ta.correlation(data_1, data_8, len) c1_9 = ta.correlation(data_1, data_9, len) c2_3 = ta.correlation(data_2, data_3, len) c2_4 = ta.correlation(data_2, data_4, len) c2_5 = ta.correlation(data_2, data_5, len) c2_6 = ta.correlation(data_2, data_6, len) c2_7 = ta.correlation(data_2, data_7, len) c2_8 = ta.correlation(data_2, data_8, len) c2_9 = ta.correlation(data_2, data_9, len) c3_4 = ta.correlation(data_3, data_4, len) c3_5 = ta.correlation(data_3, data_5, len) c3_6 = ta.correlation(data_3, data_6, len) c3_7 = ta.correlation(data_3, data_7, len) c3_8 = ta.correlation(data_3, data_8, len) c3_9 = ta.correlation(data_3, data_9, len) c4_5 = ta.correlation(data_4, data_5, len) c4_6 = ta.correlation(data_4, data_6, len) c4_7 = ta.correlation(data_4, data_7, len) c4_8 = ta.correlation(data_4, data_8, len) c4_9 = ta.correlation(data_4, data_9, len) c5_6 = ta.correlation(data_5, data_6, len) c5_7 = ta.correlation(data_5, data_7, len) c5_8 = ta.correlation(data_5, data_8, len) c5_9 = ta.correlation(data_5, data_9, len) c6_7 = ta.correlation(data_6, data_7, len) c6_8 = ta.correlation(data_6, data_8, len) c6_9 = ta.correlation(data_6, data_9, len) c7_8 = ta.correlation(data_7, data_8, len) c7_9 = ta.correlation(data_7, data_9, len) c8_9 = ta.correlation(data_8, data_9, len) //Plot plot(show_1 ? c1_1 : na, '', col_1, line_1, style, editable=false) plot(show_2 ? c1_2 : na, '', col_2, line_2, style, editable=false) plot(show_3 ? c1_3 : na, '', col_3, line_3, style, editable=false) plot(show_4 ? c1_4 : na, '', col_4, line_4, style, editable=false) plot(show_5 ? c1_5 : na, '', col_5, line_5, style, editable=false) plot(show_6 ? c1_6 : na, '', col_6, line_6, style, editable=false) plot(show_7 ? c1_7 : na, '', col_7, line_7, style, editable=false) plot(show_8 ? c1_8 : na, '', col_8, line_8, style, editable=false) plot(show_9 ? c1_9 : na, '', col_9, line_9, style, editable=false) //////////////////////////// // // // Thresholds // // // //////////////////////////// //Menu col_th = input.color(color.new(#FFFFFF, 70), 'Color   ', group='Thresholds', inline='Color') in_style_th = input.string('Dotted', 'Style   ', options=['Solid', 'Dotted', 'Dashed'], group='Thresholds', inline='Style') style_th = switch in_style_th 'Solid' => hline.style_solid 'Dotted' => hline.style_dotted 'Dashed' => hline.style_dashed width_th = input.int(1, 'Width  ', 1, 4, group='Thresholds', inline='Width') show_th_4 = input.bool(false, '', group='Thresholds', inline='Line 4') show_th_3 = input.bool(false, '', group='Thresholds', inline='Line 3') show_th_2 = input.bool(false, '', group='Thresholds', inline='Line 2') show_th_1 = input.bool(false, '', group='Thresholds', inline='Line 1') show_th_0 = input.bool(false, '', group='Thresholds', inline='Line 0') show_th__1 = input.bool(false, '', group='Thresholds', inline='Line -1') show_th__2 = input.bool(false, '', group='Thresholds', inline='Line -2') show_th__3 = input.bool(false, '', group='Thresholds', inline='Line -3') show_th__4 = input.bool(false, '', group='Thresholds', inline='Line -4') th_4 = input.float(1, '4 ', 1.00, 1.00, group='Thresholds', inline='Line 4', tooltip='Matrix cells\' background will change accordingly to threshold levels. Level 4, 0 and -4 cannot be changed.') th_3 = input.float(0.7, '3 ', -1.00, 1.00, 0.001, group='Thresholds', inline='Line 3') th_2 = input.float(0.5, '2 ', -1.00, 1.00, 0.001, group='Thresholds', inline='Line 2') th_1 = input.float(0.3, '1 ', -1.00, 1.00, 0.001, group='Thresholds', inline='Line 1') th_0 = input.float(0, '0 ', 0, 0, group='Thresholds', inline='Line 0') th__1 = input.float(-0.3, '-1', -1.00, 1.00, 0.001, group='Thresholds', inline='Line -1') th__2 = input.float(-0.5, '-2', -1.00, 1.00, 0.001, group='Thresholds', inline='Line -2') th__3 = input.float(-0.7, '-3', -1.00, 1.00, step=0.001, group='Thresholds', inline='Line -3') th__4 = input.float(-1, '-4', -1.00, -1.00, group='Thresholds', inline='Line -4') //Plot h4 = hline(th_4, '', col_th, style_th, width_th, false, show_th_4 ? display.all : display.none) h3 = hline(th_3, '', col_th, style_th, width_th, false, show_th_3 ? display.all : display.none) h2 = hline(th_2, '', col_th, style_th, width_th, false, show_th_2 ? display.all : display.none) h1 = hline(th_1, '', col_th, style_th, width_th, false, show_th_1 ? display.all : display.none) h0 = hline(th_0, '', col_th, style_th, width_th, false, show_th_0 ? display.all : display.none) h_1 = hline(th__1, '', col_th, style_th, width_th, false, show_th__1 ? display.all : display.none) h_2 = hline(th__2, '', col_th, style_th, width_th, false, show_th__2 ? display.all : display.none) h_3 = hline(th__3, '', col_th, style_th, width_th, false, show_th__3 ? display.all : display.none) h_4 = hline(th__4, '', col_th, style_th, width_th, false, show_th__4 ? display.all : display.none) //////////////////////////// // // // Levels // // // //////////////////////////// //Menu hide_lvl = input.bool(false, 'Hide', group='Levels') col_lvl_4 = input.color(color.new(#4CAF50, 80), ' 4  ', group='Levels', inline='Line 1') col_lvl_3 = input.color(color.new(#FFEB3B, 80), '  3 ', group='Levels', inline='Line 1') col_lvl_2 = input.color(color.new(#FF5252, 80), '  2 ', group='Levels', inline='Line 1') col_lvl_1 = input.color(color.new(#D1D4DC, 80), '  1  ', group='Levels', inline='Line 1', tooltip='Matrix cells\' background will change accordingly to level colors.') col_lvl__1 = input.color(color.new(#878479, 80), ' -1 ', group='Levels', inline='Line 2') col_lvl__2 = input.color(color.new(#B350AF, 80), ' -2 ', group='Levels', inline='Line 2') col_lvl__3 = input.color(color.new(#F57C00, 80), ' -3 ', group='Levels', inline='Line 2') col_lvl__4 = input.color(color.new(#5B9CF6, 80), ' -4 ', group='Levels', inline='Line 2') //Plot fill(h4, h3, hide_lvl ? na : col_lvl_4, '', false) fill(h3, h2, hide_lvl ? na : col_lvl_3, '', false) fill(h2, h1, hide_lvl ? na : col_lvl_2, '', false) fill(h1, h0, hide_lvl ? na : col_lvl_1, '', false) fill(h0, h_1, hide_lvl ? na : col_lvl__1, '', false) fill(h_1, h_2, hide_lvl ? na : col_lvl__2, '', false) fill(h_2, h_3, hide_lvl ? na : col_lvl__3, '', false) fill(h_3, h_4, hide_lvl ? na : col_lvl__4, '', false) ////////////////////////// // // // Matrix // // // ////////////////////////// //Menu prec = input.int(3, 'Precision', 1, 4, group='Matrix') col_txt_1 = input.color(#FFFFFF, 'Text Colors   1', group='Matrix', inline='Line 1') col_txt_2 = input.color(#FFFFFF, '  2', group='Matrix', inline='Line 1') col_txt_3 = input.color(#4CAF50, '  3', group='Matrix', inline='Line 1') col_txt_4 = input.color(#FFFFFF, '  4', group='Matrix', inline='Line 1') col_txt_5 = input.color(#000000, '    5', group='Matrix', inline='Line 2') col_txt_6 = input.color(#FFFFFF, '  6', group='Matrix', inline='Line 2') col_txt_7 = input.color(#000000, '  7', group='Matrix', inline='Line 2') col_txt_8 = input.color(#FFFFFF, '  8', group='Matrix', inline='Line 2') col_txt_9 = input.color(#000000, '  9', group='Matrix', inline='Line 2') col_num = input.color(#000000, 'Numbers Color', group='Matrix') fill_cell = input.bool(false, 'Fill Empty Cells', group='Matrix', inline='Fill') empty_col = input.color(#363A45, '', group='Matrix', inline='Fill') fill_corner = input.bool(false, 'Fill Corner Cell', group='Matrix', inline='Corner') corner_col = input.color(#363A45, '', group='Matrix', inline='Corner') corr_corner = input.bool(false, 'Corr. Length on Corner Cell', group='Matrix', inline='Corr. Length') corner_txt_col = input.color(#FFFFFF, '', group='Matrix', inline='Corr. Length') col_bord = input.color(#363A45, 'Border Color', group='Matrix') width_bord = input.int(1, 'Border Width', 0, group='Matrix') m_transp = input.int(0, 'Transparency', 0, 100, group='Matrix') input_tab_size = input.string('Normal', 'Size', group='Matrix', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge']) tab_size = switch input_tab_size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge input_tab_pos = input.string('Bottom Left', 'Position', group='Matrix', options=['Top Left', 'Top Center', 'Top Right', 'Middle Left', 'Middle Center', 'Middle Right', 'Bottom Left', 'Bottom Center', 'Bottom Right']) tab_pos = switch input_tab_pos 'Top Left' => position.top_left 'Top Center' => position.top_center 'Top Right' => position.top_right 'Middle Left' => position.middle_left 'Middle Center' => position.middle_center 'Middle Right' => position.middle_right 'Bottom Left' => position.bottom_left 'Bottom Center' => position.bottom_center 'Bottom Right' => position.bottom_right //Variables bg_col(c) => if c >= th_3 color.new(col_lvl_4, m_transp) else if c >= th_2 and c < th_3 color.new(col_lvl_3, m_transp) else if c >= th_1 and c < th_2 color.new(col_lvl_2, m_transp) else if c > th_0 and c < th_1 color.new(col_lvl_1, m_transp) else if c == th_0 color.new(#FFFFFF, m_transp) else if c < th_0 and c > th__1 color.new(col_lvl__1, m_transp) else if c <= th__1 and c > th__2 color.new(col_lvl__2, m_transp) else if c <= th__2 and c > th__3 color.new(col_lvl__3, m_transp) else if c <= th__3 color.new(col_lvl__4, m_transp) get_name(_str) => string[] _pair = str.split(_str, ':') string[] _chars = str.split(array.get(_pair, 1), '') string _return = array.join(_chars, '') tab = table.new(tab_pos, 10, 10, border_color=color.new(col_bord, m_transp), border_width=width_bord) _sym(cell_1, cell_2, txt, col, bgcol) => table.cell(tab, cell_1, cell_2, get_name(txt), text_color=color.new(col, m_transp), text_size=tab_size, bgcolor=color.new(bgcol, m_transp)) table.cell(tab, cell_2, cell_1, get_name(txt), text_color=color.new(col, m_transp), text_size=tab_size, bgcolor=color.new(bgcol, m_transp)) _corr(cell_1, cell_2, txt, bgcol) => table.cell(tab, cell_1, cell_2, str.tostring(txt, prec == 4 ? '#.####' : prec == 3 ? '#.###' : prec == 2 ? '#.##' : '#.#'), text_color= color.new(col_num, m_transp), text_size=tab_size, bgcolor=bg_col(bgcol)) table.cell(tab, cell_2, cell_1, str.tostring(txt, prec == 4 ? '#.####' : prec == 3 ? '#.###' : prec == 2 ? '#.##' : '#.#'), text_color= color.new(col_num, m_transp), text_size=tab_size, bgcolor=bg_col(bgcol)) _empty(colm, row) => table.cell(tab, colm, row, '', bgcolor=color.new(empty_col, m_transp)) //Plot _sym(0, 1, sym_1, col_txt_1, col_1) _sym(0, 2, sym_2, col_txt_2, col_2) _sym(0, 3, sym_3, col_txt_3, col_3) _sym(0, 4, sym_4, col_txt_4, col_4) _sym(0, 5, sym_5, col_txt_5, col_5) _sym(0, 6, sym_6, col_txt_6, col_6) _sym(0, 7, sym_7, col_txt_7, col_7) _sym(0, 8, sym_8, col_txt_8, col_8) _sym(0, 9, sym_9, col_txt_9, col_9) _corr(1, 2, c1_2, c1_2) _corr(1, 3, c1_3, c1_3) _corr(1, 4, c1_4, c1_4) _corr(1, 5, c1_5, c1_5) _corr(1, 6, c1_6, c1_6) _corr(1, 7, c1_7, c1_7) _corr(1, 8, c1_8, c1_8) _corr(1, 9, c1_9, c1_9) _corr(2, 3, c2_3, c2_3) _corr(2, 4, c2_4, c2_4) _corr(2, 5, c2_5, c2_5) _corr(2, 6, c2_6, c2_6) _corr(2, 7, c2_7, c2_7) _corr(2, 8, c2_8, c2_8) _corr(2, 9, c2_9, c2_9) _corr(3, 4, c3_4, c3_4) _corr(3, 5, c3_5, c3_5) _corr(3, 6, c3_6, c3_6) _corr(3, 7, c3_7, c3_7) _corr(3, 8, c3_8, c3_8) _corr(3, 9, c3_9, c3_9) _corr(4, 5, c4_5, c4_5) _corr(4, 6, c4_6, c4_6) _corr(4, 7, c4_7, c4_7) _corr(4, 8, c4_8, c4_8) _corr(4, 9, c4_9, c4_9) _corr(5, 6, c5_6, c5_6) _corr(5, 7, c5_7, c5_7) _corr(5, 8, c5_8, c5_8) _corr(5, 9, c5_9, c5_9) _corr(6, 7, c6_7, c6_7) _corr(6, 8, c6_8, c6_8) _corr(6, 9, c6_9, c6_9) _corr(7, 8, c7_8, c7_8) _corr(7, 9, c7_9, c7_9) _corr(8, 9, c8_9, c8_9) if fill_cell _empty(1, 1) _empty(2, 2) _empty(3, 3) _empty(4, 4) _empty(5, 5) _empty(6, 6) _empty(7, 7) _empty(8, 8) _empty(9, 9) table.cell(tab, 0, 0, corr_corner ? 'r[' + str.tostring(len) + ']' : na, text_color=color.new(corner_txt_col, m_transp), text_size=tab_size, bgcolor=color.new(corner_col, fill_corner ? m_transp : 100))
CL PMA
https://www.tradingview.com/script/wJ91tCHI-CL-PMA/
Mreg36
https://www.tradingview.com/u/Mreg36/
5
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mreg36 //@version=5 plot(close) indicator("CL PMA", overlay=true) sma1_period = input(title="SMA1 Period", defval=14) sma2_period = input(title="SMA2 Period", defval=30) sma3_period = input(title="SMA3 Period", defval=50) sma1 = ta.sma(hlc3, sma1_period) sma2 = ta.sma(hlc3, sma2_period) sma3 = ta.sma(hlc3, sma3_period) colors1 = color.orange colors2 = color.blue colors3 = color.green sma1_plot = plot(sma1, color=colors1) sma2_plot = plot(sma2, color=colors2) sma3_plot = plot(sma3, color=colors3)
Fair Value Gap [LuxAlgo]
https://www.tradingview.com/script/jWY4Uiez-Fair-Value-Gap-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
4,597
study
5
CC-BY-NC-SA-4.0
// 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=5 indicator("Fair Value Gap [LuxAlgo]", "LuxAlgo - Fair Value Gap", overlay = true, max_lines_count = 500, max_boxes_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ thresholdPer = input.float(0, "Threshold %", minval = 0, maxval = 100, step = .1, inline = 'threshold') auto = input(false, "Auto", inline = 'threshold') showLast = input.int(0, 'Unmitigated Levels', minval = 0) mitigationLevels = input.bool(false, 'Mitigation Levels') tf = input.timeframe('', "Timeframe") //Style extend = input.int(20, 'Extend', minval = 0, inline = 'extend', group = 'Style') dynamic = input(false, 'Dynamic', inline = 'extend', group = 'Style') bullCss = input.color(color.new(#089981, 70), "Bullish FVG", group = 'Style') bearCss = input.color(color.new(#f23645, 70), "Bearish FVG", group = 'Style') //Dashboard showDash = input(false, 'Show Dashboard', group = 'Dashboard') dashLoc = input.string('Top Right', 'Location', options = ['Top Right', 'Bottom Right', 'Bottom Left'], group = 'Dashboard') textSize = input.string('Small', 'Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Dashboard') //-----------------------------------------------------------------------------} //UDT's //-----------------------------------------------------------------------------{ type fvg float max float min bool isbull int t = time //-----------------------------------------------------------------------------} //Methods/Functions //-----------------------------------------------------------------------------{ n = bar_index method tosolid(color id)=> color.rgb(color.r(id),color.g(id),color.b(id)) detect()=> var new_fvg = fvg.new(na, na, na, na) threshold = auto ? ta.cum((high - low) / low) / bar_index : thresholdPer / 100 bull_fvg = low > high[2] and close[1] > high[2] and (low - high[2]) / high[2] > threshold bear_fvg = high < low[2] and close[1] < low[2] and (low[2] - high) / high > threshold if bull_fvg new_fvg := fvg.new(low, high[2], true) else if bear_fvg new_fvg := fvg.new(low[2], high, false) [bull_fvg, bear_fvg, new_fvg] //-----------------------------------------------------------------------------} //FVG's detection/display //-----------------------------------------------------------------------------{ var float max_bull_fvg = na, var float min_bull_fvg = na, var bull_count = 0, var bull_mitigated = 0 var float max_bear_fvg = na, var float min_bear_fvg = na, var bear_count = 0, var bear_mitigated = 0 var t = 0 var fvg_records = array.new<fvg>(0) var fvg_areas = array.new<box>(0) [bull_fvg, bear_fvg, new_fvg] = request.security(syminfo.tickerid, tf, detect()) //Bull FVG's if bull_fvg and new_fvg.t != t if dynamic max_bull_fvg := new_fvg.max min_bull_fvg := new_fvg.min //Populate FVG array if not dynamic fvg_areas.unshift(box.new(n-2, new_fvg.max, n+extend, new_fvg.min, na, bgcolor = bullCss)) fvg_records.unshift(new_fvg) bull_count += 1 t := new_fvg.t else if dynamic max_bull_fvg := math.max(math.min(close, max_bull_fvg), min_bull_fvg) //Bear FVG's if bear_fvg and new_fvg.t != t if dynamic max_bear_fvg := new_fvg.max min_bear_fvg := new_fvg.min //Populate FVG array if not dynamic fvg_areas.unshift(box.new(n-2, new_fvg.max, n+extend, new_fvg.min, na, bgcolor = bearCss)) fvg_records.unshift(new_fvg) bear_count += 1 t := new_fvg.t else if dynamic min_bear_fvg := math.min(math.max(close, min_bear_fvg), max_bear_fvg) //-----------------------------------------------------------------------------} //Unmitigated/Mitigated lines //-----------------------------------------------------------------------------{ //Test for mitigation if fvg_records.size() > 0 for i = fvg_records.size()-1 to 0 get = fvg_records.get(i) if get.isbull if close < get.min //Display line if mitigated if mitigationLevels line.new(get.t , get.min , time , get.min , xloc.bar_time , color = bullCss , style = line.style_dashed) //Delete box if not dynamic area = fvg_areas.remove(i) area.delete() fvg_records.remove(i) bull_mitigated += 1 else if close > get.max //Display line if mitigated if mitigationLevels line.new(get.t , get.max , time , get.max , xloc.bar_time , color = bearCss , style = line.style_dashed) //Delete box if not dynamic area = fvg_areas.remove(i) area.delete() fvg_records.remove(i) bear_mitigated += 1 //Unmitigated lines var unmitigated = array.new<line>(0) //Remove umitigated lines if barstate.islast and showLast > 0 and fvg_records.size() > 0 if unmitigated.size() > 0 for element in unmitigated element.delete() unmitigated.clear() for i = 0 to math.min(showLast-1, fvg_records.size()-1) get = fvg_records.get(i) unmitigated.push(line.new(get.t , get.isbull ? get.min : get.max , time , get.isbull ? get.min : get.max , xloc.bar_time , color = get.isbull ? bullCss : bearCss)) //-----------------------------------------------------------------------------} //Dashboard //-----------------------------------------------------------------------------{ var table_position = dashLoc == 'Bottom Left' ? position.bottom_left : dashLoc == 'Top Right' ? position.top_right : position.bottom_right var table_size = textSize == 'Tiny' ? size.tiny : textSize == 'Small' ? size.small : size.normal var tb = table.new(table_position, 3, 3 , bgcolor = #1e222d , border_color = #373a46 , border_width = 1 , frame_color = #373a46 , frame_width = 1) if showDash if barstate.isfirst tb.cell(1, 0, 'Bullish', text_color = bullCss.tosolid(), text_size = table_size) tb.cell(2, 0, 'Bearish', text_color = bearCss.tosolid(), text_size = table_size) tb.cell(0, 1, 'Count', text_size = table_size, text_color = color.white) tb.cell(0, 2, 'Mitigated', text_size = table_size, text_color = color.white) if barstate.islast tb.cell(1, 1, str.tostring(bull_count), text_color = bullCss.tosolid(), text_size = table_size) tb.cell(2, 1, str.tostring(bear_count), text_color = bearCss.tosolid(), text_size = table_size) tb.cell(1, 2, str.tostring(bull_mitigated / bull_count * 100, format.percent), text_color = bullCss.tosolid(), text_size = table_size) tb.cell(2, 2, str.tostring(bear_mitigated / bear_count * 100, format.percent), text_color = bearCss.tosolid(), text_size = table_size) //-----------------------------------------------------------------------------} //Plots //-----------------------------------------------------------------------------{ //Dynamic Bull FVG max_bull_plot = plot(max_bull_fvg, color = na) min_bull_plot = plot(min_bull_fvg, color = na) fill(max_bull_plot, min_bull_plot, color = bullCss) //Dynamic Bear FVG max_bear_plot = plot(max_bear_fvg, color = na) min_bear_plot = plot(min_bear_fvg, color = na) fill(max_bear_plot, min_bear_plot, color = bearCss) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_count > bull_count[1], 'Bullish FVG', 'Bullish FVG detected') alertcondition(bear_count > bear_count[1], 'Bearish FVG', 'Bearish FVG detected') alertcondition(bull_mitigated > bull_mitigated[1], 'Bullish FVG Mitigation', 'Bullish FVG mitigated') alertcondition(bear_mitigated > bear_mitigated[1], 'Bearish FVG Mitigation', 'Bearish FVG mitigated') //-----------------------------------------------------------------------------}
Simple and Exponential Moving Averages (20, 50, 200)
https://www.tradingview.com/script/a3QZHXxn-Simple-and-Exponential-Moving-Averages-20-50-200/
ayejay_
https://www.tradingview.com/u/ayejay_/
12
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ayejay_ //@version=5 indicator('Simple and Exponential Moving Averages', 'SMA(20, 50, 200) EMA(20, 50, 200)', overlay=true) SMA20 = ta.sma(close, 20) SMA50 = ta.sma(close, 50) SMA200 = ta.sma(close, 200) EMA20 = ta.ema(close, 20) EMA50 = ta.ema(close, 50) EMA200 = ta.ema(close, 200) plot(SMA20, color=color.new(color.red, 0), title='SMA(20)') plot(SMA50, color=color.new(color.orange, 0), title='SMA(50)') plot(SMA200, color=color.new(color.yellow, 0), title='SMA(200)') plot(EMA20, color=color.new(color.green, 0), title='EMA(20)') plot(EMA50, color=color.new(color.blue, 0), title='EMA(50)') plot(EMA200, color=color.new(color.purple, 0), title='EMA(200)')
EMA scalping - Papamallis
https://www.tradingview.com/script/leBY6Gdp-EMA-scalping-Papamallis/
LefterisPapamallis
https://www.tradingview.com/u/LefterisPapamallis/
42
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © LefterisPapamallis //@version=5 indicator("simple scalping - papamallis", overlay=false) loockback= input(22) ema_input = input(21) loockback_hl = input(1) ema21 = ta.ema(close, ema_input) emah = ta.ema(ta.highest(high,loockback_hl), ema_input) emal = ta.ema(ta.lowest(loockback_hl), ema_input) h = plot(emah, color= emah > emah[loockback] ? color.green: color.red, linewidth=2) l = plot(emal, color=emal<emal[loockback] ? color.red : color.green, linewidth=2) // plot(ema21, color=ema21 > emah ? color.green : ema21<emal ? color.red : color.black) plot(close, title="close") plotshape(ta.crossover(close, emah) and emah > emah[loockback] , style=shape.labelup, location=location.bottom, size=size.tiny, color=color.green, textcolor=color.black) plotshape(ta.crossunder(close, emal) and emal<emal[loockback] , style=shape.labeldown, location=location.top, size=size.tiny, color=color.red, textcolor=color.white) fill(h,l, color= close>emah and emah > emah[loockback] and emal > emal[loockback]? color.green : close<emal and emal<emal[loockback] and emah<emah[loockback] ? color.red : color.black, transp=30) ///macd/// fastMA = ta.ema(close, 12) slowMA = ta.ema(close, 26) macd = fastMA - slowMA signal = ta.sma(macd, 9) macd_long = ta.crossover(macd,signal) and close > emah and emah > emah[loockback] and emal > emal[loockback] macd_short = ta.crossunder(macd,signal) and close<emal and emal<emal[loockback] and emah<emah[loockback] plot(macd_long or macd_short ? close : na, style=plot.style_circles, color=macd_long ? color.yellow : color.red, linewidth=4, display=display.none, title="macd")
VWAP BANDS [qrsq]
https://www.tradingview.com/script/1VHtK97t-VWAP-BANDS-qrsq/
qrsq
https://www.tradingview.com/u/qrsq/
171
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © qrsq //@version=5 indicator("VWAP BANDS", overlay=true, timeframe="") getTheme(theme) => color lineCol = na color bgCol = na if theme == "Light" lineCol := color.rgb(255,255,255,45) bgCol := color.rgb(255,255,255,85) if theme == "Dark" lineCol := color.new(#393b44, 30) bgCol := color.new(#393b44, 92) if theme == "Blue" lineCol := color.new(#2962ff,30) bgCol := color.new(#2962ff,92) if theme == "Red" lineCol := color.new(#e84b4c, 30) bgCol := color.new(#e84b4c, 92) if theme == "Orange" lineCol := color.new(#ffb228, 30) bgCol := color.new(#ffb228, 92) if theme == "Green" lineCol := color.new(#01c082, 30) bgCol := color.new(#01c082, 92) [lineCol, bgCol] theme = input.string("Light", title="Theme", options=["Light", "Dark", "Blue", "Red", "Orange", "Green"], group="Styling") color lineCol = na color bgCol = na // lineCol = color.rgb(255,255,255,45) // bgCol = color.rgb(255,255,255,85) [_lineCol, _bgCol] = getTheme(theme) lineCol:=_lineCol bgCol:=_bgCol BV = high == low ? 0 : volume * (close - low) / (high - low) SV = high == low ? 0 : volume * (high - close) / (high - low) src = input(title = "Source", defval = hlc3, group="VWAP Settings") length = input.int(100, title="Length", group="VWAP Settings") stdevMultiplier = input.float(1.5, "SD Multiplier 1", group="VWAP Settings") stdevMultiplier2 = input.float(2, "SD Multiplier 2", group="VWAP Settings") showDouble = input.bool(true, "Show double bands", group="VWAP Settings") sumBuy = math.sum(BV, length) sumSrcBuy = math.sum(src*BV, length) sumSrcSrcBuy = math.sum(BV*math.pow(src,2), length) VWAPBuy = sumSrcBuy / sumBuy varianceBuy = (sumSrcSrcBuy / sumBuy) - math.pow(VWAPBuy, 2) stDevBuy = math.sqrt(varianceBuy < 0 ? 0 : varianceBuy) sumSell = math.sum(SV, length) sumSrcSell = math.sum(src*SV, length) sumSrcSrcSell = math.sum(SV*math.pow(src,2),length) VWAPSell = sumSrcSell / sumSell varianceSell = (sumSrcSrcSell / sumSell) - math.pow(VWAPSell, 2) stDevSell = math.sqrt(varianceSell < 0 ? 0 : varianceSell) thresholdDown = VWAPBuy - stDevBuy * stdevMultiplier thresholdUp = VWAPSell + stDevSell * stdevMultiplier bottomUpper = plot(VWAPSell - stDevSell*stdevMultiplier, color=lineCol) bottomLower = plot(thresholdDown, color=lineCol) fill(bottomUpper, bottomLower, color=bgCol) topLower = plot(VWAPBuy + stDevBuy*stdevMultiplier, color=lineCol) topUpper = plot(thresholdUp, color=lineCol) fill(topUpper, topLower, color=bgCol) bottomDbl = plot(showDouble?VWAPSell - stDevSell*stdevMultiplier2:na, color=lineCol) fill(bottomDbl, bottomLower, color=showDouble?bgCol:color.new(color.white, 100)) topDbl = plot(showDouble?VWAPBuy + stDevBuy*stdevMultiplier2:na, color=lineCol) fill(topDbl, topUpper, color=showDouble?bgCol:color.new(color.white, 100))
DELTA VOL
https://www.tradingview.com/script/0NxSJr1b/
FJVL85
https://www.tradingview.com/u/FJVL85/
39
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FJVL85 //@version=4 study("DELTA VOL",format=format.volume, precision=0) //BUY AND SELL VOLUMEN// buyvolume = iff( (high==low), 0, volume*(close-low)/(high-low)) abssellvolume = iff( (high==low), 0, volume*(high-close)/(high-low)) sellvol=0-abssellvolume diffvol=buyvolume-abssellvolume deltavol = iff((diffvol>0), (buyvolume) / (abssellvolume), (sellvol) / (buyvolume)) // PLOT INDICADOR //plot(volume, style=plot.style_columns, color=color.blue, title="TOTAL V") plot(buyvolume, style=plot.style_columns, color=color.green, title="BUY V") plot(sellvol, style=plot.style_columns, color=color.red, title="SELL V") plot(deltavol, style=plot.style_line, color=color.orange, title="DELTA")
Move in X days
https://www.tradingview.com/script/SZh29rTX-Move-in-X-days/
TheDiscordia
https://www.tradingview.com/u/TheDiscordia/
2
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TheDiscordia //@version=5 indicator("Move in X days") pmove = input.int(20, title="Percentage Move", minval=1, maxval=300, step=1) xdays = input.int(5, title="Days", minval=1, maxval=100, step=1) days = xdays - 1 v = close - open[days] t = (v / open[days]) * 100 r = t >= pmove ? t : 0 plot(r, style=plot.style_areabr)
Move Up/Down in X days
https://www.tradingview.com/script/dk2OYTwU-Move-Up-Down-in-X-days/
TheDiscordia
https://www.tradingview.com/u/TheDiscordia/
11
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © TheDiscordia //@version=5 indicator("Move Up/Down in X days") pmove = input.int(20, title="Percentage Move", minval=1, maxval=300, step=1) xdays = input.int(5, title="Days", minval=1, maxval=100, step=1) xvolume = input.int(9, title="Volume (Millions)", minval=1, maxval=300, step=1) upInputColor = input.color(color.green, "Up Color") upColor = color.new(color = upInputColor, transp = 20) downInputColor = input.color(color.red, "Down Color") downColor = color.new(color = downInputColor, transp = 20) volumeColor = input.color(color.orange, "Volume Color") days = xdays v = close - close[days] t = (v / open[days]) * 100 u = (t >= pmove or t < -pmove) ? t : 0 vup = (u > 0) ? 1 : 0 plot(vup, color=upColor, style=plot.style_areabr) vdown = (u < 0) ? 1 : 0 plot(vdown, color=downColor, style=plot.style_areabr) volup = volume > (xvolume * 1000000) volGtYest = volume > volume[1] vv = close - close[1] tv = (vv / open[1]) * 100 showVolumeBar = volup and volGtYest and (tv >= 4 or tv <= -4) vbar = showVolumeBar ? 0.5 : 0 plot(vbar, color=volumeColor, style=plot.style_columns)
KT HMA
https://www.tradingview.com/script/VRNcMC4K-KT-HMA/
nik0580
https://www.tradingview.com/u/nik0580/
27
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © nik0580 //@version=5 indicator(title='KT HMA', overlay=true) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // High - Lows plotshape(close > high[1],style=shape.triangleup,location=location.abovebar, color=color.red,text="H",size=size.tiny) plotshape(close < low[1], style=shape.triangledown,location=location.belowbar, color=color.blue,text="L",size=size.tiny) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //HMA lengthhma = input.int(88, minval=1,title = "Length") srchma = input(close, title="Source") hullma = ta.wma(2*ta.wma(srchma, lengthhma/2)-ta.wma(srchma, lengthhma), math.floor(math.sqrt(lengthhma))) hullColor = hullma > hullma[2] ? color.green : #ff0000 plot(hullma, title='HULL', color= hullColor,linewidth=4,style=plot.style_stepline) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //ATR lengthATR = input.int(13, minval=1,title ='ATR') mult = input(1.0, 'Multiplier') src = input(close, title='Source') ma = ta.ema(src, lengthATR) mahigh = plot(ta.ema(high, lengthATR), color=color.new(#2962FF, 0), title='High') malow = plot(ta.ema(low, lengthATR), color=color.new(#2962FF, 0), title='Low') fill(malow, mahigh, title='MA Fill', color=color.new(color.yellow, 50)) rangema = ta.atr(lengthATR) upper = ma + rangema * mult lower = ma - rangema * mult upper2 = ma + rangema * mult * 2 lower2 = ma - rangema * mult * 2 upper3 = ma + rangema * mult * 3 lower3 = ma - rangema * mult * 3 plot(ma, color=color.blue, title='Base') u2 = plot(upper2, color=color.blue, title='2 ATR Up') l2 = plot(lower2, color=color.blue, title='2 ATR Down') u3 = plot(upper3, color=color.blue, title='3 ATR Up') l3 = plot(lower3, color=color.blue, title='3 ATR Down') fill(u2, u3, color=color.new(color.red, 70), title='3 ATR Up') fill(l2, l3, color=color.new(color.red, 70), title='3 ATR Down')
Code Unity 1.0
https://www.tradingview.com/script/fjNmW9x5-Code-Unity-1-0/
hasindusithmin64
https://www.tradingview.com/u/hasindusithmin64/
29
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © hasindusithmin64 //@version=5 indicator(title='Code Unity 1.2', shorttitle='Codeunity Strategy', overlay=true) shbb = input(false, title='Show Bolinger Bands') shbbs = input(true, title='Show BB Signals') sblue0 = color.new(color.blue, 0) sorange0 = color.new(color.orange, 0) //Bollinger Bands lengthbb = input.int(20, minval=1, group='Bollinger Bands') src = input(close, title='Source') mult = input.float(2.0, minval=0.001, maxval=50, title='StdDev', group='Bollinger Bands') basis = ta.sma(src, lengthbb) dev = mult * ta.stdev(src, lengthbb) upper = basis + dev lower = basis - dev offset = input.int(0, 'Offset', minval=-500, maxval=500, group='Bollinger Bands') plot(shbb ? basis : na, 'BB Basis', color=color.new(#FF6D00, 0), offset=offset) pbb1 = plot(shbb ? upper : na, 'BB Upper', color=color.new(#2962FF, 0), offset=offset) pbb2 = plot(shbb ? lower : na, 'BB Lower', color=color.new(#2962FF, 0), offset=offset) fill(pbb1, pbb2, title='BB Background', color=color.rgb(33, 150, 243, 95)) // DEMA lengthd = input.int(15, minval=1, title='BB MA Length', group='BB Strategy MA') e1 = ta.ema(close, lengthd) e2 = ta.ema(e1, lengthd) dema = 2 * e1 - e2 // Stoch periodK = input.int(9, title='%K Length', minval=1, group='BB Strategy Stoch') smoothK = input.int(3, title='%K Smoothing', minval=1, group='BB Strategy Stoch') periodD = input.int(3, title='%D Smoothing', minval=1) group = 'BB Strategy Stoch' k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) // RSI rsibb = ta.rsi(close, 2) rsibbos = input.int(9, 'BB RSI OS Level', group='BB RSI') rsibbob = input.int(91, 'BB RSI OB Level', group='BB RSI') //BB Strategy shortbb = open > close and close < dema and (high > upper or high[1] > upper) and k[1] > 65 and (rsibb > rsibbob or rsibb[1] > rsibbob or rsibb[2] > rsibbob or rsibb[3] > rsibbob) longbb = open < close and close > dema and (low < lower or low[1] < lower) and k[1] < 35 and (rsibb < rsibbos or rsibb[1] < rsibbos or rsibb[2] < rsibbos or rsibb[3] < rsibbos) plotshape(shbbs ? shortbb : na, style=shape.labeldown, color=sorange0, location=location.abovebar, size=size.tiny, title='Short Label', text='SS', textcolor=color.new(color.white, 0)) plotshape(shbbs ? longbb : na, style=shape.labelup, color=sblue0, location=location.belowbar, size=size.tiny, title='Long Label', text='BB', textcolor=color.new(color.white, 0)) // signal = longbb == true ? 'BUY' : shortbb == true ? 'SELL' : 'NEUTRAL' alertcondition(shortbb,"New Short Signal","Sell") alertcondition(longbb,"New Long Signal","Buy")
Bollinger Bands
https://www.tradingview.com/script/u77AgkrI-Bollinger-Bands/
ankur1500singh
https://www.tradingview.com/u/ankur1500singh/
27
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ankur1500singh //@version=5 indicator(shorttitle="AnkurBB", title="Bollinger Bands", overlay=true, timeframe="", timeframe_gaps=true) length = input.int(20, minval=1) src = input(close, title="Source") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev offset = input.int(0, "Offset", minval = -500, maxval = 500) plot(basis, "Basis", color=#FF6D00, offset = offset) p1 = plot(upper, "Upper", color=#2962FF, offset = offset) p2 = plot(lower, "Lower", color=#2962FF, offset = offset) fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95)) vwap =ta.vwap plot(vwap,"Vwap",color=color.white,linewidth=2) src1=input(200,"Ema") EMA=ta.ema(close,src1) plot(EMA,"Ema",color=color.green,linewidth=2)
LM:AllIn
https://www.tradingview.com/script/zAHSGSXz-LM-AllIn/
lokenomics
https://www.tradingview.com/u/lokenomics/
2
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © lokenomics //@version=5 indicator(title="LM:AllIn", shorttitle="LM:AllIn", overlay=true) // ################################################################################################## // ############################################### VWAP ############################################# // ################################################################################################## //##### VOLUME ##### // Get Volumes; For NIFTY/ BN /CNXFINANCE get futures volumes; Else get stock volume symForVolume = (syminfo.tickerid == "NSE:BANKNIFTY" or syminfo.tickerid == "NSE:NIFTY") ? syminfo.tickerid+"1!" : ( syminfo.tickerid == "NSE:CNXFINANCE" ? "NSE:NIFTY1!" : syminfo.tickerid) [appropriateVolume]=request.security(symForVolume,timeframe.period,[volume]) var cumVol = 0. cumVol += nz(appropriateVolume) if barstate.islast and cumVol == 0 runtime.error("No volume is provided by the data vendor.") computeVWAP(src, isNewPeriod, stDevMultiplier) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src * appropriateVolume : src * appropriateVolume + sumSrcVol[1] sumVol := isNewPeriod ? appropriateVolume : appropriateVolume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? appropriateVolume * math.pow(src, 2) : appropriateVolume * math.pow(src, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol variance = sumSrcSrcVol / sumVol - math.pow(_vwap, 2) variance := variance < 0 ? 0 : variance stDev = math.sqrt(variance) lowerBand = _vwap - stDev * stDevMultiplier upperBand = _vwap + stDev * stDevMultiplier [_vwap, lowerBand, upperBand] hideonDWM = input(false, title="Hide VWAP on 1D or Above", group="VWAP Settings") var anchor = input.string(defval = "Session", title="Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group="VWAP Settings") src = input(title = "Source", defval = hlc3, group="VWAP Settings") offset = input(0, title="Offset", group="VWAP Settings") showBands = input(true, title="Calculate Bands", group="Standard Deviation Bands Settings") stdevMult = input(1.0, title="Bands Multiplier", group="Standard Deviation Bands Settings") timeChange(period) => ta.change(time(period)) new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true) isNewPeriod = switch anchor "Earnings" => not na(new_earnings) "Dividends" => not na(new_dividends) "Splits" => not na(new_split) "Session" => timeChange("D") "Week" => timeChange("W") "Month" => timeChange("M") "Quarter" => timeChange("3M") "Year" => timeChange("12M") "Decade" => timeChange("12M") and year % 10 == 0 "Century" => timeChange("12M") and year % 100 == 0 => false isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits" if na(src[1]) and not isEsdAnchor isNewPeriod := true float vwapValue = na float std = na float upperBandValue = na float lowerBandValue = na if not (hideonDWM and timeframe.isdwm) [_vwap, bottom, top] = computeVWAP(src, isNewPeriod, stdevMult) vwapValue := _vwap upperBandValue := showBands ? top : na lowerBandValue := showBands ? bottom : na plot(vwapValue, title="VWAP", color=#2962FF, linewidth = 2, offset=offset) //vwapValue upperBand = plot(upperBandValue, title="Upper Band", color=color.new(color.green, 75), offset=offset) lowerBand = plot(lowerBandValue, title="Lower Band", color=color.new(color.green, 75), offset=offset) fill(upperBand, lowerBand, title="Bands Fill", color= showBands ? color.new(color.green, 95) : na) // ################################################################################################## // ############################################### VWAP ############################################# // ################################################################################################## // ################################################################################################## // ############################################### CPR ############################################## // ################################################################################################## // © GuruprasadMeduri //***************GUIDE*********************************** //CPR - Applicable only for daily pivots //CPR - All 3 lines display enabled by default //CPR - Central Pivot line display cannot changed //CPR - Central Pivot is a blue line by default and can be changed from settings //CPR - Top Range & Bottom Ranage display can be changed from settings //CPR - Top Range & Bottom Ranage are Yellow lines by default and can be chaned from settings //Daily pivots - Pivot line and CPR Central line are same //Daily pivots - level 1 & 2 (S1, R1, S2 R2) display enabled by default and can be changed from settings //Daily pivots - level 3 (S3 & R3) is availale and can be seleted from settings //Daily pivots - Resistance(R) lines are Red lines and can be changed from settings //Daily pivots - Support(S) lines are Green lines and can be changed from settings //Weekly pivots - Pivot is a blue line by default and can be changed from settings //Weekly pivots - 3 levels (S1, R1, S2, R2, S3 & R3) availale and can be seleted from settings //Weekly pivots - Resistance(R) lines are crossed (+) Red lines and can be changed from settings //Weekly pivots - Support(S) lines are crossed (+) Green lines and can be changed from settings //Monthly pivots - Pivot is a blue line by default and can be changed from settings //Monthly pivots - 3 levels (S1, R1, S2, R2, S3 & R3) availale and can be seleted from settings //Monthly pivots - Resistance(R) lines are circled (o) Red lines and can be changed from settings //Monthly pivots - Support(S) lines are circled (o) Green lines and can be changed from settings //Loki settings //var cprOffset=timeframe.period //cenral pivot range pivot = (high + low + close) /3 //Central Povit BC = (high + low) / 2 //Below Central povit TC = (pivot - BC) + pivot //Top Central povot //3 support levels S1 = (pivot * 2) - high S2 = pivot - (high - low) S3 = low - 2 * (high - pivot) //3 resistance levels R1 = (pivot * 2) - low R2 = pivot + (high - low) R3 = high + 2 * (pivot-low) //Checkbox inputs CPRPlot = input.bool(title = "Plot CPR?", defval=true) DayS1R1 = input.bool(title = "Plot Daiy S1/R1?", defval=true) DayS2R2 = input.bool(title = "Plot Daiy S2/R2?", defval=false) DayS3R3 = input.bool(title = "Plot Daiy S3/R3?", defval=false) WeeklyPivotInclude = input.bool(title = "Plot Weekly Pivot?", defval=false) WeeklyS1R1 = input.bool(title = "Plot weekly S1/R1?", defval=false) WeeklyS2R2 = input.bool(title = "Plot weekly S2/R2?", defval=false) WeeklyS3R3 = input.bool(title = "Plot weekly S3/R3?", defval=false) MonthlyPivotInclude = input.bool(title = "Plot Montly Pivot?", defval=false) MonthlyS1R1 = input.bool(title = "Plot Monthly S1/R1?", defval=false) MonthlyS2R2 = input.bool(title = "Plot Monthly S2/R2?", defval=false) MonthlyS3R3 = input.bool(title = "Plot Montly S3/R3?", defval=false) //OFFSET FIXING var offsetMultiplier=75 if timeframe.period=='1' offsetMultiplier:=375 else if timeframe.period=='3' offsetMultiplier:=125 else if timeframe.period=='5' offsetMultiplier:=75 else if timeframe.period=='15' offsetMultiplier:=25 else if timeframe.period=='30' offsetMultiplier:=13 else if timeframe.period=='60' offsetMultiplier:=6 else if timeframe.period=='D' offsetMultiplier:=1 //******************DAYWISE CPR & PIVOTS************************** // Getting daywise CPR [DayPivot, DayBC, DayTC] = request.security(syminfo.tickerid, "D", [pivot[0], BC[0], TC[0]], barmerge.gaps_off, barmerge.lookahead_on) //DayBC = request.security(syminfo.tickerid, "D", BC[0], barmerge.gaps_off, barmerge.lookahead_on) //DayTC = request.security(syminfo.tickerid, "D", TC[0], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks daywse for CPR CPColour = DayPivot != DayPivot[0] ? na : color.blue BCColour = DayBC != DayBC[0] ? na : color.blue TCColour = DayTC != DayTC[0] ? na : color.blue //Plotting daywise CPR plot(DayPivot, title = "CP", offset=offsetMultiplier, color = CPColour, style = plot.style_linebr, linewidth =2) plot(CPRPlot ? DayBC : na , offset=offsetMultiplier, title = "BC" , color = BCColour, style = plot.style_line, linewidth =1) plot(CPRPlot ? DayTC : na , offset=offsetMultiplier, title = "TC" , color = TCColour, style = plot.style_line, linewidth =1) // Getting daywise Support levels [DayS1, DayS2, DayS3] = request.security(syminfo.tickerid, "D", [S1[0], S2[0], S3[0]], barmerge.gaps_off, barmerge.lookahead_on) //DayS2 = request.security(syminfo.tickerid, "D", S2[0], barmerge.gaps_off, barmerge.lookahead_on) //DayS3 = request.security(syminfo.tickerid, "D", S3[0], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for daywise Support levels DayS1Color =DayS1 != DayS1[0] ? na : color.green DayS2Color =DayS2 != DayS2[0] ? na : color.green DayS3Color =DayS3 != DayS3[0] ? na : color.green //Plotting daywise Support levels plot(DayS1R1 ? DayS1 : na, title = "D-S1" , offset=offsetMultiplier, color = DayS1Color, style = plot.style_line, linewidth =1) plot(DayS2R2 ? DayS2 : na, title = "D-S2" , offset=offsetMultiplier, color = DayS2Color, style = plot.style_line, linewidth =1) plot(DayS3R3 ? DayS3 : na, title = "D-S3" , offset=offsetMultiplier, color = DayS3Color, style = plot.style_line, linewidth =1) // Getting daywise Resistance levels [DayR1, DayR2, DayR3] = request.security(syminfo.tickerid, "D", [R1[0], R2[0], R3[0]], barmerge.gaps_off, barmerge.lookahead_on) //DayR2 = request.security(syminfo.tickerid, "D", R2[0], barmerge.gaps_off, barmerge.lookahead_on) //DayR3 = request.security(syminfo.tickerid, "D", R3[0], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for daywise Support levels DayR1Color =DayR1 != DayR1[0] ? na : color.red DayR2Color =DayR2 != DayR2[0] ? na : color.red DayR3Color =DayR3 != DayR3[0] ? na : color.red //Plotting daywise Resistance levels plot(DayS1R1 ? DayR1 : na, title = "D-R1" , offset=offsetMultiplier, color = DayR1Color, style = plot.style_line, linewidth =1) plot(DayS2R2 ? DayR2 : na, title = "D-R2" , offset=offsetMultiplier, color = DayR2Color, style = plot.style_line, linewidth =1) plot(DayS3R3 ? DayR3 : na, title = "D-R3" , offset=offsetMultiplier, color = DayR3Color, style = plot.style_line, linewidth =1) //******************WEEKLY PIVOTS************************** // Getting Weely Pivot WPivot = request.security(syminfo.tickerid, "W", pivot[0], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Weely Pivot WeeklyPivotColor =WPivot != WPivot[0] ? na : color.blue //Plotting Weely Pivot plot(WeeklyPivotInclude ? WPivot:na, title = "W-P" , color = WeeklyPivotColor, style = plot.style_circles, linewidth =1) // Getting Weely Support levels [WS1, WS2, WS3] = request.security(syminfo.tickerid, "W", [S1[0], S2[0], S3[0]],barmerge.gaps_off, barmerge.lookahead_on) //WS2 = request.security(syminfo.tickerid, "W", S2[0],barmerge.gaps_off, barmerge.lookahead_on) //WS3 = request.security(syminfo.tickerid, "W", S3[0],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for weekly Support levels WS1Color =WS1 != WS1[0] ? na : color.green WS2Color =WS2 != WS2[0] ? na : color.green WS3Color =WS3 != WS3[0] ? na : color.green //Plotting Weely Support levels plot(WeeklyS1R1 ? WS1 : na, title = "W-S1" , offset=offsetMultiplier, color = WS1Color, style = plot.style_cross, linewidth =1) plot(WeeklyS2R2 ? WS2 : na, title = "W-S2" , offset=offsetMultiplier, color = WS2Color, style = plot.style_cross, linewidth =1) plot(WeeklyS3R3 ? WS3 : na, title = "W-S3" , offset=offsetMultiplier, color = WS3Color, style = plot.style_cross, linewidth =1) // Getting Weely Resistance levels [WR1, WR2, WR3] = request.security(syminfo.tickerid, "W", [R1[0], R2[0], R3[0]], barmerge.gaps_off, barmerge.lookahead_on) //WR2 = request.security(syminfo.tickerid, "W", R2[0], barmerge.gaps_off, barmerge.lookahead_on) //WR3 = request.security(syminfo.tickerid, "W", R3[0], barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for weekly Resistance levels WR1Color = WR1 != WR1[0] ? na : color.red WR2Color = WR2 != WR2[0] ? na : color.red WR3Color = WR3 != WR3[0] ? na : color.red //Plotting Weely Resistance levels plot(WeeklyS1R1 ? WR1 : na , title = "W-R1" , offset=offsetMultiplier, color = WR1Color, style = plot.style_cross, linewidth =1) plot(WeeklyS2R2 ? WR2 : na , title = "W-R2" , offset=offsetMultiplier, color = WR2Color, style = plot.style_cross, linewidth =1) plot(WeeklyS3R3 ? WR3 : na , title = "W-R3" , offset=offsetMultiplier, color = WR3Color, style = plot.style_cross, linewidth =1) //******************MONTHLY PIVOTS************************** // Getting Monhly Pivot MPivot = request.security(syminfo.tickerid, "M", pivot[0],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Monthly Support levels MonthlyPivotColor =MPivot != MPivot[0] ? na : color.blue //Plotting Monhly Pivot plot(MonthlyPivotInclude? MPivot:na, title = " M-P" , color = MonthlyPivotColor, style = plot.style_line, linewidth =1) // Getting Monhly Support levels [MS1, MS2, MS3] = request.security(syminfo.tickerid, "M", [S1[0], S2[0], S3[0]],barmerge.gaps_off, barmerge.lookahead_on) //MS2 = request.security(syminfo.tickerid, "M", S2[0],barmerge.gaps_off, barmerge.lookahead_on) //MS3 = request.security(syminfo.tickerid, "M", S3[0],barmerge.gaps_off, barmerge.lookahead_on) //Adding linebreaks for Montly Support levels MS1Color =MS1 != MS1[0] ? na : color.green MS2Color =MS2 != MS2[0] ? na : color.green MS3Color =MS3 != MS3[0] ? na : color.green //Plotting Monhly Support levels plot(MonthlyS1R1 ? MS1 : na, title = "M-S1" , offset=offsetMultiplier, color = MS1Color, style = plot.style_circles, linewidth =1) plot(MonthlyS2R2 ? MS2 : na, title = "M-S2" , offset=offsetMultiplier, color = MS2Color, style = plot.style_circles, linewidth =1) plot(MonthlyS3R3 ? MS3 : na, title = "M-S3" , offset=offsetMultiplier, color = MS3Color, style = plot.style_circles, linewidth =1) // Getting Monhly Resistance levels [MR1, MR2, MR3] = request.security(syminfo.tickerid, "M", [R1[0], R2[0], R3[0]],barmerge.gaps_off, barmerge.lookahead_on) //MR2 = request.security(syminfo.tickerid, "M", R2[0],barmerge.gaps_off, barmerge.lookahead_on) //MR3 = request.security(syminfo.tickerid, "M", R3[0],barmerge.gaps_off, barmerge.lookahead_on) MR1Color =MR1 != MR1[0] ? na : color.red MR2Color =MR2 != MR2[0] ? na : color.red MR3Color =MR3 != MR3[0] ? na : color.red //Plotting Monhly Resistance levels plot(MonthlyS1R1 ? MR1 : na , title = "M-R1", offset=offsetMultiplier, color = MR1Color, style = plot.style_circles , linewidth =1) plot(MonthlyS2R2 ? MR2 : na , title = "M-R2" , offset=offsetMultiplier, color = MR2Color, style = plot.style_circles, linewidth =1) plot(MonthlyS3R3 ? MR3 : na, title = "M-R3" , offset=offsetMultiplier, color = MR3Color, style = plot.style_circles, linewidth =1) //*****************************INDICATORs************************** // ################################################################################################## // ############################################### CPR ############################################## // ################################################################################################## // ################################################################################################## // ############################################# FUTURES ########################################### // ################################################################################################## symFutures = (syminfo.tickerid == "NSE:CNXFINANCE") ? "NSE:NIFTY1!" : syminfo.tickerid+"1!" [futuresOpen, futuresHigh, futuresLow, futuresClose, futuresVolume]=request.security(symForVolume,timeframe.period,[open, high, low, close, volume]) plot(futuresClose, title='Nifty Futures', color=color.new(color.purple, 0), linewidth=2, style=plot.style_line) // else if syminfo.ticker=="NSE:BANKNIFTY" // [futuresOpen,futuresHigh, futuresLow,futuresClose, volumeFutures]=request.security("NSE:BANKNIFTY1!",timeframe.period,[open, high, low, close, volume]) // else if syminfo.ticker=="NSE:CNXFINANCE" // [futuresOpen,futuresHigh, futuresLow,futuresClose, volumeFutures]=request.security("NSE:BANKNIFTY1!",timeframe.period,[open, high, low, close, volume]) // else // [futuresOpen,futuresHigh, futuresLow,futuresClose, volumeFutures]=request.security(syminfo.ticker,timeframe.period,[open, high, low, close, volume]) // ################################################################################################## // ############################################# FUTURES ########################################### // ################################################################################################## // ################################################################################################## // ############################################# US FUTURES ########################################### // ################################################################################################## [USFutOpen, USFutOpen1, USFutClose, USFutClose1]=request.security("CURRENCYCOM:US30",'D',[open, open[1], close,close[1]]) //USOpeningRatio= //[futuresOpen, futuresHigh, futuresLow, futuresClose, futuresVolume]=request.security(symForVolume,timeframe.period,[open, high, low, close, volume]) //plot(futuresClose, title='Nifty Futures', color=color.new(color.purple, 0), linewidth=2, style=plot.style_line) // tUS = input.symbol("CURRENCYCOM:US30","TickerUS") // [tsUS,tsUSC1] = request.security(tUS,'D',[close,close[1]]) // tsUSTF1 = request.security(tUS,TF1,close[1]) // tsUSTF2 = request.security(tUS,TF2,close[1]) // //tsUSTF3 = request.security(tUS,TF3,close[1]) // tsUSChng = (tsUS-tsUSC1) // tsUSp = (tsUS-tsUSC1)*100/tsUSC1 // tsUS1 = (tsUS-tsUSTF1)*100/tsUSTF1 // tsUS2 = (tsUS-tsUSTF2)*100/tsUSTF2 //tsUS3 = (tsUS-tsUSC1)*100/tsUSTF3 // ################################################################################################## // ############################################# US FUTURES ########################################### // ################################################################################################## // ################################################################################################## // ######################################## MOVING AVERAGES ######################################### // ################################################################################################## //timeframe.period smaExp25 = ta.sma(close, 25) smaExp50 = ta.sma(close, 50) smaExp100 = ta.sma(close, 100) smaExp200 = ta.sma(close, 200) [sma25, sma50, sma100, sma200]= request.security(syminfo.tickerid, timeframe.period, [smaExp25, smaExp50, smaExp100, smaExp200]) plot(sma25, color=color.new(color.orange, 0), linewidth = 1, title="SMA25", style = plot.style_circles) plot(sma50, color=color.new(color.orange, 0), linewidth = 1, title="SMA50", style = plot.style_line) //plot(sma100, color=#00d8ff, linewidth = 1, title="SMA100") plot(sma200, color=color.new(color.orange, 0), linewidth = 2, title="SMA200", style = plot.style_line) //Days [sma50d, sma100d, sma200d]= request.security(syminfo.tickerid, "D", [smaExp50, smaExp100, smaExp200]) plot(sma50d, color=color.new(color.orange, 0), linewidth = 3, title="SMA50D", style = plot.style_line) plot(sma100d, color=color.new(color.orange, 0), linewidth = 4, title="SMA100D", style = plot.style_line) plot(sma200d, color=color.new(color.orange, 0), linewidth = 5, title="SMA200D", style = plot.style_line) // ################################################################################################## // ######################################## MOVING AVERAGES ######################################### // ################################################################################################## // ################################################################################################## // ######################################## SIMPLE TRENDLINE ######################################## // ################################################################################################## // shortPeriod = input(30, title="shortPeriod") // longPeriod = input(100, title="longPeriod") // if barstate.islast // float lowest_y2 = 60000 // float lowest_x2 = 0 // float highest_y2 = 0 // float highest_x2 = 0 // for i = 1 to shortPeriod // if low[i] < lowest_y2 // lowest_y2 := low[i] // lowest_x2 := i // if high[i] > highest_y2 // highest_y2 := high[i] // highest_x2 := i // float lowest_y1 = 60000 // float lowest_x1 = 0 // float highest_y1 = 0 // float highest_x1 = 0 // for j = shortPeriod + 1 to longPeriod // if low[j] < lowest_y1 // lowest_y1 := low[j] // lowest_x1 := j // if high[j] > highest_y1 // highest_y1 := high[j] // highest_x1 := j // sup = line.new(x1=bar_index[lowest_x1], y1=lowest_y1, x2=bar_index[lowest_x2], y2=lowest_y2, extend=extend.right, width=2, color=color.green) // res = line.new(x1=bar_index[highest_x1], y1=highest_y1, x2=bar_index[highest_x2], y2=highest_y2, extend=extend.right, width=2, color=color.red) // line.delete(sup[1]) // line.delete(res[1]) // if ta.crossunder(close, line.get_price(sup, bar_index[0])) // alert("break support", freq=alert.freq_once_per_bar_close) // if ta.crossover(close, line.get_price(res, bar_index[0])) // alert("break resistance", freq=alert.freq_once_per_bar_close) // ################################################################################################## // ######################################## SIMPLE TRENDLINE ######################################## // ##################################################################################################
[FrizLabz] FVG
https://www.tradingview.com/script/2mzSNuAs-FrizLabz-FVG/
FFriZz
https://www.tradingview.com/u/FFriZz/
365
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FFriZz //@version=5 indicator("[FrizLabz] FVG",overlay = true,max_lines_count = 500,max_labels_count = 500,max_boxes_count = 500,max_bars_back = 5000,explicit_plot_zorder = true) // -- Inputs -- // FVG = input.bool(true ,'FVGs | On/Off?',group = 'FVG Settings') BULLfvgc = input.color(#000000,'FVG Color : ',group = 'FVG Settings',inline = '1') BEARfvgc = input.color(#000000,'<-- BullFVG | BearFVG --> ',group = 'FVG Settings',inline = '1') TT = input.bool(true, 'FVG ToolTips?',group = 'FVG Settings') bC = input.bool(false ,'Remove Bar Color?',group = 'FVG Settings') UTC = input.int(-5,'Time Adj UTC (Match Chart UTC Time)',group = 'FVG Settings',minval=-23,maxval = 25) UTC := UTC * 3600000 // -- Constants -- // fTime = '\nTime : ' + str.format("{0,date," + 'hh:mm a' + "}", time[1] + UTC) BearFVG = high < low[2] and FVG BullFVG = low > high[2] and FVG FVGc = BullFVG ? BULLfvgc : BEARfvgc // -- Variables -- // var label Label = na bool BearFVGp = false bool BullFVGp = false // -- Labels and FVG plot Switches -- // // -- Bear -- // if BearFVG Label := TT ? label.new( x = time[1], y = math.avg(high,low[2]), text = ' ', xloc = xloc.bar_time, color = color(na), style = label.style_label_center, size = size.large, tooltip = 'Bear FVG\n---------------------' + '\nSize : ' + str.tostring(low[2] - high) + '\nTop : ' + str.tostring(low[2]) + '\nMiddle : ' + str.tostring(math.avg(low[2],high)) + '\nBottom : ' + str.tostring(high) + fTime) : na BearFVGp := true if BearFVGp == true and BearFVGp[1] == true BearFVGp := false // -- Bull -- // if BullFVG Label := TT ? label.new( x = time[1], y = math.avg(high[2],low), text = ' ', xloc = xloc.bar_time, color = color(na), style = label.style_label_center, size = size.large, tooltip = 'Bull FVG\n---------------------' + '\nSize : ' + str.tostring(low - high[2]) + '\nTop : ' + str.tostring(low) + '\nMiddle : ' + str.tostring(math.avg(high[2],low)) + '\nBottom : ' + str.tostring(high[2]) + fTime) : na BullFVGp := true if BullFVGp == true and BullFVGp[1] == true BullFVGp := false bool BullGO1 = BullFVG and BullFVGp bool BearGO1 = BearFVG and BearFVGp bool BullGO2 = BullFVG and BullGO1 == false bool BearGO2 = BearFVG and BearGO1 == false // -- Bear-Bull FVG plots -- // // Plots Need Sequences to prevent the fills from forming to plot lines and covering 2 bars if another FVG is on next Bar // Can have Bear and Bull in each plot pair because you cant have a Bull and Bear FVG on the Same bar // -- Pair 1 -- // p1 = plot(FVG ? BearGO1 ? low[2] : BullGO1 ? low : na : na, style = plot.style_stepline, offset=-1,display = display.none, editable = false) p2 = plot(FVG ? BearGO1 ? high : BullGO1 ? high[2] : na : na, style = plot.style_stepline, offset=-1, display = display.none, editable = false) fill(p1,p2,color = FVGc[1],editable = false) // -- Pair 2 -- // p3 = plot(FVG ? BearGO2 ? low[2] : BullGO2 ? low : na : na, style = plot.style_stepline, offset=-1,display = display.none, editable = false) p4 = plot(FVG ? BearGO2 ? high : BullGO2 ? high[2] : na : na, style = plot.style_stepline, offset=-1, display = display.none, editable = false) fill(p3,p4,color = FVGc[1],editable = false) barcolor(color = bC and (BullFVG or BearFVG) ? color.new(color.white,100) : na, offset = -1, editable = false)
VIX - SKEW Divergence
https://www.tradingview.com/script/uRF1KArk-VIX-SKEW-Divergence/
valpatrad
https://www.tradingview.com/u/valpatrad/
49
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © valpatrad //@version=5 indicator('VIX - SKEW Divergence') gaps = input.bool(false, 'Gaps', tooltip='If not checked, gaps are filled with the latest available value.') //////////////////////////// // // // Menu // // // //////////////////////////// //Lines show_vix = input.bool(true,'VIX                 ', group='Lines', inline='VIX') col_vix = input.color(#FF0000, '', group='Lines', inline='VIX') w_vix = input.int(1, '', 1, 4, group='Lines', inline='VIX', tooltip='The numeric value refers to the width of the line.') show_skew = input.bool(true, 'SKEW              ', group='Lines', inline='SKEW') col_skew = input.color(#00FF00, '', group='Lines', inline='SKEW') w_skew = input.int(1, '', 1, 4, group='Lines', inline='SKEW') show_div = input.bool(true, 'Divergence      ', inline='Divergence', group='Lines') col_div = input.color(#B2B5BE, '', inline='Divergence', group='Lines') w_div = input.int(1, '', 1, 4, inline='Divergence', group='Lines') show_avg_div = input.bool(true, 'Avg Divergence', inline='Avg Divergence', group='Lines') col_avg_div = input.color(#0000FF, '', inline='Avg Divergence', group='Lines') w_avg_div = input.int(1, '', 1, 4, inline='Avg Divergence', group='Lines') //VIX - SKEW Divergence Area show_vix_skew_area = input.bool(true, 'VIX - SKEW Area', group='VIX - SKEW Divergence Area', tooltip='Fill the area between the VIX and the SKEW.') data_min = input.int(40, 'Lowest Color ', 0, group='VIX - SKEW Divergence Area', inline='Low') data_max = input.int(170, 'Highest Color', 0, group='VIX - SKEW Divergence Area', inline='High') col_min = input.color(color.new(#00FF00, 50), '', group='VIX - SKEW Divergence Area', inline='Low') col_max = input.color(color.new(#FF0000, 50), '', group='VIX - SKEW Divergence Area', inline='High') //VIX Area show_vix_area = input.bool(false, 'VIX Area', group='VIX Area', tooltip='Fill the VIX area.') col_lvl_1 = input.color(color.new(#00FF00, 60), 'Level 1', group='VIX Area', inline='Level 1', tooltip='These numbers represent the thresholds and each one must be higher than the previous.') col_lvl_2 = input.color(color.new(#FFFA00, 60), 'Level 2', group='VIX Area', inline='Level 2') col_lvl_3 = input.color(color.new(#FF9600, 60), 'Level 3', group='VIX Area', inline='Level 3') col_lvl_4 = input.color(color.new(#FF0000, 60), 'Level 4', group='VIX Area', inline='Level 4') lvl_1 = input.int(12, '', 0, group='VIX Area', inline='Level 1') lvl_2 = input.int(20, '', 0, group='VIX Area', inline='Level 2') lvl_3 = input.int(37, '', 0, group='VIX Area', inline='Level 3') //Average Divergence show_div_avg = input.bool(true, 'Avg Divergence Area', group='Average Divergence', inline='Area') col_div_avg = input.color(color.new(#787B86, 50), '', group='Average Divergence', inline='Area', tooltip='Fill the area between the divergence and the average divergence.') avg_type = input.string('Median', 'Avg Type', ['Median', 'MA', 'EMA', 'WMA'], group='Average Divergence', inline='Avg') avg_len = input.int(30, 'Length', 1, group='Average Divergence', inline='Avg') ///////////////////////////// // // // Variables // // // ///////////////////////////// vix = ticker.new('CBOE', 'VIX', session.extended) skew = ticker.new('CBOE', 'SKEW', session.extended) data_vix = request.security(vix, '', close, gaps ? barmerge.gaps_on : barmerge.gaps_off) data_skew = request.security(skew, '', close, gaps ? barmerge.gaps_on : barmerge.gaps_off) div = data_skew-data_vix avg(p) => if avg_type == 'Median' ta.median(div, p) else if avg_type == 'MA' ta.sma(div, p) else if avg_type == 'EMA' ta.ema(div, p) else if avg_type == 'WMA' ta.wma(div, p) //////////////////////////// // // // Plot // // // //////////////////////////// p0 = plot(show_vix_area ? 0 : na, editable=false, display=display.none) p1 = plot(data_vix, '', col_vix, w_vix, plot.style_linebr, editable=false, display=display.none) p2 = plot(data_skew, '', col_skew, w_skew, plot.style_linebr, editable=false, display=display.none) p3 = plot(div, '', col_div, w_div, plot.style_linebr, editable=false, display=display.none) p4 = plot(avg(avg_len), '', col_avg_div, w_avg_div, plot.style_linebr, editable=false, display=display.none) fill(p1, p2, show_vix_skew_area and data_max > data_min ? color.from_gradient(data_skew - data_vix, data_min, data_max, col_min, col_max) : na) fill(p0, p1, data_vix > lvl_3 ? col_lvl_4 : data_vix > lvl_2 ? col_lvl_3 : data_vix > lvl_1 ? col_lvl_2 : col_lvl_1) fill(p3, p4, show_div_avg ? col_div_avg : na) plot(show_vix ? data_vix : na, '', col_vix, w_vix, plot.style_linebr, editable=false) plot(show_skew ? data_skew : na, '', col_skew, w_skew, plot.style_linebr, editable=false) plot(show_div ? div : na, '', col_div, w_div, plot.style_linebr, editable=false) plot(show_avg_div ? avg(avg_len) : na, '', col_avg_div, w_avg_div, plot.style_linebr, editable=false) /////////////////////////// // // // Table // // // /////////////////////////// //Menu tab_vix = input.bool(true, 'VIX                 ', group='Table', inline='VIX') tab_vix_txt = input.color(#FFFFFF, '', group='Table', inline='VIX', tooltip='The color refers to the text.') tab_skew = input.bool(true, 'SKEW              ', group='Table', inline='SKEW') tab_skew_txt = input.color(#FFFFFF, '', group='Table', inline='SKEW') tab_div = input.bool(true, 'Divergence      ', group='Table', inline='Divergence') tab_div_txt = input.color(#FFFFFF, '', group='Table', inline='Divergence') tab_avg_div = input.bool(true, 'Avg Divergence', group='Table', inline='Avg Divergence') tab_avg_div_txt = input.color(#FFFFFF, '', group='Table', inline='Avg Divergence') bkgd_tr_1 = input.int(50, 'BKGD', 0, 100, group='Table', inline='Transparency 1') txt_tr_1 = input.int(30, 'Text', 0, 100, group='Table', inline='Transparency 1', tooltip='Transparency settings for the first column.') bkgd_tr_2 = input.int(70, 'BKGD', 0, 100, group='Table', inline='Transparency 2') txt_tr_2 = input.int(0, 'Text', 0, 100, group='Table', inline='Transparency 2', tooltip='Transparency settings for the second column.') width_bord = input.int(1, 'Border Width', 0, group='Table') in_font = input.string('Default', 'Text Font' , ['Default', 'Monospace'], group='Table') font = switch in_font 'Default' => font.family_default 'Monospace' => font.family_monospace input_tab_size = input.string('Auto', 'Size', group='Table', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge']) tab_size = switch input_tab_size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge input_tab_pos = input.string('Bottom Right', 'Position', group='Table', options=['Top Left', 'Top Center', 'Top Right', 'Middle Left', 'Middle Center', 'Middle Right', 'Bottom Left', 'Bottom Center', 'Bottom Right']) tab_pos = switch input_tab_pos 'Top Left' => position.top_left 'Top Center' => position.top_center 'Top Right' => position.top_right 'Middle Left' => position.middle_left 'Middle Center' => position.middle_center 'Middle Right' => position.middle_right 'Bottom Left' => position.bottom_left 'Bottom Center' => position.bottom_center 'Bottom Right' => position.bottom_right //Variables chg_vix = (data_vix-data_vix[1])/data_vix[1]*100 chg_skew = (data_skew-data_skew[1])/data_skew[1]*100 chg_div = (div-div[1])/div[1]*100 avg_div = div-avg(avg_len) //Plot tab = table.new(tab_pos, 2, 4, border_width=width_bord) _tab(a, r, b, txt, _txt_col, _bgcol) => int row = 0 float chg = 0 string name = '' if a row := r chg := b name := txt table.cell(tab, 0, row, txt, text_color=color.new(_txt_col, txt_tr_1), text_size=tab_size, bgcolor=color.new(_bgcol, bkgd_tr_1), text_font_family=font) table.cell(tab, 1, row, name == 'Div-Avg' ? str.tostring(avg_div, '#.##') : chg > 0 ? '+' + str.tostring(chg, format.percent) : chg == 0 ? 'UNCH' : str.tostring(chg, format.percent), text_color=chg > 0 ? color.new(#4CAF50, txt_tr_2) : chg == 0 ? color.new(#FFFFFF, txt_tr_2) : color.new(#FF5252, txt_tr_2), text_size=tab_size, bgcolor=chg > 0 ? color.new(#4CAF504D, bkgd_tr_2) : chg == 0 ? color.new(#F1F1F1, bkgd_tr_2) : color.new(#FF52524D, bkgd_tr_2), text_font_family=font) if not timeframe.isintraday _tab(tab_vix, 0, chg_vix, 'VIX', tab_vix_txt, col_vix) _tab(tab_skew, 1, chg_skew, 'SKEW', tab_skew_txt, col_skew) _tab(tab_div, 2, chg_div, 'Div', tab_div_txt, col_div) _tab(tab_avg_div, 3, avg_div, 'Div-Avg', tab_avg_div_txt, col_avg_div)
PluePhantom's Trailing Stop Loss Multiple of ATR
https://www.tradingview.com/script/lk92CSBU-PluePhantom-s-Trailing-Stop-Loss-Multiple-of-ATR/
ChamodSachin
https://www.tradingview.com/u/ChamodSachin/
18
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ChamodSachin //@version=5 indicator("PluePhantom's Trailing stop loss v5", overlay=true) ATR = ta.atr(input(defval=14,title="ATR"))[1] Multip = input(defval=1.5,title="Multiplier") Longstop =low - ATR * Multip Shortstop =high + ATR * Multip plot(Longstop,"Long Stop Loss") plot(Shortstop,"Short Stop Loss")
Growth Stock Cyclic
https://www.tradingview.com/script/3ylQqBw5-Growth-Stock-Cyclic/
jamiesonpa
https://www.tradingview.com/u/jamiesonpa/
8
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // This indicator takes advantage of the fact that when the 10 and 5 year Treasury Constant Maturity Minus Federal Funds rates (T10YFF/T5YFF) // go down sharply, investors tend to rotate into stocks. This arbitrage works great for growth stocks, since growth stocks are higher beta by // virtue of their lower market cap and more speculative nature in general. This script identifies the moving-average convergence/divergence of the // average of the 10y and 5y treasury rates and then finds the variance of that macd line. By averaging that variance with the macdline's inverse, // an analog output of treasury -> stock rotation can be identified. The upper and lower thresholds bring buy and sell windows into focus. // © jamiesonpa //@version=5 indicator("Growth Stock Cyclic") t10yff = input.symbol("FRED:T10YFF", "Symbol") t10yff_security = request.security(t10yff, 'D', close) t5yff = input.symbol("FRED:T5YFF", "Symbol") t5yff_security = request.security(t5yff, 'D', close) t10yff_security := (t10yff_security + t5yff_security)/2 [t10yff_security_macdLine, t10yff_security_signalLine, t10yff_security_histLine] = ta.macd(close, 3, 12, 120) indicator_falling = ta.falling(t10yff_security_macdLine, 3) tymacdvariance = ta.sma(ta.variance(t10yff_security_macdLine,5),3) slope = t10yff_security_macdLine - t10yff_security_macdLine[1] buy_signal_line = (-t10yff_security_macdLine + tymacdvariance)/2 xMax = ta.highest(buy_signal_line,500) xMin = ta.lowest(buy_signal_line, 500) line_range = xMax - xMin buy_signal_line := 100 * buy_signal_line / line_range bsl_top_threshold = ta.variance(buy_signal_line, 20) bsl_top_threshold := (ta.sma(bsl_top_threshold, 10)/30)+10 bsl_bottom_threshold = ta.variance(buy_signal_line, 20) bsl_bottom_threshold := (ta.sma(bsl_bottom_threshold, 10)/30)-10 //plot(tymacdvariance) //plot(-t10yff_security_macdLine, color=color.red) plot(buy_signal_line, color=color.white) plot(bsl_top_threshold, color=color.red) plot(bsl_bottom_threshold, color=color.green) //plot(percent_change_10ymacdline, color= color.green) //plotshape(buysignal, location = location.abovebar, color= color.green, style = shape.cross, size = size.small)
PrasiGanFanFib
https://www.tradingview.com/script/TvkU7Pav-PrasiGanFanFib/
Prasi456
https://www.tradingview.com/u/Prasi456/
68
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Prasi456 //@version=5 indicator('autofibandGanFanPK', 'Auto Fibo & Gann Fan/Rets.', true, max_lines_count=500, max_labels_count=500) // inputs & definitions { showExtrema = input(true, 'Mark Extremum Points on the Chart                                                          ') fiboGroup = '===============[ Fibonacci ]===============' ffCount = input.int(1, 'Show', minval=0, inline='FiboFan', group=fiboGroup) ffStyle = input.string('Solid', 'Fans', options=['Dashed', 'Dotted', 'Solid'], inline='FiboFan', group=fiboGroup) showFFLabels = input.bool(true, 'Show Labels', inline='FiboFan', group=fiboGroup) frCount = input.int(1, 'Show', minval=0, inline='FiboRet', group=fiboGroup) frStyle = input.string('Dashed', 'Retracements', options=['Dashed', 'Dotted', 'Solid'], inline='FiboRet', group=fiboGroup) showFRLabels = input.bool(true, 'Show Labels', inline='FiboRet', group=fiboGroup) extendFR = input.bool(true, 'Extend the Most Recent Retracement Lines', group=fiboGroup) gannGroup = '===============[ Gann ]===============' gfCount = input.int(1, 'Show', minval=0, inline='GannFan', group=gannGroup) gfStyle = input.string('Solid', 'Fans', options=['Dashed', 'Dotted', 'Solid'], inline='GannFan', group=gannGroup) showGFLabels = input.bool(true, 'Show Labels', inline='GannFan', group=gannGroup) grCount = input.int(0, 'Show', minval=0, inline='GannRet', group=gannGroup) grStyle = input.string('Dotted', 'Retracements', options=['Dashed', 'Dotted', 'Solid'], inline='GannRet', group=gannGroup) showGRLabels = input.bool(true, 'Show Labels', inline='GannRet', group=gannGroup) extendGR = input.bool(true, 'Extend the Most Recent Retracement Lines', group=gannGroup) colorsGroup = '===============[ Line Colors ]===============' var fiboFanBearColors = array.from(input.color(color.new(color.red, 60), 'FiboFan ↘   23.6:', inline='FiboFan1', group=colorsGroup), input.color(color.new(color.red, 40), '38.2:', inline='FiboFan1', group=colorsGroup), input.color(color.new(color.red, 0), '50.0:', inline='FiboFan1', group=colorsGroup), input.color(color.new(color.red, 40), '61.8:', inline='FiboFan1', group=colorsGroup), input.color(color.new(color.red, 60), '78.6:', inline='FiboFan1', group=colorsGroup)) var fiboFanBullColors = array.from(input.color(color.new(color.green, 60), 'FiboFan ↗   23.6:', inline='FiboFan2', group=colorsGroup), input.color(color.new(color.green, 40), '38.2:', inline='FiboFan2', group=colorsGroup), input.color(color.new(color.green, 0), '50.0:', inline='FiboFan2', group=colorsGroup), input.color(color.new(color.green, 40), '61.8:', inline='FiboFan2', group=colorsGroup), input.color(color.new(color.green, 60), '78.6:', inline='FiboFan2', group=colorsGroup)) var fiboRetBearColors = array.from(input.color(color.new(color.red, 60), 'FiboRet ↘   23.6:', inline='FiboRet1', group=colorsGroup), input.color(color.new(color.red, 40), '38.2:', inline='FiboRet1', group=colorsGroup), input.color(color.new(color.red, 0), '50.0:', inline='FiboRet1', group=colorsGroup), input.color(color.new(color.red, 40), '61.8:', inline='FiboRet1', group=colorsGroup), input.color(color.new(color.red, 60), '78.6:', inline='FiboRet1', group=colorsGroup)) var fiboRetBullColors = array.from(input.color(color.new(color.green, 60), 'FiboRet ↗   23.6:', inline='FiboRet2', group=colorsGroup), input.color(color.new(color.green, 40), '38.2:', inline='FiboRet2', group=colorsGroup), input.color(color.new(color.green, 0), '50.0:', inline='FiboRet2', group=colorsGroup), input.color(color.new(color.green, 40), '61.8:', inline='FiboRet2', group=colorsGroup), input.color(color.new(color.green, 60), '78.6:', inline='FiboRet2', group=colorsGroup)) var gannFanBearColors = array.from(input.color(color.new(color.maroon, 60), 'GannFan ↘     4/1:', inline='GannFan1', group=colorsGroup), input.color(color.new(color.maroon, 40), '2/1:', inline='GannFan1', group=colorsGroup), input.color(color.new(color.maroon, 0), '1/1:', inline='GannFan1', group=colorsGroup), input.color(color.new(color.maroon, 40), '1/2:', inline='GannFan1', group=colorsGroup), input.color(color.new(color.maroon, 60), '1/4:', inline='GannFan1', group=colorsGroup)) var gannFanBullColors = array.from(input.color(color.new(color.teal, 60), 'GannFan ↗     4/1:', inline='GannFan2', group=colorsGroup), input.color(color.new(color.teal, 40), '2/1:', inline='GannFan2', group=colorsGroup), input.color(color.new(color.teal, 0), '1/1:', inline='GannFan2', group=colorsGroup), input.color(color.new(color.teal, 40), '1/2:', inline='GannFan2', group=colorsGroup), input.color(color.new(color.teal, 60), '1/4:', inline='GannFan2', group=colorsGroup)) var gannRetBearColors = array.from(input.color(color.new(color.maroon, 60), 'GannRet ↘   12.5:', inline='GannRet1', group=colorsGroup), input.color(color.new(color.maroon, 40), '25.0:', inline='GannRet1', group=colorsGroup), input.color(color.new(color.maroon, 0), '50.0:', inline='GannRet1', group=colorsGroup), input.color(color.new(color.maroon, 40), '75.0:', inline='GannRet1', group=colorsGroup), input.color(color.new(color.maroon, 60), '87.5:', inline='GannRet1', group=colorsGroup)) var gannRetBullColors = array.from(input.color(color.new(color.teal, 60), 'GannRet ↗   12.5:', inline='GannRet2', group=colorsGroup), input.color(color.new(color.teal, 40), '25.0:', inline='GannRet2', group=colorsGroup), input.color(color.new(color.teal, 0), '50.0:', inline='GannRet2', group=colorsGroup), input.color(color.new(color.teal, 40), '75.0:', inline='GannRet2', group=colorsGroup), input.color(color.new(color.teal, 60), '87.5:', inline='GannRet2', group=colorsGroup)) fiboRetLineStyle = frStyle == 'Dashed' ? line.style_dashed : frStyle == 'Dotted' ? line.style_dotted : line.style_solid fiboFanLineStyle = ffStyle == 'Dashed' ? line.style_dashed : ffStyle == 'Dotted' ? line.style_dotted : line.style_solid gannRetLineStyle = grStyle == 'Dashed' ? line.style_dashed : grStyle == 'Dotted' ? line.style_dotted : line.style_solid gannFanLineStyle = gfStyle == 'Dashed' ? line.style_dashed : gfStyle == 'Dotted' ? line.style_dotted : line.style_solid var float highPrice = na var float highestPrice = na var float lowPrice = na var float lowestPrice = na var highBar = 0 var highestBar = 0 var lowBar = 0 var lowestBar = 0 var waitingFor = '' var chartScale = 1. var scales = array.new_float() fiboRatios = array.from(.236, .382, .5, .618, .786) fiboRatioLabels = array.from('23.6', '38.2', '50', '61.8', '78.6') gannFanRatios = array.from(15. / 90, 26.25 / 90, 45. / 90, 63.75 / 90, 75. / 90) gannFanRatioLabels = array.from('4:1', '2:1', '1:1', '1:2', '1:4') gannRetRatios = array.from(.125, .25, .5, .75, .875) gannRetRatioLabels = array.from('12.5', '25', '50', '75', '87.5') var fiboRet1 = array.new_line() var fiboRet2 = array.new_line() var fiboRet3 = array.new_line() var fiboRet4 = array.new_line() var fiboRet5 = array.new_line() var fiboRet6 = array.new_line() var fiboRet7 = array.new_line() var gannRet1 = array.new_line() var gannRet2 = array.new_line() var gannRet3 = array.new_line() var gannRet4 = array.new_line() var gannRet5 = array.new_line() var gannRet6 = array.new_line() var gannRet7 = array.new_line() var fiboFan1 = array.new_line() var fiboFan2 = array.new_line() var fiboFan3 = array.new_line() var fiboFan4 = array.new_line() var fiboFan5 = array.new_line() var fiboFan6 = array.new_line() var fiboFan7 = array.new_line() var gannFan1 = array.new_line() var gannFan2 = array.new_line() var gannFan3 = array.new_line() var gannFan4 = array.new_line() var gannFan5 = array.new_line() var gannFan6 = array.new_line() var gannFan7 = array.new_line() var fiboRetLabel1 = array.new_label() var fiboRetLabel2 = array.new_label() var fiboRetLabel3 = array.new_label() var fiboRetLabel4 = array.new_label() var fiboRetLabel5 = array.new_label() var fiboFanLabel1 = array.new_label() var fiboFanLabel2 = array.new_label() var fiboFanLabel3 = array.new_label() var fiboFanLabel4 = array.new_label() var fiboFanLabel5 = array.new_label() var gannRetLabel1 = array.new_label() var gannRetLabel2 = array.new_label() var gannRetLabel3 = array.new_label() var gannRetLabel4 = array.new_label() var gannRetLabel5 = array.new_label() var gannFanLabel1 = array.new_label() var gannFanLabel2 = array.new_label() var gannFanLabel3 = array.new_label() var gannFanLabel4 = array.new_label() var gannFanLabel5 = array.new_label() var fiboRetLabels = array.new_label(5, na) var fiboFanLabels = array.new_label(5, na) var gannRetLabels = array.new_label(5, na) var gannFanLabels = array.new_label(5, na) var fiboFanSlopes = array.new_float(5, na) var gannFanSlopes = array.new_float(5, na) //} // find proper chart scale, highest and lowest pivots and draw line sets { // functions calcScale(bar1, price1, bar2, price2) => if array.size(scales) == 100000 array.shift(scales) array.push(scales, math.abs(price2 - price1) / (bar2 - bar1)) array.median(scales) isHigh() => isHigh = false bar = bar_index price = high if close < open for i = 1 to 10 by 1 if close[i] < open[i] break else bar := price < high[i] ? bar_index - i : bar price := math.max(price, high[i]) if close[i] == open[i] continue if close[i] > open[i] isHigh := true break [isHigh, bar, price] isLow() => isLow = false bar = bar_index price = low if close > open for i = 1 to 10 by 1 if close[i] > open[i] break else bar := price > low[i] ? bar_index - i : bar price := math.min(price, low[i]) if close[i] == open[i] continue if close[i] < open[i] isLow := true break [isLow, bar, price] showLabel(setType, labelArray, arrayIndex, x, y, text_1, colour) => if showFRLabels and setType == 'fret' or showGRLabels and setType == 'gret' or showFFLabels and setType == 'ffan' or showGFLabels and setType == 'gfan' label.delete(array.get(labelArray, arrayIndex)) array.set(labelArray, arrayIndex, label.new(x, y, text_1, color=na, textcolor=colour)) saveLastLabels(setType, labelArray) => if setType == 'fret' array.push(fiboRetLabel1, array.get(labelArray, 0)) array.push(fiboRetLabel2, array.get(labelArray, 1)) array.push(fiboRetLabel3, array.get(labelArray, 2)) array.push(fiboRetLabel4, array.get(labelArray, 3)) array.push(fiboRetLabel5, array.get(labelArray, 4)) else if setType == 'gret' array.push(gannRetLabel1, array.get(labelArray, 0)) array.push(gannRetLabel2, array.get(labelArray, 1)) array.push(gannRetLabel3, array.get(labelArray, 2)) array.push(gannRetLabel4, array.get(labelArray, 3)) array.push(gannRetLabel5, array.get(labelArray, 4)) else if setType == 'ffan' array.push(fiboFanLabel1, array.get(labelArray, 0)) array.push(fiboFanLabel2, array.get(labelArray, 1)) array.push(fiboFanLabel3, array.get(labelArray, 2)) array.push(fiboFanLabel4, array.get(labelArray, 3)) array.push(fiboFanLabel5, array.get(labelArray, 4)) else if setType == 'gfan' array.push(gannFanLabel1, array.get(labelArray, 0)) array.push(gannFanLabel2, array.get(labelArray, 1)) array.push(gannFanLabel3, array.get(labelArray, 2)) array.push(gannFanLabel4, array.get(labelArray, 3)) array.push(gannFanLabel5, array.get(labelArray, 4)) for i = 0 to 4 by 1 array.set(labelArray, i, na) drawLineSet(setType, ratioArray, ratioLabelArray, labelArray, lineArray1, lineArray2, lineArray3, lineArray4, lineArray5, lineArray6, lineArray7, bar1, price1, bar2, price2, extend, bullColors, bearColors, style) => colors = array.copy(price1 < price2 ? bullColors : bearColors) barRange = price1 < price2 ? bar1 - bar2 : bar2 - bar1 priceRange = price1 - price2 levelPrice = 0. array.push(lineArray1, line.new(bar1, price1, bar2, price1, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 2), style=style)) levelPrice := price1 - (setType != 'gfan' ? priceRange * (1 - array.get(ratioArray, 0)) : barRange * math.tan(array.get(ratioArray, 0) * math.pi / 2) * chartScale) array.push(lineArray2, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : levelPrice, bar2, levelPrice, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 0), style=style)) showLabel(setType, labelArray, 0, bar2, levelPrice, array.get(ratioLabelArray, 0), array.get(colors, 0)) if setType == 'ffan' array.set(fiboFanSlopes, 0, (levelPrice - price1) / (bar2 - bar1)) if setType == 'gfan' array.set(gannFanSlopes, 0, (levelPrice - price1) / (bar2 - bar1)) levelPrice := price1 - (setType != 'gfan' ? priceRange * (1 - array.get(ratioArray, 1)) : barRange * math.tan(array.get(ratioArray, 1) * math.pi / 2) * chartScale) array.push(lineArray3, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : levelPrice, bar2, levelPrice, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 1), style=style)) showLabel(setType, labelArray, 1, bar2, levelPrice, array.get(ratioLabelArray, 1), array.get(colors, 1)) if setType == 'ffan' array.set(fiboFanSlopes, 1, (levelPrice - price1) / (bar2 - bar1)) if setType == 'gfan' array.set(gannFanSlopes, 1, (levelPrice - price1) / (bar2 - bar1)) levelPrice := price1 - (setType != 'gfan' ? priceRange * (1 - array.get(ratioArray, 2)) : barRange * math.tan(array.get(ratioArray, 2) * math.pi / 2) * chartScale) array.push(lineArray4, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : levelPrice, bar2, levelPrice, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 2), style=style)) showLabel(setType, labelArray, 2, bar2, levelPrice, array.get(ratioLabelArray, 2), array.get(colors, 2)) if setType == 'ffan' array.set(fiboFanSlopes, 2, (levelPrice - price1) / (bar2 - bar1)) if setType == 'gfan' array.set(gannFanSlopes, 2, (levelPrice - price1) / (bar2 - bar1)) levelPrice := price1 - (setType != 'gfan' ? priceRange * (1 - array.get(ratioArray, 3)) : barRange * math.tan(array.get(ratioArray, 3) * math.pi / 2) * chartScale) array.push(lineArray5, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : levelPrice, bar2, levelPrice, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 3), style=style)) showLabel(setType, labelArray, 3, bar2, levelPrice, array.get(ratioLabelArray, 3), array.get(colors, 3)) if setType == 'ffan' array.set(fiboFanSlopes, 3, (levelPrice - price1) / (bar2 - bar1)) if setType == 'gfan' array.set(gannFanSlopes, 3, (levelPrice - price1) / (bar2 - bar1)) levelPrice := price1 - (setType != 'gfan' ? priceRange * (1 - array.get(ratioArray, 4)) : barRange * math.tan(array.get(ratioArray, 4) * math.pi / 2) * chartScale) array.push(lineArray6, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : levelPrice, bar2, levelPrice, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 4), style=style)) showLabel(setType, labelArray, 4, bar2, levelPrice, array.get(ratioLabelArray, 4), array.get(colors, 4)) if setType == 'ffan' array.set(fiboFanSlopes, 4, (levelPrice - price1) / (bar2 - bar1)) if setType == 'gfan' array.set(gannFanSlopes, 4, (levelPrice - price1) / (bar2 - bar1)) array.push(lineArray7, line.new(bar1, setType == 'ffan' or setType == 'gfan' ? price1 : price2, setType == 'gfan' ? bar1 : bar2, price2, extend=extend or setType == 'ffan' or setType == 'gfan' ? extend.right : extend.none, color=array.get(colors, 2), style=style)) cutLastRets() => index = array.size(fiboRet1) - 1 if index > -1 line.set_extend(array.get(fiboRet1, index), extend.none) line.set_extend(array.get(fiboRet2, index), extend.none) line.set_extend(array.get(fiboRet3, index), extend.none) line.set_extend(array.get(fiboRet4, index), extend.none) line.set_extend(array.get(fiboRet5, index), extend.none) line.set_extend(array.get(fiboRet6, index), extend.none) line.set_extend(array.get(fiboRet7, index), extend.none) index := array.size(gannRet1) - 1 if index > -1 line.set_extend(array.get(gannRet1, index), extend.none) line.set_extend(array.get(gannRet2, index), extend.none) line.set_extend(array.get(gannRet3, index), extend.none) line.set_extend(array.get(gannRet4, index), extend.none) line.set_extend(array.get(gannRet5, index), extend.none) line.set_extend(array.get(gannRet6, index), extend.none) line.set_extend(array.get(gannRet7, index), extend.none) delUnneededLines() => if array.size(fiboRet1) > frCount line.delete(array.shift(fiboRet1)) line.delete(array.shift(fiboRet2)) line.delete(array.shift(fiboRet3)) line.delete(array.shift(fiboRet4)) line.delete(array.shift(fiboRet5)) line.delete(array.shift(fiboRet6)) line.delete(array.shift(fiboRet7)) if array.size(fiboRetLabel1) > frCount - 1 and frCount > 0 label.delete(array.shift(fiboRetLabel1)) label.delete(array.shift(fiboRetLabel2)) label.delete(array.shift(fiboRetLabel3)) label.delete(array.shift(fiboRetLabel4)) label.delete(array.shift(fiboRetLabel5)) if array.size(gannRet1) > grCount line.delete(array.shift(gannRet1)) line.delete(array.shift(gannRet2)) line.delete(array.shift(gannRet3)) line.delete(array.shift(gannRet4)) line.delete(array.shift(gannRet5)) line.delete(array.shift(gannRet6)) line.delete(array.shift(gannRet7)) if array.size(gannRetLabel1) > grCount - 1 and grCount > 0 label.delete(array.shift(gannRetLabel1)) label.delete(array.shift(gannRetLabel2)) label.delete(array.shift(gannRetLabel3)) label.delete(array.shift(gannRetLabel4)) label.delete(array.shift(gannRetLabel5)) if array.size(fiboFan1) > ffCount line.delete(array.shift(fiboFan1)) line.delete(array.shift(fiboFan2)) line.delete(array.shift(fiboFan3)) line.delete(array.shift(fiboFan4)) line.delete(array.shift(fiboFan5)) line.delete(array.shift(fiboFan6)) line.delete(array.shift(fiboFan7)) if array.size(fiboFanLabel1) > ffCount - 1 and ffCount > 0 label.delete(array.shift(fiboFanLabel1)) label.delete(array.shift(fiboFanLabel2)) label.delete(array.shift(fiboFanLabel3)) label.delete(array.shift(fiboFanLabel4)) label.delete(array.shift(fiboFanLabel5)) if array.size(gannFan1) > gfCount line.delete(array.shift(gannFan1)) line.delete(array.shift(gannFan2)) line.delete(array.shift(gannFan3)) line.delete(array.shift(gannFan4)) line.delete(array.shift(gannFan5)) line.delete(array.shift(gannFan6)) line.delete(array.shift(gannFan7)) if array.size(gannFanLabel1) > gfCount - 1 and gfCount > 0 label.delete(array.shift(gannFanLabel1)) label.delete(array.shift(gannFanLabel2)) label.delete(array.shift(gannFanLabel3)) label.delete(array.shift(gannFanLabel4)) label.delete(array.shift(gannFanLabel5)) // find highests and lowests and draw retracements and fans [isH, hBar, hPrice] = isHigh() if isH chartScale := calcScale(highBar, highPrice, hBar, hPrice) if waitingFor != 'l' and hPrice < highPrice highestBar := highBar highestPrice := highPrice cutLastRets() if frCount > 0 saveLastLabels('fret', fiboRetLabels) drawLineSet('fret', fiboRatios, fiboRatioLabels, fiboRetLabels, fiboRet1, fiboRet2, fiboRet3, fiboRet4, fiboRet5, fiboRet6, fiboRet7, lowestBar, lowestPrice, highestBar, highestPrice, extendFR, fiboRetBullColors, fiboRetBearColors, fiboRetLineStyle) if ffCount > 0 saveLastLabels('ffan', fiboFanLabels) drawLineSet('ffan', fiboRatios, fiboRatioLabels, fiboFanLabels, fiboFan1, fiboFan2, fiboFan3, fiboFan4, fiboFan5, fiboFan6, fiboFan7, lowestBar, lowestPrice, highestBar, highestPrice, extendFR, fiboFanBullColors, fiboFanBearColors, fiboFanLineStyle) if grCount > 0 saveLastLabels('gret', gannRetLabels) drawLineSet('gret', gannRetRatios, gannRetRatioLabels, gannRetLabels, gannRet1, gannRet2, gannRet3, gannRet4, gannRet5, gannRet6, gannRet7, lowestBar, lowestPrice, highestBar, highestPrice, extendGR, gannRetBullColors, gannRetBearColors, gannRetLineStyle) if gfCount > 0 saveLastLabels('gfan', gannFanLabels) drawLineSet('gfan', gannFanRatios, gannFanRatioLabels, gannFanLabels, gannFan1, gannFan2, gannFan3, gannFan4, gannFan5, gannFan6, gannFan7, highestBar, highestPrice, bar_index, low, extendGR, gannFanBullColors, gannFanBearColors, gannFanLineStyle) delUnneededLines() waitingFor := 'l' if showExtrema label.new(highestBar, highestPrice, '') highBar := hBar highPrice := hPrice highPrice [isL, lBar, lPrice] = isLow() if isL chartScale := calcScale(lowBar, lowPrice, lBar, lPrice) if waitingFor != 'h' and lPrice > lowPrice lowestBar := lowBar lowestPrice := lowPrice cutLastRets() if frCount > 0 saveLastLabels('fret', fiboRetLabels) drawLineSet('fret', fiboRatios, fiboRatioLabels, fiboRetLabels, fiboRet1, fiboRet2, fiboRet3, fiboRet4, fiboRet5, fiboRet6, fiboRet7, highestBar, highestPrice, lowestBar, lowestPrice, extendFR, fiboRetBullColors, fiboRetBearColors, fiboRetLineStyle) if ffCount > 0 saveLastLabels('ffan', fiboFanLabels) drawLineSet('ffan', fiboRatios, fiboRatioLabels, fiboFanLabels, fiboFan1, fiboFan2, fiboFan3, fiboFan4, fiboFan5, fiboFan6, fiboFan7, highestBar, highestPrice, lowestBar, lowestPrice, extendFR, fiboFanBullColors, fiboFanBearColors, fiboFanLineStyle) if grCount > 0 saveLastLabels('gret', gannRetLabels) drawLineSet('gret', gannRetRatios, gannRetRatioLabels, gannRetLabels, gannRet1, gannRet2, gannRet3, gannRet4, gannRet5, gannRet6, gannRet7, highestBar, highestPrice, lowestBar, lowestPrice, extendGR, gannRetBullColors, gannRetBearColors, gannRetLineStyle) if gfCount > 0 saveLastLabels('gfan', gannFanLabels) drawLineSet('gfan', gannFanRatios, gannFanRatioLabels, gannFanLabels, gannFan1, gannFan2, gannFan3, gannFan4, gannFan5, gannFan6, gannFan7, lowestBar, lowestPrice, bar_index, high, extendGR, gannFanBullColors, gannFanBearColors, gannFanLineStyle) delUnneededLines() waitingFor := 'h' if showExtrema label.new(lowestBar, lowestPrice, '', style=label.style_label_up) lowBar := lBar lowPrice := lPrice lowPrice // extend latest retracements index = array.size(fiboRet1) - 1 if index > -1 line.set_x2(array.get(fiboRet1, index), bar_index) line.set_x2(array.get(fiboRet2, index), bar_index) line.set_x2(array.get(fiboRet3, index), bar_index) line.set_x2(array.get(fiboRet4, index), bar_index) line.set_x2(array.get(fiboRet5, index), bar_index) line.set_x2(array.get(fiboRet6, index), bar_index) line.set_x2(array.get(fiboRet7, index), bar_index) index := array.size(gannRet1) - 1 if index > -1 line.set_x2(array.get(gannRet1, index), bar_index) line.set_x2(array.get(gannRet2, index), bar_index) line.set_x2(array.get(gannRet3, index), bar_index) line.set_x2(array.get(gannRet4, index), bar_index) line.set_x2(array.get(gannRet5, index), bar_index) line.set_x2(array.get(gannRet6, index), bar_index) line.set_x2(array.get(gannRet7, index), bar_index) // relocate labels for i = 0 to 4 by 1 if showFRLabels label.set_x(array.get(fiboRetLabels, i), bar_index + 2) if showGRLabels label.set_x(array.get(gannRetLabels, i), bar_index + 2) if showFFLabels fiboFanLabel = array.get(fiboFanLabels, i) label.set_x(fiboFanLabel, bar_index + 2 * (1 + i)) label.set_y(fiboFanLabel, (waitingFor == 'l' ? lowestPrice : highestPrice) + array.get(fiboFanSlopes, i) * (bar_index + 2 * (1 + i) - (waitingFor == 'l' ? lowestBar : highestBar))) if showGFLabels gannFanLabel = array.get(gannFanLabels, i) label.set_x(gannFanLabel, bar_index + 2 * (5 - i)) label.set_y(gannFanLabel, (waitingFor == 'h' ? lowestPrice : highestPrice) + array.get(gannFanSlopes, i) * (bar_index + 2 * (5 - i) - (waitingFor == 'h' ? lowestBar : highestBar))) //label.set_y(gannFanLabel, label.get_y(gannFanLabel) + tan(array.get(gannFanRatios, i) * math.pi / 2) * chartScale * (waitingFor == "h" ? 1 : waitingFor == "l" ? -1 : 0)) //} depthTooltip = "The minimum number of bars that will be taken into account when calculating the indicator." depth = input.int(10, "Depth", minval = 1, tooltip = depthTooltip) typeP = input.string("Original", "Type", options = ["Original", "Schiff", "Modified Schiff", "Inside"]) backgroundTransparency = input.int(85, "Background Transparency", minval = 0, maxval = 100) isExtended = input.bool(false, "Extend left") extendLine = isExtended ? extend.both : extend.right medianColor = input(#f44336, "Median line                 ", inline = "ML") medianWidth = input.int(1, "", minval = 1, inline = "ML") medianStyle = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "ML") var line lineLast = na var int iLast = 0 var int iPrev = 0 var float pLast = 0 var isHighLast = false // otherwise the last pivot is a low pivot var iPrevPvt = 0 var pPrevPvt = 0. var iLastPvt = 0 var pLastPvt = 0. pivots(src, length, isHigh) => l2 = length * 2 p = nz(src[length]) isFound = true for i = 0 to l2 if isHigh and src[i] > p isFound := false if not isHigh and src[i] < p isFound := false if isFound [bar_index[length], p] else [int(na), float(na)] [iH, pH] = pivots(high, depth / 2, true ) [iL, pL] = pivots(low , depth / 2, false) pivotFound(isHigh, index, price) => if isHighLast == isHigh and not na(lineLast) // same direction if isHighLast ? price > pLast : price < pLast line.set_xy2(lineLast, index, price) [lineLast, isHighLast] else [line(na), bool(na)] else // reverse the direction (or create the very first line) id = line.new(iLast, pLast, index, price, color=na) [id, isHigh] if not na(iH) [id, isHigh] = pivotFound(true, iH, pH) if not na(id) if id != lineLast iPrevPvt := line.get_x1(lineLast) pPrevPvt := line.get_y1(lineLast) iLastPvt := line.get_x2(lineLast) pLastPvt := line.get_y2(lineLast) line.delete(lineLast) lineLast := id isHighLast := isHigh iPrev := iLast iLast := iH pLast := pH else if not na(iL) [id, isHigh] = pivotFound(false, iL, pL) if not na(id) if id != lineLast iPrevPvt := line.get_x1(lineLast) pPrevPvt := line.get_y1(lineLast) iLastPvt := line.get_x2(lineLast) pLastPvt := line.get_y2(lineLast) line.delete(lineLast) lineLast := id isHighLast := isHigh iPrev := iLast iLast := iL pLast := pL iPrev2Pvt = ta.valuewhen(ta.change(iPrevPvt), iPrevPvt, 1) pPrev2Pvt = ta.valuewhen(ta.change(pPrevPvt), pPrevPvt, 1) getMedianData(type) => var iStartMedian = 0 var pStartMedian = 0. var iEndMedian = 0 var pEndMedian = 0. iEndMedian := math.floor(math.avg(iPrevPvt, iLastPvt)) pEndMedian := math.avg(pPrevPvt, pLastPvt) if type == "Original" iStartMedian := iPrev2Pvt pStartMedian := pPrev2Pvt offsetEnd = (iLastPvt - iPrevPvt) % 2 != 0 ? (pStartMedian - pEndMedian) * 0.5 / math.abs(iStartMedian - iEndMedian - 0.5) : 0 // add offset if iEndMedian was rounded (floor) to whole bar_index pEndMedian += offsetEnd else if type == "Schiff" iStartMedian := iPrev2Pvt pStartMedian := math.avg(pPrevPvt, pPrev2Pvt) offsetEnd = (iLastPvt - iPrevPvt) % 2 != 0 ? (pStartMedian - pEndMedian) * 0.5 / math.abs(iStartMedian - iEndMedian - 0.5) : 0 pEndMedian += offsetEnd else if type == "Modified Schiff" iStartMedian := math.floor(math.avg(iPrevPvt, iPrev2Pvt)) pStartMedian := math.avg(pPrevPvt, pPrev2Pvt) offset = (pStartMedian - pEndMedian) * 0.5 / math.abs(iStartMedian - iEndMedian - 0.5) pStartMedian += (iPrev2Pvt - iPrevPvt) % 2 != 0 ? offset : 0 pEndMedian += (iLastPvt - iPrevPvt) % 2 != 0 ? offset : 0 else if type == "Inside" iStartMedian := line.get_x2(lineLast) slopeInside = (math.avg(pPrevPvt, pPrev2Pvt) - pLastPvt) / (math.avg(iPrevPvt, iPrev2Pvt) - iLastPvt) pStartMedian := slopeInside *(iStartMedian - math.avg(iPrevPvt, iLastPvt)) + pEndMedian offsetEnd = (iLastPvt - iPrevPvt) % 2 != 0 ? (pStartMedian - pEndMedian) * 0.5 / math.abs(iStartMedian - iEndMedian - 0.5) : 0 pEndMedian -= offsetEnd [iStartMedian, pStartMedian, iEndMedian, pEndMedian] drawPitchforkLine(iStart, pStart, iEnd, pEnd, color, width, style, extend) => _style = style == "Solid" ? line.style_solid : style == "Dotted" ? line.style_dotted : line.style_dashed var id = line.new(iStart, pStart, iEnd, pEnd, xloc.bar_index, extend, color, _style, width) line.set_xy1(id, iStart, pStart) line.set_xy2(id, iEnd, pEnd) id [iStartMedian, pStartMedian, iEndMedian, pEndMedian] = getMedianData(typeP) processLevel(show, level, color, width, style, lineIdOther1, lineIdOther2) => if show iEndMedianWithotRound = math.avg(iPrevPvt, iLastPvt) pEndMedianWithotOffset = math.avg(pPrevPvt, pLastPvt) iDiff = math.abs(iPrevPvt - iLastPvt) / 2 pDiff = math.abs(pPrevPvt - pLastPvt) / 2 slopeMedian = (pEndMedian - pStartMedian) / (iEndMedian - iStartMedian) tempUp = pPrevPvt > pLastPvt ? iEndMedianWithotRound - iDiff * level : iEndMedianWithotRound + iDiff * level isIntBarIndexUp = math.ceil(tempUp) - tempUp iStartUp = math.ceil(tempUp) iEndUp = iStartUp + 1 pStartUp = pEndMedianWithotOffset + pDiff * level pEndUp = slopeMedian * (iEndUp - tempUp) + pStartUp offsetUp = isIntBarIndexUp == 0 ? 0 : (pStartUp - pEndUp) * (isIntBarIndexUp) / (tempUp - iEndUp) tempDown = pPrevPvt > pLastPvt ? iEndMedianWithotRound + iDiff * level : iEndMedianWithotRound - iDiff * level isIntBarIndexDown = tempDown - math.ceil(tempDown) iStartDown = math.ceil(tempDown) iEndDown = iStartDown + 1 pStartDown = pEndMedianWithotOffset - pDiff * level pEndDown = slopeMedian * (iEndDown - tempDown) + pStartDown offsetDown = isIntBarIndexDown == 0 ? 0 : (pStartDown - pEndDown) * (isIntBarIndexDown) / (tempDown - iEndDown) lineId1 = drawPitchforkLine(iStartUp, pStartUp + offsetUp, iEndUp, pEndUp, color, width, style, extendLine) lineId2 = drawPitchforkLine(iStartDown, pStartDown - offsetDown, iEndDown, pEndDown, color, width, style, extendLine) if not na(lineIdOther1) linefill.new(lineId1, lineIdOther1, color = color.new(color, backgroundTransparency)) linefill.new(lineId2, lineIdOther2, color = color.new(color, backgroundTransparency)) else linefill.new(lineId1, lineId2, color = color.new(color, backgroundTransparency)) [lineId1, lineId2] else [lineIdOther1, lineIdOther2] show_0_25 = input(false, "", inline = "level0") value_0_25 = input.float(0.25, "", minval = .0, step = .1, inline = "level0") color_0_25 = input(#ffb74d, "", inline = "level0") width_0_25 = input.int(1, "", minval = 1, inline = "level0") style_0_25 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level0") show_0_382 = input(false, "", inline = "level1") value_0_382 = input.float(0.382, "", minval = .0, step = .1, inline = "level1") color_0_382 = input(#81c784, "", inline = "level1") width_0_382 = input.int(1, "", minval = 1, inline = "level1") style_0_382 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level1") show_0_5 = input(true, "", inline = "level2") value_0_5 = input.float(0.5, "", minval = .0, step = .1, inline = "level2") color_0_5 = input(#4caf50, "", inline = "level2") width_0_5 = input.int(1, "", minval = 1, inline = "level2") style_0_5 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level2") show_0_618 = input(false, "", inline = "level3") value_0_618 = input.float(0.618, "", minval = .0, step = .1, inline = "level3") color_0_618 = input(#009688, "", inline = "level3") width_0_618 = input.int(1, "", minval = 1, inline = "level3") style_0_618 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level3") show_0_75 = input(false, "", inline = "level4") value_0_75 = input.float(0.75, "", minval = .0, step = .1, inline = "level4") color_0_75 = input(#64b5f6, "", inline = "level4") width_0_75 = input.int(1, "", minval = 1, inline = "level4") style_0_75 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level4") show_1 = input(true, "", inline = "level5") value_1 = input.float(1, "", minval = .0, step = .1, inline = "level5") color_1 = input(#2962ff, "", inline = "level5") width_1 = input.int(1, "", minval = 1, inline = "level5") style_1 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level5") show_1_5 = input(false, "", inline = "level6") value_1_5 = input.float(1.5, "", minval = .0, step = .1, inline = "level6") color_1_5 = input(#9c27b0, "", inline = "level6") width_1_5 = input.int(1, "", minval = 1, inline = "level6") style_1_5 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level6") show_1_75 = input(false, "", inline = "level7") value_1_75 = input.float(1.75, "", minval = .0, step = .1, inline = "level7") color_1_75 = input(#e91e63, "", inline = "level7") width_1_75 = input.int(1, "", minval = 1, inline = "level7") style_1_75 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level7") show_2 = input(false, "", inline = "level8") value_2 = input.float(2, "", minval = .0, step = .1, inline = "level8") color_2 = input(#e91e63, "", inline = "level8") width_2 = input.int(1, "", minval = 1, inline = "level8") style_2 = input.string("Solid", "", options = ["Dashed", "Dotted", "Solid"], inline = "level8") if typeP == "Inside" drawPitchforkLine(iEndMedian, pEndMedian, iStartMedian, pStartMedian, medianColor, medianWidth, medianStyle, extendLine) else drawPitchforkLine(iStartMedian, pStartMedian, iEndMedian, pEndMedian, medianColor, medianWidth, medianStyle, extendLine) drawPitchforkLine(iPrevPvt, pPrevPvt, iLastPvt, pLastPvt, medianColor, medianWidth, medianStyle, extend.none) if typeP != "Original" drawPitchforkLine(iPrev2Pvt, pPrev2Pvt, iPrevPvt, pPrevPvt, medianColor, medianWidth, medianStyle, extend.none) if typeP == "Inside" drawPitchforkLine(math.round(math.avg(iPrevPvt, iPrev2Pvt)), math.avg(pPrevPvt, pPrev2Pvt), iLastPvt, pLastPvt, medianColor, medianWidth, medianStyle, extend.none) [lineId0_1, lineId0_2] = processLevel(show_0_25, value_0_25, color_0_25, width_0_25, style_0_25, line(na), line(na)) [lineId1_1, lineId1_2] = processLevel(show_0_382, value_0_382, color_0_382, width_0_382, style_0_382, lineId0_1, lineId0_2) [lineId2_1, lineId2_2] = processLevel(show_0_5, value_0_5, color_0_5, width_0_5, style_0_5, lineId1_1, lineId1_2) [lineId3_1, lineId3_2] = processLevel(show_0_618, value_0_618, color_0_618, width_0_618, style_0_618, lineId2_1, lineId2_2) [lineId4_1, lineId4_2] = processLevel(show_0_75, value_0_75, color_0_75, width_0_75, style_0_75, lineId3_1, lineId3_2) [lineId5_1, lineId5_2] = processLevel(show_1, value_1, color_1, width_1, style_1, lineId4_1, lineId4_2) [lineId6_1, lineId6_2] = processLevel(show_1_5, value_1_5, color_1_5, width_1_5, style_1_5, lineId5_1, lineId5_2) [lineId7_1, lineId7_2] = processLevel(show_1_75, value_1_75, color_1_75, width_1_75, style_1_75, lineId6_1, lineId6_2) [lineId8_1, lineId8_2] = processLevel(show_2, value_2, color_2, width_2, style_2, lineId7_1, lineId7_2) len = input.int(20, minval=1, title="Length") src = input(high, title="Source") offset = input.int(title="Offset", defval=0, minval=-500, maxval=500) out = ta.sma(src, len) plot(out, color=color.blue, title="MA", offset=offset) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing") smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing") smoothingLine = ma(out, smoothingLength, typeMA) plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
Seth's MW
https://www.tradingview.com/script/CUKWga7B-Seth-s-MW/
swj02
https://www.tradingview.com/u/swj02/
25
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © CheatCode1 //@version=5 indicator("Seth\'s Momentum Wave", overlay = false) // Input value groupings src = input.source(close, 'Momentum Source', group = 'Momentum Values') len1 = input.int(21, 'Momentum Length', 1, 500, group = 'Momentum Values') lb = input.int(50, 'Lookback Left', 1, 500, group = 'Lookback periods') rb = input.int(7, 'Lookback Right', 1, 500, group = 'Lookback periods') off = input.int(0, ' Offset length', -100, 100, group = 'Background Color' ) lf = input.int(415, 'Mean Look Back Length', 1, 500, group = 'Lookback periods') //Variable Declerations m = ta.mom(src, len1) m_col1 = ta.rising(m, 2) m_col2 = ta.falling(m, 2) ma2_ = ta.ema(m, 21) ma3_ = ta.ema(m, 55) ma4_ = ta.ema(m, 200) fall1 = ta.falling(m, 2) ? true:false grow1 = ta.rising(m, 2) ? true:false basis1 = math.avg(ma2_, ma3_) b1A = ta.falling(m, 2) b1_col = ta.rising(m, 2) ? color.green : b1A ? color.red:color.white m_std = ta.stdev(m, len1) pivh = ta.pivothigh(basis1, lb, rb) pivl = ta.pivotlow(basis1, lb, rb) val1 = ta.valuewhen(pivh, m, 1 ) val0 = ta.valuewhen(pivh, m, 0 ) valn1 = ta.valuewhen(pivl, m, 1) valn0 = ta.valuewhen(pivl, m, 0) bAVG = math.avg(basis1, m) //Double Declared for fill function >>> highm1 = ta.highest(bAVG, lf) lowm1 = ta.lowest(bAVG, lf) ma5_ = math.avg(highm1, lowm1) highm = plot(highm1, '', #73E600, 1, plot.style_line, display = display.none, editable = false) lowm = plot(lowm1, '', #E66763, 1, plot.style_line, display = display.none, editable = false) b2_col = basis1 >= ma5_ ? color.new(color.green, 95):(basis1 <= ma5_ ? color.new(color.red, 95):color.new(color.white, 100)) //Seths Moving Average Series //Seths Moving Average Series //Seths Moving Average Series //Seths Moving Average Series //Seths Moving Average Series //Seths Moving Average Series //Seths Moving Average Series maCol(maX, maL, m, src, len1) => m == ta.mom(src, len1) diff_ = ta.change(maX) macol = diff_ >= 0 and maX > maL and maX <= m ? color.new(#6AE635, 25): (diff_ < 0 and maX > maL and maX >= m ? color.new(#A80E00, 25): (diff_ <= 0 and maX < maL and maX >= m ? color.new(#E15C58, 25): (diff_ >= 0 and maX < maL and m >= maX ? color.new(color.green, 0) : color.new(color.white, 100)))) macol maL = ta.ema(m, 100) //Double Declared for fill Function ma2 = plot(ma2_, 'MA2', maCol(ma2_, maL, m, src, len1), 2, plot.style_line, editable = false) ma3 = plot(ma3_, 'MA3', maCol(ma3_, maL, m, src, len1), 2, plot.style_line, editable = false) //Plot Excecutions plot(maL, 'maL', maL >= m ? color.red: maL <= m ? color.green:na, 4, plot.style_line, editable = false) plot(basis1, 'Seth\ Momentum', m >= basis1 and not fall1 ? color.aqua:(m < basis1 and not grow1 ? color.yellow:color.white) , 4, plot.style_circles, offset = -3) fill(ma2, ma3, color.new(color.yellow, 88), '') bgcolor(b2_col, off, false, title = 'Background Color') plot(ma5_, 'Mean Length', basis1 >= m ? color.red: color.green, 2)
thursdaycolor
https://www.tradingview.com/script/cVFrLDL9-thursdaycolor/
aadityamallick
https://www.tradingview.com/u/aadityamallick/
10
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © aadityamallick //@version=5 indicator(title='THURSDAY', overlay=true) // title is the heading of the study, overlay will make the changes over the price line i.e. on the main chart. By using overlay we are not required to use the code "plot" c = color.green // defining a variable with color to use in the upcoming code bgColor = dayofweek == dayofweek.thursday ? color.new(c, 90) : color.new(color.white, 80) bgcolor(color=bgColor, transp=90) //usually the code the the one just before this line but we are using an condition with the bgcolor. It will check if the day of the week is equals to thursday the it will define a color to it which is coming from color.new code. //then ":" has been put which will show say that if the condition is not being fullfilled then which color do i place in the chart
Munich's Momentum Wave V2
https://www.tradingview.com/script/Cb8wyUOK-Munich-s-Momentum-Wave-V2/
CheatCode1
https://www.tradingview.com/u/CheatCode1/
80
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © CheatCode1 //@version=5 indicator("Munich\'s Momentum Wave V2", overlay = false) // Input value groupings src = input.source(close, 'Momentum Source', group = 'Momentum Values') len1 = input.int(21, 'Momentum Length', 1, 500, group = 'Momentum Values') lb = input.int(50, 'Lookback Left', 1, 500, group = 'Lookback periods') rb = input.int(7, 'Lookback Right', 1, 500, group = 'Lookback periods') off = input.int(0, ' Offset length', -100, 100, group = 'Background' ) lf = input.int(415, 'Mean Look Back Length', 1, 500, group = 'Lookback periods') len2 = input.int(25, minval=1, group = 'Background') std = input.float(6, minval=0.001, maxval=50, title="StdDev", group = 'Background') //Variable Declerations m = ta.mom(src, len1) a = ta.alma(close, 9, .85, 6) - (ta.alma(close, 9, .85, 6) - m) m_col1 = ta.rising(m, 2) m_col2 = ta.falling(m, 2) ma2_ = ta.ema(m, 21) ma3_ = ta.ema(m, 55) ma4_ = ta.ema(m, 9) ma6_ = ta.ema(m, 100) ma7_ = ta.ema(m, 200) ma8_ = ta.ema(m, 250) basis1 = math.avg(ma2_, ma4_) basis2 = math.avg(ma2_, ma3_) basis3 = math.avg(ma3_, ma6_) basis4 = math.avg(ma6_, ma7_) basis5 = math.avg(ma7_, ma8_) b1A = ta.falling(m, 2) b1_col = ta.rising(m, 2) ? color.green : b1A ? color.red:color.white m_a = math.avg(m, a) pivh = ta.pivothigh(m_a, lb, rb) pivl = ta.pivotlow(m_a, lb, rb) bAVG = math.avg(basis1, m) bAVG2 = math.avg(basis1, basis2, basis3, basis4, basis5) origin_ = ta.sma(bAVG2, len2) deviation = std * ta.stdev(bAVG2, len2) fallin(basis) => m <= basis and m <= a growin(basis) => m > basis //Double Declared for fill function >>> highm1 = ta.highest(bAVG[0], lf) lowm1 = ta.lowest(bAVG, lf) ma5_ = math.avg(highm1, lowm1) //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series topband = origin_ + deviation bottomband = origin_ - deviation banddiff = topband - bottomband //Plot Excecutions bgcolor(basis1 > topband and a > topband and a > a[3] ? color.new(color.red, 85):(basis1 < bottomband and a < bottomband and a < a[3] ? color.new(color.green, 85):na), off) plot(basis1, 'Munich\ Momentum 1', growin(basis1) ? color.aqua:(fallin(basis1) ? color.yellow:color.white) , 4, plot.style_line, offset = 0, editable = false) plot(basis2, 'Munich\ Momentum 2', growin(basis2) ? color.aqua:(fallin(basis2) ? color.yellow:color.white) , 4, plot.style_line, offset = 0, editable = false) plot(basis3, 'Munich\ Momentum 3', growin(basis3) ? color.aqua:(fallin(basis3) ? color.yellow:color.white) , 4, plot.style_line, offset = 0, editable = false) plot(basis4, 'Munich\ Momentum 3', growin(basis4) ? color.aqua:(fallin(basis4) ? color.yellow:color.white) , 4, plot.style_line, offset = 0, editable = false) plot(basis5, 'Munich\ Momentum 3', growin(basis5) ? color.aqua:(fallin(basis5) ? color.yellow:color.white) , 4, plot.style_line, offset = 0, editable = false) plot(a, 'Alma', a > ma5_ and growin(basis5) ? color.green:( basis5 > a and fallin(a) ? color.red:color.white), 2, plot.style_line ) //Alert Conditions inp1 = input.bool(true, 'Alerts?', confirm = true, group = 'Alerts', inline = '1') inp2 = input.bool(false, 'Lean Short', group = 'Alerts', inline = '2') inp3 = input.bool(true, 'Maybe Buy', group = 'Alerts', inline = '2') inp4 = input.bool(false, 'Lean Long', group = 'Alerts', inline = '2') inp5 = input.bool(true, 'Maybe Sell', group = 'Alerts', inline = '2') inp6 = input.bool(false, 'All Yellow', group = 'Alerts', inline = '3') inp7 = input.bool(false, 'All Aqua', group = 'Alerts', inline = '3') C1 = ta.crossunder(basis1[1], basis5[1]) C2 = a <= basis1 and a <= basis2 and a <= basis3 and a <= basis4 and a <= basis5 C3 = basis1 > topband and a > topband and a > a[3] C4 = basis1 < bottomband and a < bottomband and a < a[3] C5 = ta.crossover(basis1[1], basis5[1]) C6 = basis1[1] - basis5[1] C7 = a >= basis1 and a >= basis2 and a >= basis3 and a >= basis4 and a >= basis5 A1 = C1 and C2 and C6 <= -10 and inp1 and inp2 A2 = C1 and C2 and C4 and C6 <= -20 and inp1 and inp3 A3 = C5 and C7 and C6 >= 10 and inp1 and inp4 A4 = C5 and C7 and C6 >= 20 and C3 and inp1 and inp5 A5 = growin(basis5) and growin(basis1)[1] and growin(basis2)[1] and growin(basis3)[1] and growin(basis4)[1] and growin(basis5)[1] and growin(basis1)[2] and growin(basis2)[2] and growin(basis3)[2] and growin(basis4)[2] and growin(basis5)[2] and growin(basis1)[3] and growin(basis2)[3] and growin(basis3)[3] and growin(basis4)[3] and growin(basis5)[3] and inp7 A6 = fallin(basis5) and fallin(basis1)[1] and fallin(basis2)[1] and fallin(basis3)[1] and fallin(basis4)[1] and fallin(basis5)[1] and fallin(basis1)[2] and fallin(basis2)[2] and fallin(basis3)[2] and fallin(basis4)[2] and fallin(basis5)[2] and fallin(basis1)[3] and fallin(basis2)[3] and fallin(basis3)[3] and fallin(basis4)[3] and fallin(basis5)[3] and inp6 //HLine Strategy plot(0, 'Munich/s Wave State', color = growin(basis1) and growin(basis2) and growin(basis3) and growin(basis4) and growin(basis5) ? color.aqua : fallin(basis1) and fallin(basis2) and fallin(basis3) and fallin(basis4) and fallin(basis5) ? color.yellow : color.white, linewidth = 2) //Alerts alertcondition(A5, 'MMW V2 Alert 5', 'ALL BULLS (Aqua)') alertcondition(A6, 'MMW V2 Alert 6', 'ALL BEARS(Yellow)') alertcondition(A1, 'MMW V2 Alert 1', 'Bears In Control (Lean Short)') alertcondition(A2, 'MMW V2 Alert 2', 'Oversold! (Maybe Buy)') alertcondition(A3, 'MMW V2 Alert 3', 'Bulls in Control (Lean Long)') alertcondition(A4, 'MMW V2 Alert 4', 'Overbought! (Maybe Sell)')
GDM Price Power & Under Current
https://www.tradingview.com/script/4P6wg70A-GDM-Price-Power-Under-Current/
Re-LionsTradingAcademy
https://www.tradingview.com/u/Re-LionsTradingAcademy/
11
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © manegirishd //@version=5 indicator(title="GDM Price Power & Under Current", shorttitle="GDMPP&UC", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) Power1Input = input.int(21, minval=1, title="Power 1 Length", group="Power Settings") Power2Input = input.int(9, minval=1, title="Power 2 Length", group="Power Settings") Power3Input = input.int(7, minval=1, title="Power 3 Length", group="Power Settings") PowerSourceInput = input.source(close, "Source", group="Power Settings") UnderCurrentTypeInput = input.string("SMA", title="Under Current Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Under Current Settings") UnderCurrent1LengthInput = input.int(21, title="Under Current 1 Length", group="Under Current Settings") UnderCurrent2LengthInput = input.int(9, title="Under Current 2 Length", group="Under Current Settings") UnderCurrent3LengthInput = input.int(7, title="Under Current 3 Length", group="Under Current Settings") up1 = ta.rma(math.max(ta.change(PowerSourceInput), 0), Power1Input) down1 = ta.rma(-math.min(ta.change(PowerSourceInput), 0), Power1Input) Power1 = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1)) UnderCurrent1 = ma(Power1, UnderCurrent1LengthInput, UnderCurrentTypeInput) up2 = ta.rma(math.max(ta.change(PowerSourceInput), 0), Power2Input) down2 = ta.rma(-math.min(ta.change(PowerSourceInput), 0), Power2Input) Power2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2)) UnderCurrent2 = ma(Power2, UnderCurrent2LengthInput, UnderCurrentTypeInput) up3 = ta.rma(math.max(ta.change(PowerSourceInput), 0), Power3Input) down3 = ta.rma(-math.min(ta.change(PowerSourceInput), 0), Power3Input) Power3 = down3 == 0 ? 100 : up3 == 0 ? 0 : 100 - (100 / (1 + up3 / down3)) UnderCurrent3 = ma(Power3, UnderCurrent3LengthInput, UnderCurrentTypeInput) plot(Power1, "Power1", color=#2196F3) plot(UnderCurrent1, "UnderCurrent1", color=#311B92) plot(Power2, "Power2", color=#FF5252) plot(UnderCurrent2, "UnderCurrent2", color=#9C27B0) plot(Power3, "Power3", color=#4CAF50) plot(UnderCurrent3, "UnderCurrent3", color=#808000)
Currency Strength V2
https://www.tradingview.com/script/MGybnCWo-Currency-Strength-V2/
HayeTrading
https://www.tradingview.com/u/HayeTrading/
81
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HayeTrading //@version=5 indicator("Currency Strength", overlay=true) rsilen = input.int(14, "RSI Length") rsi = ta.rsi(close, rsilen) // Reverse the ticker value to make standard base currency rev(sec) => _r = 100 - sec _r // USD usdjpy = request.security("USDJPY", "", rsi) usdcad = request.security("USDCAD", "", rsi) eurusd = request.security("EURUSD", "", rsi) eurusd_r = rev(eurusd) gbpusd = request.security("GBPUSD", "", rsi) gbpusd_r = rev(gbpusd) audusd = request.security("AUDUSD", "", rsi) audusd_r = rev(audusd) c_usd = math.avg(usdjpy,usdcad,eurusd_r,gbpusd_r,audusd_r) // EUR eurjpy = request.security("EURJPY", "", rsi) eurcad = request.security("EURCAD", "", rsi) eurgbp = request.security("EURGBP", "", rsi) // eurusd euraud = request.security("EURAUD", "", rsi) c_eur = math.avg(eurjpy,eurcad,eurgbp,eurusd,euraud) // GBP // gbpusd eurgbp_r = rev(eurgbp) gbpjpy = request.security("GBPJPY", "", rsi) gbpcad = request.security("GBPCAD", "", rsi) gbpaud = request.security("GBPAUD", "", rsi) c_gbp = math.avg(gbpusd,eurgbp_r,gbpjpy,gbpcad,gbpaud) // CAD usdcad_r = rev(usdcad) eurcad_r = rev(eurcad) gbpcad_r = rev(gbpcad) cadjpy = request.security("CADJPY", "", rsi) audcad = request.security("AUDCAD", "", rsi) audcad_r = rev(audcad) c_cad = math.avg(usdcad_r,eurcad_r,gbpcad_r,cadjpy,audcad_r) // AUD // audusd euraud_r = rev(euraud) gbpaud_r = rev(gbpaud) // audcad audjpy = request.security("AUDJPY", "", rsi) c_aud = math.avg(audusd,euraud_r,gbpaud_r,audcad,audjpy) // JPY usdjpy_r = rev(usdjpy) eurjpy_r = rev(eurjpy) gbpjpy_r = rev(gbpjpy) cadjpy_r = rev(cadjpy) audjpy_r = rev(audjpy) c_jpy = math.avg(usdjpy_r,eurjpy_r,gbpjpy_r,cadjpy_r,audjpy_r) /// Second timeframe ///////// i_res = input.timeframe('60', "Resolution", options=['3', '5', '15', "30", "60", "120", "240", "D", "W"]) // USD usdjpy2 = request.security("USDJPY", i_res, rsi) usdcad2 = request.security("USDCAD", i_res, rsi) eurusd2 = request.security("EURUSD", i_res, rsi) eurusd_r2 = rev(eurusd2) gbpusd2 = request.security("GBPUSD", i_res, rsi) gbpusd_r2 = rev(gbpusd2) audusd2 = request.security("AUDUSD", i_res, rsi) audusd_r2 = rev(audusd2) c_usd2 = math.avg(usdjpy2,usdcad2,eurusd_r2,gbpusd_r2,audusd_r2) // EUR eurjpy2 = request.security("EURJPY", i_res, rsi) eurcad2 = request.security("EURCAD", i_res, rsi) eurgbp2 = request.security("EURGBP", i_res, rsi) // eurusd euraud2 = request.security("EURAUD", i_res, rsi) c_eur2 = math.avg(eurjpy2,eurcad2,eurgbp2,eurusd2,euraud2) // GBP // gbpusd eurgbp_r2 = rev(eurgbp2) gbpjpy2 = request.security("GBPJPY", i_res, rsi) gbpcad2 = request.security("GBPCAD", i_res, rsi) gbpaud2 = request.security("GBPAUD", i_res, rsi) c_gbp2 = math.avg(gbpusd2,eurgbp_r2,gbpjpy2,gbpcad2,gbpaud2) // CAD usdcad_r2 = rev(usdcad2) eurcad_r2 = rev(eurcad2) gbpcad_r2 = rev(gbpcad2) cadjpy2 = request.security("CADJPY", i_res, rsi) audcad2 = request.security("AUDCAD", i_res, rsi) audcad_r2 = rev(audcad2) c_cad2 = math.avg(usdcad_r2,eurcad_r2,gbpcad_r2,cadjpy2,audcad_r2) // AUD // audusd euraud_r2 = rev(euraud2) gbpaud_r2 = rev(gbpaud2) // audcad audjpy2 = request.security("AUDJPY", i_res, rsi) c_aud2 = math.avg(audusd2,euraud_r2,gbpaud_r2,audcad2,audjpy2) // JPY usdjpy_r2 = rev(usdjpy2) eurjpy_r2 = rev(eurjpy2) gbpjpy_r2 = rev(gbpjpy2) cadjpy_r2 = rev(cadjpy2) audjpy_r2 = rev(audjpy2) c_jpy2 = math.avg(usdjpy_r2,eurjpy_r2,gbpjpy_r2,cadjpy_r2,audjpy_r2) // Round RSI average values to 1 decimal place r_usd = math.round(c_usd, 1) r_eur = math.round(c_eur, 1) r_gbp = math.round(c_gbp, 1) r_cad = math.round(c_cad, 1) r_aud = math.round(c_aud, 1) r_jpy = math.round(c_jpy, 1) r_usd2 = math.round(c_usd2, 1) r_eur2 = math.round(c_eur2, 1) r_gbp2 = math.round(c_gbp2, 1) r_cad2 = math.round(c_cad2, 1) r_aud2 = math.round(c_aud2, 1) r_jpy2 = math.round(c_jpy2, 1) // Higher or lower than the value X bars ago difflen = input.int(3, "X Bar Change") highlow(val, difflen) => arrow = val > val[difflen] ? "▲" : val < val[difflen] ? "▼" : "-" arrow usd_hl = highlow(r_usd, difflen) eur_hl = highlow(r_eur, difflen) gbp_hl = highlow(r_gbp, difflen) cad_hl = highlow(r_cad, difflen) aud_hl = highlow(r_aud, difflen) jpy_hl = highlow(r_jpy, difflen) // Calculate background color scale transp=10 f_col(val) => g_base = 155 g_scale = g_base + math.min(((val - 50) * 8), 100) g_col = color.rgb(0, g_scale, 7) r_base = 90 r_rev_val = 100 - val r_scale = r_base - math.min(((r_rev_val - 50) * 3), 90) r_col = color.rgb(255, r_scale, r_scale, transp) _col = val >= 50 ? g_col : r_col _col // Table colors alt1 = color.rgb(236,216,64) alt2 = color.rgb(240,185,74) // Flat green / red flat_col(val) => _col = val >= 50 ? color.rgb(98,216,98) : color.rgb(229,92,89) _col // Use value-based colors or flat colors scale = input.string("Scale Color", options=["Scale Color", "Flat Color"]) use_scale = scale == "Scale Color" ? true : false usd_col = use_scale ? f_col(r_usd) : flat_col(r_usd) eur_col = use_scale ? f_col(r_eur) : flat_col(r_eur) gbp_col = use_scale ? f_col(r_gbp) : flat_col(r_gbp) cad_col = use_scale ? f_col(r_cad) : flat_col(r_cad) aud_col = use_scale ? f_col(r_aud) : flat_col(r_aud) jpy_col = use_scale ? f_col(r_jpy) : flat_col(r_jpy) usd_col2 = use_scale ? f_col(r_usd2) : flat_col(r_usd2) eur_col2 = use_scale ? f_col(r_eur2) : flat_col(r_eur2) gbp_col2 = use_scale ? f_col(r_gbp2) : flat_col(r_gbp2) cad_col2 = use_scale ? f_col(r_cad2) : flat_col(r_cad2) aud_col2 = use_scale ? f_col(r_aud2) : flat_col(r_aud2) jpy_col2 = use_scale ? f_col(r_jpy2) : flat_col(r_jpy2) i_tableYpos = input.string("top", "Panel position", options = ["top", "middle", "bottom"]) i_tableXpos = input.string("right", "", options = ["left", "center", "right"]) i_size = input.string("Large", "Text Size", options = ["Large", "Normal", "Auto"]) t_size = i_size == "Large" ? size.large : i_size == "Normal" ? size.normal : size.auto var table panel = table.new(i_tableYpos + "_" + i_tableXpos, 4, 7, frame_color=color.black, frame_width=1, border_color=color.black, border_width=1) if barstate.islast // Table header. table.cell(panel, 0, 0, "Ticker", bgcolor = alt2) table.cell(panel, 1, 0, "RSI " + timeframe.period, bgcolor =alt2) table.cell(panel, 2, 0, "RSI " + str.tostring(i_res) , bgcolor =alt2) // Column 1 table.cell(panel, 0, 1, "USD", bgcolor = alt1, text_size=t_size) table.cell(panel, 0, 2, "EUR", bgcolor = alt2, text_size=t_size) table.cell(panel, 0, 3, "GBP", bgcolor = alt1, text_size=t_size) table.cell(panel, 0, 4, "CAD", bgcolor = alt2, text_size=t_size) table.cell(panel, 0, 5, "AUD", bgcolor = alt1, text_size=t_size) table.cell(panel, 0, 6, "JPY", bgcolor = alt2, text_size=t_size) // Column 2 table.cell(panel, 1, 1, str.tostring(r_usd) + usd_hl, text_halign=text.align_right, bgcolor = usd_col, text_size=t_size) table.cell(panel, 1, 2, str.tostring(r_eur) + eur_hl, text_halign=text.align_right, bgcolor = eur_col, text_size=t_size) table.cell(panel, 1, 3, str.tostring(r_gbp) + gbp_hl, text_halign=text.align_right, bgcolor = gbp_col, text_size=t_size) table.cell(panel, 1, 4, str.tostring(r_cad) + cad_hl, text_halign=text.align_right, bgcolor = cad_col, text_size=t_size) table.cell(panel, 1, 5, str.tostring(r_aud) + aud_hl, text_halign=text.align_right, bgcolor = aud_col, text_size=t_size) table.cell(panel, 1, 6, str.tostring(r_jpy) + jpy_hl, text_halign=text.align_right, bgcolor = jpy_col, text_size=t_size) // Column 3 table.cell(panel, 2, 1, str.tostring(r_usd2), bgcolor = usd_col2, text_size=t_size) table.cell(panel, 2, 2, str.tostring(r_eur2), bgcolor = eur_col2, text_size=t_size) table.cell(panel, 2, 3, str.tostring(r_gbp2), bgcolor = gbp_col2, text_size=t_size) table.cell(panel, 2, 4, str.tostring(r_cad2), bgcolor = cad_col2, text_size=t_size) table.cell(panel, 2, 5, str.tostring(r_aud2), bgcolor = aud_col2, text_size=t_size) table.cell(panel, 2, 6, str.tostring(r_jpy2), bgcolor = jpy_col2, text_size=t_size)
Swing Points
https://www.tradingview.com/script/2VlRTYE4-swing-points/
tufedtm
https://www.tradingview.com/u/tufedtm/
325
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © tufedtm //@version=5 indicator(title='Swing Points', shorttitle='Swing H/L', overlay=true, max_lines_count=500, max_labels_count=500) len = input.int(title='Length', defval=2, minval=1) point_max = input.int(title='Maximum Points Displayed', defval=10, minval=0, maxval=250) show_high = input.bool(title='High', defval=true, inline='show', group='Show pivots?') show_low = input.bool(title='Low', defval=true, inline='show', group='Show pivots?') show_lines = input.bool(title='Lines', defval=false, inline='show', group='Show pivots?') del_high = input.bool(title='High', defval=true, inline='del', group='Delete crossed pivots?') del_low = input.bool(title='Low', defval=true, inline='del', group='Delete crossed pivots?') color_high = input.color(title='High', defval=color.new(color.white, 25), inline='style', group='Label style') style_high_option = input.string(title='', defval='Triangle down (▼)', options=['Triangle up (▲)', 'Triangle down (▼)', 'Arrow up (↑)', 'Arrow down (↓)', 'Label up (⬆)', 'Label down (⬇)', 'Plus (+)', 'Cross (⨯)', 'Circle (●)', 'Diamond (◆)', 'Flag (⚑)', 'Square (■)', 'None'], inline='style', group='Label style') color_low = input.color(title='Low', defval=color.new(color.white, 25), inline='style', group='Label style') style_low_option = input.string(title='', defval='Triangle up (▲)', options=['Triangle up (▲)', 'Triangle down (▼)', 'Arrow up (↑)', 'Arrow down (↓)', 'Label up (⬆)', 'Label down (⬇)', 'Plus (+)', 'Cross (⨯)', 'Circle (●)', 'Diamond (◆)', 'Flag (⚑)', 'Square (■)', 'None'], inline='style', group='Label style') line_high_color = input.color(title='High', defval=color.new(color.white, 25), inline='line style', group='Line style') line_high_style_option = input.string(title='', defval='solid (─)', options=['solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)'], inline='line style', group='Line style') line_low_color = input.color(title='Low', defval=color.new(color.white, 25), inline='line style', group='Line style') line_low_style_option = input.string(title='', defval='solid (─)', options=['solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)'], inline='line style', group='Line style') line_crossed_style_option = input.string(title='Crossed Line', defval='dotted (┈)', options=['solid (─)', 'dotted (┈)', 'dashed (╌)', 'arrow left (←)', 'arrow right (→)', 'arrows both (↔)'], inline='line style', group='Line style') var style_high = (style_high_option == 'Triangle up (▲)') ? label.style_triangleup : (style_high_option == 'Triangle down (▼)') ? label.style_triangledown : (style_high_option == 'Arrow up (↑)') ? label.style_arrowup : (style_high_option == 'Arrow down (↓)') ? label.style_arrowdown : (style_high_option == 'Label up (⬆)') ? label.style_label_up : (style_high_option == 'Label down (⬇)') ? label.style_label_down : (style_high_option == 'Plus (+)') ? label.style_cross: (style_high_option == 'Cross (⨯)') ? label.style_xcross : (style_high_option == 'Circle (●)') ? label.style_circle : (style_high_option == 'Diamond (◆)') ? label.style_diamond : (style_high_option == 'Flag (⚑)') ? label.style_flag : (style_high_option == 'Square (■)') ? label.style_square : (style_high_option == 'None') ? label.style_none : label.style_triangledown var style_low = (style_low_option == 'Triangle up (▲)') ? label.style_triangleup : (style_low_option == 'Triangle down (▼)') ? label.style_triangledown : (style_low_option == 'Arrow up (↑)') ? label.style_arrowup : (style_low_option == 'Arrow down (↓)') ? label.style_arrowdown : (style_low_option == 'Label up (⬆)') ? label.style_label_up : (style_low_option == 'Label down (⬇)') ? label.style_label_down : (style_low_option == 'Plus (+)') ? label.style_cross: (style_low_option == 'Cross (⨯)') ? label.style_xcross : (style_low_option == 'Circle (●)') ? label.style_circle : (style_low_option == 'Diamond (◆)') ? label.style_diamond : (style_low_option == 'Flag (⚑)') ? label.style_flag : (style_low_option == 'Square (■)') ? label.style_square : (style_low_option == 'None') ? label.style_none : label.style_triangleup var line_high_style = (line_high_style_option == 'dotted (┈)') ? line.style_dotted : (line_high_style_option == 'dashed (╌)') ? line.style_dashed : (line_high_style_option == 'arrow left (←)') ? line.style_arrow_left : (line_high_style_option == 'arrow right (→)') ? line.style_arrow_right : (line_high_style_option == 'arrows both (↔)') ? line.style_arrow_both : line.style_solid var line_low_style = (line_low_style_option == 'dotted (┈)') ? line.style_dotted : (line_low_style_option == 'dashed (╌)') ? line.style_dashed : (line_low_style_option == 'arrow left (←)') ? line.style_arrow_left : (line_low_style_option == 'arrow right (→)') ? line.style_arrow_right : (line_low_style_option == 'arrows both (↔)') ? line.style_arrow_both : line.style_solid var line_crossed_style = (line_crossed_style_option == 'solid (─)') ? line.style_solid : (line_crossed_style_option == 'dashed (╌)') ? line.style_dashed : (line_crossed_style_option == 'arrow left (←)') ? line.style_arrow_left : (line_crossed_style_option == 'arrow right (→)') ? line.style_arrow_right : (line_crossed_style_option == 'arrows both (↔)') ? line.style_arrow_both : line.style_dotted var label[] high_labels = array.new_label() var label[] low_labels = array.new_label() var line[] high_lines = array.new_line() var line[] low_lines = array.new_line() replot_line(lines) => if array.size(lines) > 0 for i = array.size(lines) - 1 to 0 by 1 line_ = array.get(lines, i) y1 = line.get_y1(line_) if bar_index == line.get_x2(line_) and not( high > y1 and low < y1 ) line.set_x2(line_, bar_index + 1) else line.set_style(line_, line_crossed_style) if show_high and ta.pivothigh(len, len) array.push(high_labels, label.new(bar_index - len, high[len], yloc=yloc.abovebar, color=color_high, style=style_high, size=size.auto)) if show_lines array.push(high_lines, line.new(x1=bar_index - len, y1=high[len], x2=bar_index, y2=high[len], color=line_high_color, style=line_high_style)) if show_low and ta.pivotlow(len, len) array.push(low_labels, label.new(bar_index - len, low[len], yloc=yloc.belowbar, color=color_low, style=style_low, size=size.auto)) if show_lines array.push(low_lines, line.new(x1=bar_index - len, y1=low[len], x2=bar_index, y2=low[len], color=line_low_color, style=line_low_style)) if array.size(high_labels) > 0 for i = array.size(high_labels) - 1 to 0 if del_high and high > label.get_y(array.get(high_labels, i)) label.delete(array.get(high_labels, i)) array.remove(high_labels, i) if show_lines line.delete(array.get(high_lines, i)) array.remove(high_lines, i) if array.size(low_labels) > 0 for i = array.size(low_labels) - 1 to 0 if del_low and low < label.get_y(array.get(low_labels, i)) label.delete(array.get(low_labels, i)) array.remove(low_labels, i) if show_lines line.delete(array.get(low_lines, i)) array.remove(low_lines, i) if array.size(high_labels) > point_max label.delete(array.shift(high_labels)) if show_lines line.delete(array.shift(high_lines)) if array.size(low_labels) > point_max label.delete(array.shift(low_labels)) if show_lines line.delete(array.shift(low_lines)) if show_lines replot_line(high_lines) replot_line(low_lines)
Simple Buy Sell Signals
https://www.tradingview.com/script/13E0KubE-Simple-Buy-Sell-Signals/
TradingTail
https://www.tradingview.com/u/TradingTail/
252
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mayurssupe //@version=5 indicator("Simple Buy Sell Signals",overlay=true,format=format.price,shorttitle="SBS") //RSI Setting sbs = input.bool(defval = true,title = "Default Signals",group = "Options") _hide = input.bool(defval=true,title="Lines",group = "Options") _fastPeriod = input.int(defval = 13,title = "Fast Period",group = "Moving Averages") _slowPeriod = input.int(defval = 21,title = "slow Period",group = "Moving Averages") //Green / Red Candle greenbar = close > open redbar = close < open //BB Average Line var int line_wid = 3 fsec(tf,exp) => request.security(ticker.heikinashi(syminfo.tickerid) , tf , exp) funcWith(tf,exp) => request.security(syminfo.tickerid , tf , exp) ma1 = funcWith("",math.avg(ta.ema(hlc3,_fastPeriod),ta.ema(hlc3,_fastPeriod))) ma2 = funcWith("",ta.ema(hlc3,_slowPeriod)) // plot(ma1,color=color.green) // plot(ma2,color=color.orange) nmL = ta.crossover(ma1,ma2) and ma1 > ma2 and sbs and volume[1] > volume nmS = ta.crossunder(ma1,ma2) and ma2 > ma1 and sbs and volume[1] > volume // if(nmL) // strategy.entry("Long",strategy.long) // strategy.exit("exit","Short",profit = 1000,loss = 500) // if(nmS) // strategy.entry("Short",strategy.short) // strategy.exit("exit","Long",profit = 1000,loss = 500) has_long = nmL[1] ? 1 : 0 has_short = nmS[1] ? 1 : 0 barup = _hide ? ta.valuewhen(has_long,bar_index,0) : na barHigh = _hide ? ta.valuewhen(has_long,high,0): na bardown = _hide ? ta.valuewhen(has_short,bar_index,0): na barLow =_hide ? ta.valuewhen(has_short,low,0): na l1= line.new(barup,barHigh,barup + 1 ,barHigh,color=color.rgb(40, 255, 47,50),extend=extend.right,width=3,style=line.style_solid) line.delete(l1[1]) l2= line.new(bardown,barLow,bardown + 1 ,barLow,color=color.rgb(255, 1, 77,50),extend=extend.right,width=3,style=line.style_solid) line.delete(l2[1]) plotshape(nmL[1] ? nmL[1] : 0,title="Long",style=shape.labelup,text="Buy",textcolor=color.white,color=color.aqua,location=location.belowbar) plotshape(nmS[1] ? nmS[1] : 0,title="Short",style=shape.labeldown,text="Sell",textcolor=color.white,color=color.orange,location=location.abovebar)
Opens, Closes, Highs and Lows.
https://www.tradingview.com/script/oJdX3bZz-Opens-Closes-Highs-and-Lows/
Lenny_Kiruthu
https://www.tradingview.com/u/Lenny_Kiruthu/
87
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Lenny_Kiruthu //@version=5 indicator(title="Opens, Closes, High and Lows.", shorttitle="Top Down OCHL", overlay=true) // USER INPUTS // Today's Inputs THigh = input.bool(defval=true, title="Today's High", inline="1", group="Today's Settings") TLow = input.bool(defval=true, title="Today's Low", inline="2", group="Today's Settings") TOpen = input.bool(defval=true, title="Today's Open", inline="3", group="Today's Settings") TClose = input.bool(defval=true, title="Today's Close", inline="4", group="Today's Settings") // Input criteria for Today's line type and width LineType1 = input.string(defval="line.style_solid", title="Line Type", options=["line.style_solid","line.style_dotted","line.style_dashed"], group="Today's Settings") Linewidth1 = input.int(defval=1, title="Line Width", minval=1, maxval=6, group="Today's Settings") // Input criteria for Today's line colors THighColor = input.color(defval=color.green, title="| Today's High color", group="Today's Settings", inline="1") TLowColor = input.color(defval=color.red, title="| Today's Low color", group="Today's Settings", inline="2") TOpenColor = input.color(defval=color.orange, title="| Today's Open color", group="Today's Settings", inline="3") TCloseColor = input.color(defval=color.blue, title="| Today's Close Color", group="Today's Settings", inline="4") // Yesterday's Inputs YHigh = input.bool(defval=false, title="Yesterday's High", inline="5", group="Yesterday's Settings") YLow = input.bool(defval=false, title="Yesterday's Low", inline="6", group="Yesterday's Settings") YOpen = input.bool(defval=false, title="Yesterday's Open", inline="7", group="Yesterday's Settings") YClose = input.bool(defval=false, title="Yesterday's Close", inline="8", group="Yesterday's Settings") // Input criteria for Yesterday's line type and width LineType2 = input.string(defval="line.style_solid", title="Line Type", options=["line.style_solid","line.style_dotted","line.style_dashed"], group="Yesterday's Settings") Linewidth2 = input.int(defval=2, title="Line Width", minval=1, maxval=6, group="Yesterday's Settings") // Input criteria for Yesterday's line colors YHighColor = input.color(defval=color.green, title="| Yesterday's High color", group="Yesterday's Settings", inline="5") YLowColor = input.color(defval=color.red, title="| Yesterday's Low color", group="Yesterday's Settings", inline="6") YOpenColor = input.color(defval=color.orange, title="| Yesterday's Open color", group="Yesterday's Settings", inline="7") YCloseColor = input.color(defval=color.blue, title="| Yesterday's Close color", group="Yesterday's Settings", inline="8") // Weekly inputs WHigh = input.bool(defval=true, title="Week's High", inline="9", group="Weekly Settings") WLow = input.bool(defval=true, title="Week's Low", inline="10", group="Weekly Settings") WOpen = input.bool(defval=true, title="Week's Open", inline="11", group="Weekly Settings") WClose = input.bool(defval=true, title="Week's Close", inline="12", group="Weekly Settings") // Input criteria for Weekly line type and width LineType3 = input.string(defval="line.style_solid", title="Line Type", options=["line.style_solid","line.style_dotted","line.style_dashed"], group="Weekly Settings") Linewidth3 = input.int(defval=3, title="Line Width", minval=1, maxval=6, group="Weekly Settings") // Input criteria for Weekly line colors WHighColor = input.color(defval=color.green, title="| Week's High color", group="Weekly Settings", inline="9") WLowColor = input.color(defval=color.red, title="| Week's Low color", group="Weekly Settings", inline="10") WOpenColor = input.color(defval=color.orange, title="| Week's Open color", group="Weekly Settings", inline="11") WCloseColor = input.color(defval=color.blue, title="| Week's Close color", group="Weekly Settings", inline="12") // Month's Inputs MHigh = input.bool(defval=false, title="Month's High", inline="13", group="Monthly Settings") MLow = input.bool(defval=false, title="Month's Low", inline="14", group="Monthly Settings") MOpen = input.bool(defval=false, title="Month's Open", inline="15", group="Monthly Settings") MClose = input.bool(defval=false, title="Month's Close", inline="16", group="Monthly Settings") // Input criteria for Monthly line type and width LineType4 = input.string(defval="line.style_solid", title="Line Type", options=["line.style_solid","line.style_dotted","line.style_dashed"], group="Monthly Settings") Linewidth4 = input.int(defval=4, title="Line Width", minval=1, maxval=6, group="Monthly Settings") // Input criteria for Monthly line colors MHighColor = input.color(defval=color.green, title="| Month's High color", group="Monthly Settings", inline="13") MLowColor = input.color(defval=color.red, title="| Month's Low color", group="Monthly Settings", inline="14") MOpenColor = input.color(defval=color.orange, title="| Month's Open color", group="Monthly Settings", inline="15") MCloseColor = input.color(defval=color.blue, title="| Month's Close color", group="Monthly Settings", inline="16") // Changing line styles L1 = switch LineType1 "line.style_solid" => style=line.style_solid "line.style_dotted" => style=line.style_dotted "line.style_dashed" => style=line.style_dashed L2 = switch LineType2 "line.style_solid" => style=line.style_solid "line.style_dotted" => style=line.style_dotted "line.style_dashed" => style=line.style_dashed L3 = switch LineType3 "line.style_solid" => style=line.style_solid "line.style_dotted" => style=line.style_dotted "line.style_dashed" => style=line.style_dashed L4 = switch LineType4 "line.style_solid" => style=line.style_solid "line.style_dotted" => style=line.style_dotted "line.style_dashed" => style=line.style_dashed // Requesting data from the higher timeframes. [Todays_High, Todays_Low, Todays_Open, Todays_Close] = request.security(syminfo.ticker, "D", [high[0], low[0], open[0],close[0]], lookahead=barmerge.lookahead_on) [Yesterdays_High, Yesterdays_Low, Yesterdays_Open, Yesterdays_Close] = request.security(syminfo.ticker, "D", [high[1], low[1], open[1],close[1]], lookahead=barmerge.lookahead_on) [Weekly_High, Weekly_Low, Weekly_Open, Weekly_Close] = request.security(syminfo.ticker,"W", [high[0], low[0], open[0],close[0]], lookahead=barmerge.lookahead_on) [Monthly_High, Monthly_Low, Monthly_Open, Monthly_Close] = request.security(syminfo.ticker,"M", [high[0], low[0], open[0],close[0]], lookahead=barmerge.lookahead_on) // Actual plotting of the high, low, open & close lines. if THigh THLine = line.new(x1=bar_index -1, y1=Todays_High, x2=bar_index, y2=Todays_High, color=THighColor, style=L1, width=Linewidth1, extend=extend.both) line.delete(THLine[1]) if TLow TLLine = line.new(x1=bar_index -1, y1=Todays_Low, x2=bar_index, y2=Todays_Low, color=TLowColor, style=L1, width=Linewidth1, extend=extend.both) line.delete(TLLine[1]) if TOpen TOLine = line.new(x1=bar_index -1, y1=Todays_Open, x2=bar_index, y2=Todays_Open, color=TOpenColor, style=L1, width=Linewidth1, extend=extend.both) line.delete(TOLine[1]) if TClose TCLine = line.new(x1=bar_index -1, y1=Todays_Close, x2=bar_index, y2=Todays_Close, color=TCloseColor , style=L1, width=Linewidth1, extend=extend.both) line.delete(TCLine[1]) if YHigh YHLine = line.new(x1=bar_index -1, y1=Yesterdays_High, x2=bar_index, y2=Yesterdays_High, color=YHighColor, style=L2, width=Linewidth2, extend=extend.both) line.delete(YHLine[1]) if YLow YLLine = line.new(x1=bar_index -1, y1=Yesterdays_Low, x2=bar_index, y2=Yesterdays_Low, color=YLowColor, style=L2, width=Linewidth2, extend=extend.both) line.delete(YLLine[1]) if YOpen YOLine = line.new(x1=bar_index -1, y1=Yesterdays_Open, x2=bar_index, y2=Yesterdays_Open, color=YOpenColor, style=L2, width=Linewidth2, extend=extend.both) line.delete(YOLine[1]) if YClose YCLine = line.new(x1=bar_index -1, y1=Yesterdays_Close, x2=bar_index, y2=Yesterdays_Close, color=YCloseColor, style=L2, width=Linewidth2, extend=extend.both) line.delete(YCLine[1]) if WHigh WHLine = line.new(x1=bar_index -1, y1=Weekly_High, x2=bar_index, y2=Weekly_High, color=WHighColor, style=L3, width=Linewidth3, extend=extend.both) line.delete(WHLine[1]) if WLow WLLine = line.new(x1=bar_index -1, y1=Weekly_Low, x2=bar_index, y2=Weekly_Low, color=WLowColor, style=L3, width=Linewidth3, extend=extend.both) line.delete(WLLine[1]) if WOpen WOLine = line.new(x1=bar_index -1, y1=Weekly_Open, x2=bar_index, y2=Weekly_Open, color=WOpenColor, style=L3, width=Linewidth3, extend=extend.both) line.delete(WOLine[1]) if WClose WCLine = line.new(x1=bar_index -1, y1=Weekly_Close, x2=bar_index, y2=Weekly_Close, color=WCloseColor, style=L3, width=Linewidth3, extend=extend.both) line.delete(WCLine[1]) if MHigh MHLine = line.new(x1=bar_index -1, y1=Monthly_High, x2=bar_index, y2=Monthly_High, color=MHighColor, style=L4, width=Linewidth4, extend=extend.both) line.delete(MHLine[1]) if MLow MLLine = line.new(x1=bar_index -1, y1=Monthly_Low, x2=bar_index, y2=Monthly_Low, color=MLowColor, style=L4, width=Linewidth4, extend=extend.both) line.delete(MLLine[1]) if MOpen MOLine = line.new(x1=bar_index -1, y1=Monthly_Open, x2=bar_index, y2=Monthly_Open, color=MOpenColor, style=L4, width=Linewidth4, extend=extend.both) line.delete(MOLine[1]) if MClose MCLine = line.new(x1=bar_index -1, y1=Monthly_Close, x2=bar_index, y2=Monthly_Close, color=MCloseColor, style=L4, width=Linewidth4, extend=extend.both) line.delete(MCLine[1]) // Plotting the labels that appear at respective opens, closes, highs and lows // Today's plotshapes plotshape(Todays_High and THigh ? Todays_High : na, title="Today's High", style=shape.labelup, location=location.absolute, color=THighColor, text="Today's High", textcolor=color.white, size=size.small, show_last=1) plotshape(Todays_Low and TLow ? Todays_Low : na, title="Today's Low", style=shape.labelup, location=location.absolute, color=TLowColor, text="Today's Low", textcolor=color.white, size=size.small, show_last=1) plotshape(Todays_Open and TOpen ? Todays_Open : na, title="Today's Open", style=shape.labelup, location=location.absolute, color=TOpenColor, text="Today's Open", textcolor=color.white, size=size.small, show_last=1) plotshape(Todays_Close and TClose ? Todays_Close : na, title="Today's Close", style=shape.labelup, location=location.absolute, color=TCloseColor, text="Today's Close", textcolor=color.white, size=size.small, show_last=1) // Yesterday's plotshapes plotshape(Yesterdays_High and YHigh ? Yesterdays_High : na, title="Yesterday's High", style=shape.labelup, location=location.absolute, color=YHighColor, text="Yesterday's High", textcolor=color.white, size=size.small, show_last=1) plotshape(Yesterdays_Low and YLow ? Yesterdays_Low : na, title="Yesterday's Low", style=shape.labelup, location=location.absolute, color=YLowColor, text="Yesterday's Low", textcolor=color.white, size=size.small, show_last=1) plotshape(Yesterdays_Open and YOpen ? Yesterdays_Open : na, title="Yesterday's Open", style=shape.labelup, location=location.absolute, color=YOpenColor, text="Yesterday's Open", textcolor=color.white, size=size.small, show_last=1) plotshape(Yesterdays_Close and YClose ? Yesterdays_Close : na, title="Yesterday's Close", style=shape.labelup, location=location.absolute, color=YCloseColor, text="Yesterday's Close", textcolor=color.white, size=size.small, show_last=1) // weekly plotshapes plotshape(Weekly_High and WHigh ? Weekly_High : na, title="Week's High", style=shape.labelup, location=location.absolute, color=WHighColor, text="Week's high", textcolor=color.white, size=size.small, show_last=1) plotshape(Weekly_Low and WLow ? Weekly_Low : na, title="Week's Low", style=shape.labelup, location=location.absolute, color=WLowColor, text="Week's Low", textcolor=color.white, size=size.small, show_last=1) plotshape(Weekly_Open and WOpen ? Weekly_Open : na, title="Week's Open", style=shape.labelup, location=location.absolute, color=WOpenColor, text="Week's Open", textcolor=color.white, size=size.small, show_last=1) plotshape(Weekly_Close and WClose ? Weekly_Close : na, title="Week's Close", style=shape.labelup, location=location.absolute, color=WCloseColor, text="Week's Close", textcolor=color.white, size=size.small, show_last=1) // Monthly plotshapes plotshape(Monthly_High and MHigh ? Monthly_High : na, title="Month's High", style=shape.labelup, location=location.absolute, color=MHighColor, text="Months's High", textcolor=color.white, size=size.small, show_last=1) plotshape(Monthly_Low and MLow ? Monthly_Low : na, title="Month's Low", style=shape.labelup, location=location.absolute, color=MLowColor, text="Month's Low", textcolor=color.white, size=size.small, show_last=1) plotshape(Monthly_Open and MOpen ? Monthly_Open : na, title="Month's Open", style=shape.labelup, location=location.absolute, color=MOpenColor, text="Months's Open", textcolor=color.white, size=size.small, show_last=1) plotshape(Monthly_Close and MClose ? Monthly_Close : na, title="Month's Close", style=shape.labelup, location=location.absolute, color=MCloseColor, text="Month's Close", textcolor=color.white, size=size.small, show_last=1)
Consolidation Channels + MMA
https://www.tradingview.com/script/k3ERRqgW-Consolidation-Channels-MMA/
Mohammed_Khan
https://www.tradingview.com/u/Mohammed_Khan/
27
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Mohammed_Khan //@version=5 indicator("Consolidation Channels + MMA", overlay=true) // ============================================================================= // ||||||||||||||||||||||||||||||||-CHANNEL-|||||||||||||||||||||||||||||||||||| // ============================================================================= lookback = input.int(200, "Lookback") band_multiplier = input.float(2.5, "Band Multiplier") channel(lookback) => x = 0.0 for i = 1 to lookback x += (open[i] + close[i]) / 2 x := x / lookback upper_channel = channel(lookback) + ((channel(lookback) / 100) * band_multiplier) lower_channel = channel(lookback) - ((channel(lookback) / 100) * band_multiplier) plot(upper_channel, color=color.orange, style=plot.style_circles) plot(channel(lookback), color=color.red, style=plot.style_circles) plot(lower_channel, color=color.yellow, style=plot.style_circles) // ============================================================================= // |||||||||||||||||||||||||||-MEAN MOVING AVG-||||||||||||||||||||||||||||||||| // ============================================================================= period = input.int(20, "Period") method = input.string("OHLC", "Method", options=["High | Low", "Open | Close", "OHLC"]) mean_moving(period, method) => mean = 0.0 for i = 1 to period mean := switch method "High | Low" => mean += (high[i] + low[i]) / 2 "Open | Close" => mean += (open[i] + close[i]) / 2 "OHLC" => mean += (open[i] + high[i] + low[i]+ close[i]) / 4 mean := mean / period plot(mean_moving(period, method), color=color.white)
標的相對上市
https://www.tradingview.com/script/R4ICm4hP-%E6%A8%99%E7%9A%84%E7%9B%B8%E5%B0%8D%E4%B8%8A%E5%B8%82/
etelephantal72
https://www.tradingview.com/u/etelephantal72/
7
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Morty //@version=4 study("標的相對上市", resolution="") s2 = input(title="上市", type=input.symbol, defval="TWSE:TAIEX") f() => [open, high, low, close] [o1, h1, l1, c1] = security(syminfo.tickerid, timeframe.period, f()) [o2, h2, l2, c2] = security(s2, timeframe.period, f()) c = o1/o2 < c1/c2 ? #E2DED0 : #4E4F50 plotcandle(o1/o2, h1/h2, l1/l2, c1/c2, color=c, wickcolor=c, bordercolor=c) // Donchian Channels length = input(50, "Donchian Channel Length", minval=1) mid_ma_length = input(5, "Midline moving avarage length", minval=1) lower = lowest(l1/l2, length) upper = highest(h1/h2, length) basis = avg(upper, lower) pallete = ema(c1/c2, mid_ma_length) > basis ? #76B947 : #F83839 plot(basis, "Basis", color=pallete, linewidth=2) u = plot(upper, "Upper", color=#2962FF) l = plot(lower, "Lower", color=#2962FF) fill(u, l, color=color.rgb(33, 150, 243, 95), title="Background")
Range Gap/Open to Close/Close to Close
https://www.tradingview.com/script/5glbSQxp-Range-Gap-Open-to-Close-Close-to-Close/
seba34e
https://www.tradingview.com/u/seba34e/
28
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © seba34e //@version=5 indicator("Range Gap/Open to Close/Close to Close") GapOrDay = input.string("Gap", title = "Condition", options = ["Gap", "Open To Close", "Close To Close"] ) Gatillo = input.float(1.2, "Target Percentage", step=0.1) filter_from = input (true, title="Apply From Filter", group = "FROM") i_startTime = input.time(title='Start Date', defval=timestamp('01 Jan 2022 05:00'), group= "FROM", tooltip='Date & time to begin trading from') filter_until = input (true, title = "Apply Until Filter", group = "UNTIL") i_endTime = input.time(title='End Date', defval=timestamp('1 Jul 2022 04:00'), group= "UNTIL", tooltip='Date & time to stop trading') FechaValida() => from = time >= i_startTime or not filter_from until = time <= i_endTime or not filter_until from and until var totalDays = 0 var trueDays = 0 diferencia_puntos = math.abs(close[1]-open) gap_porcentage = math.abs ((1-open/close[1] ) *100) openClosePorcentage = math.abs ((1- close/open ) *100) closeClosePorcentage = math.abs ((1-close /close [1]) *100) //plot (diferencia_puntos, style=plot.style_histogram) plot (GapOrDay=="Gap" ? gap_porcentage : na, style=plot.style_columns, color= gap_porcentage>=Gatillo ? color.red : color.green) plot (GapOrDay=="Open To Close" ? openClosePorcentage : na, style=plot.style_columns, color= openClosePorcentage>=Gatillo ? color.red : color.green) plot (GapOrDay=="Close To Close" ? closeClosePorcentage : na, style=plot.style_columns, color= closeClosePorcentage>=Gatillo ? color.red : color.green) hline(Gatillo, linestyle = hline.style_solid, color=color.blue) if GapOrDay == 'Gap' and gap_porcentage <= Gatillo and FechaValida() trueDays := trueDays + 1 if GapOrDay == 'Open To Close' and openClosePorcentage <= Gatillo and FechaValida() trueDays := trueDays + 1 if GapOrDay == 'Close To Close' and closeClosePorcentage <= Gatillo and FechaValida() trueDays := trueDays + 1 if FechaValida() totalDays := totalDays + 1 bgcolor(FechaValida() ? color.new(color.yellow ,transp = 95) : na ) var table TheTable = table.new(position.top_right , 2, 8, border_width=2) fill_Cell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) => _cellText = _title + '' + _value table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor, text_halign=text.align_right) //Prepare cells if barstate.islast fill_Cell(TheTable, 0, 0, "", 'Condition:' , color.blue, color.yellow) fill_Cell(TheTable, 1, 0, GapOrDay, " ", color.blue, color.yellow) fill_Cell(TheTable, 0, 1, "", 'Deviation:' , color.black, color.yellow) fill_Cell(TheTable, 1, 1, "", str.tostring(Gatillo,"0.00") + "%" , color.black, color.yellow) fill_Cell(TheTable, 0, 2, "", 'Total Days:' , color.blue, color.yellow) fill_Cell(TheTable, 1, 2, str.tostring(totalDays), " ", color.blue, color.yellow) fill_Cell(TheTable, 0, 3, "", 'Under Condition Days' , color.green, color.white) fill_Cell(TheTable, 1, 3, str.tostring(trueDays) + ' (' + str.tostring(trueDays/totalDays,"0.00%") + ')', " ", color.green, color.white) fill_Cell(TheTable, 0, 4, "", 'Over Condition Days' , color.red, color.white) fill_Cell(TheTable, 1, 4, str.tostring(totalDays - trueDays) + ' (' + str.tostring((totalDays-trueDays)/totalDays,"0.00%") + ')', " ", color.red, color.white)
Advance Decline Index
https://www.tradingview.com/script/jZnhWIv0-Advance-Decline-Index/
viewer405
https://www.tradingview.com/u/viewer405/
153
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © viewer405 //@version=5 indicator(title="ADD Indicator", shorttitle="ADD") bullColor = #26a69a bearColor = #ef5350 timeInterval = input.timeframe("", title="Time Interval") style = input.string("line", title="Candle Style", options=["bars", "line", "candles", "ratio"]) default = input.string("USI:ADD", title="Default Ticker", options=["USI:ADD", "USI:ADDQ", "USI:ADDA", "USI:ADVDEC.US", "USI:ADVDEC.NY", "USI:ADVDEC.NQ", "USI:ADVDEC.DJ", "USI:ADVDEC.AM", "USI:ADVDEC.AX"]) enableSummaryTable = input.bool(true, "Enable Summary Table") enableThresholds = input.bool(true, "Enable Threshold Lines") enableMA = input.bool(false, "Enable Moving Averages") ma1Length = input.int(10, "1st MA Length") ma2Length = input.int(20, "2nd MA Length") ma1Source = input.string("close", "1st MA Source", options=["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"]) ma2Source = input.string("close", "2nd MA Source", options=["open", "high", "low", "close", "hl2", "hlc3", "ohlc4"]) ma1Type = input.string("ema", "1st MA Type", options=["ema", "sma"]) ma2Type = input.string("ema", "2nd MA Type", options=["ema", "sma"]) prefix = switch syminfo.prefix "NYSE" => "USI:ADVDEC.NY" "NASDAQ" => "USI:ADVDEC.NQ" "USI" => syminfo.ticker => "" adType = switch syminfo.type "crypto" => "USI:ADDQ" // Crypto is behaving like tech sector, use NASDAQ. "economic" => "" "fund" => "" "cfd" => "" // (contract for difference) "dr" => "" // (depository receipt) "stock" => "USI:ADVDEC.US" "index" => "" => "" index = switch syminfo.ticker "ES" => "USI:ADD" "SPY" => "USI:ADD" "SPX" => "USI:ADD" "NQ" => "USI:ADDQ" "QQQ" => "USI:ADDQ" "TQQQ" => "USI:ADDQ" "NASDAQ" => "USI:ADDQ" "YM" => "USI:ADVDEC.DJ" "DJI" => "USI:ADVDEC.DJ" => "" uIndex = switch syminfo.ticker "ES" => "USI:ADV" "SPY" => "USI:ADV" "SPX" => "USI:ADV" "NQ" => "USI:ADVQ" "QQQ" => "USI:ADVQ" "TQQQ" => "USI:ADVQ" "NASDAQ" => "USI:ADVQ" "YM" => "USI:ADVN.DJ" "DJI" => "USI:ADVN.DJ" => "" dIndex = switch syminfo.ticker "ES" => "USI:DECL" "SPY" => "USI:DECL" "SPX" => "USI:DECL" "NQ" => "USI:DECLQ" "QQQ" => "USI:DECLQ" "TQQQ" => "USI:DECLQ" "NASDAQ" => "USI:DECLQ" "YM" => "USI:DECL.DJ" "DJI" => "USI:DECL.DJ" => "" ticker = prefix != "" ? prefix : (adType != "" ? adType : (index != "" ? index : default)) // As of 2022, TradingView has not yet resolved data issues when querying daily // candlestick data for USI:ADD. Use 390 minutes instead of the daily. It // equates to 6 1/2 hours that the markets are open Monday to Friday. if timeframe.isdaily and style == "candles" timeInterval := '390' uO = request.security(uIndex, timeInterval, open) uH = request.security(uIndex, timeInterval, high) uL = request.security(uIndex, timeInterval, low) uC = request.security(uIndex, timeInterval, close) dO = request.security(dIndex, timeInterval, open) dH = request.security(dIndex, timeInterval, high) dL = request.security(dIndex, timeInterval, low) dC = request.security(dIndex, timeInterval, close) ratio = uC > dC ? math.round(uC / dC, 2) : -math.round(dC / uC, 2) o = request.security(ticker, timeInterval, open) h = request.security(ticker, timeInterval, high) l = request.security(ticker, timeInterval, low) c = request.security(ticker, timeInterval, close) getMASourcePrice(source, o, h, l, c) => price = switch source "open" => o "high" => h "low" => l "close" => c "hl2" => (h + l) / 2 "hlc3" => (h + l + c) / 3 "ohlc4" => (o + h + l + c) / 4 => c price ma1Price = getMASourcePrice(ma1Source, o, h, l, c) ma2Price = getMASourcePrice(ma2Source, o, h, l, c) ma1 = ma1Type == "ema" ? ta.ema(ma1Price, ma1Length) : ta.sma(ma1Price, ma1Length) ma2 = ma2Type == "ema" ? ta.ema(ma2Price, ma2Length) : ta.sma(ma2Price, ma2Length) plot(ma1, "1st MA", display = enableMA ? display.all : display.none, color=color.fuchsia) plot(ma2, "2nd MA", display = enableMA ? display.all : display.none, color=color.aqua) if barstate.islast and enableSummaryTable table legend = table.new(position.top_right, 3, 4, bgcolor = color.gray, frame_width = 2) table.cell(legend, 0, 0, ticker + " " + str.tostring(c) + " | Ratio: " + str.tostring(ratio) + ":1") table.cell(legend, 0, 1, uIndex + " " + str.tostring(uC)) table.cell(legend, 0, 2, dIndex + " " + str.tostring(dC)) isBar = style == "bars" ? true : false isLine = style == "line" ? true : false isRatio = style == "ratio" ? true : false isCandle = style == "candles" ? true : false plot(c, display=isLine ? display.all : display.none) plot(ratio, style = plot.style_columns, display = isRatio ? display.all : display.none) plotbar(open=o, high=h, low=l, close=c, color=c < o ? bearColor : bullColor, display=isBar ? display.all : display.none) plotcandle(open=o, high=h, low=l, close=c, color=c < o ? bearColor : bullColor, bordercolor=na, display=isCandle ? display.all : display.none) hline(0, "Middle Band", color=color.new(#787B86, 50), display = enableThresholds ? display.all : display.none) hline(500, "Upper Band +500", color=color.new(bullColor, 75), display = display.none) hline(-500, "Lower Band -500", color=color.new(bearColor, 75), display = display.none) hline(1000, "Upper Band +1000", color=color.new(bullColor, 50), display = enableThresholds ? display.all : display.none) hline(-1000, "Lower Band -1000", color=color.new(bearColor, 50), display = enableThresholds ? display.all : display.none) hline(1500, "Upper Band +1500", color=color.new(bullColor, 25), display = display.none) hline(-1500, "Lower Band -1500", color=color.new(bearColor, 25), display = display.none) hline(2000, "Upper Band +2000", color=color.new(bullColor, 0), display = enableThresholds ? display.all : display.none) hline(-2000, "Lower Band -2000", color=color.new(bearColor, 0), display = enableThresholds ? display.all : display.none)
Symbol Info
https://www.tradingview.com/script/yiM1S2K2-Symbol-Info/
Munkhtur
https://www.tradingview.com/u/Munkhtur/
24
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Munkhtur //@version=5 indicator("Symbol Info", shorttitle = "Info", overlay = true) Vertical = input.string("top", "", inline = "1", options = ["top", "middle", "bottom"], group ="Position") Horizontal = input.string("right", "", inline = "1", options = ["left", "center", "right"], group ="Position", tooltip = "Shows on the selected location") First = input.string("Ticker", "", inline = "2", options = ["Ticker", "Timeframe", ""], group ="Symbol info") Second = input.string("Timeframe","", inline = "2", options = ["Ticker", "Timeframe", ""], group ="Symbol info", tooltip = "Shows Symbol info in order") textsize = input.string("small", "Size", inline = "3", options = ["tiny", "small", "normal", "large", "huge", "auto"], group ="Text settings") text_color = input.color (color.new(color.blue, 0), "Color", inline = "3", group ="Text settings") background = input.color (color.new(color.gray, 100), 'Background', inline = "3", group ="Text settings") text1 = input.string("Do Your Own Research✔️【DYOR】", "Text 1", inline = "4", group ="Text", tooltip = "Texts automatically switches") text2 = input.string("Not Financial Advice❌【NFA】", "Text 2", inline = "4", group ="Text") var Symbol_info = table.new(Vertical + '_' + Horizontal, 1, 2) period = timeframe.period string symbol = "" string timeframe = "" string ticker = "" ticker := (syminfo.ticker + " ") timeframe := switch period == "S" => "1S " period == "60" => "1H " period == "120" => "2H " period == "180" => "3H " period == "240" => "4H " period == "360" => "6H " => period + (timeframe.isminutes ? "M " : "") Column_1 = switch First "Ticker" => ticker "Timeframe" => timeframe Column_2 = switch Second "Ticker" => ticker "Timeframe" => timeframe symbol := Column_1 + (Column_1 == "" ? "" : "") + Column_2 if barstate.islast varip bool changeText = true changeText := not changeText text_switch = str.length(text2) != 0 and changeText ? text2 : text1 table.cell(Symbol_info, 0, 0, symbol, 0, 0, text_color, text.align_right, text_size = textsize, bgcolor = background) table.cell(Symbol_info, 0, 1, text_switch, 0, 0, text_color, text_size = textsize, bgcolor = background)
Dr. Mahdi Kazempour - Crypto Trade Dashboard and Indicator Panel
https://www.tradingview.com/script/F56fpIs0-Dr-Mahdi-Kazempour-Crypto-Trade-Dashboard-and-Indicator-Panel/
drmahdikazempour
https://www.tradingview.com/u/drmahdikazempour/
46
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © drmahdikazempour //@version=4 study("Dr. Mahdi Kazempour - Crypto Trade Dashboard and Indicator Panel ", overlay = false) currentSymbol = syminfo.description stattextsize = input(defval = size.small, title = "Panel Size", options = [size.tiny, size.small, size.normal, size.large]) tableposy = input(defval='bottom', title='Panel Position', options=['bottom', 'middle', 'top'], inline='pos') tableposx = input(defval='left', title='', options=['left', 'center', 'right'], inline='pos') symbol0 = syminfo.tickerid symbol1 = input(defval = "BINANCE:BTCUSDT", type = input.symbol) symbol2 = input(defval = "SKILLING:NASDAQ", type = input.symbol) symbol3 = input(defval = "BINANCE:ETHUSDT", type = input.symbol) symbol4 = input(defval = "CRYPTOCAP:TOTAL2", type = input.symbol) source = close//input(defval = close, title = "Source") indi0 = input(defval = true, title = "RSI", inline = "rsi") indi0l = input(defval = 14, title = "", inline = "rsi") indi1 = input(defval = true, title = "MACD", inline = "macd") indi1l1 = input(defval = 12, title = "", inline = "macd") indi1l2 = input(defval = 26, title = "", inline = "macd") indi1l3 = input(defval = 9, title = "", inline = "macd") indi2 = input(defval = true, title = "DMI", inline = "dmi") indi2l1 = input(defval = 14, title = "", inline = "dmi") indi2l2 = input(defval = 14, title = "", inline = "dmi") indi3 = input(defval = true, title = "CCI", inline = "cci") indi3l = input(defval = 20, title = "", inline = "cci") indi4 = input(defval = true, title = "MFI", inline = "mfi") indi4l = input(defval = 20, title = "", inline = "mfi") indi5 = input(defval = true, title = "Momentum", inline = "momentum") indi5l = input(defval = 10, title = "", inline = "momentum") indi6 = input(defval = true, title =" MA", inline = "indi6") indi6t = input(defval = "SMA", title = "", options = ["SMA","EMA"], inline = "indi6") indi6l = input(defval = 50, title = "", minval = 1, inline = "indi6") indi7 = input(defval = true, title =" MA", inline = "indi7") indi7t = input(defval = "SMA", title = "", options = ["SMA","EMA"], inline = "indi7") indi7l = input(defval = 200, title = "", minval = 1, inline = "indi7") var indinames = array.new_string(12) var precision = array.new_string(12, '#.##########') if barstate.isfirst array.set(indinames, 0, "RSI"), array.set(precision, 0, '#.##') array.set(indinames, 1, "MACD Line"), array.set(precision, 0, '#.##') array.set(indinames, 2, "MACD Signal"), array.set(precision, 0, '#.##') array.set(indinames, 3, "MACD Histogram"), array.set(precision, 0, '#.##') array.set(indinames, 4, "+DI"), array.set(precision, 4, '#.##') array.set(indinames, 5, "-DI"), array.set(precision, 5, '#.##') array.set(indinames, 6, "ADX"), array.set(precision, 6, '#.##') array.set(indinames, 7, "CCI"), array.set(precision, 7, '#.##') array.set(indinames, 8, "MFI"), array.set(precision, 8, '#.##') array.set(indinames, 9, "Momentum") array.set(indinames, 10, "Price") array.set(indinames, 11, "Volume") // get indicator values indicators = array.new_float(800, 0) RSI0 = security(symbol0, timeframe.period, rsi(source, indi0l)) [macdLine0, signalLine0, histLine0] = security(symbol0, timeframe.period, macd(close, indi1l1, indi1l2, indi1l3)) [diplus0, diminus0, adx0]= security(symbol0, timeframe.period, dmi(indi2l1, indi2l2)) cci0 = security(symbol0, timeframe.period, cci(source, indi3l)) mfi0 = security(symbol0, timeframe.period, mfi(source, indi4l)) mom0 = security(symbol0, timeframe.period, mom(source, indi5l)) pr01 = security(symbol0, timeframe.period, indi6t == "SMA" ? close : close) vol02 = security(symbol0, timeframe.period, indi7t == "SMA" ? volume : volume) RSI1 = security(symbol1, timeframe.period, rsi(source, indi0l)) [macdLine1, signalLine1, histLine1] = security(symbol1, timeframe.period, macd(close, indi1l1, indi1l2, indi1l3)) [diplus1, diminus1, adx1]= security(symbol1, timeframe.period, dmi(indi2l1, indi2l2)) cci1 = security(symbol1, timeframe.period, cci(source, indi3l)) mfi1 = security(symbol1, timeframe.period, mfi(source, indi4l)) mom1 = security(symbol1, timeframe.period, mom(source, indi5l)) pr11 = security(symbol1, timeframe.period, indi6t == "SMA" ? close : close) vol12 = security(symbol1, timeframe.period, indi7t == "SMA" ? volume : volume) RSI2 = security(symbol2, timeframe.period, rsi(source, indi0l)) [macdLine2, signalLine2, histLine2] = security(symbol2, timeframe.period, macd(close, indi1l1, indi1l2, indi1l3)) [diplus2, diminus2, adx2]= security(symbol2, timeframe.period, dmi(indi2l1, indi2l2)) cci2 = security(symbol2, timeframe.period, cci(source, indi3l)) mfi2 = security(symbol2, timeframe.period, mfi(source, indi4l)) mom2 = security(symbol2, timeframe.period, mom(source, indi5l)) pr21 = security(symbol2, timeframe.period, indi6t == "SMA" ? close : close) vol22 = security(symbol2, timeframe.period, indi7t == "SMA" ? volume : volume) RSI3 = security(symbol3, timeframe.period, rsi(source, indi0l)) [macdLine3, signalLine3, histLine3] = security(symbol3, timeframe.period, macd(close, indi1l1, indi1l2, indi1l3)) [diplus3, diminus3, adx3]= security(symbol3, timeframe.period, dmi(indi2l1, indi2l2)) cci3 = security(symbol3, timeframe.period, cci(source, indi3l)) mfi3 = security(symbol3, timeframe.period, mfi(source, indi4l)) mom3 = security(symbol3, timeframe.period, mom(source, indi5l)) pr31 = security(symbol3, timeframe.period, indi6t == "SMA" ? close : close) vol32 = security(symbol3, timeframe.period, indi7t == "SMA" ? volume : volume) RSI4 = security(symbol4, timeframe.period, rsi(source, indi0l)) [macdLine4, signalLine4, histLine4] = security(symbol4, timeframe.period, macd(close, indi1l1, indi1l2, indi1l3)) [diplus4, diminus4, adx4]= security(symbol4, timeframe.period, dmi(indi2l1, indi2l2)) cci4 = security(symbol4, timeframe.period, cci(source, indi3l)) mfi4 = security(symbol4, timeframe.period, mfi(source, indi4l)) mom4 = security(symbol4, timeframe.period, mom(source, indi5l)) pr41 = security(symbol4, timeframe.period, indi6t == "SMA" ? close : close) vol42 = security(symbol4, timeframe.period, indi7t == "SMA" ? volume : volume) f_add_indi(enabled, index, indi, indi1)=> if enabled array.set(indicators, index, 1) array.set(indicators, index + 1, indi) if not na(indi) array.set(indicators, index + 2, indi1) // set indicator values // symbol 0 f_add_indi(indi0, 0 * 40 + 0, RSI0, RSI0[1]) f_add_indi(indi1, 0 * 40 + 3, macdLine0, macdLine0[1]) f_add_indi(indi1, 0 * 40 + 6, signalLine0, signalLine0[1]) f_add_indi(indi1, 0 * 40 + 9, histLine0, histLine0[1]) f_add_indi(indi2, 0 * 40 + 12, diplus0, diplus0[1]) f_add_indi(indi2, 0 * 40 + 15, diminus0, diminus0[1]) f_add_indi(indi2, 0 * 40 + 18, adx0, adx0[1]) f_add_indi(indi3, 0 * 40 + 21, cci0, cci0[1]) f_add_indi(indi4, 0 * 40 + 24, mfi0, mfi0[1]) f_add_indi(indi5, 0 * 40 + 27, mom0, mom0[1]) f_add_indi(indi6, 0 * 40 + 30, pr01, pr01[1]) f_add_indi(indi7, 0 * 40 + 33, vol02, vol02[1]) // symbol 1 f_add_indi(indi0, 1 * 40 + 0, RSI1, RSI1[1]) f_add_indi(indi1, 1 * 40 + 3, macdLine1, macdLine1[1]) f_add_indi(indi1, 1 * 40 + 6, signalLine1, signalLine1[1]) f_add_indi(indi1, 1 * 40 + 9, histLine1, histLine1[1]) f_add_indi(indi2, 1 * 40 + 12, diplus1, diplus1[1]) f_add_indi(indi2, 1 * 40 + 15, diminus1, diminus1[1]) f_add_indi(indi2, 1 * 40 + 18, adx1, adx1[1]) f_add_indi(indi3, 1 * 40 + 21, cci1, cci1[1]) f_add_indi(indi4, 1 * 40 + 24, mfi1, mfi1[1]) f_add_indi(indi5, 1 * 40 + 27, mom1, mom1[1]) f_add_indi(indi6, 1 * 40 + 30, pr11, pr11[1]) f_add_indi(indi7, 1 * 40 + 33, vol12, vol12[1]) // symbol 2 f_add_indi(indi0, 2 * 40 + 0, RSI2, RSI2[1]) f_add_indi(indi1, 2 * 40 + 3, macdLine2, macdLine2[1]) f_add_indi(indi1, 2 * 40 + 6, signalLine2, signalLine2[1]) f_add_indi(indi1, 2 * 40 + 9, histLine2, histLine2[1]) f_add_indi(indi2, 2 * 40 + 12, diplus2, diplus2[1]) f_add_indi(indi2, 2 * 40 + 15, diminus2, diminus2[1]) f_add_indi(indi2, 2 * 40 + 18, adx2, adx2[1]) f_add_indi(indi3, 2 * 40 + 21, cci2, cci2[1]) f_add_indi(indi4, 2 * 40 + 24, mfi2, mfi2[1]) f_add_indi(indi5, 2 * 40 + 27, mom2, mom2[1]) f_add_indi(indi6, 2 * 40 + 30, pr21, pr21[1]) f_add_indi(indi7, 2 * 40 + 33, vol22, vol22[1]) // symbol 3 f_add_indi(indi0, 3 * 40 + 0, RSI3, RSI3[1]) f_add_indi(indi1, 3 * 40 + 3, macdLine3, macdLine3[1]) f_add_indi(indi1, 3 * 40 + 6, signalLine3, signalLine3[1]) f_add_indi(indi1, 3 * 40 + 9, histLine3, histLine3[1]) f_add_indi(indi2, 3 * 40 + 12, diplus3, diplus3[1]) f_add_indi(indi2, 3 * 40 + 15, diminus3, diminus3[1]) f_add_indi(indi2, 3 * 40 + 18, adx3, adx3[1]) f_add_indi(indi3, 3 * 40 + 21, cci3, cci3[1]) f_add_indi(indi4, 3 * 40 + 24, mfi3, mfi3[1]) f_add_indi(indi5, 3 * 40 + 27, mom3, mom3[1]) f_add_indi(indi6, 3 * 40 + 30, pr31, pr31[1]) f_add_indi(indi7, 3 * 40 + 33, vol32, vol32[1]) // symbol 4 f_add_indi(indi0, 4 * 40 + 0, RSI4, RSI4[1]) f_add_indi(indi1, 4 * 40 + 3, macdLine4, macdLine4[1]) f_add_indi(indi1, 4 * 40 + 6, signalLine4, signalLine4[1]) f_add_indi(indi1, 4 * 40 + 9, histLine4, histLine4[1]) f_add_indi(indi2, 4 * 40 + 12, diplus4, diplus4[1]) f_add_indi(indi2, 4 * 40 + 15, diminus4, diminus4[1]) f_add_indi(indi2, 4 * 40 + 18, adx4, adx4[1]) f_add_indi(indi3, 4 * 40 + 21, cci4, cci4[1]) f_add_indi(indi4, 4 * 40 + 24, mfi4, mfi4[1]) f_add_indi(indi5, 4 * 40 + 27, mom4, mom4[1]) f_add_indi(indi6, 4 * 40 + 30, pr41, pr41[1]) f_add_indi(indi7, 4 * 40 + 33, vol42, vol42[1]) var indicatorTable = table.new(position = tableposy + '_' + tableposx, columns = 20, rows= 15, frame_color = color.maroon, frame_width = 4, border_width = 1, border_color = color.green) if barstate.islast // symbols table.cell(table_id = indicatorTable, column = 0, row = 0, text = "Indicator", bgcolor = color.green, text_color = color.white, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 1, text = "Panel", bgcolor = color.green, text_color = color.white, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 2, text = symbol0, text_halign = text.align_left, bgcolor = color.silver, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 3, text = symbol1, text_halign = text.align_left, bgcolor = color.aqua, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 4, text = symbol2, text_halign = text.align_left, bgcolor = color.silver, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 5, text = symbol3, text_halign = text.align_left, bgcolor = color.aqua, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = 0, row = 6, text = symbol4, text_halign = text.align_left, bgcolor = color.silver, text_color = color.black, text_size=stattextsize) // indicator values col = color.yellow for j = 0 to 4 for i = 0 to 11 index = j * 40 + i * 3 if array.get(indicators, index) == 1 // enabled table.cell(table_id = indicatorTable, column = i + 1, row = 1, text = array.get(indinames, i), bgcolor = col, text_color = color.black, text_size=stattextsize) if i >= 1 and i <= 6 if i == 1 table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = i + 2, row = 0, text = "M A C D", bgcolor = col, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = i + 3, row = 0, text = "", bgcolor = col, text_color = color.black, text_size=stattextsize) if i == 4 table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = i + 2, row = 0, text = "D M I", bgcolor = col, text_color = color.black, text_size=stattextsize) table.cell(table_id = indicatorTable, column = i + 3, row = 0, text = "", bgcolor = col, text_color = color.black, text_size=stattextsize) if i == 3 or i == 6 col := col == color.yellow ? color.orange : color.yellow else table.cell(table_id = indicatorTable, column = i + 1, row = 0, text = "", bgcolor = col, text_color = color.black, text_size=stattextsize) col := col == color.yellow ? color.orange : color.yellow bgcol = array.get(indicators, index + 1) > array.get(indicators, index + 2) ? color.lime : array.get(indicators, index + 1) < array.get(indicators, index + 2) ? color.red : color.gray txtcol = array.get(indicators, index + 1) > array.get(indicators, index + 2) ? color.black : array.get(indicators, index+ 1) < array.get(indicators, index + 2) ? color.white : color.black txt = tostring(array.get(indicators, index + 1), array.get(precision, i)) table.cell(table_id = indicatorTable, column = i + 1, row = j + 2, text = txt, bgcolor = bgcol, text_color = txtcol, text_size=stattextsize)
Smart Money Concepts [LuxAlgo]
https://www.tradingview.com/script/CnB3fSph-Smart-Money-Concepts-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
33,222
study
5
CC-BY-NC-SA-4.0
// 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=5 indicator("Smart Money Concepts [LuxAlgo]", "Smart Money Concepts [LuxAlgo]" , overlay = true , max_labels_count = 500 , max_lines_count = 500 , max_boxes_count = 500 , max_bars_back = 500) //-----------------------------------------------------------------------------{ //Constants //-----------------------------------------------------------------------------{ color TRANSP_CSS = #ffffff00 //Tooltips string MODE_TOOLTIP = 'Allows to display historical Structure or only the recent ones' string STYLE_TOOLTIP = 'Indicator color theme' string COLOR_CANDLES_TOOLTIP = 'Display additional candles with a color reflecting the current trend detected by structure' string SHOW_INTERNAL = 'Display internal market structure' string CONFLUENCE_FILTER = 'Filter non significant internal structure breakouts' string SHOW_SWING = 'Display swing market Structure' string SHOW_SWING_POINTS = 'Display swing point as labels on the chart' string SHOW_SWHL_POINTS = 'Highlight most recent strong and weak high/low points on the chart' string INTERNAL_OB = 'Display internal order blocks on the chart\n\nNumber of internal order blocks to display on the chart' string SWING_OB = 'Display swing order blocks on the chart\n\nNumber of internal swing blocks to display on the chart' string FILTER_OB = 'Method used to filter out volatile order blocks \n\nIt is recommended to use the cumulative mean range method when a low amount of data is available' string SHOW_EQHL = 'Display equal highs and equal lows on the chart' string EQHL_BARS = 'Number of bars used to confirm equal highs and equal lows' string EQHL_THRESHOLD = 'Sensitivity threshold in a range (0, 1) used for the detection of equal highs & lows\n\nLower values will return fewer but more pertinent results' string SHOW_FVG = 'Display fair values gaps on the chart' string AUTO_FVG = 'Filter out non significant fair value gaps' string FVG_TF = 'Fair value gaps timeframe' string EXTEND_FVG = 'Determine how many bars to extend the Fair Value Gap boxes on chart' string PED_ZONES = 'Display premium, discount, and equilibrium zones on chart' //-----------------------------------------------------------------------------{ //Settings //-----------------------------------------------------------------------------{ //General //----------------------------------------{ mode = input.string('Historical' , options = ['Historical', 'Present'] , group = 'Smart Money Concepts' , tooltip = MODE_TOOLTIP) style = input.string('Colored' , options = ['Colored', 'Monochrome'] , group = 'Smart Money Concepts' , tooltip = STYLE_TOOLTIP) show_trend = input(false, 'Color Candles' , group = 'Smart Money Concepts' , tooltip = COLOR_CANDLES_TOOLTIP) //----------------------------------------} //Internal Structure //----------------------------------------{ show_internals = input(true, 'Show Internal Structure' , group = 'Real Time Internal Structure' , tooltip = SHOW_INTERNAL) show_ibull = input.string('All', 'Bullish Structure' , options = ['All', 'BOS', 'CHoCH'] , inline = 'ibull' , group = 'Real Time Internal Structure') swing_ibull_css = input(#089981, '' , inline = 'ibull' , group = 'Real Time Internal Structure') //Bear Structure show_ibear = input.string('All', 'Bearish Structure' , options = ['All', 'BOS', 'CHoCH'] , inline = 'ibear' , group = 'Real Time Internal Structure') swing_ibear_css = input(#f23645, '' , inline = 'ibear' , group = 'Real Time Internal Structure') ifilter_confluence = input(false, 'Confluence Filter' , group = 'Real Time Internal Structure' , tooltip = CONFLUENCE_FILTER) internal_structure_size = input.string('Tiny', 'Internal Label Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Real Time Internal Structure') //----------------------------------------} //Swing Structure //----------------------------------------{ show_Structure = input(true, 'Show Swing Structure' , group = 'Real Time Swing Structure' , tooltip = SHOW_SWING) //Bull Structure show_bull = input.string('All', 'Bullish Structure' , options = ['All', 'BOS', 'CHoCH'] , inline = 'bull' , group = 'Real Time Swing Structure') swing_bull_css = input(#089981, '' , inline = 'bull' , group = 'Real Time Swing Structure') //Bear Structure show_bear = input.string('All', 'Bearish Structure' , options = ['All', 'BOS', 'CHoCH'] , inline = 'bear' , group = 'Real Time Swing Structure') swing_bear_css = input(#f23645, '' , inline = 'bear' , group = 'Real Time Swing Structure') swing_structure_size = input.string('Small', 'Swing Label Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'Real Time Swing Structure') //Swings show_swings = input(false, 'Show Swings Points' , inline = 'swings' , group = 'Real Time Swing Structure' , tooltip = SHOW_SWING_POINTS) length = input.int(50, '' , minval = 10 , inline = 'swings' , group = 'Real Time Swing Structure') show_hl_swings = input(true, 'Show Strong/Weak High/Low' , group = 'Real Time Swing Structure' , tooltip = SHOW_SWHL_POINTS) //----------------------------------------} //Order Blocks //----------------------------------------{ show_iob = input(true, 'Internal Order Blocks' , inline = 'iob' , group = 'Order Blocks' , tooltip = INTERNAL_OB) iob_showlast = input.int(5, '' , minval = 1 , inline = 'iob' , group = 'Order Blocks') show_ob = input(false, 'Swing Order Blocks' , inline = 'ob' , group = 'Order Blocks' , tooltip = SWING_OB) ob_showlast = input.int(5, '' , minval = 1 , inline = 'ob' , group = 'Order Blocks') ob_filter = input.string('Atr', 'Order Block Filter' , options = ['Atr', 'Cumulative Mean Range'] , group = 'Order Blocks' , tooltip = FILTER_OB) ibull_ob_css = input.color(color.new(#3179f5, 80), 'Internal Bullish OB' , group = 'Order Blocks') ibear_ob_css = input.color(color.new(#f77c80, 80), 'Internal Bearish OB' , group = 'Order Blocks') bull_ob_css = input.color(color.new(#1848cc, 80), 'Bullish OB' , group = 'Order Blocks') bear_ob_css = input.color(color.new(#b22833, 80), 'Bearish OB' , group = 'Order Blocks') //----------------------------------------} //EQH/EQL //----------------------------------------{ show_eq = input(true, 'Equal High/Low' , group = 'EQH/EQL' , tooltip = SHOW_EQHL) eq_len = input.int(3, 'Bars Confirmation' , minval = 1 , group = 'EQH/EQL' , tooltip = EQHL_BARS) eq_threshold = input.float(0.1, 'Threshold' , minval = 0 , maxval = 0.5 , step = 0.1 , group = 'EQH/EQL' , tooltip = EQHL_THRESHOLD) eq_size = input.string('Tiny', 'Label Size' , options = ['Tiny', 'Small', 'Normal'] , group = 'EQH/EQL') //----------------------------------------} //Fair Value Gaps //----------------------------------------{ show_fvg = input(false, 'Fair Value Gaps' , group = 'Fair Value Gaps' , tooltip = SHOW_FVG) fvg_auto = input(true, "Auto Threshold" , group = 'Fair Value Gaps' , tooltip = AUTO_FVG) fvg_tf = input.timeframe('', "Timeframe" , group = 'Fair Value Gaps' , tooltip = FVG_TF) bull_fvg_css = input.color(color.new(#00ff68, 70), 'Bullish FVG' , group = 'Fair Value Gaps') bear_fvg_css = input.color(color.new(#ff0008, 70), 'Bearish FVG' , group = 'Fair Value Gaps') fvg_extend = input.int(1, "Extend FVG" , minval = 0 , group = 'Fair Value Gaps' , tooltip = EXTEND_FVG) //----------------------------------------} //Previous day/week high/low //----------------------------------------{ //Daily show_pdhl = input(false, 'Daily' , inline = 'daily' , group = 'Highs & Lows MTF') pdhl_style = input.string('⎯⎯⎯', '' , options = ['⎯⎯⎯', '----', '····'] , inline = 'daily' , group = 'Highs & Lows MTF') pdhl_css = input(#2157f3, '' , inline = 'daily' , group = 'Highs & Lows MTF') //Weekly show_pwhl = input(false, 'Weekly' , inline = 'weekly' , group = 'Highs & Lows MTF') pwhl_style = input.string('⎯⎯⎯', '' , options = ['⎯⎯⎯', '----', '····'] , inline = 'weekly' , group = 'Highs & Lows MTF') pwhl_css = input(#2157f3, '' , inline = 'weekly' , group = 'Highs & Lows MTF') //Monthly show_pmhl = input(false, 'Monthly' , inline = 'monthly' , group = 'Highs & Lows MTF') pmhl_style = input.string('⎯⎯⎯', '' , options = ['⎯⎯⎯', '----', '····'] , inline = 'monthly' , group = 'Highs & Lows MTF') pmhl_css = input(#2157f3, '' , inline = 'monthly' , group = 'Highs & Lows MTF') //----------------------------------------} //Premium/Discount zones //----------------------------------------{ show_sd = input(false, 'Premium/Discount Zones' , group = 'Premium & Discount Zones' , tooltip = PED_ZONES) premium_css = input.color(#f23645, 'Premium Zone' , group = 'Premium & Discount Zones') eq_css = input.color(#b2b5be, 'Equilibrium Zone' , group = 'Premium & Discount Zones') discount_css = input.color(#089981, 'Discount Zone' , group = 'Premium & Discount Zones') //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ n = bar_index atr = ta.atr(200) cmean_range = ta.cum(high - low) / n //HL Output function hl() => [high, low] //Get ohlc values function get_ohlc()=> [close[1], open[1], high, low, high[2], low[2]] //Display Structure function display_Structure(x, y, txt, css, dashed, down, lbl_size)=> structure_line = line.new(x, y, n, y , color = css , style = dashed ? line.style_dashed : line.style_solid) structure_lbl = label.new(int(math.avg(x, n)), y, txt , color = TRANSP_CSS , textcolor = css , style = down ? label.style_label_down : label.style_label_up , size = lbl_size) if mode == 'Present' line.delete(structure_line[1]) label.delete(structure_lbl[1]) //Swings detection/measurements swings(len)=> var os = 0 upper = ta.highest(len) lower = ta.lowest(len) os := high[len] > upper ? 0 : low[len] < lower ? 1 : os[1] top = os == 0 and os[1] != 0 ? high[len] : 0 btm = os == 1 and os[1] != 1 ? low[len] : 0 [top, btm] //Order block coordinates function ob_coord(use_max, loc, target_top, target_btm, target_left, target_type)=> min = 99999999. max = 0. idx = 1 ob_threshold = ob_filter == 'Atr' ? atr : cmean_range //Search for highest/lowest high within the structure interval and get range if use_max for i = 1 to (n - loc)-1 if (high[i] - low[i]) < ob_threshold[i] * 2 max := math.max(high[i], max) min := max == high[i] ? low[i] : min idx := max == high[i] ? i : idx else for i = 1 to (n - loc)-1 if (high[i] - low[i]) < ob_threshold[i] * 2 min := math.min(low[i], min) max := min == low[i] ? high[i] : max idx := min == low[i] ? i : idx array.unshift(target_top, max) array.unshift(target_btm, min) array.unshift(target_left, time[idx]) array.unshift(target_type, use_max ? -1 : 1) //Set order blocks display_ob(boxes, target_top, target_btm, target_left, target_type, show_last, swing, size)=> for i = 0 to math.min(show_last-1, size-1) get_box = array.get(boxes, i) box.set_lefttop(get_box, array.get(target_left, i), array.get(target_top, i)) box.set_rightbottom(get_box, array.get(target_left, i), array.get(target_btm, i)) box.set_extend(get_box, extend.right) color css = na if swing if style == 'Monochrome' css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80) border_css = array.get(target_type, i) == 1 ? #b2b5be : #5d606b box.set_border_color(get_box, border_css) else css := array.get(target_type, i) == 1 ? bull_ob_css : bear_ob_css box.set_border_color(get_box, css) box.set_bgcolor(get_box, css) else if style == 'Monochrome' css := array.get(target_type, i) == 1 ? color.new(#b2b5be, 80) : color.new(#5d606b, 80) else css := array.get(target_type, i) == 1 ? ibull_ob_css : ibear_ob_css box.set_border_color(get_box, css) box.set_bgcolor(get_box, css) //Line Style function get_line_style(style) => out = switch style '⎯⎯⎯' => line.style_solid '----' => line.style_dashed '····' => line.style_dotted //Set line/labels function for previous high/lows phl(h, l, tf, css)=> var line high_line = line.new(na,na,na,na , xloc = xloc.bar_time , color = css , style = get_line_style(pdhl_style)) var label high_lbl = label.new(na,na , xloc = xloc.bar_time , text = str.format('P{0}H', tf) , color = TRANSP_CSS , textcolor = css , size = size.small , style = label.style_label_left) var line low_line = line.new(na,na,na,na , xloc = xloc.bar_time , color = css , style = get_line_style(pdhl_style)) var label low_lbl = label.new(na,na , xloc = xloc.bar_time , text = str.format('P{0}L', tf) , color = TRANSP_CSS , textcolor = css , size = size.small , style = label.style_label_left) hy = ta.valuewhen(h != h[1], h, 1) hx = ta.valuewhen(h == high, time, 1) ly = ta.valuewhen(l != l[1], l, 1) lx = ta.valuewhen(l == low, time, 1) if barstate.islast ext = time + (time - time[1])*20 //High line.set_xy1(high_line, hx, hy) line.set_xy2(high_line, ext, hy) label.set_xy(high_lbl, ext, hy) //Low line.set_xy1(low_line, lx, ly) line.set_xy2(low_line, ext, ly) label.set_xy(low_lbl, ext, ly) //-----------------------------------------------------------------------------} //Global variables //-----------------------------------------------------------------------------{ var trend = 0, var itrend = 0 var top_y = 0., var top_x = 0 var btm_y = 0., var btm_x = 0 var itop_y = 0., var itop_x = 0 var ibtm_y = 0., var ibtm_x = 0 var trail_up = high, var trail_dn = low var trail_up_x = 0, var trail_dn_x = 0 var top_cross = true, var btm_cross = true var itop_cross = true, var ibtm_cross = true var txt_top = '', var txt_btm = '' //Alerts bull_choch_alert = false bull_bos_alert = false bear_choch_alert = false bear_bos_alert = false bull_ichoch_alert = false bull_ibos_alert = false bear_ichoch_alert = false bear_ibos_alert = false bull_iob_break = false bear_iob_break = false bull_ob_break = false bear_ob_break = false eqh_alert = false eql_alert = false //Structure colors var bull_css = style == 'Monochrome' ? #b2b5be : swing_bull_css var bear_css = style == 'Monochrome' ? #b2b5be : swing_bear_css var ibull_css = style == 'Monochrome' ? #b2b5be : swing_ibull_css var ibear_css = style == 'Monochrome' ? #b2b5be : swing_ibear_css //Labels size var internal_structure_lbl_size = internal_structure_size == 'Tiny' ? size.tiny : internal_structure_size == 'Small' ? size.small : size.normal var swing_structure_lbl_size = swing_structure_size == 'Tiny' ? size.tiny : swing_structure_size == 'Small' ? size.small : size.normal var eqhl_lbl_size = eq_size == 'Tiny' ? size.tiny : eq_size == 'Small' ? size.small : size.normal //Swings [top, btm] = swings(length) [itop, ibtm] = swings(5) //-----------------------------------------------------------------------------} //Pivot High //-----------------------------------------------------------------------------{ var line extend_top = na var label extend_top_lbl = label.new(na, na , color = TRANSP_CSS , textcolor = bear_css , style = label.style_label_down , size = size.tiny) if top top_cross := true txt_top := top > top_y ? 'HH' : 'LH' if show_swings top_lbl = label.new(n-length, top, txt_top , color = TRANSP_CSS , textcolor = bear_css , style = label.style_label_down , size = swing_structure_lbl_size) if mode == 'Present' label.delete(top_lbl[1]) //Extend recent top to last bar line.delete(extend_top[1]) extend_top := line.new(n-length, top, n, top , color = bear_css) top_y := top top_x := n - length trail_up := top trail_up_x := n - length if itop itop_cross := true itop_y := itop itop_x := n - 5 //Trailing maximum trail_up := math.max(high, trail_up) trail_up_x := trail_up == high ? n : trail_up_x //Set top extension label/line if barstate.islast and show_hl_swings line.set_xy1(extend_top, trail_up_x, trail_up) line.set_xy2(extend_top, n + 20, trail_up) label.set_x(extend_top_lbl, n + 20) label.set_y(extend_top_lbl, trail_up) label.set_text(extend_top_lbl, trend < 0 ? 'Strong High' : 'Weak High') //-----------------------------------------------------------------------------} //Pivot Low //-----------------------------------------------------------------------------{ var line extend_btm = na var label extend_btm_lbl = label.new(na, na , color = TRANSP_CSS , textcolor = bull_css , style = label.style_label_up , size = size.tiny) if btm btm_cross := true txt_btm := btm < btm_y ? 'LL' : 'HL' if show_swings btm_lbl = label.new(n - length, btm, txt_btm , color = TRANSP_CSS , textcolor = bull_css , style = label.style_label_up , size = swing_structure_lbl_size) if mode == 'Present' label.delete(btm_lbl[1]) //Extend recent btm to last bar line.delete(extend_btm[1]) extend_btm := line.new(n - length, btm, n, btm , color = bull_css) btm_y := btm btm_x := n-length trail_dn := btm trail_dn_x := n-length if ibtm ibtm_cross := true ibtm_y := ibtm ibtm_x := n - 5 //Trailing minimum trail_dn := math.min(low, trail_dn) trail_dn_x := trail_dn == low ? n : trail_dn_x //Set btm extension label/line if barstate.islast and show_hl_swings line.set_xy1(extend_btm, trail_dn_x, trail_dn) line.set_xy2(extend_btm, n + 20, trail_dn) label.set_x(extend_btm_lbl, n + 20) label.set_y(extend_btm_lbl, trail_dn) label.set_text(extend_btm_lbl, trend > 0 ? 'Strong Low' : 'Weak Low') //-----------------------------------------------------------------------------} //Order Blocks Arrays //-----------------------------------------------------------------------------{ var iob_top = array.new_float(0) var iob_btm = array.new_float(0) var iob_left = array.new_int(0) var iob_type = array.new_int(0) var ob_top = array.new_float(0) var ob_btm = array.new_float(0) var ob_left = array.new_int(0) var ob_type = array.new_int(0) //-----------------------------------------------------------------------------} //Pivot High BOS/CHoCH //-----------------------------------------------------------------------------{ //Filtering var bull_concordant = true if ifilter_confluence bull_concordant := high - math.max(close, open) > math.min(close, open - low) //Detect internal bullish Structure if ta.crossover(close, itop_y) and itop_cross and top_y != itop_y and bull_concordant bool choch = na if itrend < 0 choch := true bull_ichoch_alert := true else bull_ibos_alert := true txt = choch ? 'CHoCH' : 'BOS' if show_internals if show_ibull == 'All' or (show_ibull == 'BOS' and not choch) or (show_ibull == 'CHoCH' and choch) display_Structure(itop_x, itop_y, txt, ibull_css, true, true, internal_structure_lbl_size) itop_cross := false itrend := 1 //Internal Order Block if show_iob ob_coord(false, itop_x, iob_top, iob_btm, iob_left, iob_type) //Detect bullish Structure if ta.crossover(close, top_y) and top_cross bool choch = na if trend < 0 choch := true bull_choch_alert := true else bull_bos_alert := true txt = choch ? 'CHoCH' : 'BOS' if show_Structure if show_bull == 'All' or (show_bull == 'BOS' and not choch) or (show_bull == 'CHoCH' and choch) display_Structure(top_x, top_y, txt, bull_css, false, true, swing_structure_lbl_size) //Order Block if show_ob ob_coord(false, top_x, ob_top, ob_btm, ob_left, ob_type) top_cross := false trend := 1 //-----------------------------------------------------------------------------} //Pivot Low BOS/CHoCH //-----------------------------------------------------------------------------{ var bear_concordant = true if ifilter_confluence bear_concordant := high - math.max(close, open) < math.min(close, open - low) //Detect internal bearish Structure if ta.crossunder(close, ibtm_y) and ibtm_cross and btm_y != ibtm_y and bear_concordant bool choch = false if itrend > 0 choch := true bear_ichoch_alert := true else bear_ibos_alert := true txt = choch ? 'CHoCH' : 'BOS' if show_internals if show_ibear == 'All' or (show_ibear == 'BOS' and not choch) or (show_ibear == 'CHoCH' and choch) display_Structure(ibtm_x, ibtm_y, txt, ibear_css, true, false, internal_structure_lbl_size) ibtm_cross := false itrend := -1 //Internal Order Block if show_iob ob_coord(true, ibtm_x, iob_top, iob_btm, iob_left, iob_type) //Detect bearish Structure if ta.crossunder(close, btm_y) and btm_cross bool choch = na if trend > 0 choch := true bear_choch_alert := true else bear_bos_alert := true txt = choch ? 'CHoCH' : 'BOS' if show_Structure if show_bear == 'All' or (show_bear == 'BOS' and not choch) or (show_bear == 'CHoCH' and choch) display_Structure(btm_x, btm_y, txt, bear_css, false, false, swing_structure_lbl_size) //Order Block if show_ob ob_coord(true, btm_x, ob_top, ob_btm, ob_left, ob_type) btm_cross := false trend := -1 //-----------------------------------------------------------------------------} //Order Blocks //-----------------------------------------------------------------------------{ //Set order blocks var iob_boxes = array.new_box(0) var ob_boxes = array.new_box(0) //Delete internal order blocks box coordinates if top/bottom is broken for element in iob_type index = array.indexof(iob_type, element) if close < array.get(iob_btm, index) and element == 1 array.remove(iob_top, index) array.remove(iob_btm, index) array.remove(iob_left, index) array.remove(iob_type, index) bull_iob_break := true else if close > array.get(iob_top, index) and element == -1 array.remove(iob_top, index) array.remove(iob_btm, index) array.remove(iob_left, index) array.remove(iob_type, index) bear_iob_break := true //Delete internal order blocks box coordinates if top/bottom is broken for element in ob_type index = array.indexof(ob_type, element) if close < array.get(ob_btm, index) and element == 1 array.remove(ob_top, index) array.remove(ob_btm, index) array.remove(ob_left, index) array.remove(ob_type, index) bull_ob_break := true else if close > array.get(ob_top, index) and element == -1 array.remove(ob_top, index) array.remove(ob_btm, index) array.remove(ob_left, index) array.remove(ob_type, index) bear_ob_break := true iob_size = array.size(iob_type) ob_size = array.size(ob_type) if barstate.isfirst if show_iob for i = 0 to iob_showlast-1 array.push(iob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time)) if show_ob for i = 0 to ob_showlast-1 array.push(ob_boxes, box.new(na,na,na,na, xloc = xloc.bar_time)) if iob_size > 0 if barstate.islast display_ob(iob_boxes, iob_top, iob_btm, iob_left, iob_type, iob_showlast, false, iob_size) if ob_size > 0 if barstate.islast display_ob(ob_boxes, ob_top, ob_btm, ob_left, ob_type, ob_showlast, true, ob_size) //-----------------------------------------------------------------------------} //EQH/EQL //-----------------------------------------------------------------------------{ var eq_prev_top = 0. var eq_top_x = 0 var eq_prev_btm = 0. var eq_btm_x = 0 if show_eq eq_top = ta.pivothigh(eq_len, eq_len) eq_btm = ta.pivotlow(eq_len, eq_len) if eq_top max = math.max(eq_top, eq_prev_top) min = math.min(eq_top, eq_prev_top) if max < min + atr * eq_threshold eqh_line = line.new(eq_top_x, eq_prev_top, n-eq_len, eq_top , color = bear_css , style = line.style_dotted) eqh_lbl = label.new(int(math.avg(n-eq_len, eq_top_x)), eq_top, 'EQH' , color = #00000000 , textcolor = bear_css , style = label.style_label_down , size = eqhl_lbl_size) if mode == 'Present' line.delete(eqh_line[1]) label.delete(eqh_lbl[1]) eqh_alert := true eq_prev_top := eq_top eq_top_x := n-eq_len if eq_btm max = math.max(eq_btm, eq_prev_btm) min = math.min(eq_btm, eq_prev_btm) if min > max - atr * eq_threshold eql_line = line.new(eq_btm_x, eq_prev_btm, n-eq_len, eq_btm , color = bull_css , style = line.style_dotted) eql_lbl = label.new(int(math.avg(n-eq_len, eq_btm_x)), eq_btm, 'EQL' , color = #00000000 , textcolor = bull_css , style = label.style_label_up , size = eqhl_lbl_size) eql_alert := true if mode == 'Present' line.delete(eql_line[1]) label.delete(eql_lbl[1]) eq_prev_btm := eq_btm eq_btm_x := n-eq_len //-----------------------------------------------------------------------------} //Fair Value Gaps //-----------------------------------------------------------------------------{ var bullish_fvg_max = array.new_box(0) var bullish_fvg_min = array.new_box(0) var bearish_fvg_max = array.new_box(0) var bearish_fvg_min = array.new_box(0) float bullish_fvg_avg = na float bearish_fvg_avg = na bullish_fvg_cnd = false bearish_fvg_cnd = false [src_c1, src_o1, src_h, src_l, src_h2, src_l2] = request.security(syminfo.tickerid, fvg_tf, get_ohlc()) if show_fvg delta_per = (src_c1 - src_o1) / src_o1 * 100 change_tf = timeframe.change(fvg_tf) threshold = fvg_auto ? ta.cum(math.abs(change_tf ? delta_per : 0)) / n * 2 : 0 //FVG conditions bullish_fvg_cnd := src_l > src_h2 and src_c1 > src_h2 and delta_per > threshold and change_tf bearish_fvg_cnd := src_h < src_l2 and src_c1 < src_l2 and -delta_per > threshold and change_tf //FVG Areas if bullish_fvg_cnd array.unshift(bullish_fvg_max, box.new(n-1, src_l, n + fvg_extend, math.avg(src_l, src_h2) , border_color = bull_fvg_css , bgcolor = bull_fvg_css)) array.unshift(bullish_fvg_min, box.new(n-1, math.avg(src_l, src_h2), n + fvg_extend, src_h2 , border_color = bull_fvg_css , bgcolor = bull_fvg_css)) if bearish_fvg_cnd array.unshift(bearish_fvg_max, box.new(n-1, src_h, n + fvg_extend, math.avg(src_h, src_l2) , border_color = bear_fvg_css , bgcolor = bear_fvg_css)) array.unshift(bearish_fvg_min, box.new(n-1, math.avg(src_h, src_l2), n + fvg_extend, src_l2 , border_color = bear_fvg_css , bgcolor = bear_fvg_css)) for bx in bullish_fvg_min if low < box.get_bottom(bx) box.delete(bx) box.delete(array.get(bullish_fvg_max, array.indexof(bullish_fvg_min, bx))) for bx in bearish_fvg_max if high > box.get_top(bx) box.delete(bx) box.delete(array.get(bearish_fvg_min, array.indexof(bearish_fvg_max, bx))) //-----------------------------------------------------------------------------} //Previous day/week high/lows //-----------------------------------------------------------------------------{ //Daily high/low [pdh, pdl] = request.security(syminfo.tickerid, 'D', hl() , lookahead = barmerge.lookahead_on) //Weekly high/low [pwh, pwl] = request.security(syminfo.tickerid, 'W', hl() , lookahead = barmerge.lookahead_on) //Monthly high/low [pmh, pml] = request.security(syminfo.tickerid, 'M', hl() , lookahead = barmerge.lookahead_on) //Display Daily if show_pdhl phl(pdh, pdl, 'D', pdhl_css) //Display Weekly if show_pwhl phl(pwh, pwl, 'W', pwhl_css) //Display Monthly if show_pmhl phl(pmh, pml, 'M', pmhl_css) //-----------------------------------------------------------------------------} //Premium/Discount/Equilibrium zones //-----------------------------------------------------------------------------{ var premium = box.new(na, na, na, na , bgcolor = color.new(premium_css, 80) , border_color = na) var premium_lbl = label.new(na, na , text = 'Premium' , color = TRANSP_CSS , textcolor = premium_css , style = label.style_label_down , size = size.small) var eq = box.new(na, na, na, na , bgcolor = color.rgb(120, 123, 134, 80) , border_color = na) var eq_lbl = label.new(na, na , text = 'Equilibrium' , color = TRANSP_CSS , textcolor = eq_css , style = label.style_label_left , size = size.small) var discount = box.new(na, na, na, na , bgcolor = color.new(discount_css, 80) , border_color = na) var discount_lbl = label.new(na, na , text = 'Discount' , color = TRANSP_CSS , textcolor = discount_css , style = label.style_label_up , size = size.small) //Show Premium/Discount Areas if barstate.islast and show_sd avg = math.avg(trail_up, trail_dn) box.set_lefttop(premium, math.max(top_x, btm_x), trail_up) box.set_rightbottom(premium, n, .95 * trail_up + .05 * trail_dn) label.set_xy(premium_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_up) box.set_lefttop(eq, math.max(top_x, btm_x), .525 * trail_up + .475*trail_dn) box.set_rightbottom(eq, n, .525 * trail_dn + .475 * trail_up) label.set_xy(eq_lbl, n, avg) box.set_lefttop(discount, math.max(top_x, btm_x), .95 * trail_dn + .05 * trail_up) box.set_rightbottom(discount, n, trail_dn) label.set_xy(discount_lbl, int(math.avg(math.max(top_x, btm_x), n)), trail_dn) //-----------------------------------------------------------------------------} //Trend //-----------------------------------------------------------------------------{ var color trend_css = na if show_trend if style == 'Colored' trend_css := itrend == 1 ? bull_css : bear_css else if style == 'Monochrome' trend_css := itrend == 1 ? #b2b5be : #5d606b plotcandle(open, high, low, close , color = trend_css , wickcolor = trend_css , bordercolor = trend_css , editable = false) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ //Internal Structure alertcondition(bull_ibos_alert, 'Internal Bullish BOS', 'Internal Bullish BOS formed') alertcondition(bull_ichoch_alert, 'Internal Bullish CHoCH', 'Internal Bullish CHoCH formed') alertcondition(bear_ibos_alert, 'Internal Bearish BOS', 'Internal Bearish BOS formed') alertcondition(bear_ichoch_alert, 'Internal Bearish CHoCH', 'Internal Bearish CHoCH formed') //Swing Structure alertcondition(bull_bos_alert, 'Bullish BOS', 'Internal Bullish BOS formed') alertcondition(bull_choch_alert, 'Bullish CHoCH', 'Internal Bullish CHoCH formed') alertcondition(bear_bos_alert, 'Bearish BOS', 'Bearish BOS formed') alertcondition(bear_choch_alert, 'Bearish CHoCH', 'Bearish CHoCH formed') //order Blocks alertcondition(bull_iob_break, 'Bullish Internal OB Breakout', 'Price broke bullish internal OB') alertcondition(bear_iob_break, 'Bearish Internal OB Breakout', 'Price broke bearish internal OB') alertcondition(bull_ob_break, 'Bullish Swing OB Breakout', 'Price broke bullish swing OB') alertcondition(bear_ob_break, 'Bearish Swing OB Breakout', 'Price broke bearish swing OB') //EQH/EQL alertcondition(eqh_alert, 'Equal Highs', 'Equal highs detected') alertcondition(eql_alert, 'Equal Lows', 'Equal lows detected') //FVG alertcondition(bullish_fvg_cnd, 'Bullish FVG', 'Bullish FVG formed') alertcondition(bearish_fvg_cnd, 'Bearish FVG', 'Bearish FVG formed') //-----------------------------------------------------------------------------}
Growth Stock Arbitrage Indicator [@PierceARK]
https://www.tradingview.com/script/ubbiffe2-Growth-Stock-Arbitrage-Indicator-PierceARK/
jamiesonpa
https://www.tradingview.com/u/jamiesonpa/
12
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // This indicator takes advantage of the fact that when the 10 and 5 year Treasury Constant Maturity Minus Federal Funds rates (T10YFF/T5YFF) // go down sharply, investors tend to rotate into stocks. This arbitrage works great for growth stocks, since growth stocks are higher beta by // virtue of their lower market cap and more speculative nature in general. This script identifies the moving-average convergence/divergence of the // average of the 10y and 5y treasury rates and then finds the variance of that macd line. By averaging that variance with the macdline's inverse, // an analog output of treasury -> stock rotation can be identified. The upper and lower thresholds bring buy and sell windows into focus. // © jamiesonpa //@version=5 indicator("Investment Time") t10yff = input.symbol("FRED:T10YFF", "Symbol") t10yff_security = request.security(t10yff, 'D', close) t5yff = input.symbol("FRED:T5YFF", "Symbol") t5yff_security = request.security(t5yff, 'D', close) t10yff_security := (t10yff_security + t5yff_security)/2 [t10yff_security_macdLine, t10yff_security_signalLine, t10yff_security_histLine] = ta.macd(close, 3, 12, 120) indicator_falling = ta.falling(t10yff_security_macdLine, 3) tymacdvariance = ta.sma(ta.variance(t10yff_security_macdLine,5),3) slope = t10yff_security_macdLine - t10yff_security_macdLine[1] buy_signal_line = (-t10yff_security_macdLine + tymacdvariance)/2 xMax = ta.highest(buy_signal_line,500) xMin = ta.lowest(buy_signal_line, 500) line_range = xMax - xMin buy_signal_line := 100 * buy_signal_line / line_range bsl_top_threshold = ta.variance(buy_signal_line, 20) bsl_top_threshold := (ta.sma(bsl_top_threshold, 10)/30)+10 bsl_bottom_threshold = ta.variance(buy_signal_line, 20) bsl_bottom_threshold := (ta.sma(bsl_bottom_threshold, 10)/30)-10 //plot(tymacdvariance) //plot(-t10yff_security_macdLine, color=color.red) plot(buy_signal_line, color=color.white) plot(bsl_top_threshold, color=color.red) plot(bsl_bottom_threshold, color=color.green) //plot(percent_change_10ymacdline, color= color.green) //plotshape(buysignal, location = location.abovebar, color= color.green, style = shape.cross, size = size.small)
TTM Wave ABC By GanymedeNil
https://www.tradingview.com/script/iwpHSy5A/
ganymedenil
https://www.tradingview.com/u/ganymedenil/
23
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ganymedenil //@version=5 indicator("TTM Wave ABC By GanymedeNil") showA = input.bool(true,"Show TTM Wave A") showB = input.bool(false,"Show TTM Wave B") showC = input.bool(false,"Show TTM Wave C") // A float ttmwas = na float ttmwaf = na if showA [_,_,ASlowHist] = ta.macd(close,8,55,55) ttmwas := ASlowHist [_,_,AFastHist] = ta.macd(close,8,34,34) ttmwaf := AFastHist plot(ttmwas,style=plot.style_histogram,title="TTM wave A Slow",color=#296a22,linewidth=3) plot(ttmwaf,style=plot.style_histogram,title="TTM wave A Fast",color=#f3701c,linewidth=3) // B float ttmwbs = na float ttmwbf = na if showB [_,_,BSlowHist] = ta.macd(close,8,144,144) ttmwbs := BSlowHist [_,_,BFastHist] = ta.macd(close,8,89,89) ttmwbf := BFastHist plot(ttmwbs,style=plot.style_histogram,title="TTM wave B Slow",color=#296a22,linewidth=3) plot(ttmwbf,style=plot.style_histogram,title="TTM wave B Fast",color=#f3701c,linewidth=3) // C float ttmwcmacd = na float ttmwcf = na if showC [Cmacd,_,CSlowHist] = ta.macd(close,8,377,377) ttmwcmacd := Cmacd [_,_,CFastHist] = ta.macd(close,8,233,233) ttmwcf := CFastHist plot(ttmwcmacd,style=plot.style_histogram,title="TTM wave C Macd",color=#296a22,linewidth=3) plot(ttmwcf,style=plot.style_histogram,title="TTM wave C Fast",color=#f3701c,linewidth=3)
Trend Friendly RSI
https://www.tradingview.com/script/vj1NZFkE/
faytterro
https://www.tradingview.com/u/faytterro/
283
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © faytterro //@version=5 indicator("Trend Friendly RSI", timeframe="", timeframe_gaps=true) src=input(hlc3,title="source") len=input.int(25,title="lenght", maxval=500) cr(x, y) => z = 0.0 weight = 0.0 for i = 0 to y-1 z:=z + x[i]*((y-1)/2+1-math.abs(i-(y-1)/2)) z/(((y+1)/2)*(y+1)/2) cr= cr(src,2*len-1) width=input.int(3, title="linewidth", minval=1) dizi = array.new_float(500) var line=array.new_line() //if barstate.islast for i=0 to len*2 array.set(dizi,i,(i*(i-1)*(cr-2*cr[1]+cr[2])/2+i*(cr[1]-cr[2])+cr[2])) x=close-array.get(dizi,len) y=x>0? math.sqrt(100*x/ta.highest(x,200)) : -math.sqrt(100*x/ta.lowest(x,200)) y:=y*.5+nz(y[1])*.5 plot(5*y+50, color=cr>cr[1]? #00fc08 : #fc0303, linewidth=2) hline(50) top=hline(70) bot=hline(30) fill(top,bot, color=color.blue, transp=90) buy=ta.crossover(ta.change(5*y+50),0) and 5*y+50<30 and cr>cr[1] sell=ta.crossunder(ta.change(5*y+50),0) and 5*y+50>70 and cr<cr[1] alertcondition(buy or sell) bgcolor(color= buy? #00fc08 : sell? #fc0303 : na, transp=50) barcolor(color= buy? #00fc08 : sell? #fc0303 : na)
High & Low Of Custom Session
https://www.tradingview.com/script/epHKLqAs-High-Low-Of-Custom-Session/
goofoffgoose
https://www.tradingview.com/u/goofoffgoose/
139
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © goofoffgoose // This script boxes a custom session and sets the box at the high and low of the session and draws that box to the next session. // Box color is determined by price in relation to the box position. Box color is set at the start of the next session. This allows // user to lookback at multiple box sets to see how each day closed in relation to the session highlighed. // Table is for debuging //@version=5 indicator('High & Low Of Custom Session', shorttitle='High/Low ', overlay=true, max_boxes_count=500) // Inputs tf = input.timeframe("5", "Open Range Timeframe", tooltip="Set this to the timeframe you are viewing") hilo_session = input.session('0831-0930', title='Custom Session') show_open_box = input.bool (title="Show Open Range Box?", defval=true , group="Session") // show open range box hiColor = input.color(color.rgb(0,220,255,85) , title="Close Hi Color" , group="Session", inline="Open Box color") loColor = input.color(color.rgb(200,100,255,85) , title="Close Lo Color" , group="Session", inline="Open Box color" ) sessionBoxColor = input.color(color.rgb(70,70,70,50), title="Extended Range Color", group="Session", inline="Open Box color") hiloBoxColor = input.color(color.rgb(70,70,70,50), title="Open Range Color", group="Session", inline="Open Box color") show_bg = input.bool (title="Show background", defval=true, group="Background", inline="bg") bgcolor = input.color(color.rgb(70,70,70,80), title="Background Color", group="Background", inline='bg') //Create box boxBorderSize = input.int(0, title="Box border size", minval=0) // Variables currentValue = request.security(syminfo.tickerid,"1" , close) var dayHighPrice = 0.0 var dayLowPrice = 0.0 var prevDayClose = 0.0 var box sessionBox = na var box hiloBox = na // See if a new calendar day started on the intra-day time frame newDayStart = dayofmonth != dayofmonth[1] and timeframe.isintraday /////Sessions inSession(session, sessionTimeZone=syminfo.timezone) => na(time(tf, session + ":1234567")) == false //Functions IsSessionStart(sessionTime, sessionTimeZone=syminfo.timezone) => inSess = not na(time(timeframe.period, sessionTime, sessionTimeZone)) inSess and not inSess[1] IsLastBarSession(sessionTime, sessionTimeZone=syminfo.timezone) => var int lastBarHour = na var int lastBarMinute = na var int lastBarSecond = na inSess = not na(time(timeframe.period, sessionTime, sessionTimeZone)) if not inSess and inSess[1] lastBarHour := hour[1] lastBarMinute := minute[1] lastBarSecond := second[1] hour == lastBarHour and minute == lastBarMinute and second == lastBarSecond SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var float sessionHighPrice = na if insideSession and not insideSession[1] sessionHighPrice := high else if insideSession sessionHighPrice := math.max(sessionHighPrice, high) sessionHighPrice SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var float sessionLowPrice = na if insideSession and not insideSession[1] sessionLowPrice := low else if insideSession sessionLowPrice := math.min(sessionLowPrice, low) sessionLowPrice // Hi/low varibles var float s_low = 0.0 var float s_high = 0.0 // In Session High/Low Calculations var float hilo_low = close var float hilo_high = close var box HiLoBox = na // If a new day starts, set the high and low to that bar's data. Else // during the day track the highest high and lowest low. if IsSessionStart(hilo_session) dayHighPrice := high dayLowPrice := low prevDayClose := close[1] else dayHighPrice := math.max(dayHighPrice, high) dayLowPrice := math.min(dayLowPrice, low) // When a new day start, create a new box for that day. // Else, during the day, update that day's box color if IsSessionStart(hilo_session) sessionBox := box.new(left=bar_index, top=dayHighPrice, right=bar_index + 1, bottom=dayLowPrice, border_width=boxBorderSize,border_color=sessionBoxColor, bgcolor=sessionBoxColor)//, extend=extend.right) HiLoBox := box.new(left=bar_index, top=dayHighPrice, right=bar_index +1, bottom=dayLowPrice, border_width=boxBorderSize, border_color=sessionBoxColor, bgcolor=hiloBoxColor) var color boxColor = color(color.rgb(0,70,0,50)) isFirstBarOfSession = IsSessionStart(hilo_session) isSessionLast = IsLastBarSession(hilo_session) // Plot High/Low box if isFirstBarOfSession and show_open_box box.set_left(id=sessionBox, left=bar_index - 1) box.set_left(id=HiLoBox, left=bar_index - 1) else na if isSessionLast and show_open_box s_low := dayLowPrice s_high := dayHighPrice box.set_right(id=sessionBox, right=bar_index) box.set_top(id=sessionBox, top=dayHighPrice) box.set_bottom(id=sessionBox, bottom=dayLowPrice) box.set_right(id =HiLoBox, right=bar_index) box.set_top(id =HiLoBox, top=dayHighPrice) box.set_bottom(id=HiLoBox, bottom=dayLowPrice) else box.set_right(id=sessionBox, right=bar_index ) boxColor := (currentValue < (s_low)) ? (loColor) : (currentValue > (s_high)) ? (hiColor) : (hiloBoxColor) box.set_bgcolor(sessionBox, color=(boxColor)) box.set_bgcolor(HiLoBox, color=(hiloBoxColor)) int(na) // Bg session color bgcolor(inSession(hilo_session) and show_bg ? color(bgcolor) : na) //Debug table var table myTable = table.new(position.top_right, 20, 20) a = "high" b = s_high c = "low" d = s_low e = "current" f = currentValue if barstate.isconfirmed // defines the table table.cell(myTable, 6,2, str.tostring(a), text_color = color.teal) table.cell(myTable, 6,3, str.tostring(b), text_color = color.teal) table.cell(myTable, 7,2, str.tostring(c), text_color = color.purple) table.cell(myTable, 7,3, str.tostring(d), text_color = color.purple) table.cell(myTable, 8,2, str.tostring(e), text_color = color.lime) table.cell(myTable, 8,3, str.tostring(f), text_color = color.lime)
SubCandle
https://www.tradingview.com/script/ekTYTNDN-SubCandle/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
312
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("SubCandle", overlay=true) numberOfBacktestBars = input.int(5000, 'Backtest Bars', maxval=20000, step=1000) import PineCoders/Time/3 as t var ltf = int(timeframe.in_seconds(timeframe.period) / (100000/numberOfBacktestBars)) var strLtf = t.secondsToTfString(ltf) [lo, lh, ll, lc] = request.security_lower_tf(syminfo.tickerid, strLtf, [open, high, low, close], true) low_indices_sorted = array.sort_indices(ll, order.ascending) high_indices_sorted = array.sort_indices(lh, order.descending) ll_index = array.size(lh)>0? array.get(low_indices_sorted, 0) : 0 hh_index = array.size(ll)>0? array.get(high_indices_sorted, 0) : 0 high_after_low = array.size(lh)>0? array.max(array.slice(lh, ll_index>=array.size(ll)-1? ll_index : ll_index+1, array.size(lh))) : na low_after_high = array.size(ll)>0? array.min(array.slice(ll, hh_index>=array.size(lh)-1? hh_index : hh_index+1, array.size(ll))) : na newOpen = high_after_low == high? high_after_low: low_after_high newHigh = math.min(high_after_low, high) newLow = math.max(low_after_high, low) newClose = close nColor=newOpen>newClose?color.red : color.green plotcandle(newOpen, newHigh, newLow, newClose, title='SubCandle', color=color.new(nColor, 80), bordercolor = nColor, wickcolor=nColor)
Daily/Weekly Extremes
https://www.tradingview.com/script/K87BmrjK-Daily-Weekly-Extremes/
Zeal_Trading
https://www.tradingview.com/u/Zeal_Trading/
22
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Zeal_Trading // ////////// DAILY/WEEKLY EXTREMES ////////// // // This indicator calculates the daily and weekly +-1 standard deviation of the S&P 500 based on 2 methodologies: // 1. VIX - Using the market's expectation of forward volatility, one can calculate the daily expectation by dividing the VIX by the square root of 252 (the number of trading days in a year). // Similarly, dividing by the square root of 50 will give you the weekly expected range based on the VIX. // 2. ATR - We also provided expected weekly and daily ranges based on 5 day/week ATR. // /////////////////////////////////////////// //@version=5 indicator("Daily/Weekly Extremes", overlay=true) rangeType = input.string(title="Range Type", defval="ATR", options=["VIX","ATR"]) vix_daily = request.security('VIX','D',close[1], lookahead=barmerge.lookahead_on) vix_weekly = request.security('VIX','W',close[1], lookahead=barmerge.lookahead_on) es_daily_open = syminfo.ticker == 'SPX' ? request.security('SPX','D', open, lookahead=barmerge.lookahead_on) : request.security('ES1!','D', open, lookahead=barmerge.lookahead_on) es_weekly_open = syminfo.ticker == 'SPX' ? request.security('SPX','W', open, lookahead=barmerge.lookahead_on) : request.security('ES1!','W', open, lookahead=barmerge.lookahead_on) daily_atr_5 = syminfo.ticker == 'SPX' ? request.security('SPX','D',ta.atr(5)) : request.security('ES1!','D',ta.atr(5)) weekly_atr_5 = syminfo.ticker == 'SPX' ? request.security('SPX','W',ta.atr(5)) : request.security('ES1!','W',ta.atr(5)) top_daily_range = float(na) bottom_daily_range = float(na) top_weekly_range = float(na) bottom_weekly_range = float(na) if rangeType == "VIX" daily_range = ((vix_daily/math.sqrt(252)))/100*es_daily_open weekly_range = ((vix_weekly/math.sqrt(50)))/100*es_weekly_open top_daily_range := es_daily_open + daily_range bottom_daily_range := es_daily_open - daily_range top_weekly_range := es_weekly_open + weekly_range bottom_weekly_range := es_weekly_open - weekly_range else top_daily_range := es_daily_open + daily_atr_5/2 bottom_daily_range := es_daily_open - daily_atr_5/2 top_weekly_range := es_weekly_open + weekly_atr_5/2 bottom_weekly_range := es_weekly_open - weekly_atr_5/2 plot(syminfo.ticker == 'ES1!' or syminfo.ticker == 'SPX' ? top_daily_range : na, color=color.orange, title = "Daily High") plot(syminfo.ticker == 'ES1!' or syminfo.ticker == 'SPX' ? bottom_daily_range : na, color=color.orange, title = "Daily Low") plot(syminfo.ticker == 'ES1!' or syminfo.ticker == 'SPX' ? top_weekly_range : na, color=color.fuchsia, title = "Weekly High") plot(syminfo.ticker == 'ES1!' or syminfo.ticker == 'SPX' ? bottom_weekly_range : na, color=color.fuchsia, title = "Weekly Low")
Quick Levels
https://www.tradingview.com/script/R8RomlwK-Quick-Levels/
SamRecio
https://www.tradingview.com/u/SamRecio/
106
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("Quick Levels", overlay = true, max_lines_count = 500, max_labels_count = 500) //Color & Style Functions/////////////////////////////////////////////////////// colorpicker(_input) => _input == "RED"?color.red: _input == "ORANGE"?color.orange: _input == "YELLOW"?color.yellow: _input == "GREEN"?color.green: _input == "BLUE"?color.blue: _input == "PURPLE"?color.fuchsia: _input == "WHITE"?color.white: _input == "BLACK"?color.rgb(0,0,0): _input == "GRAY"?color.gray: chart.fg_color stylepicker(_input) => _input == "SOLID"?line.style_solid: _input == "DASHED"?line.style_dashed: _input == "DOTTED"?line.style_dotted: str.contains(_input,"SOLID")?line.style_solid: str.contains(_input,"DASHED")?line.style_dashed: str.contains(_input,"DOTTED")?line.style_dotted: line.style_solid linestyle(_input) => _input == "___"?"solid": _input == "- - -"?"dashed": _input == ". . ."?"dotted": _input == "___zone"?"solid_zone": _input == "- - -zone"?"dashed_zone": _input == ". . .zone"?"dotted_zone": na //////////////////////////////////////////////////////////////////////////////// //Remove commas at start and end remove_c(_string) => var string s = str.replace_all(_string,";",",") in_len = str.length(s) if str.startswith(s,",") s := str.replace(s,",","",0) if str.endswith(s,",") s := str.replace(s,",","",in_len) s //Inputs//////////////////////////////////////////////////////////////////////// lab_size = input.string("small", title = "Label Size", options = ["tiny","small","normal","large","huge"], inline = "2", group = "Settings") lab_offset = input.int(10, title = "Label Offset", inline = "2", group = "Settings") z_op = input.int(90, title = "Zone Opacity", minval = 0, maxval = 100, inline = "3", group = "Settings") tog_lvl = input.bool(true, title = "Price Labels", inline = "3", group = "Settings") symbol1 = input.symbol("", title = "Ticker", group = "Group 1", inline = "2") lvls1 = str.replace_all(input.string("", title = "Levels", group = "Group 1", inline = "2", tooltip = "LEVELS\nInsert as many levels as needed for this style of line & ticker.\nSeparate by commas (,)\nPlease No Semicolons (;)\nExample:\n100,100.5,101,102,103")," ","") txt1 = input.string("", title = "Text", group = "Group 1", inline = "2") col1 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 1", inline = "2") style1 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 1", inline = "2") width1 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 1", inline = "2") tog_1 = lvls1 == ""?false:true output1 = tog_1?(symbol1 == ""?syminfo.tickerid:symbol1) + "," + (col1=="default"?" ":col1) + "," + linestyle(style1) + "," + str.tostring(width1*-1) + "," + (txt1 == ""?" ":txt1) + "," + remove_c(lvls1) + ";":"" symbol2 = input.symbol("", title = "Ticker", group = "Group 2", inline = "2") lvls2 = str.replace_all(input.string("", title = "Levels", group = "Group 2", inline = "2")," ","") txt2 = input.string("", title = "Text", group = "Group 2", inline = "2") col2 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 2", inline = "2") style2 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 2", inline = "2") width2 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 2", inline = "2") tog_2 = lvls2 == ""?false:true output2 = tog_2?((symbol2 == ""?syminfo.tickerid:symbol2) + "," + (col2=="default"?" ":col2) + "," + linestyle(style2) + "," + str.tostring(width2*-1) + "," + (txt2 == ""?" ":txt2) + "," + str.replace_all(lvls2," ","") + ";"):"" symbol3 = input.symbol("", title = "Ticker", group = "Group 3", inline = "2") lvls3 = str.replace_all(input.string("", title = "Levels", group = "Group 3", inline = "2")," ","") txt3 = input.string("", title = "Text", group = "Group 3", inline = "2") col3 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 3", inline = "2") style3 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 3", inline = "2") width3 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 3", inline = "2") tog_3 = lvls3 == ""?false:true output3 = tog_3?((symbol3 == ""?syminfo.tickerid:symbol3) + "," + (col3=="default"?" ":col3) + "," + linestyle(style3) + "," + str.tostring(width3*-1) + "," + (txt3 == ""?" ":txt3) + "," + str.replace_all(lvls3," ","") + ";"):"" symbol4 = input.symbol("", title = "Ticker", group = "Group 4", inline = "2") lvls4 = str.replace_all(input.string("", title = "Levels", group = "Group 4", inline = "2")," ","") txt4 = input.string("", title = "Text", group = "Group 4", inline = "2") col4 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 4", inline = "2") style4 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 4", inline = "2") width4 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 4", inline = "2") tog_4 = lvls4 == ""?false:true output4 = tog_4?((symbol4 == ""?syminfo.tickerid:symbol4) + "," + (col4=="default"?" ":col4) + "," + linestyle(style4) + "," + str.tostring(width4*-1) + "," + (txt4 == ""?" ":txt4) + "," + str.replace_all(lvls4," ","") + ";"):"" symbol5 = input.symbol("", title = "Ticker", group = "Group 5", inline = "2") lvls5 = str.replace_all(input.string("", title = "Levels", group = "Group 5", inline = "2")," ","") txt5 = input.string("", title = "Text", group = "Group 5", inline = "2") col5 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 5", inline = "2") style5 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 5", inline = "2") width5 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 5", inline = "2") tog_5 = lvls5 == ""?false:true output5 = tog_5?((symbol5 == ""?syminfo.tickerid:symbol5) + "," + (col5=="default"?" ":col5) + "," + linestyle(style5) + "," + str.tostring(width5*-1) + "," + (txt5 == ""?" ":txt5) + "," + str.replace_all(lvls5," ","") + ";"):"" symbol6 = input.symbol("", title = "Ticker", group = "Group 6", inline = "2") lvls6 = str.replace_all(input.string("", title = "Levels", group = "Group 6", inline = "2")," ","") txt6 = input.string("", title = "Text", group = "Group 6", inline = "2") col6 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], group = "Group 6", inline = "2") style6 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], group = "Group 6", inline = "2") width6 = input.int(1, title = "Thickness", minval = 0, maxval = 5, group = "Group 6", inline = "2") tog_6 = lvls6 == ""?false:true output6 = tog_6?((symbol6 == ""?syminfo.tickerid:symbol6) + "," + (col6=="default"?" ":col6) + "," + linestyle(style6) + "," + str.tostring(width6*-1) + "," + (txt6 == ""?" ":txt6) + "," + lvls6 + ";"):"" //Inputs///////////////////////////////////////////////////////////////// input = str.upper(output1 + output2 + output3 + output4 + output5 + output6) //No Level Message////////////////////////////////////////////////////////////// if str.contains(input,syminfo.ticker) == false runtime.error("No levels for this ticker. Please input levels or change ticker. Current Ticker: " + syminfo.ticker) //Variable initialization/////////////////////////////////////////////////////// var line lvl_line = na var label lvl_lab = na var line z1 = na var line z2 = na //Delete all lines & Labels a_allLines = line.all if array.size(a_allLines) > 0 for i = 0 to array.size(a_allLines) - 1 line.delete(array.get(a_allLines, i)) a_allLabels = label.all if array.size(a_allLabels) > 0 for i = 0 to array.size(a_allLabels) - 1 label.delete(array.get(a_allLabels, i)) //////////////////////////////////////////////////////////////////////////////// //Line and label drawing split = str.split(input,";") for i = 0 to array.size(split) - 1 split_get = array.get(split,i) small_split = str.split(split_get,",") if array.size(small_split) > 5 ssf = str.replace_all(array.get(small_split,0)," ","") if (ssf == syminfo.ticker) or (ssf == syminfo.tickerid) or (ssf == "\n" + syminfo.ticker) or (ssf == "\n" + syminfo.tickerid) for e = 5 to array.size(small_split) - 1 lvl = str.replace_all(array.get(small_split,e)," ","") co = colorpicker(str.replace_all(array.get(small_split,1)," ","")) sty = stylepicker(str.replace_all(array.get(small_split,2)," ","")) z = str.contains(str.replace_all(array.get(small_split,2)," ",""),"ZONE") thick = str.tonumber(str.replace_all(array.get(small_split,3)," ","")) < 0? str.tonumber(str.replace_all(array.get(small_split,3)," ","")) * -1:1 txt = tog_lvl?array.get(small_split,4) +" "+ str.format("{0,number,currency}",str.tonumber(lvl)):array.get(small_split,4) if str.tonumber(lvl) > 0 and (z == false) lvl_line := line.new(bar_index,str.tonumber(lvl),bar_index+1,str.tonumber(lvl), extend = extend.right, color = co, style = sty, width = int(thick)) lvl_lab := label.new(bar_index + lab_offset, str.tonumber(lvl), text = txt , color = color.new(color.black,100), size = lab_size, textcolor = co, style = label.style_label_lower_left) if z and (array.size(small_split) == 7) and (e == 6) z_lvl1 = math.max(str.tonumber(str.replace_all(array.get(small_split,5)," ","")),str.tonumber(str.replace_all(array.get(small_split,6)," ",""))) z_lvl2 = math.min(str.tonumber(str.replace_all(array.get(small_split,5)," ","")),str.tonumber(str.replace_all(array.get(small_split,6)," ",""))) z_txt = tog_lvl?array.get(small_split,4) +" "+ str.format("{0,number,currency}",z_lvl2) + " - " + str.format("{0,number,currency}",z_lvl1):array.get(small_split,4) lvl_lab := label.new(bar_index + lab_offset, z_lvl1, text = z_txt , color = color.new(color.black,100), size = lab_size, textcolor = co, style = label.style_label_lower_left) z1 := line.new(bar_index,z_lvl1,bar_index+1,z_lvl1, extend = extend.right, color = co, style = sty, width = int(thick)) z2 := line.new(bar_index,z_lvl2,bar_index+1,z_lvl2, extend = extend.right, color = co, style = sty, width = int(thick)) linefill.new(z1,z2, color = color.new(co,z_op))
Rollover LTE
https://www.tradingview.com/script/7DU3M38z-Rollover-LTE/
Skipper86
https://www.tradingview.com/u/Skipper86/
41
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Skipper86 //@version=5 indicator(title="Rollover LTE", shorttitle="Rollover LTE", overlay=true) //Generic input, not intended to be changed source = input.source(close) //Input length1 = input.int(20, "Length 1", minval=1) length2 = input.int(50, "Length 2", minval=1) RolloverPrice1 = source[length1] RolloverPrice2 = source[length2] RolloverStrength1 = source-RolloverPrice1 RolloverStrength2 = source-RolloverPrice2 RolloverStrength = RolloverStrength1 + RolloverStrength2 MA1 = ta.sma(source, length1) MA2 = ta.sma(source, length2) Upper = math.max(RolloverPrice1,RolloverPrice2,MA1,MA2) Lower = math.min(RolloverPrice1,RolloverPrice2,MA1,MA2) Color1 = color.rgb(229, 229, 229, 0) Color2 = color.rgb(0, 97, 255, 0) Color6 = RolloverStrength >= 0 ? color.rgb(0,255,2,70) : color.rgb(255,0,0,70) plot(source, offset = length1, title="Rollover Price 1", color=Color1) plot(source, offset = length2, title="Rollover Price 2", color=Color2) plot(MA1, title="SMA 1", color=Color1) plot(MA2, title="SMA 2", color=Color2) p1 = plot(Upper, title="Max", color=Color1, display=display.none) p2 = plot(Lower, title="Min", color=Color1, display=display.none) fill(p1, p2, title = "Background", color=Color6)
iBox, Initial Balance | IB High, Low, Midpoint | Opening
https://www.tradingview.com/script/0jpQvEWD/
Roul_Charts
https://www.tradingview.com/u/Roul_Charts/
280
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Roul_Charts // Roul // 11.2022 // 12.2022 seems that my changes where not saved. So had to reupload it... // 03.2023 Reworked Settings menu, Reworked Style menu, added closing, added Crypto Exchanges and pairs with UTC+0 as IB range // 11.2023 Added more Ticker and Exchanges, Added SouthAfrica, Added Premarket Range for US and EU, Added more IB Extensions, // Added Yesterday High and Low Lines // prepared a new GAP Detector Indicator based on iBOX Logic // Added crossover and crossunder Alertconditions for all Lines // Added the Plot x Days back Feature, FINALLY!! //@version=5 indicator(title='iBox, Initial Balance | IB High, Low, Mid | Open, Close', shorttitle='iBOX', overlay=true, max_bars_back=1050, max_boxes_count=250, max_labels_count=250, max_lines_count=250) //#################################### // Settings //#################################### GP1 = "===== Settings =====" Plot_x_days = input.int(defval=10, title='Plot only last x days', tooltip='please add days for weekends too', group=GP1) //#################################### // Timezones and IB Ranges //#################################### GP2a = "=============== Universal ===============" Timezone = input.string(defval="Europe/Berlin", title="Universal Timezone", group=GP2a, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Universal Exchange Timezone") Select_Universal_IB = input.session(title="Universal IB Time", defval="0900-0959", group=GP2a, inline="Universal IB") GP2b = "=============== Europe ===============" Timezone_EU = input.string(defval="Europe/Berlin", title="Europe Timezone", group=GP2b, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the European Exchange Timezone") Select_EU_IB = input.session(title="EU IB Time", defval="0900-0959", group=GP2b, inline="EU IB") Select_EU_Premarket = input.session(title="EU Premarket Time", defval="0800-0859", group=GP2b, inline="EU Premarket") // Select_EU_Session = input.session(title="EU", defval="0900-1730", group=GP2b, inline="EU") // EU Session, Monday - Friday GP2c = "=============== USA ===============" Timezone_US = input.string(defval="America/New_York", title="USA Timezone", group=GP2c, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the USA Exchange Timezone") Select_US_IB = input.session(title="US IB Time", defval="0930-1029", group=GP2c, inline="US IB") Select_US_Premarket = input.session(title="US Premarket Time", defval="0830-0929", group=GP2c, inline="US Premarket") // Select_US_Session = input.session(title="US", defval="0930-1600", group=GP2c, inline="US") // US Session, Monday - Friday GP2d = "=============== Brazil ===============" Timezone_Brazil = input.string(defval="America/Sao_Paulo", title="Brazil Timezone", group=GP2d, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Brazilian Exchange Timezone") Select_Brazil_IB = input.session(title="Brazil IB Time", defval="1000-1059", group=GP2d, inline="Brazil IB") GP2e = "=============== Asia ===============" Timezone_Asia = input.string(defval="Asia/Shanghai", title="Asia Timezone", group=GP2e, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Asian Exchange Timezone") Select_Asia_IB = input.session(title="Asia IB Time", defval="0915-1014", group=GP2e, inline="Asia IB") Select_Asia_Session = input.session(title="Asia Session", defval="0800-1459", group=GP2e, inline="AS") // Asian Session, During Winter Time //Select_Asia_Session = input.session(title="Asia Session", defval="0800-1359", group=GP2e, inline="AS") // Asian Session, During Summer Time GP2f = "=============== Tokyo ===============" Timezone_Tokyo = input.string(defval="Asia/Tokyo", title="Tokyo Timezone", group=GP2f, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Tokyo Exchange Timezone") Select_Tokyo_IB = input.session(title="Tokyo IB Time", defval="0900-0959", group=GP2f, inline="Tokyo IB") GP2g = "=============== India ===============" Timezone_India = input.string(defval="Asia/Kolkata", title="India Timezone", group=GP2g, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Indian Exchange Timezone") Select_India_IB = input.session(title="India IB Time", defval="0900-0959", group=GP2g, inline="India IB") GP2h = "=============== Ozeania ===============" Timezone_Oceania = input.string(defval="Australia/Sydney", title="Oceania Timezone", group=GP2h, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Oceanian Exchange Timezone") Select_Oceania_IB = input.session(title="Oceania IB Time", defval="1000-1059", group=GP2h, inline="Oceania IB") GP2i = "=============== SouthAfrica ===============" Timezone_SouthAfrica = input.string(defval="Africa/Johannesburg" , title="SouthAfrica Timezone", group=GP2i, options=["GMT", "Africa/Johannesburg", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the SouthAfrica Exchange Timezone") Select_SouthAfrica_IB = input.session(title="SouthAfrica IB Time", defval="0900-0959", group=GP2i, inline="SouthAfrica IB") GP2j = "=============== Crypto ===============" Timezone_Crypto = input.string(defval="Etc/UTC", title="Crypto Timezone", group=GP2j, options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Crypto Exchange Timezone") Select_Crypto_IB = input.session(title="Crypto IB Time", defval="0000-0059", group=GP2j, inline="Crypto IB") //#################################### // Initial Balance Settings //#################################### GP6 = "===== Initial Balance Settings =====" Lines_IB_active = input(title='Show IB Lines?', defval=true, group=GP6) IB_Lines_width = input.int(2, 'IB Lines Width', minval=1, maxval=4, group=GP6) IB_Lines_Color = input(color.new(color.rgb(166, 51, 91), 0), 'IB Lines Color', group=GP6) IB_Lines_Style_Option = input.string("solid (─)", title="IB Lines Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP6) IB_Lines_Extension_alt = input(title='Use alternate possibly wrong IB Extension calculation?', defval=false, tooltip="Normal Calculation is: IB Range = IB High - IB Low that is the Range of the Initial Balance. This seems to be valid and heavily recogniced from the market. The alternate Calculation is the distance from Opening to IB High and the distance from Opening to IB Low which can work but is not my favorite", group=GP6) GP7 = "===== Initial Balance 1.5 Extension Settings =====" Lines_IB_15_Extension_active = input(title='Show IB 1.5 Extension Lines?', defval=false, group=GP7) IB_Lines15_width = input.int(3, 'IB 1.5 Lines Width', minval=1, maxval=4, group=GP7) IB_Lines15_Color = input(color.new(color.rgb(127,39,70), 0), 'IB 1.5 Lines Color', group=GP7) IB_Lines15_Style_Option = input.string("solid (─)", title="IB 1.5 Lines Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP7) GP8 = "===== Initial Balance 2.0 Extension Settings =====" Lines_IB_20_Extension_active = input(title='Show IB 2.0 Extension Lines?', defval=false, group=GP8) IB_Lines20_width = input.int(4, 'IB 2.0 Lines Width', minval=1, maxval=4, group=GP8) IB_Lines20_Color = input(color.new(color.rgb(107,33,59), 0), 'IB 2.0 Lines Color', group=GP8) IB_Lines20_Style_Option = input.string("solid (─)", title="IB 2.0 Lines Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP8) GP8a = "===== Initial Balance 2.5 Extension Settings =====" Lines_IB_25_Extension_active = input(title='Show IB 2.5 Extension Lines?', defval=false, group=GP8a) IB_Lines25_width = input.int(4, 'IB 2.5 Lines Width', minval=1, maxval=4, group=GP8a) IB_Lines25_Color = input(color.new(color.rgb(107,33,59), 0), 'IB 2.5 Lines Color', group=GP8a) IB_Lines25_Style_Option = input.string("solid (─)", title="IB 2.5 Lines Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP8a) GP8b = "===== Initial Balance 3.0 Extension Settings =====" Lines_IB_30_Extension_active = input(title='Show IB 3.0 Extension Lines?', defval=false, group=GP8b) IB_Lines30_width = input.int(4, 'IB 3.0 Lines Width', minval=1, maxval=4, group=GP8b) IB_Lines30_Color = input(color.new(color.rgb(107,33,59), 0), 'IB 3.0 Lines Color', group=GP8b) IB_Lines30_Style_Option = input.string("solid (─)", title="IB 3.0 Lines Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP8b) GP9 = "===== Initial Balance Halfback Settings =====" Lines_IB_Halfback_active = input(title='Show IB Halfback Line?', defval=true, group=GP9) IB_Halfback_Line_width = input.int(2, 'IB Halfback Line Width', minval=1, maxval=4, group=GP9) IB_Halfback_Line_Color = input(color.new(color.rgb(166, 51, 91), 0), 'IB Halfback Line Color', group=GP9) IB_Halfback_Line_Style_Option = input.string("dotted (┈)", title="IB Halfback Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP9) GP9a = "===== Premarket Line Settings =====" Lines_Premarket_active = input(title='Show Premarket Line?', defval=false, group=GP9a) Premarket_Line_width = input.int(1, 'Premarket Line Width', minval=1, maxval=4, group=GP9a) Premarket_High_Line_Color = input(color.new(#51b0fe, 0), 'Premarket High Line Color', group=GP9a) Premarket_Low_Line_Color = input(color.new(#51b0fe, 0), 'Premarket Low Line Color', group=GP9a) Premarket_High_Line_Style_Option = input.string("arrow right (→)", title="Premarket High Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP9a) Premarket_Low_Line_Style_Option = input.string("arrow right (→)", title="Premarket Low Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP9a) GP10 = "===== Opening Line Settings =====" Lines_Opening_active = input(title='Show Opening Line?', defval=true, group=GP10) Opening_Line_width = input.int(2, 'IB Opening Line Width', minval=1, maxval=4, group=GP10) Opening_Line_Color = input(color.new(color.rgb(218, 135 , 24), 0), 'Opening Line Color', group=GP10) Opening_Line_Style_Option = input.string("dotted (┈)", title="Opening Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP10) GP11 = "===== Previous Day Closing Line Settings =====" PrevD_Lines_Closing_active = input(title='Show Yesterdays Closing?', defval=false, group=GP11) PrevD_Closing_Line_width = input.int(2, 'Yesterday Closing Line Width', minval=1, maxval=4, group=GP11) PrevD_Closing_Line_Color = input(color.new(#653ac9, 0), 'Yesterday Closing Line Color', group=GP11) PrevD_Closing_Line_Style_Option = input.string("dashed (╌)", title="Yesterday Closing Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP11) GP11a = "===== Previous Day High Line Settings =====" PrevD_Lines_High_active = input(title='Show Yesterdays High?', defval=false, group=GP11a) PrevD_High_Line_width = input.int(2, 'Yesterday High Line Width', minval=1, maxval=4, group=GP11a) PrevD_High_Line_Color = input(color.new(#028ea3, 0), 'Yesterday High Line Color', group=GP11a) PrevD_High_Line_Style_Option = input.string("dashed (╌)", title="Yesterday High Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP11a) GP11b = "===== Previous Day Low Line Settings =====" PrevD_Lines_Low_active = input(title='Show Yesterdays Low?', defval=false, group=GP11b) PrevD_Low_Line_width = input.int(2, 'Yesterday Low Line Width', minval=1, maxval=4, group=GP11b) PrevD_Low_Line_Color = input(color.new(#04437e, 0), 'Yesterday Low Line Color', group=GP11b) PrevD_Low_Line_Style_Option = input.string("dashed (╌)", title="Yesterday Low Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP11b) GP12 = "===== Asia Line Settings =====" Lines_Asia_Session_active = input(title='Show Asia Range High/Low?', defval=false, group=GP12) Asia_Line_width = input.int(2, 'Asia Line Width', minval=1, maxval=4, group=GP12) Asia_Session_High_Line_Color = input(color.new(color.rgb(138,138,138), 0), 'Asia Session High Line Color', group=GP12) Asia_Session_Low_Line_Color = input(color.new(color.rgb(138,138,138), 0), 'Asia Session Low Line Color', group=GP12) Asia_Session_High_Line_Style_Option = input.string("solid (─)", title="Asia Session High Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP12) Asia_Session_Low_Line_Style_Option = input.string("solid (─)", title="Asia Session Low Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)", "arrow left (←)", "arrow right (→)", "arrows both (↔)"], group=GP12) GP13 = "===== Label Settings =====" Labels_active = input(title='Show Text Labels for Lines?', defval=false, group=GP13) Labels_Transparency = input.int(30, 'Labels Transparency?', minval=0, maxval=100, group=GP13) //#################################### // Checks //#################################### //Current Candle in IB Range? In_Universal_IB = not na(time(timeframe.period, Select_Universal_IB, Timezone)) // Calculate time for the Universal IB In_EU_IB = not na(time(timeframe.period, Select_EU_IB, Timezone_EU)) // Calculate time for the EU IB In_US_IB = not na(time(timeframe.period, Select_US_IB, Timezone_US)) // Calculate time for the US IB In_Brazil_IB = not na(time(timeframe.period, Select_Brazil_IB, Timezone_Brazil)) // Calculate time for the Brazil IB In_Asia_IB = not na(time(timeframe.period, Select_Asia_IB, Timezone_Asia)) // Calculate time for the Asia IB In_Tokyo_IB = not na(time(timeframe.period, Select_Tokyo_IB, Timezone_Tokyo)) // Calculate time for the Tokyo IB In_India_IB = not na(time(timeframe.period, Select_India_IB, Timezone_India)) // Calculate time for the India IB In_Oceania_IB = not na(time(timeframe.period, Select_Oceania_IB, Timezone_Oceania)) // Calculate time for the Oceania IB In_SouthAfrica_IB = not na(time(timeframe.period, Select_SouthAfrica_IB, Timezone_SouthAfrica)) // Calculate time for the SouthAfrica IB In_Crypto_IB = not na(time(timeframe.period, Select_Crypto_IB, Timezone_Crypto)) // Calculate time for the Crypto IB //Current Candle in Session? // In_Globex_Session = not na(time(timeframe.period, Select_Globex_Session, Timezone)) // Calculate time for the Globex/Overnight session In_Asia_Session = not na(time(timeframe.period, Select_Asia_Session, Timezone_Asia)) // Calculate time for the Asian Session In_EU_Premarket = not na(time(timeframe.period, Select_EU_Premarket, Timezone_EU)) // Calculate time for the Asian Session In_US_Premarket = not na(time(timeframe.period, Select_US_Premarket, Timezone_US)) // Calculate time for the Asian Session // In_EU_Session = not na(time(timeframe.period, Select_EU_Session, Timezone_EU)) // Calculate time for the EU Session // In_US_Session = not na(time(timeframe.period, Select_US_Session, Timezone_US)) // Calculate time for the US Session //In_Day_Session = not na(time(timeframe.period, Select_Day_Session, Timezone_EU)) // Calculate time for the Day Session //In_Day_Session = time(timeframe.period, Select_Day_Session, Timezone_EU) // Calculate time for the Day Session // Define Session End Time and End of Lines // US_Session_EndHour = input.int(title="US Cash Session End Hour", defval=21, minval=0, maxval=23, group=GP1, inline="US_End") // US Session End Hour // US_Session_EndMin = input.int(title="US Cash Session End Min.", defval=59, minval=0, maxval=59, group=GP1, inline="US_End", tooltip="This is where all the lines and drawings end. Must be Less than the start of Globex") // US Session End Minute // var Cash_Session_EndTime = timestamp(Timezone, year, month, dayofmonth, US_Session_EndHour, US_Session_EndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) // NewYork_OR_offset = input.int(title="New York Open Offset", tooltip="New York Session Opening Range Starts after x minutes", defval=30, minval=0, maxval=59, group=GP1) // New York Opening Range Initial Balance Opening Minute // Globex_Session_Col = input.color(title="Session",tooltip="Globex Session Highlight Color", defval=color.silver, group=GP1, inline="GS") // Globex (Overnight) Session, color setting for background highlights // Asia_Session_Col = input.color(title="Session",tooltip="Asia Session Highlight Color", defval=color.white, group=GP1, inline="AS") // Asia Session, color setting for background highlights, 1st hr box and High and Low lines // EU_Session_Col = input.color(title="Session",tooltip="EU Session Highlight Color", defval=color.green, group=GP1, inline="LS") // EU Session, color setting for background highlights, 1st hr box and High and Low lines // US_Session_Col = input.color(title="Session",tooltip="US Session Highlight Color", defval=color.blue, group=GP1, inline="NY") // US Session, color setting for background highlights, 1st hr box and High and Low lines // Globex_Level_Col = input.color(title="Levels",tooltip="Globex Levels Color", defval=color.gray, group=GP1, inline="GS") // Globex (Overnight) Session, color setting for level lines // Asia_Level_Col = input.color(title="Levels",tooltip="Asia Levels Color", defval=color.gray, group=GP1, inline="AS") // Asia Session, color setting for level lines // EU_Level_Col = input.color(title="Levels",tooltip="EU Levels Color", defval=color.gray, group=GP1, inline="EU") // EU Session, color setting for level lines // US_Level_Col = input.color(title="Levels",tooltip="US Level Color", defval=color.gray, group=GP1, inline="US") // US Session, color setting for level lines //#################################### // Variables //#################################### var line IB_High_Line = na var line IB_Low_Line = na var line IB_High15_Line = na var line IB_High20_Line = na var line IB_High25_Line = na var line IB_High30_Line = na var line IB_Low15_Line = na var line IB_Low20_Line = na var line IB_Low25_Line = na var line IB_Low30_Line = na var line IB_Halfback_Line = na var line Premarket_High_Line = na var line Premarket_Low_Line = na var line Opening_Line = na var line PrevD_Closing_Line = na var line PrevD_High_Line = na var line PrevD_Low_Line = na var line Asia_Session_High_Line = na var line Asia_Session_Low_Line = na var IB_High_value = 0.0 var IB_High15_value = 0.0 var IB_High20_value = 0.0 var IB_High25_value = 0.0 var IB_High30_value = 0.0 var IB_Low_value = 0.0 var IB_Low15_value = 0.0 var IB_Low20_value = 0.0 var IB_Low25_value = 0.0 var IB_Low30_value = 0.0 var IB_Halfback_value = 0.0 var Premarket_Start_Time = 0 var Premarket_End_Time = 0 var Premarket_High_value = 0.0 var Premarket_Low_value = 0.0 var Opening_value = 0.0 var PrevD_Closing_value = 0.0 var PrevD_High_value = 0.0 var PrevD_Low_value = 0.0 var PrevD_Closing_time = 0 var Start_Time = 0 var End_Time = 0 var bool Relevant_IB_Range = false var bool Relevant_Premarket = false var Day_Session_End = 0 var Asia_Session_Start_Time = 0 var Asia_Session_End_Time = 0 var Asia_Session_High_value = 0.0 var Asia_Session_Low_value = 0.0 var label IB_Low_Label = na var label IB_Low15_Label = na var label IB_Low20_Label = na var label IB_Low25_Label = na var label IB_Low30_Label = na var label IB_High_Label = na var label IB_High15_Label = na var label IB_High20_Label = na var label IB_High25_Label = na var label IB_High30_Label = na var label IB_Halfback_Label = na var label Premarket_High_Label = na var label Premarket_Low_Label = na var label Opening_Label = na var label PrevD_Closing_Label = na var label PrevD_High_Label = na var label PrevD_Low_Label = na var label Asia_Session_High_Label = na var label Asia_Session_Low_Label = na //#################################### // Define Exchanges and Ticker Symbols for Ranges //#################################### EU_Index_Array = array.from("EUREX","EUREX_DLY","EURONEXT","EURONEXT_DLY","ICEEUR","ICEEUR_DLY","TRADEGATE","XETR","XETR_DLY") EU_Ticker_Array = array.from("DAX30","DAX40","DAXEUR","GERMANY40MINICFD","DE30EUR","DE40","DEU40","GER30","GER40","GERMANY40CFD","GRXEUR","GDAXIM","3XJN","GDAXI","DECEUR","DE30.F","GER40FT","DAX","MIDDE50","MDAX","GERMID50","TDXP","GERTEC30","TECDAX","FTSE100","FTSGBP","UK100","UK100.F","UK100CFD","UK100GBP","UKXGBP","FTSE","UKCGBP","UK100FT","FR40","FR40EUR","FRA40","FRANCE40CFD","FRXEUR","FCHI","CAC","CACEUR","FRA40FT","ESX50","ESXEUR","EU50","EU50EUR","EUSTX50","EURO50","EUCEUR","IT40","ITA40","ITALY40CFD","MIBEUR","SUI20","SW20","SWI20","SWICHF","CH20","SMI","SWCCHF", "CH20CHF","ES35","ESP35","SP35","SPA35","SPAIN35CFD","ESCEUR","ESPIXEUR","NETH25","NL25","NL25EUR","NTH25","NED25","OMX30","OMXS30","NOR25","OBX20","OBX25") US_Index_Array = array.from("CME_MINI","CME_MINI_DL","DJ","DJ_DLY","NASDAQ","NASDAQ_DLY","SP","SP_DLY","TSX","TSX_DLY","CSE","NYSE") US_Ticker_Array = array.from("NAS100","NAS100USD","NASDAQ","NDQ100","NDQM","NDQUSD","NDX","NQ1!","NSXUSD","US100","USTEC","USTEC.F","USTECH100CFD","USATEC","NQCUSD","NAS100FT","DXY","USXUSD","USDX","USDOLLAR","RTY","US2000","RUT","US2000USD","USARUS","USSMALLCAP2000CFD","SP500","SPIUSD","SPX","SPX500","SPX500USD","SPXM","SPXUSD","US500","US500.F","USSP500CFD","USA500","SPCUSD","SP500FT","DJ30","DJ30.F","DJI","DOWUSD","US30","US30USD","WALLSTREETCFD","WS30M","USAIND","DJCUSD","DJ30FT","VIX","VOLX","CA60","CAN60") Brazil_Index_Array = array.from("BMFBOVESPA","BMFBOVESPA_DLY") Brazil_Ticker_Array = array.from("BFSPX","BRA50","IBRX50","BVSPX") Asia_Index_Array = array.from("SSE","SSE_DLY","HSI","HSI_DLY") Asia_Ticker_Array = array.from("CHINA50","CHINA50CFD","CHINAH","CHN50","CN50","CN50USD","CNXUSD","CNCUSD","CHINAHHKD","CHINA50FT","HKIND","HK33HKD","HK50","HK50.F","HKXHKD","HONGKONG50CFD","HSI","HSXHKD","HKCHKD","HK50FT","SCI25","SG30SGD","SG25","SIMSCI","STI30") Tokyo_Index_Array = array.from("TOCOM","TOCOM_DLY","TSE","TSE_DLY") Tokyo_Ticker_Array = array.from("J225","JAP225","JAPAN225CFD","JP225USD","JP225YJPY","JPN225","JPXJPY","NIKKEI225","NKIUSD","NIKKEI","JP225","NKCJPY","JPN225FT") India_Index_Array = array.from("NSE","NSE_DLY","BSE","BSE_DLY") India_Ticker_Array = array.from("INDIA50","INDIA50CFD","INDUSD","NIFTY50","NIFTY","IND50") Oceania_Index_Array = array.from("ASX","ASX_DLY") Oceania_Ticker_Array = array.from("ASX200","ASXAUD","AU200","AU200AUD","AUS200","AUSTRALIA200CFD","AUXAUD","AUS","AUCAUD","SPI200") SouthAfrica_Index_Array = array.from("JSE", "JSE_DLY") SouthAfrica_Ticker_Array = array.from("SA40") Crypto_Index_Array = array.from("BINANCE","BINANCEUS","BINGX","BITFINEX","BITFLYER","BITGET","BITHUMB","BITKUB","BITMEX","BITPANDAPRO","HONEYSWAPPOLYGON","HONEYSWAP","INTOTHEBLOCK","KORBIT","KRAKEN","KUCOIN","MEXC","OKCOIN","OKX","PANCAKESWAP","BITRUE","BITSO","BITSTAMP","BITTREX","BTSE","BYBIT","CEXIO","COINMETRICS","COINBASE","COINEX","COINFLOOR","PANGOLIN","PHEMEX","POLONIEX","PYTH","QUICKSWAP","SPOOKYSWAP","SUSHISWAP","SUSHISWAPPOLYGON","THEROCKTRADING","TIMEX","TRADERJOE","UNISWAP","UNISWAP3ARBITRUM","UNISWAP3ETH","UNISWAP3POLYGON","UPBIT","WHITEBIT","WOONETWORK","XEXCHANGE","DEFILLAMA","DELTA","DERIBIT","DYDX","EXMO","GATEIO","GEMINI","GLASSNODE") Crypto_Ticker_Array = array.from("0XUSD","1INCHBTC","1INCHUSD","AAVEUSD","AAVEUSDY","ADAUSD","ALICEUSD","ALOGUSD","ANTUSD","ATOMUSD","AVAXUSD","AXSUSD","BALBTC","BALUSD","BALUSDT","BANDUSD","BATUSD","BCHEUR","BCHUSD","BNBUSD","BNTUSD","BTCBYN","BTCEUR","BTCGBP","BTCUSD", "BTCUSDC","BTCUSDT","CHRUSD","CHZBTC","CHZUSDT","COMPUSD","COMPUSDC","COMPUSDT","CRVBTC","CRVUSD","CRVUSDT","DAIUSD","DAIUSDT","DASHUSD","DOGEUSD","DOTUSD","DYDXUSD","EGLDUSD","ENJUSDT","EOSUSD","ETCUSD","ETHBTC","ETHBYN","ETHEUR","ETHUSD", "ETHUSDC","FILUSD","FRMUSD","GALAUSD","GRTBTC","GRTUSD","HBARUSD","HOTUSD","ICPUSD","IOSTUSD","KNCUSD","KNCUSDT","LINKUSD","LINKUSDT","LRCUSD","LRCUSDT","LTCBTC","LTCBYN","LTCEUR","LTCUSD","LTCUSDT","MANAUSD","MATICUSD","MATICUSD C","MKRBTC", "MKRUSD","MKRUSDC","NEARUSD","NEOUSD","OCEANUSD","OMGUSD","ONEUSD","QTUMUSD","REPUSD","SANDUSD","SHIBUSD","SHIBUSDC","SKLUSD","SNXUSD","SNXUSDT","SOLUSD","SRMBTC","SUSHIUSD","SXPUSD","THETAUSD","TRXUSD","UMAUSD","UNIUSD","UNIUSDT","USDCUSD", "USDTUSD","USDUSDC","VETUSD","WBTCUSD","XLMUSD","XMRUSD","XRBTC","XRPBYN","XRPEUR","XRPUSD","XTZUSD","YFIUSD","ZECUSD") Ticker_EU_Range = array.includes(EU_Index_Array, syminfo.prefix) or array.includes(EU_Ticker_Array, syminfo.ticker) Ticker_US_Range = array.includes(US_Index_Array, syminfo.prefix) or array.includes(US_Ticker_Array, syminfo.ticker) Ticker_Brazil_Range = array.includes(Brazil_Index_Array, syminfo.prefix) or array.includes(Brazil_Ticker_Array, syminfo.ticker) Ticker_Asia_Range = array.includes(Asia_Index_Array, syminfo.prefix) or array.includes(Asia_Ticker_Array, syminfo.ticker) Ticker_Tokyo_Range = array.includes(Tokyo_Index_Array, syminfo.prefix) or array.includes(Tokyo_Ticker_Array, syminfo.ticker) Ticker_India_Range = array.includes(India_Index_Array, syminfo.prefix) or array.includes(India_Ticker_Array, syminfo.ticker) Ticker_Oceania_Range = array.includes(Oceania_Index_Array, syminfo.prefix) or array.includes(Oceania_Ticker_Array, syminfo.ticker) Ticker_SouthAfrica_Range = array.includes(SouthAfrica_Index_Array, syminfo.prefix) or array.includes(SouthAfrica_Ticker_Array, syminfo.ticker) Ticker_Crypto_Range = array.includes(Crypto_Index_Array, syminfo.prefix) or array.includes(Crypto_Ticker_Array, syminfo.ticker) //#################################### // Functions //#################################### //Function to define Sessions Lows SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var float sessionLowPrice = na if insideSession and not insideSession[1] sessionLowPrice := low else if insideSession sessionLowPrice := math.min(sessionLowPrice, low) sessionLowPrice //Function to define Sessions Highs SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var float sessionHighPrice = na if insideSession and not insideSession[1] sessionHighPrice := high else if insideSession sessionHighPrice := math.max(sessionHighPrice, high) sessionHighPrice //Function to define Sessions Opening SessionOpening(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var float sessionOpeningPrice = na sessionOpeningPrice := insideSession and not insideSession[1] ? open : sessionOpeningPrice[1] //Function to define Previous Day Values PrevDayClosing_Value() => var float PrevDayClosingPrice = na PrevDayClosingPrice := request.security(syminfo.tickerid, "1D", close[1], barmerge.gaps_on, lookahead=barmerge.lookahead_on) PrevDayHigh_Value() => var float PrevDayHighPrice = na PrevDayHighPrice := request.security(syminfo.tickerid, "1D", high[1], barmerge.gaps_on, lookahead=barmerge.lookahead_on) PrevDayLow_Value() => var float PrevDayLowPrice = na PrevDayLowPrice := request.security(syminfo.tickerid, "1D", low[1], barmerge.gaps_on, lookahead=barmerge.lookahead_on) PrevDayClosing_Time() => var int PrevDayClosingTime = 0 PrevDayClosingTime := request.security(syminfo.tickerid, "1D", time_close[1], barmerge.gaps_on, lookahead=barmerge.lookahead_on) PrevDayFridayClosing_Time() => var int PrevDayFridayClosingTime = 0 PrevDayFridayClosingTime := request.security(syminfo.tickerid, "1D", time_close[2]) //Function to define Sessions Start Time SessionStart(sessionTime, sessionTimeZone=syminfo.timezone) => insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone)) var int sessionStartTime = 0 sessionStartTime := insideSession and not insideSession[1] ? time : sessionStartTime[1] Lines_Plot(_Start_Time, _Start_Value, _End_Time, _color, _style, _width) => var line _line = na //line.delete(_line) _line := line.new(x1=_Start_Time, y1=_Start_Value, x2=_End_Time, y2=_Start_Value, xloc=xloc.bar_time, color=_color, style=_style, width=_width) _line //#################################### // Functions end! //#################################### // Call functions to separate here between US, EU and Asia if Ticker_EU_Range IB_Low_value := SessionLow(Select_EU_IB, Timezone_EU) IB_High_value := SessionHigh(Select_EU_IB, Timezone_EU) Opening_value := SessionOpening(Select_EU_IB, Timezone_EU) Start_Time := SessionStart(Select_EU_IB, Timezone_EU) Premarket_Start_Time := SessionStart(Select_EU_Premarket, Timezone_EU) Premarket_Low_value := SessionLow(Select_EU_Premarket, Timezone_EU) Premarket_High_value := SessionHigh(Select_EU_Premarket, Timezone_EU) Relevant_IB_Range := In_EU_IB Relevant_Premarket := In_EU_Premarket else if Ticker_US_Range IB_Low_value := SessionLow(Select_US_IB, Timezone_US) IB_High_value := SessionHigh(Select_US_IB, Timezone_US) Opening_value := SessionOpening(Select_US_IB, Timezone_US) Start_Time := SessionStart(Select_US_IB, Timezone_US) Premarket_Start_Time := SessionStart(Select_US_Premarket, Timezone_US) Premarket_Low_value := SessionLow(Select_US_Premarket, Timezone_US) Premarket_High_value := SessionHigh(Select_US_Premarket, Timezone_US) Relevant_IB_Range := In_US_IB Relevant_Premarket := In_US_Premarket else if Ticker_Brazil_Range IB_Low_value := SessionLow(Select_Brazil_IB, Timezone_Brazil) IB_High_value := SessionHigh(Select_Brazil_IB, Timezone_Brazil) Opening_value := SessionOpening(Select_Brazil_IB, Timezone_Brazil) Start_Time := SessionStart(Select_Brazil_IB, Timezone_Brazil) Relevant_IB_Range := In_Brazil_IB else if Ticker_Asia_Range IB_Low_value := SessionLow(Select_Asia_IB, Timezone_Asia) IB_High_value := SessionHigh(Select_Asia_IB, Timezone_Asia) Opening_value := SessionOpening(Select_Asia_IB, Timezone_Asia) Start_Time := SessionStart(Select_Asia_IB, Timezone_Asia) Relevant_IB_Range := In_Asia_IB else if Ticker_Tokyo_Range IB_Low_value := SessionLow(Select_Tokyo_IB, Timezone_Tokyo) IB_High_value := SessionHigh(Select_Tokyo_IB, Timezone_Tokyo) Opening_value := SessionOpening(Select_Tokyo_IB, Timezone_Tokyo) Start_Time := SessionStart(Select_Tokyo_IB, Timezone_Tokyo) Relevant_IB_Range := In_Tokyo_IB else if Ticker_India_Range IB_Low_value := SessionLow(Select_India_IB, Timezone_India) IB_High_value := SessionHigh(Select_India_IB, Timezone_India) Opening_value := SessionOpening(Select_India_IB, Timezone_India) Start_Time := SessionStart(Select_India_IB, Timezone_India) Relevant_IB_Range := In_India_IB else if Ticker_Oceania_Range IB_Low_value := SessionLow(Select_Oceania_IB, Timezone_Oceania) IB_High_value := SessionHigh(Select_Oceania_IB, Timezone_Oceania) Opening_value := SessionOpening(Select_Oceania_IB, Timezone_Oceania) Start_Time := SessionStart(Select_Oceania_IB, Timezone_Oceania) Relevant_IB_Range := In_Oceania_IB else if Ticker_SouthAfrica_Range IB_Low_value := SessionLow(Select_SouthAfrica_IB, Timezone_SouthAfrica) IB_High_value := SessionHigh(Select_SouthAfrica_IB, Timezone_SouthAfrica) Opening_value := SessionOpening(Select_SouthAfrica_IB, Timezone_SouthAfrica) Start_Time := SessionStart(Select_SouthAfrica_IB, Timezone_SouthAfrica) Relevant_IB_Range := In_SouthAfrica_IB else if Ticker_Crypto_Range IB_Low_value := SessionLow(Select_Crypto_IB, Timezone_Crypto) IB_High_value := SessionHigh(Select_Crypto_IB, Timezone_Crypto) Opening_value := SessionOpening(Select_Crypto_IB, Timezone_Crypto) Start_Time := SessionStart(Select_Crypto_IB, Timezone_Crypto) Relevant_IB_Range := In_Crypto_IB else IB_Low_value := SessionLow(Select_Universal_IB, Timezone) IB_High_value := SessionHigh(Select_Universal_IB, Timezone) Opening_value := SessionOpening(Select_Universal_IB, Timezone) Start_Time := SessionStart(Select_Universal_IB, Timezone) Relevant_IB_Range := In_Universal_IB Asia_Session_Start_Time := SessionStart(Select_Asia_Session, Timezone_Asia) Asia_Session_High_value := SessionHigh(Select_Asia_Session, Timezone_Asia) Asia_Session_Low_value := SessionLow(Select_Asia_Session, Timezone_Asia) PrevD_Closing_time := PrevDayClosing_Time() PrevD_Closing_value := PrevDayClosing_Value() PrevD_High_value := PrevDayHigh_Value() PrevD_Low_value := PrevDayLow_Value() //if (dayofweek == dayofweek.monday) // PrevD_Closing_time := PrevDayFridayClosing_Time() // Day_Session_End := PrevD_Closing_time + 172850000 //else // PrevD_Closing_time := PrevDayClosing_Time() // Day_Session_End := PrevD_Closing_time + 86290000 IB_Halfback_value := (IB_High_value + IB_Low_value) / 2 if IB_Lines_Extension_alt == false IB_High15_value := IB_High_value + ((IB_High_value - IB_Low_value) * 0.5) IB_High20_value := IB_High_value + ((IB_High_value - IB_Low_value) * 1.0) IB_High25_value := IB_High_value + ((IB_High_value - IB_Low_value) * 1.5) IB_High30_value := IB_High_value + ((IB_High_value - IB_Low_value) * 2.0) IB_Low15_value := IB_Low_value - ((IB_High_value - IB_Low_value) * 0.5) IB_Low20_value := IB_Low_value - ((IB_High_value - IB_Low_value) * 1.0) IB_Low25_value := IB_Low_value - ((IB_High_value - IB_Low_value) * 1.5) IB_Low30_value := IB_Low_value - ((IB_High_value - IB_Low_value) * 2.0) else IB_High15_value := Opening_value + ((IB_High_value - Opening_value) * 1.5) IB_High20_value := Opening_value + ((IB_High_value - Opening_value) * 2.0) IB_High25_value := Opening_value + ((IB_High_value - Opening_value) * 2.5) IB_High30_value := Opening_value + ((IB_High_value - Opening_value) * 3.0) IB_Low15_value := Opening_value - ((Opening_value - IB_Low_value) * 1.5) IB_Low20_value := Opening_value - ((Opening_value - IB_Low_value) * 2.0) IB_Low25_value := Opening_value - ((Opening_value - IB_Low_value) * 2.5) IB_Low30_value := Opening_value - ((Opening_value - IB_Low_value) * 3.0) End_Time := Start_Time + 86280000 //Add one complete Day minus 2 minutes in Milliseconds to extend Lines until new session starts Asia_Session_End_Time := Asia_Session_Start_Time + 86280000 Premarket_End_Time := Premarket_Start_Time + 3540000 // Add 59 minutes Day_Session_End := PrevD_Closing_time + 86280000 //if Extend_Asia_Lines == true //Asia_Session_End_Time := (Asia_Session_Start_Time + 86280000) //else //Asia_Session_End_Time := (Asia_Session_Start_Time + 20700000) // During German Summertime MESZ Eurex Opening at 02:00 // Asia_Session_End_Time := (Asia_Session_Start_Time + 24300000) // During German Wintertime MEZ Eurex Opening at 01:00 //#################################### // Plot Lines only x Days Back //#################################### _MILLISECONDS_IN_DAY = 24 * 60 * 60 * 1000 lastBarDate = timestamp(year(timenow), month(timenow), dayofmonth(timenow), hour(timenow), minute(timenow), second(timenow)) thisBarDate = timestamp(year, month, dayofmonth, hour, minute, second) daysLeft = math.floor((lastBarDate - thisBarDate) / _MILLISECONDS_IN_DAY) In_Plot_Range = daysLeft <= Plot_x_days //#################################### // Line Styles //#################################### Line_Style_Function(Line_Style_Option) => var string Line_Style = "" if Line_Style_Option == "dotted (┈)" Line_Style := line.style_dotted else if Line_Style_Option == "dashed (╌)" Line_Style := line.style_dashed else if Line_Style_Option == "arrow left (←)" Line_Style := line.style_arrow_left else if Line_Style_Option == "arrow right (→)" Line_Style := line.style_arrow_right else if Line_Style_Option == "arrows both (↔)" Line_Style := line.style_arrow_both else if Line_Style_Option == "solid (─)" Line_Style := line.style_solid Line_Style IB_Lines_Style = Line_Style_Function(IB_Lines_Style_Option) IB_Lines15_Style = Line_Style_Function(IB_Lines15_Style_Option) IB_Lines20_Style = Line_Style_Function(IB_Lines20_Style_Option) IB_Lines25_Style = Line_Style_Function(IB_Lines25_Style_Option) IB_Lines30_Style = Line_Style_Function(IB_Lines30_Style_Option) IB_Halfback_Line_Style = Line_Style_Function(IB_Halfback_Line_Style_Option) Premarket_High_Line_Style = Line_Style_Function(Premarket_High_Line_Style_Option) Premarket_Low_Line_Style = Line_Style_Function(Premarket_Low_Line_Style_Option) Opening_Line_Style = Line_Style_Function(Opening_Line_Style_Option) PrevD_Closing_Line_Style = Line_Style_Function(PrevD_Closing_Line_Style_Option) PrevD_High_Line_Style = Line_Style_Function(PrevD_High_Line_Style_Option) PrevD_Low_Line_Style = Line_Style_Function(PrevD_Low_Line_Style_Option) Asia_Session_High_Line_Style = Line_Style_Function(Asia_Session_High_Line_Style_Option) Asia_Session_Low_Line_Style = Line_Style_Function(Asia_Session_Low_Line_Style_Option) //#################################### // Plots //#################################### if Relevant_IB_Range and In_Plot_Range and timeframe.isintraday if Relevant_IB_Range[1] line.delete(IB_Low_Line) line.delete(IB_Low15_Line) line.delete(IB_Low20_Line) line.delete(IB_Low25_Line) line.delete(IB_Low30_Line) line.delete(IB_High_Line) line.delete(IB_High15_Line) line.delete(IB_High20_Line) line.delete(IB_High25_Line) line.delete(IB_High30_Line) line.delete(IB_Halfback_Line) line.delete(Premarket_High_Line) line.delete(Premarket_Low_Line) line.delete(Opening_Line) line.delete(Asia_Session_High_Line) line.delete(Asia_Session_Low_Line) label.delete(IB_Low_Label) label.delete(IB_Low15_Label) label.delete(IB_Low20_Label) label.delete(IB_Low25_Label) label.delete(IB_Low30_Label) label.delete(IB_High_Label) label.delete(IB_High15_Label) label.delete(IB_High20_Label) label.delete(IB_High25_Label) label.delete(IB_High30_Label) label.delete(IB_Halfback_Label) label.delete(Premarket_High_Label) label.delete(Premarket_Low_Label) label.delete(Opening_Label) label.delete(Asia_Session_High_Label) label.delete(Asia_Session_Low_Label) //Create IB high/low lines if Lines_IB_active IB_Low_Line := Lines_Plot(Start_Time, IB_Low_value, End_Time, IB_Lines_Color, IB_Lines_Style, IB_Lines_width) IB_High_Line := Lines_Plot(Start_Time, IB_High_value, End_Time, IB_Lines_Color, IB_Lines_Style, IB_Lines_width) if Lines_IB_active and Labels_active IB_Low_Label := label.new(x=End_Time, y=IB_Low_value, text= "IB_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines_Color,Labels_Transparency), style=label.style_label_left) IB_High_Label := label.new(x=End_Time, y=IB_High_value, text= "IB_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines_Color,Labels_Transparency), style=label.style_label_left) if Lines_IB_15_Extension_active IB_Low15_Line := Lines_Plot(Start_Time, IB_Low15_value, End_Time, IB_Lines15_Color, IB_Lines15_Style, IB_Lines15_width) IB_High15_Line := Lines_Plot(Start_Time, IB_High15_value, End_Time, IB_Lines15_Color, IB_Lines15_Style, IB_Lines15_width) if Lines_IB_15_Extension_active and Labels_active IB_Low15_Label := label.new(x=End_Time, y=IB_Low15_value, text= "IB_L1.5", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines15_Color,Labels_Transparency), style=label.style_label_left) IB_High15_Label := label.new(x=End_Time, y=IB_High15_value, text= "IB_H1.5", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines15_Color,Labels_Transparency), style=label.style_label_left) if Lines_IB_20_Extension_active IB_Low20_Line := Lines_Plot(Start_Time, IB_Low20_value, End_Time, IB_Lines20_Color, IB_Lines20_Style, IB_Lines20_width) IB_High20_Line := Lines_Plot(Start_Time, IB_High20_value, End_Time, IB_Lines20_Color, IB_Lines20_Style, IB_Lines20_width) if Lines_IB_20_Extension_active and Labels_active IB_Low20_Label := label.new(x=End_Time, y=IB_Low20_value, text= "IB_L2.0", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines20_Color,Labels_Transparency), style=label.style_label_left) IB_High20_Label := label.new(x=End_Time, y=IB_High20_value, text= "IB_H2.0", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines20_Color,Labels_Transparency), style=label.style_label_left) if Lines_IB_25_Extension_active IB_Low25_Line := Lines_Plot(Start_Time, IB_Low25_value, End_Time, IB_Lines25_Color, IB_Lines25_Style, IB_Lines25_width) IB_High25_Line := Lines_Plot(Start_Time, IB_High25_value, End_Time, IB_Lines25_Color, IB_Lines25_Style, IB_Lines25_width) if Lines_IB_25_Extension_active and Labels_active IB_Low25_Label := label.new(x=End_Time, y=IB_Low25_value, text= "IB_L2.5", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines25_Color,Labels_Transparency), style=label.style_label_left) IB_High25_Label := label.new(x=End_Time, y=IB_High25_value, text= "IB_H2.5", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines25_Color,Labels_Transparency), style=label.style_label_left) if Lines_IB_30_Extension_active IB_Low30_Line := Lines_Plot(Start_Time, IB_Low30_value, End_Time, IB_Lines30_Color, IB_Lines30_Style, IB_Lines30_width) IB_High30_Line := Lines_Plot(Start_Time, IB_High30_value, End_Time, IB_Lines30_Color, IB_Lines30_Style, IB_Lines30_width) if Lines_IB_30_Extension_active and Labels_active IB_Low30_Label := label.new(x=End_Time, y=IB_Low30_value, text= "IB_L3.0", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines30_Color,Labels_Transparency), style=label.style_label_left) IB_High30_Label := label.new(x=End_Time, y=IB_High30_value, text= "IB_H3.0", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Lines30_Color,Labels_Transparency), style=label.style_label_left) //Create Initial Balance Halfback line if Lines_IB_Halfback_active IB_Halfback_Line := Lines_Plot(Start_Time, IB_Halfback_value, End_Time, IB_Halfback_Line_Color, IB_Halfback_Line_Style, IB_Halfback_Line_width) if Lines_IB_Halfback_active and Labels_active IB_Halfback_Label := label.new(x=End_Time, y=IB_Halfback_value, text= "IB_HB", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(IB_Halfback_Line_Color,Labels_Transparency), style=label.style_label_left) //Create Premarket high/low lines if Lines_Premarket_active Premarket_High_Line := Lines_Plot(Premarket_Start_Time, Premarket_High_value, Premarket_End_Time, Premarket_High_Line_Color, Premarket_High_Line_Style, Premarket_Line_width) Premarket_Low_Line := Lines_Plot(Premarket_Start_Time, Premarket_Low_value, Premarket_End_Time, Premarket_Low_Line_Color, Premarket_Low_Line_Style, Premarket_Line_width) if Lines_Premarket_active and Labels_active Premarket_High_Label := label.new(x=Premarket_End_Time, y=Premarket_High_value, text= "Pmkt_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Premarket_High_Line_Color,Labels_Transparency), style=label.style_label_left) Premarket_Low_Label := label.new(x=Premarket_End_Time, y=Premarket_Low_value, text= "Pmkt_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Premarket_Low_Line_Color,Labels_Transparency), style=label.style_label_left) //Create Opening Line if Lines_Opening_active Opening_Line := Lines_Plot(Start_Time, Opening_value, End_Time, Opening_Line_Color, Opening_Line_Style, Opening_Line_width) if Lines_Opening_active and Labels_active Opening_Label := label.new(x=End_Time, y=Opening_value, text= "Open", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Opening_Line_Color,Labels_Transparency), style=label.style_label_left) //Create Asia Session high/low lines if Lines_Asia_Session_active Asia_Session_High_Line := Lines_Plot(Asia_Session_Start_Time, Asia_Session_High_value, Asia_Session_End_Time, Asia_Session_High_Line_Color, Asia_Session_High_Line_Style, Asia_Line_width) Asia_Session_Low_Line := Lines_Plot(Asia_Session_Start_Time, Asia_Session_Low_value, Asia_Session_End_Time, Asia_Session_Low_Line_Color, Asia_Session_Low_Line_Style, Asia_Line_width) if Lines_Asia_Session_active and Labels_active Asia_Session_High_Label := label.new(x=Asia_Session_End_Time, y=Asia_Session_High_value, text= "Asia_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Asia_Session_High_Line_Color,Labels_Transparency), style=label.style_label_left) Asia_Session_Low_Label := label.new(x=Asia_Session_End_Time, y=Asia_Session_Low_value, text= "Asia_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Asia_Session_Low_Line_Color,Labels_Transparency), style=label.style_label_left) //Create Premarket Session high/low lines else if Relevant_Premarket and In_Plot_Range and timeframe.isintraday if Relevant_Premarket[1] line.delete(Premarket_High_Line) line.delete(Premarket_Low_Line) label.delete(Premarket_High_Label) label.delete(Premarket_Low_Label) if Lines_Premarket_active Premarket_High_Line := Lines_Plot(Premarket_Start_Time, Premarket_High_value, Premarket_End_Time, Premarket_High_Line_Color, Premarket_High_Line_Style, Premarket_Line_width) Premarket_Low_Line := Lines_Plot(Premarket_Start_Time, Premarket_Low_value, Premarket_End_Time, Premarket_Low_Line_Color, Premarket_Low_Line_Style, Premarket_Line_width) if Lines_Premarket_active and Labels_active Premarket_High_Label := label.new(x=Premarket_End_Time, y=Premarket_High_value, text= "Pmkt_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Premarket_High_Line_Color,Labels_Transparency), style=label.style_label_left) Premarket_Low_Label := label.new(x=Premarket_End_Time, y=Premarket_Low_value, text= "Pmkt_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Premarket_Low_Line_Color,Labels_Transparency), style=label.style_label_left) //Create Asia Session high/low lines else if In_Asia_Session and In_Plot_Range and timeframe.isintraday if In_Asia_Session[1] line.delete(Asia_Session_High_Line) line.delete(Asia_Session_Low_Line) label.delete(Asia_Session_High_Label) label.delete(Asia_Session_Low_Label) if Lines_Asia_Session_active Asia_Session_High_Line := Lines_Plot(Asia_Session_Start_Time, Asia_Session_High_value, Asia_Session_End_Time, Asia_Session_High_Line_Color, Asia_Session_High_Line_Style, Asia_Line_width) Asia_Session_Low_Line := Lines_Plot(Asia_Session_Start_Time, Asia_Session_Low_value, Asia_Session_End_Time, Asia_Session_Low_Line_Color, Asia_Session_Low_Line_Style, Asia_Line_width) if Lines_Asia_Session_active and Labels_active Asia_Session_High_Label := label.new(x=Asia_Session_End_Time, y=Asia_Session_High_value, text= "Asia_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Asia_Session_High_Line_Color,Labels_Transparency), style=label.style_label_left) Asia_Session_Low_Label := label.new(x=Asia_Session_End_Time, y=Asia_Session_Low_value, text= "Asia_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(Asia_Session_Low_Line_Color,Labels_Transparency), style=label.style_label_left) //Plot Previous Day Lines newDay = dayofmonth != dayofmonth[1] if newDay and In_Plot_Range and timeframe.isintraday if PrevD_Lines_Closing_active PrevD_Closing_Line := Lines_Plot(PrevD_Closing_time, PrevD_Closing_value, Day_Session_End, PrevD_Closing_Line_Color, PrevD_Closing_Line_Style, PrevD_Closing_Line_width) if PrevD_Lines_Closing_active and Labels_active PrevD_Closing_Label := label.new(x=Day_Session_End, y=PrevD_Closing_value, text= "PrevD_C", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(PrevD_Closing_Line_Color,Labels_Transparency), style=label.style_label_left) if PrevD_Lines_High_active PrevD_High_Line := Lines_Plot(PrevD_Closing_time, PrevD_High_value, Day_Session_End, PrevD_High_Line_Color, PrevD_High_Line_Style, PrevD_High_Line_width) if PrevD_Lines_High_active and Labels_active PrevD_High_Label := label.new(x=Day_Session_End, y=PrevD_High_value, text= "PrevD_H", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(PrevD_High_Line_Color,Labels_Transparency), style=label.style_label_left) if PrevD_Lines_Low_active PrevD_Low_Line := Lines_Plot(PrevD_Closing_time, PrevD_Low_value, Day_Session_End, PrevD_Low_Line_Color, PrevD_Low_Line_Style, PrevD_Low_Line_width) if PrevD_Lines_Low_active and Labels_active PrevD_Low_Label := label.new(x=Day_Session_End, y=PrevD_Low_value, text= "PrevD_L", xloc=xloc.bar_time, yloc=yloc.price, color=color.new(color.black,100), textalign= text.align_right, textcolor=color.new(PrevD_Low_Line_Color,Labels_Transparency), style=label.style_label_left) //#################################### // Plots end! //#################################### //#################################### // Alert Conditions //#################################### crossover_IB_High = ta.crossover(close, IB_High_value) and not Relevant_IB_Range crossunder_IB_High = ta.crossunder(close, IB_High_value) and not Relevant_IB_Range crossover_IB_High15 = ta.crossover(close, IB_High15_value) and not Relevant_IB_Range crossunder_IB_High15 = ta.crossunder(close, IB_High15_value) and not Relevant_IB_Range crossover_IB_High20 = ta.crossover(close, IB_High20_value) and not Relevant_IB_Range crossunder_IB_High20 = ta.crossunder(close, IB_High20_value) and not Relevant_IB_Range crossover_IB_High25 = ta.crossover(close, IB_High25_value) and not Relevant_IB_Range crossunder_IB_High25 = ta.crossunder(close, IB_High25_value) and not Relevant_IB_Range crossover_IB_High30 = ta.crossover(close, IB_High30_value) and not Relevant_IB_Range crossunder_IB_High30 = ta.crossunder(close, IB_High30_value) and not Relevant_IB_Range crossover_IB_Low = ta.crossover(close, IB_Low_value) and not Relevant_IB_Range crossunder_IB_Low = ta.crossunder(close, IB_Low_value) and not Relevant_IB_Range crossover_IB_Low15 = ta.crossover(close, IB_Low15_value) and not Relevant_IB_Range crossunder_IB_Low15 = ta.crossunder(close, IB_Low15_value) and not Relevant_IB_Range crossover_IB_Low20 = ta.crossover(close, IB_Low20_value) and not Relevant_IB_Range crossunder_IB_Low20 = ta.crossunder(close, IB_Low20_value) and not Relevant_IB_Range crossover_IB_Low25 = ta.crossover(close, IB_Low25_value) and not Relevant_IB_Range crossunder_IB_Low25 = ta.crossunder(close, IB_Low25_value) and not Relevant_IB_Range crossover_IB_Low30 = ta.crossover(close, IB_Low30_value) and not Relevant_IB_Range crossunder_IB_Low30 = ta.crossunder(close, IB_Low30_value) and not Relevant_IB_Range crossover_IB_Halfback = ta.crossover(close, IB_Halfback_value) and not Relevant_IB_Range crossunder_IB_Halfback = ta.crossunder(close, IB_Halfback_value) and not Relevant_IB_Range crossover_Premarket_High = ta.crossover(close, Premarket_High_value) and not Relevant_Premarket crossunder_Premarket_High = ta.crossunder(close, Premarket_High_value) and not Relevant_Premarket crossover_Premarket_Low = ta.crossover(close, Premarket_Low_value) and not Relevant_Premarket crossunder_Premarket_Low = ta.crossunder(close, Premarket_Low_value) and not Relevant_Premarket crossover_Opening = ta.crossover(close, Opening_value) and not Relevant_IB_Range crossunder_Opening = ta.crossunder(close, Opening_value) and not Relevant_IB_Range crossover_PrevDay_Closing = ta.crossover(close, PrevD_Closing_value) crossunder_PrevDay_Closing = ta.crossunder(close, PrevD_Closing_value) crossover_PrevDay_High = ta.crossover(close, PrevD_High_value) crossunder_PrevDay_High = ta.crossunder(close, PrevD_High_value) crossover_PrevDay_Low = ta.crossover(close, PrevD_Low_value) crossunder_PrevDay_Low = ta.crossunder(close, PrevD_Low_value) crossover_Asia_Low = ta.crossover(close, Asia_Session_Low_value) and not In_Asia_Session crossunder_Asia_Low = ta.crossunder(close, Asia_Session_Low_value) and not In_Asia_Session crossover_Asia_High = ta.crossover(close, Asia_Session_High_value) and not In_Asia_Session crossunder_Asia_High = ta.crossunder(close, Asia_Session_High_value) and not In_Asia_Session alertcondition(crossover_IB_High, "Crossover IB High Line","Crossover IB High Line") alertcondition(crossunder_IB_High, "Crossunder IB High Line","Crossunder IB High Line") alertcondition(crossover_IB_High15, "Crossover IB High 1.5 Line","Crossover IB High 1.5 Line") alertcondition(crossunder_IB_High15, "Crossunder IB High 1.5 Line","Crossunder IB High 1.5 Line") alertcondition(crossover_IB_High20, "Crossover IB High 2.0 Line","Crossover IB High 2.0 Line") alertcondition(crossunder_IB_High20, "Crossunder IB High 2.0 Line","Crossunder IB High 2.0 Line") alertcondition(crossover_IB_High25, "Crossover IB High 2.5 Line","Crossover IB High 2.5 Line") alertcondition(crossunder_IB_High25, "Crossunder IB High 2.5 Line","Crossunder IB High 2.5 Line") alertcondition(crossover_IB_High30, "Crossover IB High 3.0 Line","Crossover IB High 3.0 Line") alertcondition(crossunder_IB_High30, "Crossunder IB High 3.0 Line","Crossunder IB High 3.0 Line") alertcondition(crossover_IB_Low, "Crossover IB Low Line","Crossover IB Low Line") alertcondition(crossunder_IB_Low, "Crossunder IB Low Line","Crossunder IB Low Line") alertcondition(crossover_IB_Low15, "Crossover IB Low 1.5 Line","Crossover IB Low 1.5 Line") alertcondition(crossunder_IB_Low15, "Crossunder IB Low 1.5 Line","Crossunder IB Low 1.5 Line") alertcondition(crossover_IB_Low20, "Crossover IB Low 2.0 Line","Crossover IB Low 2.0 Line") alertcondition(crossunder_IB_Low20, "Crossunder IB Low 2.0 Line","Crossunder IB Low 2.0 Line") alertcondition(crossover_IB_Low25, "Crossover IB Low 2.5 Line","Crossover IB Low 2.5 Line") alertcondition(crossunder_IB_Low25, "Crossunder IB Low 2.5 Line","Crossunder IB Low 2.5 Line") alertcondition(crossover_IB_Low30, "Crossover IB Low 3.0 Line","Crossover IB Low 3.0 Line") alertcondition(crossunder_IB_Low30, "Crossunder IB Low 3.0 Line","Crossunder IB Low 3.0 Line") alertcondition(crossover_IB_Halfback, "Crossover IB Halfback Line","Crossover IB Halfback Line") alertcondition(crossunder_IB_Halfback, "Crossunder IB Halfback Line","Crossunder IB Halfback Line") alertcondition(crossover_Premarket_High, "Crossover Premarket High Line","Crossover Premarket High Line") alertcondition(crossunder_Premarket_High, "Crossunder Premarket High Line","Crossunder Premarket High Line") alertcondition(crossover_Premarket_Low, "Crossover Premarket Low Line","Crossover Premarket Low Line") alertcondition(crossunder_Premarket_Low, "Crossunder Premarket Low Line","Crossunder Premarket Low Line") alertcondition(crossover_Opening, "Crossover Opening Line","Crossover Opening Line") alertcondition(crossunder_Opening, "Crossunder Opening Line","Crossunder Opening Line") alertcondition(crossover_PrevDay_Closing, "Crossover Previous Day Closing Line","Crossover Previous Day Closing Line") alertcondition(crossunder_PrevDay_Closing, "Crossunder Previous Day Closing Line","Crossunder Previous Day Closing Line") alertcondition(crossover_PrevDay_High, "Crossover Previous Day High Line","Crossover Previous Day High Line") alertcondition(crossunder_PrevDay_High, "Crossunder Previous Day High Line","Crossunder Previous Day High Line") alertcondition(crossover_PrevDay_Low, "Crossover Previous Day Low Line","Crossover Previous Day Low Line") alertcondition(crossunder_PrevDay_Low, "Crossunder Previous Day Low Line","Crossunder Previous Day Low Line") alertcondition(crossover_Asia_High, "Crossover Asia High Line","Crossover Asia High Line") alertcondition(crossunder_Asia_High, "Crossunder Asia High Line","Crossunder Asia High Line") alertcondition(crossover_Asia_Low, "Crossover Asia Low Line","Crossover Asia Low Line") alertcondition(crossunder_Asia_Low, "Crossunder Asia Low Line","Crossunder Asia Low Line") //#################################### // Alert Conditions end! //#################################### //#################################### // Data checks //#################################### //dt = time - time[1] //if barstate.islast and Lines_IB_active and timeframe.isintraday // label.new(time + 3*dt, close, str.tostring(Start_Time), xloc=xloc.bar_time) // label.new(time + 3*dt, close, str.tostring(Lines_IB_active), xloc=xloc.bar_time) //if barstate.islastconfirmedhistory // label.new(x=bar_index + 2, y=close, style=label.style_label_left, // color=color.new(color.yellow, 80), size=size.large, // text=syminfo.ticker + " has this data" + // "\nsource/exchange prefix:\n" + syminfo.prefix) // label.new(time + 3*dt, close, str.tostring(Lines_IB_active), xloc=xloc.bar_time)
München's Momentum Wave
https://www.tradingview.com/script/C5NERSl0-M%C3%BCnchen-s-Momentum-Wave/
CheatCode1
https://www.tradingview.com/u/CheatCode1/
121
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © CheatCode1 //@version=5 indicator("Munich\'s Momentum Wave", overlay = false) // Input value groupings src = input.source(close, 'Momentum Source', group = 'Momentum Values') len1 = input.int(21, 'Momentum Length', 1, 500, group = 'Momentum Values') lb = input.int(50, 'Lookback Left', 1, 500, group = 'Lookback periods') rb = input.int(7, 'Lookback Right', 1, 500, group = 'Lookback periods') off = input.int(0, ' Offset length', -100, 100, group = 'Background Color' ) lf = input.int(415, 'Mean Look Back Length', 1, 500, group = 'Lookback periods') //Variable Declerations m = ta.mom(src, len1) m_col1 = ta.rising(m, 2) m_col2 = ta.falling(m, 2) ma2_ = ta.ema(m, 21) ma3_ = ta.ema(m, 55) ma4_ = ta.ema(m, 200) fall1 = ta.falling(m, 2) ? true:false grow1 = ta.rising(m, 2) ? true:false basis1 = math.avg(ma2_, ma3_) b1A = ta.falling(m, 2) b1_col = ta.rising(m, 2) ? color.green : b1A ? color.red:color.white m_std = ta.stdev(m, len1) pivh = ta.pivothigh(basis1, lb, rb) pivl = ta.pivotlow(basis1, lb, rb) val1 = ta.valuewhen(pivh, m, 1 ) val0 = ta.valuewhen(pivh, m, 0 ) valn1 = ta.valuewhen(pivl, m, 1) valn0 = ta.valuewhen(pivl, m, 0) bAVG = math.avg(basis1, m) //Double Declared for fill function >>> highm1 = ta.highest(bAVG, lf) lowm1 = ta.lowest(bAVG, lf) ma5_ = math.avg(highm1, lowm1) highm = plot(highm1, '', #73E600, 1, plot.style_line, display = display.none, editable = false) lowm = plot(lowm1, '', #E66763, 1, plot.style_line, display = display.none, editable = false) b2_col = basis1 >= ma5_ ? color.new(color.green, 95):(basis1 <= ma5_ ? color.new(color.red, 95):color.new(color.white, 100)) //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series //Munichs Moving Average Series maCol(maX, maL, m, src, len1) => m == ta.mom(src, len1) diff_ = ta.change(maX) macol = diff_ >= 0 and maX > maL and maX <= m ? color.new(#6AE635, 25): (diff_ < 0 and maX > maL and maX >= m ? color.new(#A80E00, 25): (diff_ <= 0 and maX < maL and maX >= m ? color.new(#E15C58, 25): (diff_ >= 0 and maX < maL and m >= maX ? color.new(color.green, 0) : color.new(color.white, 100)))) macol maL = ta.ema(m, 100) //Double Declared for fill Function ma2 = plot(ma2_, 'MA2', maCol(ma2_, maL, m, src, len1), 2, plot.style_line, editable = false) ma3 = plot(ma3_, 'MA3', maCol(ma3_, maL, m, src, len1), 2, plot.style_line, editable = false) //Plot Excecutions plot(maL, 'maL', maL >= m ? color.red: maL <= m ? color.green:na, 4, plot.style_line, editable = false) plot(basis1, 'Munich\ Momentum', m >= basis1 and not fall1 ? color.aqua:(m < basis1 and not grow1 ? color.yellow:color.white) , 4, plot.style_circles, offset = -3) fill(ma2, ma3, color.new(color.yellow, 88), '') bgcolor(b2_col, off, false, title = 'Background Color') plot(ma5_, 'Mean Length', basis1 >= m ? color.red: color.green, 2)
BTMM|TDI
https://www.tradingview.com/script/ailrNbYh-BTMM-TDI/
The_Trading_Jedi
https://www.tradingview.com/u/The_Trading_Jedi/
242
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © bullcatcherJC //@version=5 indicator("BTMM|TDI", overlay=false) // USER Interface RSI_input = input.int(title="RSI", defval=21, minval=5, group='TDI Components', inline="RSI") RSI_c = input.color(title="Color", defval=#000000, group='TDI Components', inline="RSI") TL_input = input.int(title="TrendLine", defval=7, minval=3, group='TDI Components', inline="TL") TL_c = input.color(title="Color", defval=#FF0000, group='TDI Components', inline="TL") BL_input = input.int(title="BaseLine", defval=34, minval=14, group='TDI Components', inline="BL") BL_c = input.color(title="Color", defval=color.yellow, group='TDI Components', inline="BL") VB_input = input.float(title="Volatility Bands", defval=1.6185, minval=1.0, group='TDI Components', inline="VB") VB_c = input.color(title="Color", defval=#b2ebf2, group='TDI Components', inline="VB") BU_c = input.color(title="Bullish", defval=#0064FF, group='Color Scheme', inline="CS") BE_c = input.color(title="Bearish", defval=#FF0000, group='Color Scheme', inline="CS") is_showDataTBL = input.bool(title='Show Data Table', defval=false) // Position Size Calculator is_showLotSize = input.bool(title="Activate Lot Size Module", defval=false) i_accountCurrency = input.string('USD', title='Account Currency', options=['GBP', 'USD', 'EUR', 'AUD', 'NZD', 'JPY', 'CAD', 'CHF']) Capital = input.float(defval=50000, title="Account Balance", minval=0.0) RiskPerTrade = input.float(defval=1.0, title="Risk % on Balance", minval=0.0) / 100 PipsRisked = input.float(defval=30, title="Pips at Risk", minval=0.1) // Convert to Base Account Currency sec01 = i_accountCurrency == syminfo.currency ? syminfo.ticker : syminfo.currency + i_accountCurrency sec03 = i_accountCurrency == syminfo.currency ? 1 : request.security(sec01, '1', close) pip_Movement = syminfo.mintick == 0.00001 ? 10 : syminfo.mintick == 0.001 ? 1000 : 100 AmountRisked = math.round(Capital * RiskPerTrade) Lotsize = AmountRisked / (PipsRisked * pip_Movement) / sec03 int mintime = time if time[1] mintime := math.min(mintime, time - time[1]) mintime txt = 'Currency = ' + i_accountCurrency + '\nBalance = ' + str.tostring(Capital,'#,###') + '\nRisk = ' + str.tostring(RiskPerTrade*100) + '%' + '\nAmount = ' + str.tostring(AmountRisked,'#,###') + '\nPips = ' + str.tostring(PipsRisked,'#.#') + '\nLot Size = ' + str.tostring(Lotsize,'#.##') if is_showLotSize var label psclabel = na label.delete(psclabel) psclabel := label.new(x=time + 15*mintime, y=40, xloc=xloc.bar_time, text=txt, color=color.black, textcolor=color.white, textalign=text.align_left, size=size.normal) psclabel // TDI Setup r = ta.rsi(close, RSI_input) r_plot = ta.sma(r, 2) r_tl = ta.sma(r, TL_input) r_gbl = ta.sma(r, BL_input) SD = VB_input * ta.stdev(r, BL_input) VB_UP = r_gbl + SD VB_DOWN = r_gbl - SD // Higher TimeFrame RSI vs TL Bias var HTF3 = timeframe.isintraday and 3 * timeframe.multiplier <= 960 ? str.tostring(3 * timeframe.multiplier, '') : '3D' r_bias = r_plot - r_tl > 0 ? BU_c : BE_c HTF_c = request.security(syminfo.tickerid, HTF3, r_bias) bgcolor(color.new(HTF_c, 85)) // Plots UL = 70, MID = 50, LL = 30 hline(MID, 'Balance Level', color=color.white, linestyle=hline.style_dotted) hline(UL, 'Upper Level', color=color.white, linestyle=hline.style_dotted) hline(LL, 'Lower Level', color=color.white, linestyle=hline.style_dotted) plot(r_plot, 'RSI', color=RSI_c, linewidth=2) plot(r_tl, 'RSI TrendLine', color=TL_c, linewidth=2) plot(r_gbl, 'Market Baseline', color=BL_c, linewidth=2) plot(VB_UP, 'Volatility Upper', color=VB_c, linewidth=2) plot(VB_DOWN, 'Volatility Lower', color=VB_c, linewidth=2) // MACD Zero Lag Trend Bias dema(period) => 2 * ta.ema(close, period) - ta.ema(ta.ema(close, period), period) mzl = dema(12) - dema(26) plotshape(mzl < 0, title='Trend DN', style=shape.labeldown, location=location.top, color=BE_c) plotshape(mzl > 0, title='Trend UP', style=shape.labelup, location=location.bottom, color=BU_c) // BTMM EMA Position vs Closing Price Scoring y1 = ta.ema(close, 13), y2 = ta.ema(close, 50), y3 = ta.ema(close, 200), y4 = ta.ema(close, 800) p_vs_y1 = close>y1 ? 1 : close<y1 ? -1 : 0 p_vs_y2 = close>y2 ? 1 : close<y2 ? -1 : 0 p_vs_y3 = close>y3 ? 1 : close<y3 ? -1 : 0 p_vs_y4 = close>y4 ? 1 : close<y4 ? -1 : 0 y1_vs_y2 = y1>y2 ? 1 : y1<y2 ? -1 : 0 y1_vs_y3 = y1>y3 ? 1 : y1<y3 ? -1 : 0 y1_vs_y4 = y1>y4 ? 1 : y1<y4 ? -1 : 0 y2_vs_y3 = y2>y3 ? 1 : y2<y3 ? -1 : 0 y2_vs_y4 = y2>y4 ? 1 : y2<y4 ? -1 : 0 y3_vs_y4 = y3>y4 ? 1 : y3<y4 ? -1 : 0 EMA_score = p_vs_y1 + p_vs_y2 + p_vs_y3 + p_vs_y4 + y1_vs_y2 + y1_vs_y3 + y1_vs_y4 + y2_vs_y3 + y2_vs_y4 + y3_vs_y4 EMA_score_C = EMA_score>0 ? BU_c : EMA_score<0 ? BE_c : color.yellow // DataTable + Color Scheme Definitions r_plotc = r_plot > 50 ? BU_c : BE_c r_tlc = r_plot > r_tl ? BU_c : BE_c r_gblc = r_gbl > r_gbl[1] ? BU_c : BE_c if is_showDataTBL var main_table = table.new(position.middle_right, 5, 5, frame_color=#000000, frame_width=2, border_color=#000000, border_width=1) table.cell(main_table, 0, 0, 'TF', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 1, 0, 't3', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 2, 0, 't2', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 3, 0, 't1', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 4, 0, 't0', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 0, 1, 'R', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 0, 2, 'TL', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 0, 3, 'BL', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) table.cell(main_table, 0, 4, 'EMA', text_color=color.white, text_size=size.small, bgcolor=color.new(color.black, 50)) for i = 1 to 4 table.cell(main_table, i, 1, str.tostring(r_plot[4-i], '#.#'), text_color=#000000, text_size=size.small, bgcolor=color.new(r_plotc[4-i], 50)) table.cell(main_table, i, 2, str.tostring(r_tl[4-i], '#.#'), text_color=#000000, text_size=size.small, bgcolor=color.new(r_tlc[4-i], 50)) table.cell(main_table, i, 3, str.tostring(r_gbl[4-i], '#.#'), text_color=#000000, text_size=size.small, bgcolor=color.new(r_gblc[4-i], 50)) table.cell(main_table, i, 4, str.tostring(EMA_score[4-i], '#'), text_color=#000000, text_size=size.small, bgcolor=color.new(EMA_score_C[4-i], 50))
Pivot-Based Channels & Bands [Misu]
https://www.tradingview.com/script/XQOZbYrE-Pivot-Based-Channels-Bands-Misu/
Fontiramisu
https://www.tradingview.com/u/Fontiramisu/
53
study
5
CC-BY-NC-SA-4.0
// 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/ // © Fontiramisu //@version=5 indicator("Pivot Channel-Bands [Misu]", shorttitle="P Channel-Band [Misu]", overlay=true) // import Fontiramisu/fontLib/80 as fontilab import Fontiramisu/fontilab/6 as fontilab // res = input.timeframe(title="Resolution", defval=timeframe.period) // resClose = request.security(syminfo.tickerid, res, close, barmerge.gaps_off, barmerge.lookahead_on) // resHigh = request.security(syminfo.tickerid, res, high, barmerge.gaps_off, barmerge.lookahead_on) // resLow = request.security(syminfo.tickerid, res, low, barmerge.gaps_off, barmerge.lookahead_on) showBands = input.bool(false, title="Pivot Bands", group="show :") showMidBands = input.bool(false, title="Pivot Mid Band", group="show :") showChannels = input.bool(true, title="Pivot Channels", group="show :") showMidChannel = input.bool(true, title="Pivot Mid Channel", group="show :") // ------ Find dev pivots ------ [ // -- Var user input -- var devTooltip = "Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot." var depthTooltip = "The minimum number of bars that will be taken into account when analyzing pivots." thresholdMultiplier = input.float(title="Deviation", defval=2.5, minval=0, tooltip=devTooltip) depth = input.int(title="Depth", defval=10, minval=1, tooltip=depthTooltip) // Prepare pivot variables var line lineLast = na var int iLast = 0 // Index last var int iPrev = 0 // Index previous var float pLast = 0 // Price last var float pLastHigh = 0 // Price last var float pLastLow = 0 // Price last var isHighLast = false // If false then the last pivot was a pivot low isPivotUpdate = false pivotHighHist = array.new<float>(0,0) pivotLowHist = array.new<float>(0,0) // Get pivot information from dev pivot finding function [dupLineLast, dupIsHighLast, dupIPrev, dupILast, dupPLast, dupPLastHigh, dupPLastLow] = fontilab.getDeviationPivots(thresholdMultiplier, depth, lineLast, isHighLast, iLast, pLast, true, close, high, low)//resClose, resHigh, resLow) if not na(dupIsHighLast) lineLast := dupLineLast isHighLast := dupIsHighLast iPrev := dupIPrev iLast := dupILast pLast := dupPLast pLastHigh := dupPLastHigh pLastLow := dupPLastLow isPivotUpdate := true // Get last Pivots. var highP = 0.0 var lowP = 0.0 var midP = 0.0 highP := isHighLast ? pLast : highP lowP := not isHighLast ? pLast : lowP midP := (highP + lowP)/2 // Calculate predicated pivots, support and resistances. pPivot = (highP + lowP + close)/3 supp1 = 2 * pPivot - highP resi1 = 2 * pPivot - lowP supp2 = pPivot - (resi1 - supp1) resi2 = pPivot + (resi1 - supp1) // Plot. // Channels. pPivotPlot = plot(pPivot, title='pPivot', linewidth=2, display=showMidChannel ? display.all : display.none, editable=true, color=color.yellow) supp1Plot = plot(supp1, title='supp1', linewidth=1, display=showChannels ? display.all : display.none, editable=true, color=color.green) supp2Plot = plot(supp2, title='supp2', linewidth=1, display=showChannels ? display.all : display.none, editable=true, color=color.green) resi1Plot = plot(resi1, title='resi1', linewidth=1, display=showChannels ? display.all : display.none, color=color.red) resi2Plot = plot(resi2, title='resi2', linewidth=1, display=showChannels ? display.all : display.none, color=color.red) // Bands. midPPlot = plot(midP, title='Mid Pivot', linewidth=2, display=showMidBands ? display.all : display.none, color=color.yellow) highPlot = plot(highP, title='High Pivot', linewidth=2, display=showBands ? display.all : display.none, color=color.red) lowPlot = plot(lowP, title='Low Pivot', linewidth=2, display=showBands ? display.all : display.none, color=color.green) fill(supp1Plot, supp2Plot, color.new(color.green, 90), 'Upper Area', display=showChannels ? display.all : display.none) fill(resi1Plot, resi2Plot, color.new(color.red, 90), 'Lower Area', display=showChannels ? display.all : display.none) // ] ------ Find dev pivots ------ [ // show_table = input(true, "Show table with stats", group = "Drawings") // if show_table // var table ATHtable = table.new(position.bottom_right, 10, 10, frame_color = color.gray, bgcolor = color.gray, border_width = 1, frame_width = 1, border_color = color.white) // table.cell(ATHtable, 1, 0, text="pLastLow", bgcolor=color.green, tooltip="") // table.cell(ATHtable, 1, 0, text=str.tostring(pLastLow), bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 1, text="resWeights", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 1, text=textresWeights, bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 2, text="resBarIndexes", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 2, text=textresBarIndexes, bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 3, text="resNbHighs", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 3, text=textresNbHighs, bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 4, text="resNbLows", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 4, text=textresNbLows, bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 5, text="Prices", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 5, text=str.tostring(textTopResPrices), bgcolor=color.green, tooltip="") // table.cell(ATHtable, 0, 6, text="Weights", bgcolor=color.silver, tooltip="") // table.cell(ATHtable, 1, 6, text=str.tostring(textTopResWeights), bgcolor=color.green, tooltip="") // ]
MAs+VOl
https://www.tradingview.com/script/myFD2DqR-MAs-VOl/
Swing-Trades
https://www.tradingview.com/u/Swing-Trades/
3
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Syed.Shahbaaz.Quadri //@version=5 indicator("MAs+VOl", overlay=true) length1 = input.int(50, "Fast SMA") source1 = close FastSMA=ta.sma(source1, length1) plot(FastSMA, color=color.new(color.red,20),title="FastSMA") length2 = input.int(100, "Slow SMA") source2 = close SlowSMA=ta.sma(source2, length2) plot(SlowSMA, color=color.new(color.green,20),title="SlowSMA") //length3 = input.int(50, "Fast EMA") //source3 = close //FastEMA=ta.ema(source3, length3) //FastEMA=ta.ema(close, 50) //plot(FastSMA, color=color.new(color.yellow,20),title="FastEMA") //length4 = input.int(100, "Slow EMA") //source4 = close //SlowEMA=ta.ema(source4, length4) //SlowEMA=ta.ema(close, 100) //plot(SlowSMA, color=color.new(color.blue,20),title="SlowEMA") //FastEMA=ta.ema(close, 50) //SlowEMA=ta.ema(close, 100) plot(ta.ema(close,50),title="50 EMA",color = color.new(color.yellow, 20)) plot(ta.ema(close,100),title="100 EMA",color = color.new(color.blue, 20))
PUBG
https://www.tradingview.com/script/sauBdqt2-PUBG/
cryptoberger
https://www.tradingview.com/u/cryptoberger/
13
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 //DESCRIPTION //Pluto star appears on a chart when price goes in the in the extreme price range territory, i.e. beyond 2 standard deviation from the mean (or mid Bollinger Band). //What makes a Pluto Star appear on a chart: //1. Check if the candle[1]'s' high and low, both are completely outside of the Bollinger Bands (close, 20, 2) - Lets call it Pluto Star Candle //2. Pluto Star Candle must not be a result of sudden price movement. Hence the previous candle[2] must give a BB Blast. // In other words, the candle[2] must have it's either open or close outside of Bollinger Bands, to confirm a BB Blast before the Pluto Star //3. Candle, following the Pluto Star must not break the high (in case of upper BB i.e. short call) or low (in case of lower BB, i.e. long call), to confirm the reversal to the mean // This implies that Pluto Star appears on chart, above/below the next candle of actual Pluto Star Candle //----- The above 3 conditions make a Pluto Star appear on a chart. But one must wait for a trade signal. Read the following conditions //4. There is a signal line, which is nothing but ema(close,5) //5. The red dotted line is the signal range (and also acts as Stop Loss). The price must close above/below the signal line within the signal range //6. For a red Pluto Star (short call), the price must close below the signal line, within next 6 candles (signal range). Else there is no trigger for a trade //7. For a green Pluto Star (long call), the price must close above the signal line, within next 6 candles (signal range). Else there is no trigger for a trade //8. If any of the candle crosses the Stop Loss line within signal range, there is no trigger for a trade //9. In a normal scenario, the price must return to the mean, i.e. mid Bollinger Band. In best case scenario, it must go to the opposite side Bollinger Band. //Recommendation: Test it with Nifty and Bank Nifty charts on 30 mins and 1 hour timeframes study(title="Pluto", overlay=true) var bool isPlutoS = false var bool isPlutoL = false //Read BB data [mBB, uBB, lBB] = bb(close, 20, 2) //Check if there previous candle was a Pluto Star Candle for Long call if (high < high[1]) and (high[1] > uBB[1]) and (low[1] > uBB[1]) and ((open[2] > uBB[2]) or (close[2] > uBB[2])) isPlutoS := true else isPlutoS := false //Check if there previous candle was a Pluto Star Candle for Long call if (low > low[1]) and (high[1] < lBB[1]) and (low[1] < lBB[1]) and ((open[2] < lBB[2]) or (close[2] < lBB[2])) isPlutoL := true else isPlutoL := false //Plot signal line ema5 = ema(close, 5) plot(ema5, color=color.gray, style=plot.style_line, linewidth=1,title="Signal Line") //Plot the star above/below the current candle plotchar(isPlutoS, title="SELL", char='★', location=location.abovebar, color=color.red, size=size.small) plotchar(isPlutoL, title="BUY", char='★', location=location.belowbar, color=color.green, size=size.small) //Plot the signal range and stop loss dotted line if isPlutoS and (high[2] > high[1]) line.new(bar_index[1], high[2], bar_index+5, high[2], style=line.style_dotted, color=color.red, width=2) if isPlutoS and (high[2] < high[1]) line.new(bar_index[1], high[1], bar_index+5, high[1], style=line.style_dotted, color=color.red, width=2) if isPlutoL and (low[2] < low[1]) line.new(bar_index[1], low[2], bar_index+5, low[2], style=line.style_dotted, color=color.red, width=2) if isPlutoL and (low[2] > low[1]) line.new(bar_index[1], low[1], bar_index+5, low[1], style=line.style_dotted, color=color.red, width=2) isPlutoS := false isPlutoL := false
Dynamic Relative Strength
https://www.tradingview.com/script/viOkGyHw-Dynamic-Relative-Strength/
RohitNain
https://www.tradingview.com/u/RohitNain/
23
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Inspired from © bharatTrader //@version=4 study("Dynamic Relative Strength", shorttitle="Dynamic Relative Strength") //Input source = input(title="Source", type=input.source, defval=close) comparativeTickerId = input("NSE:CNXSMALLCAP", type=input.symbol, title="Comparative Symbol") length = input(123, type=input.integer, minval=1, title="Daily Period") inpLen2 = input(52, title= 'Weekly Period') length := timeframe.isweekly ? inpLen2 : length Monthly = input(10, title='Monthly Period') length := timeframe.ismonthly ? Monthly : length // Other Settings showZeroLine = input(defval=true, type=input.bool, title="Show Zero Line") showRefDateLbl = input(defval=false, type=input.bool, title="Show Reference Label") toggleRSColor = input(defval=true, type=input.bool, title="Toggle RS color on crossovers") showRSTrend = input(defval=false, type=input.bool, title="RS Trend,", group="RS Trend", inline="RS Trend") base = input(title="Range", minval=1, defval=5, group="RS Trend", inline="RS Trend") showMA = input(defval=false, type=input.bool, title="Show Moving Average,", group="RS Mean", inline="RS Mean") lengthMA = input(61, type=input.integer, minval=1, title="Period", group="RS Mean", inline="RS Mean") //Set up baseSymbol = security(syminfo.tickerid, timeframe.period, source) comparativeSymbol = security(comparativeTickerId, timeframe.period, source) //Calculations res = ((baseSymbol/baseSymbol[length])/(comparativeSymbol/comparativeSymbol[length]) - 1) resColor = toggleRSColor ? res > 0 ? color.green : color.red : color.blue refDay = showRefDateLbl and barstate.islast ? dayofmonth(time[length]) : na refMonth = showRefDateLbl and barstate.islast ? month(time[length]) : na refYear = showRefDateLbl and barstate.islast ? year(time[length]) : na refLabelStyle = res[length] > 0 ? label.style_label_up : label.style_label_down refDateLabel = showRefDateLbl and barstate.islast ? label.new(bar_index - length, 0, text="RS-" + tostring(length) + " reference, " + tostring(refDay) + "-" + tostring(refMonth) + "-" + tostring(refYear), color=color.blue, style=refLabelStyle, yloc=yloc.price) : na y0 = res - res[base] angle0 = atan(y0/base) // radians zeroLineColor = iff(showRSTrend, angle0 > 0.0 ? color.green : color.maroon, color.maroon) //Plot plot(showZeroLine ? 0 : na, linewidth=2, color=zeroLineColor, title="Zero Line / RS Trend") plot(res, title="RS", linewidth=2, color= resColor) plot(showMA ? sma(res, lengthMA) : na, color=color.gray, title="MA")
10 EMA Strategy
https://www.tradingview.com/script/GSzcGCrs-10-EMA-Strategy/
steph1980
https://www.tradingview.com/u/steph1980/
24
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © steph1980 //@version=5 indicator('10 EMA RLT', overlay=true) // user input maLength = input.int(title='MA Length', defval=10) maType = input.string(title='MA type', defval='EMA', options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"]) getMA(_maType, _maLength) => switch _maType 'EMA' => ta.ema(close, _maLength) 'SMA' => ta.sma(close, _maLength) 'HMA' => ta.hma(close, _maLength) 'WMA' => ta.wma(close, _maLength) 'VWMA' => ta.vwma(close, _maLength) 'VWAP' => ta.vwap 'DEMA' => e1=ta.ema(close, _maLength) e2=ta.ema(e1, _maLength) 2 * e1 - e2 ma = getMA(maType, maLength) bullCandle = open < close bearCandle = open > close var int inTrade = 0 longCondition = bearCandle and close > ma and inTrade == 0 shortCondition = bullCandle and close < ma and inTrade == 0 if longCondition inTrade := 1 if shortCondition inTrade := -1 if close < ma and inTrade == 1 or close > ma and inTrade == -1 inTrade :=0 plot(ma) plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, title='long') plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, title='short') alertcondition(longCondition, title='10 EMA Long trade', message='10 EMA longtrade detected on {{ticker}}') alertcondition(shortCondition, title='10 EMA short trade', message='10 EMA shorttrade detected on {{ticker}}')
Normalized MACD with RSI [bkeevil]
https://www.tradingview.com/script/EtUYT322-Normalized-MACD-with-RSI-bkeevil/
bkeevil
https://www.tradingview.com/u/bkeevil/
114
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © bkeevil // @version=5 indicator(title="Normalized MACD with RSI", shorttitle="MACD-RSI", timeframe="", timeframe_gaps=true) // Getting inputs src = input(title="Source", defval=close) fast_ma_period = input.int(defval=12, title='Fast MA Period') slow_ma_period = input.int(defval=26, title='Slow MA Period') sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA", "WMA"]) signal_ma_period = input.int(defval=9, title='Signal MA Period', minval=1, maxval=50) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA", "WMA"]) norm_ma_period = input.int(defval=50, title='Normalization Period', minval=1) rsi_period = input.int(defval=14, title="RSI Period",minval=1) // Colors // Plot colors col_macd_up = color.new(color.green,50) col_macd_down = color.new(color.red,50) col_signal = color.new(color.yellow,50) col_grow_above = #004400 col_fall_above = #008800 col_grow_below = #440000 col_fall_below = #880000 col_rsi = color.new(color.blue,50) col_background = color.new(color.blue,95) // Function Definitions ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) slow_ma = ma(src,slow_ma_period,sma_source) fast_ma = ma(src,fast_ma_period,sma_source) ratio = math.min(slow_ma,fast_ma) / math.max(slow_ma,fast_ma) standard_macd = (slow_ma < fast_ma) ? 1 - ratio : ratio - 1 lowest_macd = ta.lowest(standard_macd,norm_ma_period) normalized_macd = ((standard_macd - lowest_macd) / (ta.highest(standard_macd,norm_ma_period) - lowest_macd) + .000001) * 2 - 1 macd = (norm_ma_period < 2) ? standard_macd : normalized_macd signal = ma(macd,signal_ma_period,sma_signal) diff = macd - signal histogram = diff > 1 ? 1 : diff < -1 ? -1 : diff histogram_color = histogram >= 0 ? (histogram > histogram[1] ? col_grow_above : col_fall_above) : (histogram > histogram[1] ? col_grow_below : col_fall_below) macd_color = macd > macd[1] ? col_macd_up : col_macd_down rsi_up = ta.rma(math.max(ta.change(src), 0), rsi_period) rsi_down = ta.rma(-math.min(ta.change(src), 0), rsi_period) rsi = rsi_down == 0 ? 100 : rsi_up == 0 ? 0 : 2 - (4 / (1 + rsi_up / rsi_down)) rsiUpperBand = hline(0.6, "RSI Upper Band", color=color.silver, editable = false) rsiLowerBand = hline(-0.6, "RSI Lower Band", color=color.silver, editable = false) fill(rsiUpperBand, rsiLowerBand, col_background, title="Background Fill") plot(histogram,"Histogram",color=histogram_color,style=plot.style_columns) plot(signal,"Signal",color=col_signal,display=display.none) plot(macd,"MACD",linewidth=2,color=macd_color) plot(rsi,"RSI",linewidth=2,color=col_rsi) plotshape(ta.cross(macd,signal) ? macd : na,"MACD Crossover",style=shape.circle,location=location.absolute,editable=false,size=size.tiny,color=macd_color)
[GTH] Revenue
https://www.tradingview.com/script/gfGfY9Uo-GTH-Revenue/
gehteha
https://www.tradingview.com/u/gehteha/
19
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © gehteha //@version=5 indicator(title="[GTH] Revenue", precision=0) r1 = request.financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ") r2 = request.financial(syminfo.tickerid, "SALES_ESTIMATES", "FQ") col_p = input.color(title="Postive Surprise", defval=color.green) col_n = input.color(title="Negative Surprise", defval=color.red) h_off = input.int(title="Horizontal Offset", defval=0) col = r1 > r2 ? col_p : col_n plotcandle(r1,r1,r2,r2, title="Revenue", color = col, wickcolor=#00000000, bordercolor=col, editable=false) plot(r1, title="Reported Revenue", color=color.black, linewidth=3) //plot(r3, title="Total Revenue, last Twelve Trailing Months", color=color.blue, linewidth=3) float diff = r1-r1[1] perc = r1 != r1[1] ? (r1/r1[1])-1 : na bool plot_perc = r1 != r1[1] ? true : false if plot_perc label.new(bar_index + h_off , r1, str.tostring(str.format("{0,number,percent}", math.abs(perc))), color = diff>0 ? col_p : col_n, style = diff>0 ? label.style_label_down : label.style_label_up, textcolor=color.white)
Minus1percent
https://www.tradingview.com/script/JVjft9rU/
erador84
https://www.tradingview.com/u/erador84/
8
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © erador84 //@version=5 indicator("BuyPrice-1percent", overlay=true) //minus 1 percent variable variableValue = (close*0.99) labelText = str.tostring (variableValue) ourLabel = label.new(x=bar_index, y=close, text= "-1%: " + labelText, color=color.black, textcolor=color.white, style=label.style_label_right, size=size.large, textalign=text.align_right) label.set_x(id=ourLabel, x=bar_index[2]) label.delete(ourLabel[1])
Sushman Ticcy Toppy Percent Change Monitor
https://www.tradingview.com/script/XL3EP3uL-Sushman-Ticcy-Toppy-Percent-Change-Monitor/
shwirleyq
https://www.tradingview.com/u/shwirleyq/
7
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shwirleyq //@version=5 indicator("Percent Change Monitor", overlay=false) currentTimeFrame = input.timeframe("","Timeframe") stock1 = input.symbol(defval="AAPL", title="Symbol 1") stock2 = input.symbol(defval="MSFT", title="Symbol 2") stock3 = input.symbol(defval="AMZN", title="Symbol 3") stock4 = input.symbol(defval="TSLA", title="Symbol 4") stock5 = input.symbol(defval="GOOGL", title="Symbol 5") Price1 = request.security(stock1, currentTimeFrame, close[1]) Price2 = request.security(stock1, currentTimeFrame, close) Price3 = request.security(stock2, currentTimeFrame, close[1]) Price4 = request.security(stock2, currentTimeFrame, close) Price5 = request.security(stock3, currentTimeFrame, close[1]) Price6 = request.security(stock3, currentTimeFrame, close) Price7 = request.security(stock4, currentTimeFrame, close[1]) Price8 = request.security(stock4, currentTimeFrame, close) Price9 = request.security(stock5, currentTimeFrame, close[1]) Price10 = request.security(stock5, currentTimeFrame, close) PercentChg3 = ((Price2 - Price1)+ (Price4 - Price3)+ (Price6 - Price5)+ (Price8 - Price7)+ (Price10 - Price9))/ (Price1+Price3+Price5+Price7+Price9) *100 plot(PercentChg3,style=plot.style_columns,color=PercentChg3>0 ? color.green : color.red)
SMAs Distances
https://www.tradingview.com/script/K1MdJk2l-SMAs-Distances/
seba34e
https://www.tradingview.com/u/seba34e/
23
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Create by seba34e //@version=5 indicator('SMAs Distances', overlay=true) // Inputs and variables src = input (close, title = 'Source MA', tooltip='Source', group= "SMA") sma1 = input.int ( 8, title = 'SMA 1', minval=1, tooltip='SMA #1', inline="SMA1") sma2 = input.int ( 20, title = 'SMA 2', minval=1, tooltip='SMA #2', inline="SMA2") sma3 = input.int ( 50, title = 'SMA 3', minval=1, tooltip='SMA #3', inline="SMA3") sma4 = input.int ( 100, title = 'SMA 4', minval=1, tooltip='SMA #4', inline="SMA4") sma5 = input.int ( 200, title = 'SMA 4', minval=1, tooltip='SMA #5', inline="SMA5") alertSma1 = input.float (1.00, title = "* Alert on +/- (%)", inline="SMA1") alertSma2 = input.float (1.00, title = "* Alert on +/- (%)", inline="SMA2") alertSma3 = input.float (1.00, title = "* Alert on +/- (%)", inline="SMA3") alertSma4 = input.float (1.00, title = "* Alert on +/- (%)", inline="SMA4") alertSma5 = input.float (1.00, title = "* Alert on +/- (%)", inline="SMA5") HighLevel = input.float (80.00, title = "RSI High Level", tooltip = "RSI High Level", group = "RSI") LowLevel = input.float (20.00, title = "RSI Low Level" , tooltip = "RSI Low Level" , group = "RSI") srcRSI = input (close, title = 'Source RSI' , tooltip = "RSI Source" , group = "RSI") RSILengh = input.int ( 14, title = 'RSI Lenght' , tooltip = "RSI Lengh" , group = "RSI", minval=1) tablePosition = input.string(title = 'Table Position', defval="Top right", options = ["Top right", "Top left", "Bottom right", "Bottom left"], tooltip='Position of the table') xRSI = ta.rsi(srcRSI, RSILengh) // Get EMAs xSMA1 = ta.sma (src, sma1) xSMA2 = ta.sma (src, sma2) xSMA3 = ta.sma (src, sma3) xSMA4 = ta.sma (src, sma4) xSMA5 = ta.sma (src, sma5) // Ploting EMAs plot(xSMA1, color=color.new(color.yellow, 0), linewidth=2, title='SMA 1') plot(xSMA2, color=color.new(color.blue , 0), linewidth=2, title='SMA 2') plot(xSMA3, color=color.new(color.purple, 0), linewidth=2, title='SMA 3') plot(xSMA4, color=color.new(color.maroon, 0), linewidth=2, title='SMA 4') plot(xSMA5, color=color.new(color.red , 0), linewidth=2, title='SMA 5') // Prepare table var bgcolor = color.new(color.black, 50) var table emaTable = table.new(tablePosition == "Top right" ? position.top_right : tablePosition == "Top left" ? position.top_left : tablePosition == "Bottom right" ? position.bottom_right : position.bottom_left, 5, 6, border_width=4) fill_Cell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) => _cellText = _title + '\n' + _value table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor, text_halign=text.align_right) // Prepare cells if barstate.islast fill_Cell(emaTable, 0, 0, 'Distance SMA ' + str.tostring (sma1) , str.tostring(close - xSMA1, "0.00") + '\n ' + str.tostring(1-xSMA1/close, "0.00%") , bgcolor, color.yellow) fill_Cell(emaTable, 1, 0, 'Distance SMA ' + str.tostring (sma2) , str.tostring(close - xSMA2, "0.00") + '\n ' + str.tostring(1-xSMA2/close, "0.00%") , bgcolor, color.blue) fill_Cell(emaTable, 0, 1, 'Distance SMA ' + str.tostring (sma3) , str.tostring(close - xSMA3, "0.00") + '\n ' + str.tostring(1-xSMA3/close, "0.00%") , bgcolor, color.purple) fill_Cell(emaTable, 1, 1, 'Distance SMA ' + str.tostring (sma4) , str.tostring(close - xSMA4, "0.00") + '\n ' + str.tostring(1-xSMA4/close, "0.00%") , bgcolor, color.maroon) fill_Cell(emaTable, 0, 2, 'Distance SMA ' + str.tostring (sma5) , str.tostring(close - xSMA5, "0.00") + '\n ' + str.tostring(1-xSMA5/close, "0.00%") , bgcolor, color.red) fill_Cell(emaTable, 1, 2, 'RSI\n' + str.tostring (xRSI, "0.00") , xRSI > HighLevel ? "Overbought" : xRSI < LowLevel ? "Oversold" : "Neutral" , bgcolor, color.white) alertcondition (math.abs((xSMA1/close*100)-100) >= alertSma1, title = "Alerta on SMA 1", message="Alerta on SMA 1") alertcondition (math.abs((xSMA2/close*100)-100) >= alertSma2, title = "Alerta on SMA 2", message="Alerta on SMA 2") alertcondition (math.abs((xSMA3/close*100)-100) >= alertSma3, title = "Alerta on SMA 3", message="Alerta on SMA 3") alertcondition (math.abs((xSMA4/close*100)-100) >= alertSma4, title = "Alerta on SMA 4", message="Alerta on SMA 4") alertcondition (math.abs((xSMA5/close*100)-100) >= alertSma5, title = "Alerta on SMA 5", message="Alerta on SMA 5")
Copy/Paste Levels Creator Tool
https://www.tradingview.com/script/2iod1yUp-Copy-Paste-Levels-Creator-Tool/
SamRecio
https://www.tradingview.com/u/SamRecio/
35
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("Copy/Paste Levels Creator Tool", overlay = true) linestyle(_input) => _input == "___"?"solid": _input == "- - -"?"dashed": _input == ". . ."?"dotted": _input == "___zone"?"solid_zone": _input == "- - -zone"?"dashed_zone": _input == ". . .zone"?"dotted_zone": na symbol1 = input.symbol("", title = "Ticker", confirm = true, group = "Level 1", inline = "2") col1 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 1", inline = "2") style1 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 1", inline = "2") width1 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 1", inline = "2") txt1 = input.string("", title = "Text", confirm = true, group = "Level 1", inline = "2") lvls1 = input.string("", title = "Levels", confirm = true, group = "Level 1", inline = "2", tooltip = "LEVELS\nInsert as many levels as needed for this style of line on the specified Ticker.\nSeparate by commas (,)\nNo Spaces\nNo comma at the end!\nExample:\n100,100.5,101,102,103") output1 = symbol1 + "," + (col1=="default"?" ":col1) + "," + linestyle(style1) + "," + str.tostring(width1*-1) + "," + (txt1 == ""?" ":txt1) + "," + str.replace_all(lvls1," ","") + ";" tog_2 = input.bool(false, title = "Enable Level 2", confirm = true, group = "Level 2", inline = "1") symbol2 = input.symbol("", title = "Ticker", confirm = true, group = "Level 2", inline = "2") col2 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 2", inline = "2") style2 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 2", inline = "2") width2 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 2", inline = "2") txt2 = input.string("", title = "Text", confirm = true, group = "Level 2", inline = "2") lvls2 = input.string("", title = "Levels", confirm = true, group = "Level 2", inline = "2") output2 = tog_2?(symbol2 + "," + (col2=="default"?" ":col2) + "," + linestyle(style2) + "," + str.tostring(width2*-1) + "," + (txt2 == ""?" ":txt2) + "," + str.replace_all(lvls2," ","") + ";"):"" tog_3 = input.bool(false, title = "Enable Level 3", confirm = true, group = "Level 3", inline = "1") symbol3 = input.symbol("", title = "Ticker", confirm = true, group = "Level 3", inline = "2") col3 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 3", inline = "2") style3 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 3", inline = "2") width3 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 3", inline = "2") txt3 = input.string("", title = "Text", confirm = true, group = "Level 3", inline = "2") lvls3 = input.string("", title = "Levels", confirm = true, group = "Level 3", inline = "2") output3 = tog_3?(symbol3 + "," + (col3=="default"?" ":col3) + "," + linestyle(style3) + "," + str.tostring(width3*-1) + "," + (txt3 == ""?" ":txt3) + "," + str.replace_all(lvls3," ","") + ";"):"" tog_4 = input.bool(false, title = "Enable Level 4", confirm = true, group = "Level 4", inline = "1") symbol4 = input.symbol("", title = "Ticker", confirm = true, group = "Level 4", inline = "2") col4 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 4", inline = "2") style4 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 4", inline = "2") width4 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 4", inline = "2") txt4 = input.string("", title = "Text", confirm = true, group = "Level 4", inline = "2") lvls4 = input.string("", title = "Levels", confirm = true, group = "Level 4", inline = "2") output4 = tog_4?(symbol4 + "," + (col4=="default"?" ":col4) + "," + linestyle(style4) + "," + str.tostring(width4*-1) + "," + (txt4 == ""?" ":txt4) + "," + str.replace_all(lvls4," ","") + ";"):"" tog_5 = input.bool(false, title = "Enable Level 5", confirm = true, group = "Level 5", inline = "1") symbol5 = input.symbol("", title = "Ticker", confirm = true, group = "Level 5", inline = "2") col5 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 5", inline = "2") style5 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 5", inline = "2") width5 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 5", inline = "2") txt5 = input.string("", title = "Text", confirm = true, group = "Level 5", inline = "2") lvls5 = input.string("", title = "Levels", confirm = true, group = "Level 5", inline = "2") output5 = tog_5?(symbol5 + "," + (col5=="default"?" ":col5) + "," + linestyle(style5) + "," + str.tostring(width5*-1) + "," + (txt5 == ""?" ":txt5) + "," + str.replace_all(lvls5," ","") + ";"):"" tog_6 = input.bool(false, title = "Enable Level 6", confirm = true, group = "Level 6", inline = "1") symbol6 = input.symbol("", title = "Ticker", confirm = true, group = "Level 6", inline = "2") col6 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 6", inline = "2") style6 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 6", inline = "2") width6 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 6", inline = "2") txt6 = input.string("", title = "Text", confirm = true, group = "Level 6", inline = "2") lvls6 = input.string("", title = "Levels", confirm = true, group = "Level 6", inline = "2") output6 = tog_6?(symbol6 + "," + (col6=="default"?" ":col6) + "," + linestyle(style6) + "," + str.tostring(width6*-1) + "," + (txt6 == ""?" ":txt6) + "," + str.replace_all(lvls6," ","") + ";"):"" tog_7 = input.bool(false, title = "Enable Level 7", confirm = true, group = "Level 7", inline = "1") symbol7 = input.symbol("", title = "Ticker", confirm = true, group = "Level 7", inline = "2") col7 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 7", inline = "2") style7 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 7", inline = "2") width7 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 7", inline = "2") txt7 = input.string("", title = "Text", confirm = true, group = "Level 7", inline = "2") lvls7 = input.string("", title = "Levels", confirm = true, group = "Level 7", inline = "2") output7 = tog_7?(symbol7 + "," + (col7=="default"?" ":col7) + "," + linestyle(style7) + "," + str.tostring(width7*-1) + "," + (txt7 == ""?" ":txt7) + "," + str.replace_all(lvls7," ","") + ";"):"" tog_8 = input.bool(false, title = "Enable Level 8", confirm = true, group = "Level 8", inline = "1") symbol8 = input.symbol("", title = "Ticker", confirm = true, group = "Level 8", inline = "2") col8 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 8", inline = "2") style8 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 8", inline = "2") width8 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 8", inline = "2") txt8 = input.string("", title = "Text", confirm = true, group = "Level 8", inline = "2") lvls8 = input.string("", title = "Levels", confirm = true, group = "Level 8", inline = "2") output8 = tog_8?(symbol8 + "," + (col8=="default"?" ":col8) + "," + linestyle(style8) + "," + str.tostring(width8*-1) + "," + (txt8 == ""?" ":txt8) + "," + str.replace_all(lvls8," ","") + ";"):"" tog_9 = input.bool(false, title = "Enable Level 9", confirm = true, group = "Level 9", inline = "1") symbol9 = input.symbol("", title = "Ticker", confirm = true, group = "Level 9", inline = "2") col9 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 9", inline = "2") style9 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 9", inline = "2") width9 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 9", inline = "2") txt9 = input.string("", title = "Text", confirm = true, group = "Level 9", inline = "2") lvls9 = input.string("", title = "Levels", confirm = true, group = "Level 9", inline = "2") output9 = tog_9?(symbol9 + "," + (col9=="default"?" ":col9) + "," + linestyle(style9) + "," + str.tostring(width9*-1) + "," + (txt9 == ""?" ":txt9) + "," + str.replace_all(lvls9," ","") + ";"):"" tog_10 = input.bool(false, title = "Enable Level 10", confirm = true, group = "Level 10", inline = "1") symbol10 = input.symbol("", title = "Ticker", confirm = true, group = "Level 10", inline = "2") col10 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 10", inline = "2") style10 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 10", inline = "2") width10 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 10", inline = "2") txt10 = input.string("", title = "Text", confirm = true, group = "Level 10", inline = "2") lvls10 = input.string("", title = "Levels", confirm = true, group = "Level 10", inline = "2") output10 = tog_10?(symbol10 + "," + (col10=="default"?" ":col10) + "," + linestyle(style10) + "," + str.tostring(width10*-1) + "," + (txt10 == ""?" ":txt10) + "," + str.replace_all(lvls10," ","") + ";"):"" tog_11 = input.bool(false, title = "Enable Level 11", confirm = true, group = "Level 11", inline = "1") symbol11 = input.symbol("", title = "Ticker", confirm = true, group = "Level 11", inline = "2") col11 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 11", inline = "2") style11 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 11", inline = "2") width11 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 11", inline = "2") txt11 = input.string("", title = "Text", confirm = true, group = "Level 11", inline = "2") lvls11 = input.string("", title = "Levels", confirm = true, group = "Level 11", inline = "2", tooltip = "LEVELS\nInsert as many levels as needed for this style of line on the specified Ticker.\nSeparate by commas (,)\nNo Spaces\nNo comma at the end!\nExample:\n100,100.5,101,102,103") output11 = tog_11?symbol11 + "," + (col11=="default"?" ":col11) + "," + linestyle(style11) + "," + str.tostring(width11*-1) + "," + (txt11 == ""?" ":txt11) + "," + str.replace_all(lvls11," ","") + ";":"" tog_12 = input.bool(false, title = "Enable Level 12", confirm = true, group = "Level 12", inline = "1") symbol12 = input.symbol("", title = "Ticker", confirm = true, group = "Level 12", inline = "2") col12 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 12", inline = "2") style12 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 12", inline = "2") width12 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 12", inline = "2") txt12 = input.string("", title = "Text", confirm = true, group = "Level 12", inline = "2") lvls12 = input.string("", title = "Levels", confirm = true, group = "Level 12", inline = "2") output12 = tog_12?(symbol12 + "," + (col12=="default"?" ":col12) + "," + linestyle(style12) + "," + str.tostring(width12*-1) + "," + (txt12 == ""?" ":txt12) + "," + str.replace_all(lvls12," ","") + ";"):"" tog_13 = input.bool(false, title = "Enable Level 13", confirm = true, group = "Level 13", inline = "1") symbol13 = input.symbol("", title = "Ticker", confirm = true, group = "Level 13", inline = "2") col13 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 13", inline = "2") style13 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 13", inline = "2") width13 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 13", inline = "2") txt13 = input.string("", title = "Text", confirm = true, group = "Level 13", inline = "2") lvls13 = input.string("", title = "Levels", confirm = true, group = "Level 13", inline = "2") output13 = tog_13?(symbol13 + "," + (col13=="default"?" ":col13) + "," + linestyle(style13) + "," + str.tostring(width13*-1) + "," + (txt13 == ""?" ":txt13) + "," + str.replace_all(lvls13," ","") + ";"):"" tog_14 = input.bool(false, title = "Enable Level 14", confirm = true, group = "Level 14", inline = "1") symbol14 = input.symbol("", title = "Ticker", confirm = true, group = "Level 14", inline = "2") col14 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 14", inline = "2") style14 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 14", inline = "2") width14 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 14", inline = "2") txt14 = input.string("", title = "Text", confirm = true, group = "Level 14", inline = "2") lvls14 = input.string("", title = "Levels", confirm = true, group = "Level 14", inline = "2") output14 = tog_14?(symbol14 + "," + (col14=="default"?" ":col14) + "," + linestyle(style14) + "," + str.tostring(width14*-1) + "," + (txt14 == ""?" ":txt14) + "," + str.replace_all(lvls14," ","") + ";"):"" tog_15 = input.bool(false, title = "Enable Level 15", confirm = true, group = "Level 15", inline = "1") symbol15 = input.symbol("", title = "Ticker", confirm = true, group = "Level 15", inline = "2") col15 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 15", inline = "2") style15 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 15", inline = "2") width15 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 15", inline = "2") txt15 = input.string("", title = "Text", confirm = true, group = "Level 15", inline = "2") lvls15 = input.string("", title = "Levels", confirm = true, group = "Level 15", inline = "2") output15 = tog_15?(symbol15 + "," + (col15=="default"?" ":col15) + "," + linestyle(style15) + "," + str.tostring(width15*-1) + "," + (txt15 == ""?" ":txt15) + "," + str.replace_all(lvls15," ","") + ";"):"" tog_16 = input.bool(false, title = "Enable Level 16", confirm = true, group = "Level 16", inline = "1") symbol16 = input.symbol("", title = "Ticker", confirm = true, group = "Level 16", inline = "2") col16 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 16", inline = "2") style16 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 16", inline = "2") width16 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 16", inline = "2") txt16 = input.string("", title = "Text", confirm = true, group = "Level 16", inline = "2") lvls16 = input.string("", title = "Levels", confirm = true, group = "Level 16", inline = "2") output16 = tog_16?(symbol16 + "," + (col16=="default"?" ":col16) + "," + linestyle(style16) + "," + str.tostring(width16*-1) + "," + (txt16 == ""?" ":txt16) + "," + str.replace_all(lvls16," ","") + ";"):"" tog_17 = input.bool(false, title = "Enable Level 17", confirm = true, group = "Level 17", inline = "1") symbol17 = input.symbol("", title = "Ticker", confirm = true, group = "Level 17", inline = "2") col17 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 17", inline = "2") style17 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 17", inline = "2") width17 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 17", inline = "2") txt17 = input.string("", title = "Text", confirm = true, group = "Level 17", inline = "2") lvls17 = input.string("", title = "Levels", confirm = true, group = "Level 17", inline = "2") output17 = tog_17?(symbol17 + "," + (col17=="default"?" ":col17) + "," + linestyle(style17) + "," + str.tostring(width17*-1) + "," + (txt17 == ""?" ":txt17) + "," + str.replace_all(lvls17," ","") + ";"):"" tog_18 = input.bool(false, title = "Enable Level 18", confirm = true, group = "Level 18", inline = "1") symbol18 = input.symbol("", title = "Ticker", confirm = true, group = "Level 18", inline = "2") col18 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 18", inline = "2") style18 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 18", inline = "2") width18 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 18", inline = "2") txt18 = input.string("", title = "Text", confirm = true, group = "Level 18", inline = "2") lvls18 = input.string("", title = "Levels", confirm = true, group = "Level 18", inline = "2") output18 = tog_18?(symbol18 + "," + (col18=="default"?" ":col18) + "," + linestyle(style18) + "," + str.tostring(width18*-1) + "," + (txt18 == ""?" ":txt18) + "," + str.replace_all(lvls18," ","") + ";"):"" tog_19 = input.bool(false, title = "Enable Level 19", confirm = true, group = "Level 19", inline = "1") symbol19 = input.symbol("", title = "Ticker", confirm = true, group = "Level 19", inline = "2") col19 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 19", inline = "2") style19 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 19", inline = "2") width19 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 19", inline = "2") txt19 = input.string("", title = "Text", confirm = true, group = "Level 19", inline = "2") lvls19 = input.string("", title = "Levels", confirm = true, group = "Level 19", inline = "2") output19 = tog_19?(symbol19 + "," + (col19=="default"?" ":col19) + "," + linestyle(style19) + "," + str.tostring(width19*-1) + "," + (txt19 == ""?" ":txt19) + "," + str.replace_all(lvls19," ","") + ";"):"" tog_20 = input.bool(false, title = "Enable Level 20", confirm = true, group = "Level 20", inline = "1") symbol20 = input.symbol("", title = "Ticker", confirm = true, group = "Level 20", inline = "2") col20 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 20", inline = "2") style20 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 20", inline = "2") width20 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 20", inline = "2") txt20 = input.string("", title = "Text", confirm = true, group = "Level 20", inline = "2") lvls20 = input.string("", title = "Levels", confirm = true, group = "Level 20", inline = "2") output20 = tog_20?(symbol20 + "," + (col20=="default"?" ":col20) + "," + linestyle(style20) + "," + str.tostring(width20*-1) + "," + (txt20 == ""?" ":txt20) + "," + str.replace_all(lvls20," ","") + ";"):"" tog_21 = input.bool(false, title = "Enable Level 21", confirm = true, group = "Level 21", inline = "1") symbol21 = input.symbol("", title = "Ticker", confirm = true, group = "Level 21", inline = "2") col21 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 21", inline = "2") style21 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 21", inline = "2") width21 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 21", inline = "2") txt21 = input.string("", title = "Text", confirm = true, group = "Level 21", inline = "2") lvls21 = input.string("", title = "Levels", confirm = true, group = "Level 21", inline = "2", tooltip = "LEVELS\nInsert as many levels as needed for this style of line on the specified Ticker.\nSeparate by commas (,)\nNo Spaces\nNo comma at the end!\nExample:\n100,100.5,101,102,103") output21 = tog_21?symbol21 + "," + (col21=="default"?" ":col21) + "," + linestyle(style21) + "," + str.tostring(width21-1) + "," + (txt21 == ""?" ":txt21) + "," + str.replace_all(lvls21," ","") + ";":"" tog_22 = input.bool(false, title = "Enable Level 22", confirm = true, group = "Level 22", inline = "1") symbol22 = input.symbol("", title = "Ticker", confirm = true, group = "Level 22", inline = "2") col22 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 22", inline = "2") style22 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 22", inline = "2") width22 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 22", inline = "2") txt22 = input.string("", title = "Text", confirm = true, group = "Level 22", inline = "2") lvls22 = input.string("", title = "Levels", confirm = true, group = "Level 22", inline = "2") output22 = tog_22?(symbol22 + "," + (col22=="default"?" ":col22) + "," + linestyle(style22) + "," + str.tostring(width22-1) + "," + (txt22 == ""?" ":txt22) + "," + str.replace_all(lvls22," ","") + ";"):"" tog_23 = input.bool(false, title = "Enable Level 23", confirm = true, group = "Level 23", inline = "1") symbol23 = input.symbol("", title = "Ticker", confirm = true, group = "Level 23", inline = "2") col23 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 23", inline = "2") style23 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 23", inline = "2") width23 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 23", inline = "2") txt23 = input.string("", title = "Text", confirm = true, group = "Level 23", inline = "2") lvls23 = input.string("", title = "Levels", confirm = true, group = "Level 23", inline = "2") output23 = tog_23?(symbol23 + "," + (col23=="default"?" ":col23) + "," + linestyle(style23) + "," + str.tostring(width23-1) + "," + (txt23 == ""?" ":txt23) + "," + str.replace_all(lvls23," ","") + ";"):"" tog_24 = input.bool(false, title = "Enable Level 24", confirm = true, group = "Level 24", inline = "1") symbol24 = input.symbol("", title = "Ticker", confirm = true, group = "Level 24", inline = "2") col24 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 24", inline = "2") style24 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 24", inline = "2") width24 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 24", inline = "2") txt24 = input.string("", title = "Text", confirm = true, group = "Level 24", inline = "2") lvls24 = input.string("", title = "Levels", confirm = true, group = "Level 24", inline = "2") output24 = tog_24?(symbol24 + "," + (col24=="default"?" ":col24) + "," + linestyle(style24) + "," + str.tostring(width24-1) + "," + (txt24 == ""?" ":txt24) + "," + str.replace_all(lvls24," ","") + ";"):"" tog_25 = input.bool(false, title = "Enable Level 25", confirm = true, group = "Level 25", inline = "1") symbol25 = input.symbol("", title = "Ticker", confirm = true, group = "Level 25", inline = "2") col25 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 25", inline = "2") style25 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 25", inline = "2") width25 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 25", inline = "2") txt25 = input.string("", title = "Text", confirm = true, group = "Level 25", inline = "2") lvls25 = input.string("", title = "Levels", confirm = true, group = "Level 25", inline = "2") output25 = tog_25?(symbol25 + "," + (col25=="default"?" ":col25) + "," + linestyle(style25) + "," + str.tostring(width25-1) + "," + (txt25 == ""?" ":txt25) + "," + str.replace_all(lvls25," ","") + ";"):"" tog_26 = input.bool(false, title = "Enable Level 26", confirm = true, group = "Level 26", inline = "1") symbol26 = input.symbol("", title = "Ticker", confirm = true, group = "Level 26", inline = "2") col26 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 26", inline = "2") style26 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 26", inline = "2") width26 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 26", inline = "2") txt26 = input.string("", title = "Text", confirm = true, group = "Level 26", inline = "2") lvls26 = input.string("", title = "Levels", confirm = true, group = "Level 26", inline = "2") output26 = tog_26?(symbol26 + "," + (col26=="default"?" ":col26) + "," + linestyle(style26) + "," + str.tostring(width26-1) + "," + (txt26 == ""?" ":txt26) + "," + str.replace_all(lvls26," ","") + ";"):"" tog_27 = input.bool(false, title = "Enable Level 27", confirm = true, group = "Level 27", inline = "1") symbol27 = input.symbol("", title = "Ticker", confirm = true, group = "Level 27", inline = "2") col27 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 27", inline = "2") style27 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 27", inline = "2") width27 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 27", inline = "2") txt27 = input.string("", title = "Text", confirm = true, group = "Level 27", inline = "2") lvls27 = input.string("", title = "Levels", confirm = true, group = "Level 27", inline = "2") output27 = tog_27?(symbol27 + "," + (col27=="default"?" ":col27) + "," + linestyle(style27) + "," + str.tostring(width27-1) + "," + (txt27 == ""?" ":txt27) + "," + str.replace_all(lvls27," ","") + ";"):"" tog_28 = input.bool(false, title = "Enable Level 28", confirm = true, group = "Level 28", inline = "1") symbol28 = input.symbol("", title = "Ticker", confirm = true, group = "Level 28", inline = "2") col28 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 28", inline = "2") style28 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 28", inline = "2") width28 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 28", inline = "2") txt28 = input.string("", title = "Text", confirm = true, group = "Level 28", inline = "2") lvls28 = input.string("", title = "Levels", confirm = true, group = "Level 28", inline = "2") output28 = tog_28?(symbol28 + "," + (col28=="default"?" ":col28) + "," + linestyle(style28) + "," + str.tostring(width28-1) + "," + (txt28 == ""?" ":txt28) + "," + str.replace_all(lvls28," ","") + ";"):"" tog_29 = input.bool(false, title = "Enable Level 29", confirm = true, group = "Level 29", inline = "1") symbol29 = input.symbol("", title = "Ticker", confirm = true, group = "Level 29", inline = "2") col29 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 29", inline = "2") style29 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 29", inline = "2") width29 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 29", inline = "2") txt29 = input.string("", title = "Text", confirm = true, group = "Level 29", inline = "2") lvls29 = input.string("", title = "Levels", confirm = true, group = "Level 29", inline = "2") output29 = tog_29?(symbol29 + "," + (col29=="default"?" ":col29) + "," + linestyle(style29) + "," + str.tostring(width29-1) + "," + (txt29 == ""?" ":txt29) + "," + str.replace_all(lvls29," ","") + ";"):"" tog_30 = input.bool(false, title = "Enable Level 30", confirm = true, group = "Level 30", inline = "1") symbol30 = input.symbol("", title = "Ticker", confirm = true, group = "Level 30", inline = "2") col30 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 30", inline = "2") style30 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 30", inline = "2") width30 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 30", inline = "2") txt30 = input.string("", title = "Text", confirm = true, group = "Level 30", inline = "2") lvls30 = input.string("", title = "Levels", confirm = true, group = "Level 30", inline = "2") output30 = tog_30?(symbol30 + "," + (col30=="default"?" ":col30) + "," + linestyle(style30) + "," + str.tostring(width30-1) + "," + (txt30 == ""?" ":txt30) + "," + str.replace_all(lvls30," ","") + ";"):"" tog_31 = input.bool(false, title = "Enable Level 31", confirm = true, group = "Level 31", inline = "1") symbol31 = input.symbol("", title = "Ticker", confirm = true, group = "Level 31", inline = "2") col31 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 31", inline = "2") style31 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 31", inline = "2") width31 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 31", inline = "2") txt31 = input.string("", title = "Text", confirm = true, group = "Level 31", inline = "2") lvls31 = input.string("", title = "Levels", confirm = true, group = "Level 31", inline = "2", tooltip = "LEVELS\nInsert as many levels as needed for this style of line on the specified Ticker.\nSeparate by commas (,)\nNo Spaces\nNo comma at the end!\nExample:\n100,100.5,101,102,103") output31 = tog_31?symbol31 + "," + (col31=="default"?" ":col31) + "," + linestyle(style31) + "," + str.tostring(width31-1) + "," + (txt31 == ""?" ":txt31) + "," + str.replace_all(lvls31," ","") + ";":"" tog_32 = input.bool(false, title = "Enable Level 32", confirm = true, group = "Level 32", inline = "1") symbol32 = input.symbol("", title = "Ticker", confirm = true, group = "Level 32", inline = "2") col32 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 32", inline = "2") style32 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 32", inline = "2") width32 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 32", inline = "2") txt32 = input.string("", title = "Text", confirm = true, group = "Level 32", inline = "2") lvls32 = input.string("", title = "Levels", confirm = true, group = "Level 32", inline = "2") output32 = tog_32?(symbol32 + "," + (col32=="default"?" ":col32) + "," + linestyle(style32) + "," + str.tostring(width32-1) + "," + (txt32 == ""?" ":txt32) + "," + str.replace_all(lvls32," ","") + ";"):"" tog_33 = input.bool(false, title = "Enable Level 33", confirm = true, group = "Level 33", inline = "1") symbol33 = input.symbol("", title = "Ticker", confirm = true, group = "Level 33", inline = "2") col33 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 33", inline = "2") style33 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 33", inline = "2") width33 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 33", inline = "2") txt33 = input.string("", title = "Text", confirm = true, group = "Level 33", inline = "2") lvls33 = input.string("", title = "Levels", confirm = true, group = "Level 33", inline = "2") output33 = tog_33?(symbol33 + "," + (col33=="default"?" ":col33) + "," + linestyle(style33) + "," + str.tostring(width33-1) + "," + (txt33 == ""?" ":txt33) + "," + str.replace_all(lvls33," ","") + ";"):"" tog_34 = input.bool(false, title = "Enable Level 34", confirm = true, group = "Level 34", inline = "1") symbol34 = input.symbol("", title = "Ticker", confirm = true, group = "Level 34", inline = "2") col34 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 34", inline = "2") style34 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 34", inline = "2") width34 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 34", inline = "2") txt34 = input.string("", title = "Text", confirm = true, group = "Level 34", inline = "2") lvls34 = input.string("", title = "Levels", confirm = true, group = "Level 34", inline = "2") output34 = tog_34?(symbol34 + "," + (col34=="default"?" ":col34) + "," + linestyle(style34) + "," + str.tostring(width34-1) + "," + (txt34 == ""?" ":txt34) + "," + str.replace_all(lvls34," ","") + ";"):"" tog_35 = input.bool(false, title = "Enable Level 35", confirm = true, group = "Level 35", inline = "1") symbol35 = input.symbol("", title = "Ticker", confirm = true, group = "Level 35", inline = "2") col35 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 35", inline = "2") style35 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 35", inline = "2") width35 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 35", inline = "2") txt35 = input.string("", title = "Text", confirm = true, group = "Level 35", inline = "2") lvls35 = input.string("", title = "Levels", confirm = true, group = "Level 35", inline = "2") output35 = tog_35?(symbol35 + "," + (col35=="default"?" ":col35) + "," + linestyle(style35) + "," + str.tostring(width35-1) + "," + (txt35 == ""?" ":txt35) + "," + str.replace_all(lvls35," ","") + ";"):"" tog_36 = input.bool(false, title = "Enable Level 36", confirm = true, group = "Level 36", inline = "1") symbol36 = input.symbol("", title = "Ticker", confirm = true, group = "Level 36", inline = "2") col36 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 36", inline = "2") style36 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 36", inline = "2") width36 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 36", inline = "2") txt36 = input.string("", title = "Text", confirm = true, group = "Level 36", inline = "2") lvls36 = input.string("", title = "Levels", confirm = true, group = "Level 36", inline = "2") output36 = tog_36?(symbol36 + "," + (col36=="default"?" ":col36) + "," + linestyle(style36) + "," + str.tostring(width36-1) + "," + (txt36 == ""?" ":txt36) + "," + str.replace_all(lvls36," ","") + ";"):"" tog_37 = input.bool(false, title = "Enable Level 37", confirm = true, group = "Level 37", inline = "1") symbol37 = input.symbol("", title = "Ticker", confirm = true, group = "Level 37", inline = "2") col37 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 37", inline = "2") style37 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 37", inline = "2") width37 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 37", inline = "2") txt37 = input.string("", title = "Text", confirm = true, group = "Level 37", inline = "2") lvls37 = input.string("", title = "Levels", confirm = true, group = "Level 37", inline = "2") output37 = tog_37?(symbol37 + "," + (col37=="default"?" ":col37) + "," + linestyle(style37) + "," + str.tostring(width37-1) + "," + (txt37 == ""?" ":txt37) + "," + str.replace_all(lvls37," ","") + ";"):"" tog_38 = input.bool(false, title = "Enable Level 38", confirm = true, group = "Level 38", inline = "1") symbol38 = input.symbol("", title = "Ticker", confirm = true, group = "Level 38", inline = "2") col38 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 38", inline = "2") style38 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 38", inline = "2") width38 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 38", inline = "2") txt38 = input.string("", title = "Text", confirm = true, group = "Level 38", inline = "2") lvls38 = input.string("", title = "Levels", confirm = true, group = "Level 38", inline = "2") output38 = tog_38?(symbol38 + "," + (col38=="default"?" ":col38) + "," + linestyle(style38) + "," + str.tostring(width38-1) + "," + (txt38 == ""?" ":txt38) + "," + str.replace_all(lvls38," ","") + ";"):"" tog_39 = input.bool(false, title = "Enable Level 39", confirm = true, group = "Level 39", inline = "1") symbol39 = input.symbol("", title = "Ticker", confirm = true, group = "Level 39", inline = "2") col39 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 39", inline = "2") style39 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 39", inline = "2") width39 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 39", inline = "2") txt39 = input.string("", title = "Text", confirm = true, group = "Level 39", inline = "2") lvls39 = input.string("", title = "Levels", confirm = true, group = "Level 39", inline = "2") output39 = tog_39?(symbol39 + "," + (col39=="default"?" ":col39) + "," + linestyle(style39) + "," + str.tostring(width39-1) + "," + (txt39 == ""?" ":txt39) + "," + str.replace_all(lvls39," ","") + ";"):"" tog_40 = input.bool(false, title = "Enable Level 40", confirm = true, group = "Level 40", inline = "1") symbol40 = input.symbol("", title = "Ticker", confirm = true, group = "Level 40", inline = "2") col40 = input.string("default", title = "Color", options = ["default","red","orange","yellow","green","blue","purple","white","black","gray"], confirm = true, group = "Level 40", inline = "2") style40 = input.string("___", title = "Style", options = ["___","- - -",". . .","___zone","- - -zone",". . .zone"], confirm = true, group = "Level 40", inline = "2") width40 = input.int(1, title = "Thickness", minval = 0, maxval = 5, confirm = true, group = "Level 40", inline = "2") txt40 = input.string("", title = "Text", confirm = true, group = "Level 40", inline = "2") lvls40 = input.string("", title = "Levels", confirm = true, group = "Level 40", inline = "2") output40 = tog_40?(symbol40 + "," + (col40=="default"?" ":col40) + "," + linestyle(style40) + "," + str.tostring(width40-1) + "," + (txt40 == ""?" ":txt40) + "," + str.replace_all(lvls40," ","") + ";"):"" if symbol1 == "" runtime.error("Please Insert Symbol into Level 1.") if lvls1 == "" runtime.error("Please Insert at Lease 1 Level into Level 1.") if tog_2 and symbol2 == "" runtime.error("Please Insert Symbol into Level 2.") if tog_2 and lvls2 == "" runtime.error("Please Insert at Lease 1 Level into Level 2.") if tog_3 and symbol3 == "" runtime.error("Please Insert Symbol into Level 3.") if tog_3 and lvls3 == "" runtime.error("Please Insert at Lease 1 Level into Level 3.") if tog_4 and symbol4 == "" runtime.error("Please Insert Symbol into Level 4.") if tog_4 and lvls4 == "" runtime.error("Please Insert at Lease 1 Level into Level 4.") if tog_5 and symbol5 == "" runtime.error("Please Insert Symbol into Level 5.") if tog_5 and lvls5 == "" runtime.error("Please Insert at Lease 1 Level into Level 5.") if tog_6 and symbol6 == "" runtime.error("Please Insert Symbol into Level 6.") if tog_6 and lvls6 == "" runtime.error("Please Insert at Lease 1 Level into Level 6.") if tog_7 and symbol7 == "" runtime.error("Please Insert Symbol into Level 7.") if tog_7 and lvls7 == "" runtime.error("Please Insert at Lease 1 Level into Level 7.") if tog_8 and symbol8 == "" runtime.error("Please Insert Symbol into Level 8.") if tog_8 and lvls8 == "" runtime.error("Please Insert at Lease 1 Level into Level 8.") if tog_9 and symbol9 == "" runtime.error("Please Insert Symbol into Level 9.") if tog_9 and lvls9 == "" runtime.error("Please Insert at Lease 1 Level into Level 9.") if tog_10 and symbol10 == "" runtime.error("Please Insert Symbol into Level 10.") if tog_10 and lvls10 == "" runtime.error("Please Insert at Lease 1 Level into Level 10.") if tog_11 and symbol11 == "" runtime.error("Please Insert Symbol into Level 11.") if tog_11 and lvls11 == "" runtime.error("Please Insert at Lease 1 Level into Level 11.") if tog_12 and symbol12 == "" runtime.error("Please Insert Symbol into Level 12.") if tog_12 and lvls12 == "" runtime.error("Please Insert at Lease 1 Level into Level 12.") if tog_13 and symbol13 == "" runtime.error("Please Insert Symbol into Level 13.") if tog_13 and lvls13 == "" runtime.error("Please Insert at Lease 1 Level into Level 13.") if tog_14 and symbol14 == "" runtime.error("Please Insert Symbol into Level 14.") if tog_14 and lvls14 == "" runtime.error("Please Insert at Lease 1 Level into Level 14.") if tog_15 and symbol15 == "" runtime.error("Please Insert Symbol into Level 15.") if tog_15 and lvls15 == "" runtime.error("Please Insert at Lease 1 Level into Level 15.") if tog_16 and symbol16 == "" runtime.error("Please Insert Symbol into Level 16.") if tog_16 and lvls16 == "" runtime.error("Please Insert at Lease 1 Level into Level 16.") if tog_17 and symbol17 == "" runtime.error("Please Insert Symbol into Level 17.") if tog_17 and lvls17 == "" runtime.error("Please Insert at Lease 1 Level into Level 17.") if tog_18 and symbol18 == "" runtime.error("Please Insert Symbol into Level 18.") if tog_18 and lvls18 == "" runtime.error("Please Insert at Lease 1 Level into Level 18.") if tog_19 and symbol19 == "" runtime.error("Please Insert Symbol into Level 19.") if tog_19 and lvls19 == "" runtime.error("Please Insert at Lease 1 Level into Level 19.") if tog_20 and symbol20 == "" runtime.error("Please Insert Symbol into Level 20.") if tog_20 and lvls20 == "" runtime.error("Please Insert at Lease 1 Level into Level 20.") if tog_21 and symbol21 == "" runtime.error("Please Insert Symbol into Level 21.") if tog_21 and lvls21 == "" runtime.error("Please Insert at Lease 1 Level into Level 21.") if tog_22 and symbol22 == "" runtime.error("Please Insert Symbol into Level 22.") if tog_22 and lvls22 == "" runtime.error("Please Insert at Lease 1 Level into Level 22.") if tog_23 and symbol23 == "" runtime.error("Please Insert Symbol into Level 23.") if tog_23 and lvls23 == "" runtime.error("Please Insert at Lease 1 Level into Level 23.") if tog_24 and symbol24 == "" runtime.error("Please Insert Symbol into Level 24.") if tog_24 and lvls24 == "" runtime.error("Please Insert at Lease 1 Level into Level 24.") if tog_25 and symbol25 == "" runtime.error("Please Insert Symbol into Level 25.") if tog_25 and lvls25 == "" runtime.error("Please Insert at Lease 1 Level into Level 25.") if tog_26 and symbol26 == "" runtime.error("Please Insert Symbol into Level 26.") if tog_26 and lvls26 == "" runtime.error("Please Insert at Lease 1 Level into Level 26.") if tog_27 and symbol27 == "" runtime.error("Please Insert Symbol into Level 27.") if tog_27 and lvls27 == "" runtime.error("Please Insert at Lease 1 Level into Level 27.") if tog_28 and symbol28 == "" runtime.error("Please Insert Symbol into Level 28.") if tog_28 and lvls28 == "" runtime.error("Please Insert at Lease 1 Level into Level 28.") if tog_29 and symbol29 == "" runtime.error("Please Insert Symbol into Level 29.") if tog_29 and lvls29 == "" runtime.error("Please Insert at Lease 1 Level into Level 29.") if tog_30 and symbol30 == "" runtime.error("Please Insert Symbol into Level 30.") if tog_30 and lvls30 == "" runtime.error("Please Insert at Lease 1 Level into Level 30.") if tog_31 and symbol31 == "" runtime.error("Please Insert Symbol into Level 31.") if tog_31 and lvls31 == "" runtime.error("Please Insert at Lease 1 Level into Level 31.") if tog_32 and symbol32 == "" runtime.error("Please Insert Symbol into Level 32.") if tog_32 and lvls32 == "" runtime.error("Please Insert at Lease 1 Level into Level 32.") if tog_33 and symbol33 == "" runtime.error("Please Insert Symbol into Level 33.") if tog_33 and lvls33 == "" runtime.error("Please Insert at Lease 1 Level into Level 33.") if tog_34 and symbol34 == "" runtime.error("Please Insert Symbol into Level 34.") if tog_34 and lvls34 == "" runtime.error("Please Insert at Lease 1 Level into Level 34.") if tog_35 and symbol35 == "" runtime.error("Please Insert Symbol into Level 35.") if tog_35 and lvls35 == "" runtime.error("Please Insert at Lease 1 Level into Level 35.") if tog_36 and symbol36 == "" runtime.error("Please Insert Symbol into Level 36.") if tog_36 and lvls36 == "" runtime.error("Please Insert at Lease 1 Level into Level 36.") if tog_37 and symbol37 == "" runtime.error("Please Insert Symbol into Level 37.") if tog_37 and lvls37 == "" runtime.error("Please Insert at Lease 1 Level into Level 37.") if tog_38 and symbol38 == "" runtime.error("Please Insert Symbol into Level 38.") if tog_38 and lvls38 == "" runtime.error("Please Insert at Lease 1 Level into Level 38.") if tog_39 and symbol39 == "" runtime.error("Please Insert Symbol into Level 39.") if tog_39 and lvls39 == "" runtime.error("Please Insert at Lease 1 Level into Level 39.") if tog_40 and symbol40 == "" runtime.error("Please Insert Symbol into Level 40.") if tog_40 and lvls40 == "" runtime.error("Please Insert at Lease 1 Level into Level 40.") output = "Here are your formatted levels! \n" + output1 + output2 + output3 + output4 + output5 + output6 + output7 + output8 + output9 + output10 + output11 + output12 + output13 + output14 + output15 + output16 + output17 + output18 + output19 + output20 + output21 + output22 + output23 + output24 + output25 + output26 + output27 + output28 + output29 + output30 + output31 + output32 + output33 + output34 + output35 + output36 + output37 + output38 + output39 + output40 alert(output)