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
Broadening Formations [QuantVue]
https://www.tradingview.com/script/PghpY09l-Broadening-Formations-QuantVue/
QuantVue
https://www.tradingview.com/u/QuantVue/
290
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/ // © QuantVue //@version=5 indicator("Broadening Formations [QuantVue]", overlay = true) //inputs dtlColor = input.color(color.red, 'Down Trend Line Color', inline = '0') utlColor = input.color(color.green, 'Up Trend Line Color', inline = '1') pastColor = input.color(color.orange, 'Crossed Line Color', inline = '2') extendLine = input.bool(false, 'Extend Lines Until Crossed', inline = '3') onlyLast = input.bool(true, 'Most Recent Line Only', inline = '3', tooltip = 'If multiple lines share pivot points, checking this will only show the most recent line.') hideCrossed = input.bool(false, 'Hide Crossed Lines', inline = '4') showCross = input.bool(false, 'Show Crosses', inline ='4', tooltip = 'Hiding crossed lines will only leave trend lines on the chart that have not been breached by your selected source. Showing crosses will plot an "X" where price crosses the trendline based on your selected source.') crossDown = input.color(color.red, 'Cross Below Color', inline = '5') crossUp = input.color(color.lime, 'Cross Above Color', inline = '5') maxLines = input.int(4, 'Max Number of Crossed Lines to Show', step = 2, minval = 0, maxval = 50) crossSrc = input.string('Close', 'Cross Source', options = ['Close', 'High/Low']) maxLineLen = input.int(252, 'Max Line Length', tooltip = 'Will remove line if it is not crossed after selected amount of bars') maxDistAway = input.int(40, 'Max Distance from Line', tooltip = 'Will remove line if price gets farther away than seleced percentage') pivLen = input.int(9, 'Pivot Length', step = 1, minval = 1) maxLines := hideCrossed ? 0 : maxLines type pivot string pivType int x1 float y1 int x2 float y2 // arrays var line[] dtlArray = array.new_line() var line[] utlArray = array.new_line() //functions createLine(ptype, x1, y1, x2, y2)=> piv = pivot.new(ptype, x1, y1, x2, y2) trendline = line.new(x1, y1, x2, y2, extend = extendLine ? extend.right : extend.none, color = ptype == 'ph' ? dtlColor : utlColor, width = 2) if ptype == 'ph' dtlArray.unshift(trendline) else if ptype == 'pl' utlArray.unshift(trendline) piv getSlope(line)=> slopePh = (line.get_y2(line) - line.get_y1(line))/(line.get_x2(line) -line.get_x1(line)) extendedPh = line.get_y2(line) - slopePh * (line.get_x2(line) - bar_index) extendedPh // variables ph = ta.pivothigh(high, pivLen, pivLen) pl = ta.pivotlow(low, pivLen, pivLen) var int utlX1 = na, var float utlY1 = na var int utlX2 = na, var float utlY2 = na var int dtlX2 = na, var float dtlY2 = na var int dtlX1 = na, var float dtlY1 = na if pl utlX1 := utlX2, utlY1 := utlY2 utlX2 := bar_index[pivLen], utlY2 := low[pivLen] if utlY1 > utlY2 createLine('pl', utlX1, utlY1, utlX2, utlY2) if ph dtlX1 := dtlX2, dtlY1 := dtlY2 dtlX2 := bar_index[pivLen], dtlY2 := high[pivLen] if dtlY1 < dtlY2 createLine('ph', dtlX1, dtlY1, dtlX2, dtlY2) for l in utlArray src = crossSrc == 'Close' ? close : low first = l == utlArray.get(0) extended = getSlope(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > maxLineLen or ((low - l.get_y2()) / low) * 100 > maxDistAway l.delete() if src > line.get_price(l, bar_index) and not first and onlyLast l.delete() var line [] tempUtl = array.new_line(maxLines/2) var label [] tempUL = array.new_label(maxLines/2) if src < line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color = pastColor, style = line.style_dashed, width = 1) crossLabel = showCross ? label.new(bar_index, low, ' ', yloc = yloc.belowbar, color = crossDown, style = label.style_xcross, size = size.tiny) : na alert('Trendline Crossed', alert.freq_once_per_bar) line.delete(l) tempUtl.unshift(newLine) tempUL.unshift(crossLabel) if tempUtl.size() > (maxLines/2) line.delete(tempUtl.pop()) label.delete(tempUL.pop()) for l in dtlArray first = l == dtlArray.get(0) src = crossSrc == 'Close' ? close : high extended = getSlope(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > maxLineLen or ((l.get_y2() - high) / l.get_y2()) * 100 > maxDistAway l.delete() if src < line.get_price(l, bar_index) and not first and onlyLast l.delete() var line [] tempDtl = array.new_line(maxLines/2) var label [] tempDL = array.new_label(maxLines/2) if src > line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color = pastColor, style = line.style_dashed, width = 1) crossLabel = showCross ? label.new(bar_index, high, '', yloc = yloc.abovebar, style = label.style_xcross, color = crossUp, size = size.tiny) : na alert('Trendline Crossed', alert.freq_once_per_bar) line.delete(l) tempDtl.unshift(newLine) tempDL.unshift(crossLabel) if tempDtl.size() > (maxLines/2) line.delete(tempDtl.pop()) label.delete(tempDL.pop()) if utlArray.size() > 0 and dtlArray.size() > 0 firstUTL = utlArray.get(0) firstDTL = dtlArray.get(0) if firstUTL.get_x2() == firstDTL.get_x2() alert('Broadening Formation Detected', alert.freq_once_per_bar_close)
ASG Delta %
https://www.tradingview.com/script/APsHJfbF-ASG-Delta/
Asgardian_
https://www.tradingview.com/u/Asgardian_/
39
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/ // © Asgardian_ //@version=5 indicator(title="ASG Delta %", overlay=true) i_normal = input.bool(title="Norm ", defval=true, inline='row1') i_reverse = input.bool(title="Rev ", defval=true, inline='row1') i_extra = input.bool(title="Ext", defval=true, inline='row1') i_arrow = input.bool(title="↑↓", defval=false, inline='row1') i_percent = input.bool(title="%", defval=false, inline='row1') i_size = input.string(title='', defval='[BOX]', options=["[BOX]", 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], inline = 'row1') i_startDate = input.time(title='From Date/Time', defval=timestamp("1 MAY 2023"), confirm=true) i_endDate = input.time(title='To Date/Time', defval=timestamp("14 JUN 2023"), confirm=true) i_col_bull = input.color(title='Bull', defval=color.new(color.green, 70), inline='row3') i_col_bear = input.color(title='Bear', defval=color.new(color.red, 70), inline='row3') i_col_normal = input.color(title='Norm', defval=color.new(color.white, 85), inline='row3') i_col_border = input.color(title='Bord', defval=color.new(color.white, 50), inline='row3') i_col_text = input.color(title='Text', defval=color.new(color.white, 25), inline='row3') size = i_size == 'Tiny' ? size.tiny : i_size == 'Small' ? size.small : i_size == 'Normal' ? size.normal : i_size == 'Large' ? size.large : i_size == 'Huge' ? size.huge : size.normal dt = time - time[1] f_draw_box(_x1, _y1, _x2, _y2, _dir, _text, _just, _col) => box = box.new(_x1, _y1, _x2, _y2, xloc=xloc.bar_time, border_color=i_col_border, border_width=1, bgcolor=_col, text=_text, text_color=i_col_text, text_halign=_just, text_font_family=font.family_monospace, text_size=size.auto) box.delete(box[1]) f_draw_extra_lines(_x, _y, _min, _max) => topLine=line.new(x1=_x + (dt*2), y1=_max, x2=_x + (dt*7), y2=_max, xloc=xloc.bar_time, color=i_col_text, style=line.style_solid, width=1) line.delete(topLine[1]) currentLine=line.new(x1=_x + (dt*2), y1=_y, x2=_x + (dt*7), y2=_y, xloc=xloc.bar_time, color=i_col_text, style=line.style_solid, width=1) line.delete(currentLine[1]) bottomLine=line.new(x1=_x + (dt*2), y1=_min, x2=_x + (dt*7), y2=_min, xloc=xloc.bar_time, color=i_col_text, style=line.style_solid, width=1) line.delete(bottomLine[1]) f_draw_extra_label(_x, _y, _text, _just) => lbl=label.new(x=_x, y=_y, text=_text, xloc=xloc.bar_time, color=color.new(#ffffff, 100), style=label.style_label_left ,textcolor=i_col_text, textalign=_just, text_font_family=font.family_monospace, size=size) label.delete(lbl[1]) f_get_percentage(_from, _to) => math.round(((_from - _to) / _to)*100, 2) f_get_display_text(_direction, _fromY, _toY)=> string displayN='', string displayR='' if i_normal displayN := str.format("{0,number,###.00}", f_get_percentage(_fromY, _toY))+(i_percent?'%':na) if i_reverse displayR := str.format("{0,number,###.00}", f_get_percentage(_toY, _fromY))+(i_percent?'%':na) if (i_normal and i_reverse) if str.substring(displayN, 0, 1) =='-' displayR := ' ' + displayR if str.substring(displayR, 0, 1) == '-' displayN := ' ' + displayN if i_arrow and i_normal displayN := (_direction ? '▲' : '▼' )+displayN if i_arrow and i_reverse displayR := (_direction ? '▼' : '▲')+displayR _direction ? displayN + (i_normal and i_reverse?'\n':na) + displayR : displayR + (i_normal and i_reverse?'\n':na) + displayN var HHTime = 0, var LLTime = 0 var float HH = 10e-10, var float LL = 10e10 if i_startDate <= time and i_endDate >= time if high > HH HH := high HHTime := time if low < LL LL := low LLTime := time if barstate.islast bool direction = false, float fromY = 0.0, float toY = 0.0 if LLTime < HHTime direction := true // uptrend fromY := HH toY := LL else direction := false // downtrend fromY := LL toY := HH // main delta f_draw_box(i_startDate, fromY, i_endDate, toY, direction, f_get_display_text(direction, fromY, toY), text.align_center, direction ? i_col_bull : i_col_bear) // extra deltas minVal = math.min(close, math.min(fromY, toY)) maxVal = math.max(close, math.max(fromY, toY)) if i_extra and minVal < close and close < maxVal if i_size == '[BOX]' width = i_endDate + ((i_endDate - i_startDate)/2) f_draw_box(i_endDate+(dt*0), maxVal, width, close, direction, f_get_display_text(direction, direction?maxVal:close, direction?close:maxVal), text.align_center, i_col_normal) f_draw_box(i_endDate+(dt*0), minVal, width, close, direction, f_get_display_text(direction, direction?close:minVal, direction?minVal:close), text.align_center, i_col_normal) else f_draw_extra_lines(i_endDate, close, minVal, maxVal) f_draw_extra_label(i_endDate, (close + maxVal) / 2, f_get_display_text(direction, direction?maxVal:close, direction?close:maxVal), text.align_left) f_draw_extra_label(i_endDate, (close + minVal) / 2, f_get_display_text(direction, direction?close:minVal, direction?minVal:close), text.align_left)
Smoother Momentum Stops [Loxx]
https://www.tradingview.com/script/v8XgnKnE-Smoother-Momentum-Stops-Loxx/
loxx
https://www.tradingview.com/u/loxx/
264
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("Smoother Momentum Stops [Loxx]", overlay = true, timeframe="", timeframe_gaps = true) color greencolor = #2DD204 color redcolor = #D2042D smmom(float src, float per)=> float alphareg = 2.0 / (1.0 + per) float alphadbl = 2.0 / (1.0 + math.sqrt(per)) float ema = src float ema21 = src float ema22 = src if bar_index > 0 ema := nz(ema[1]) + alphareg * (src - nz(ema[1])) ema21 := nz(ema21[1]) + alphadbl * (src - nz(ema21[1])) ema22 := nz(ema22[1]) + alphadbl * (ema21 - nz(ema22[1])) float out = (ema22 - ema) out fema(float src, simple int len)=> float alpha = (2.0 / (2.0 + (len - 1.0) / 2.0)) float out = 0. out := nz(out[1]) + alpha * (src - nz(out[1])) out variant(typein, src, per)=> float out = 0. if typein == "Exponential Moving Average - EMA" out := ta.ema(src, per) if typein == "Fast Exponential Moving Average - FEMA" out := fema(src, per) if typein == "Linear Weighted Moving Average - LWMA" out := ta.wma(src, per) if typein == "Simple Moving Average - SMA" out := ta.sma(src, per) if typein == "Smoothed Moving Average - SMMA" out := ta.rma(src, per) out float inpPrice = input.source(close, "Source", group = "Basic Settings") int inpMomPeriod = input.int(20, "Momentum Period", group = "Basic Settings") int inpAvgPeriod = input.int(20, "Average Period", group = "Basic Settings") string inpAvgMethod = input.string("Simple Moving Average - SMA", "Smoothing Type", options = ["Exponential Moving Average - EMA", "Fast Exponential Moving Average - FEMA", "Linear Weighted Moving Average - LWMA", "Simple Moving Average - SMA", "Smoothed Moving Average - SMMA"], group = "Basic Settings") float inpMultiplier = input.float(1.5, "Multiplier", group = "Basic Settings") colorbars = input.bool(false, "Color bars?", group = "UI Options") showSigs = input.bool(true, "Show signals?", group = "UI Options") _avg = variant(inpAvgMethod, inpPrice, inpAvgPeriod) _mom = inpMultiplier * smmom(inpPrice, inpMomPeriod) float stopu = na float stopd = na float stopda = na float stopua = na if _mom > 0 stopu := na(stopu[1]) ? _avg - _mom : math.max(nz(stopu[1]), _avg - _mom) stopd := na stopda := na stopua := na(stopu[1]) ? stopu : na if _mom < 0 stopd := na(stopd[1]) ? _avg - _mom : math.min(nz(stopd[1]), _avg - _mom) stopu := na stopua := na stopda := na(stopd[1]) ? stopd : na colorout = stopu ? greencolor : redcolor goLong = stopu and stopd[1] goShort = stopd and stopu[1] plotshape(showSigs and goLong, title = "Long", color = color.yellow, textcolor = color.yellow, text = "L", style = shape.triangleup, location = location.belowbar, size = size.small) plotshape(showSigs and goShort, title = "Short", color = color.fuchsia, textcolor = color.fuchsia, text = "S", style = shape.triangledown, location = location.abovebar, size = size.small) alertcondition(goLong, title="Long", message="Smoother Momentum Stops [Loxx]: Long\nSymbol: {{ticker}}\nPrice: {{close}}") alertcondition(goShort, title="Short", message="Smoother Momentum Stops [Loxx]: Short\nSymbol: {{ticker}}\nPrice: {{close}}") plot(stopu ? stopu : na, "Upper", color = greencolor, linewidth = 2, style = plot.style_linebr) plot(stopd ? stopd : na, "Lower", color = redcolor, linewidth = 2, style = plot.style_linebr) float support = ta.valuewhen(stopua, stopua, 0) float resistance = ta.valuewhen(stopda, stopda, 0) plot(resistance, style = plot.style_circles, color = redcolor) plot(support, style = plot.style_circles, color = greencolor) barcolor(colorbars ? colorout : na)
RSI-MFI Machine Learning [ Manhattan distance ]
https://www.tradingview.com/script/jrjOQDgc-RSI-MFI-Machine-Learning-Manhattan-distance/
TZack88
https://www.tradingview.com/u/TZack88/
738
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/ // © TZack88 //@version=5 indicator("RSI-MFI Machine Learning [ Manhattan distance ]",shorttitle = "RSI-MFI [ Machine Learning ]" , overlay=true) string Core = "➞ Core Settings 🔸" int ShortPriod = input.int (26, 'Short Period', 1,group=Core) int LongPriod = input.int (14, 'Long Period', 2,group=Core) int Neighbours = math.floor(math.sqrt(input.int (8,'Neighbours Count', 5,group=Core))) float MAXZ = ta.highest(high, 20) float MINZ = ta.lowest(low,20) var int signal = 0 var float prediction = 0.0 var LLong = false var SShort = false int Class = close[4] < close[0] ? -1 : close[4] > close[0] ? 1 : 0 //-------- { var array<float> feature1 = array.new_float(0) var array<float> feature2 = array.new_float(0) var array<int> directions = array.new_int(0) var array<float> data = array.new_float() var array<int> predictions = array.new_int(0) // Regression Line Calculation regline() => array.push(data , close) if array.size(data) > 25 array.shift(data) Size = array.size(data) X = array.avg(data) - (ta.linreg(close,Size,0) - ta.linreg(close,Size,1)) * math.floor(Size/ 2) + 0.5 * (ta.linreg(close,Size,0) - ta.linreg(close,Size,1)) Y = (array.avg(data) - (ta.linreg(close,Size,0) - ta.linreg(close,Size,1)) * math.floor(Size/ 2)) + (ta.linreg(close,Size,0) - ta.linreg(close,Size,1)) * (Size - 1) [X , Y ] [ X , Y ] = regline() Regline = math.avg(X,Y) // RSI Data Calculation RSI_Data(float src , int dir) => math.avg(ta.mfi(ta.rsi(src,dir + 4 ), dir) , ta.mfi(ta.rsi(src,dir + 2 ), dir), ta.mfi(ta.rsi(src,dir + 4 ), dir), ta.mfi(ta.rsi(src,dir + 5 ), dir)) LongData = RSI_Data(hlc3,LongPriod) ShortData = RSI_Data(hlc3,ShortPriod) array.push(feature1, LongData) array.push(feature2, ShortData) array.push(directions, Class) // Nearest Neighbor Calculation int size = array.size(directions) float dust = -999.0 for i = 0 to size - 1 // Calculate the Manhattan distance of the current point to all historic points. float ManD = math.abs(LongData - array.get(feature1, i)) + math.abs(ShortData - array.get(feature2, i)) if ManD > dust dust := ManD if array.size(predictions) >= Neighbours array.shift(predictions) array.push(predictions, array.get(directions, i)) // Prediction and Trade Signals prediction := array.sum(predictions) * 5 LongColor = int(prediction) > 7 ? color.new(color.rgb(14, 232, 232),20): color.new(color.rgb(14, 232, 232),80) ShortColor = int(-prediction) > 7 ? color.new(#FF0080ff,20): color.new(#FF0080ff,80) C = not (prediction > 0) and not (prediction < 0) signal := prediction > 0 ? 1 : prediction < 0 ? -1 : C ? 0 : nz(signal[1]) // Long and Short Trade Conditions int changed = ta.change(signal) bool startLongTrade = changed and signal==1 bool startShortTrade = changed and signal==-1 if startLongTrade and close > Regline LLong:= true SShort:= false if startShortTrade and close < Regline LLong:= false SShort:= true LongCon = (LLong and not LLong[1]) and close > open ShortCon = (SShort and not SShort[1]) and close < open // Plots plotshape(LongCon ? MINZ : na, 'Buy', shape.labelup, location.belowbar, LongColor,size=size.small,editable = false) plotshape(ShortCon? MAXZ: na , 'Sell', shape.labeldown, location.abovebar, ShortColor, size=size.small,editable = false) plot(Regline,color = LLong ? color.new(color.from_gradient(prediction,-1,100,#1f4037,#99f2c8),30) : SShort ? color.new(color.from_gradient(-prediction,-1,100,#FF416C,#FF4B2B),30) : na ,linewidth = 2) alertcondition(LongCon,"BUY Signal") alertcondition(ShortCon,"Sell Signal")
Linear Correlation Coefficient W/ MAs and Significance Tests
https://www.tradingview.com/script/EUZehIbw-Linear-Correlation-Coefficient-W-MAs-and-Significance-Tests/
jsalemfinancial
https://www.tradingview.com/u/jsalemfinancial/
9
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/ // © jsalemfinancial //@version=5 indicator("Linear Correlation Coefficient") partner = math.log(nz(request.security(input.symbol(defval="QQQ", title="Security"), timeframe.period, close))) len = input.int(defval=31, title="Period", minval=16) cc(sec1, sec2, len) => // Correlation Coefficent function, credit @balipour for structure. sec1_sum = 0.0, sec2_sum = 0.0 for i=0 to (len-1) sec1_sum := sec1_sum + nz(sec1[i]) sec2_sum := sec2_sum + nz(sec2[i]) sec1_mean = sec1_sum / len sec2_mean = sec2_sum / len sum12=0.0, sum1=0.0, sum2=0.0 for i=0 to (len-1) sum12 := sum12 + (nz(sec1[i]) - sec1_mean) * (nz(sec2[i]) - sec2_mean) sum1 := sum1 + math.pow(nz(sec1[i]) - sec1_mean, 2) sum2 := sum2 + math.pow(nz(sec2[i]) - sec2_mean, 2) sum12 / math.sqrt(sum1 * sum2) coeff = cc(math.log(close), partner, len) t_score = coeff*math.sqrt(len-2)/math.sqrt(1-math.pow(coeff, 2)) //Hypothesis: H_0: p = 0. Use sample of size > 30 as it is two-tail. zelen_severo_consts = array.new_float(6) //array for the taylor approximation coefficients. array.set(zelen_severo_consts, 0, 0.2316419), array.set(zelen_severo_consts, 1, 0.319381530), array.set(zelen_severo_consts, 2, -0.356563782) array.set(zelen_severo_consts, 3, 1.781477937), array.set(zelen_severo_consts, 4, -1.821255978), array.set(zelen_severo_consts, 5, 1.330274429) zsc(index) => array.get(zelen_severo_consts, index) PI = 3.1415926535 E = 2.7182818284 T = 1/(1 + zsc(0)*t_score) p_normal_cdf = 1 - ((math.pow(E, -math.pow(t_score, 2)/2)/(math.sqrt(2*PI))) * (zsc(1)*T + zsc(2)*math.pow(T,2) + zsc(3)*math.pow(T,3) + zsc(4)*math.pow(T,4) + zsc(5)*math.pow(T,5))) + math.pow(10, -5) bar_color = if p_normal_cdf < 0.05 or p_normal_cdf > 0.95 color.yellow else color.olive band1 = hline(0.5, color=color.gray) band2 = hline(0.7, color=color.gray) band3 = hline(-0.5, color=color.gray) band4 = hline(-0.7, color=color.gray) fill(band1, band2, color=color.rgb(0, 150, 0, 90)) fill(band3, band4, color=color.rgb(150, 95, 0, 90)) hline(0, color=color.gray, linestyle=hline.style_solid) plot(coeff, color=bar_color, linewidth=3, style=plot.style_histogram) plot(ta.sma(coeff, input.int(defval=50, title="SMA Long")), color=color.blue) plot(ta.sma(coeff, input.int(defval=9, title="SMA Short")), color=color.red)
Mobius - Trend Pivot
https://www.tradingview.com/script/znfMUs8L-Mobius-Trend-Pivot/
dudeowns
https://www.tradingview.com/u/dudeowns/
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/ // © coderboring //@version=5 indicator("Mobius - Trend Pivot", overlay = true) // Mobius // V01.01.29.2019 // Uses trend of higher highs with higher lows and trend of lower lows with lower highs to locate pivots. Distance for trend is set by the user. Confirmation of a reversal from pivots is set with a multiple of the pivot bars range. That multiple is also a user input. // Trading Rules // 1) Trade when price crosses and closes outside the pivot Confirmation line. At that point looking for best entry. Min trade is 2 contracts // 2) Know your risk point before entering trade. Typical risk point is the pivot line itself. If your risk is crossed look for an exit. Never use hard stops - you'll often get out for little or no loss // 3) Know your Risk off point before entering. Typical Risk Off is an ATR multiple. Offer Risk Off as soon as possible for a Risk Free trade // 4) set mental stop one tick above entry when Risk Off is achieved // 5) if trade continues your way move mental stop for your runner to last support / resistance each time a new support / resistance is hit. n = input( 5, "n ") R_Mult = input(.7, "R_Mult") o = open h = high l = low c = close x = bar_index //nan = Double.NaN; ts = syminfo.mintick TrueRange(h, c, l) => math.max(c[1], h) - math.min(c[1], l) tr = TrueRange(h, c, l) var hh = float(na) hh := math.sum(h > h[1] ? 1 : 0, n) >= n and math.sum(l > l[1] ? 1 : 0, n) >= n-1 ? h : h > hh ? h : hh var xh = int(na) xh := h == hh ? x : xh hh_ = line.new(na, na, na, na, xloc.bar_index, extend.right, color.red) if barstate.islast line.set_xy1(hh_, xh, hh) line.set_xy2(hh_, xh+ 1, hh) Average(data , len) => math.sum(data, len) / len TickSize() => syminfo.mintick var hR = float(na) hR := h == hh ? math.round(Average(tr, n)/TickSize(), 0)*TickSize() : hR var PrevL = float(na) PrevL := h == hh ? l[1] : PrevL STO = line.new(na, na, na, na, xloc.bar_index, extend.right, color.red) STO_RO = line.new(na, na, na, na, xloc.bar_index, extend.right, color.white, line.style_dashed) sto = float(na) if barstate.isconfirmed sto := math.round((math.max(PrevL, hh - (hR * R_Mult))) / ts, 0) * ts line.set_xy1(STO, xh, sto) line.set_xy2(STO, xh+ 1, sto) sto_ro = sto - math.min(hR, TickSize() * 16) line.set_xy1(STO_RO, xh, sto_ro) line.set_xy2(STO_RO, xh+ 1, sto_ro) var ll = float(na) ll := math.sum(l < l[1] ? 1 : 0, n) >= n and math.sum(h < h[1] ? 1 : 0, n) >= n-1 ? l : l < ll[1] ? l : ll var xl = int(na) xl := l == ll ? x : xl ll_ = line.new(na, na, na, na, xloc.bar_index, extend.right, color.green) if barstate.isconfirmed line.set_xy1(ll_, xl, ll) line.set_xy2(ll_, xl+ 1, ll) var lR = float(na) lR := l == ll ? math.round(Average(tr, n)/TickSize(), 0)*TickSize() : lR var PrevH = float(na) PrevH := l == ll ? h[1] : PrevH BTO = line.new(na, na, na, na, xloc.bar_index, extend.right, color.green) BTO_RO = line.new(na, na, na, na, xloc.bar_index, extend.right, color.white, line.style_dashed) bto = float(na) if barstate.isconfirmed bto := math.round((math.min(PrevH, ll + (lR * R_Mult))) / ts, 0) * ts line.set_xy1(BTO, xl, bto) line.set_xy2(BTO, xl+ 1, bto) if barstate.isconfirmed bto_ro = bto + math.min(lR, TickSize() * 16) line.set_xy1(STO_RO, xl, bto_ro) line.set_xy2(STO_RO, xl+ 1, bto_ro) linefill.new(STO, hh_, color.new(color.red, 85)) linefill.new(ll_, BTO, color.new(color.green, 85)) if ta.crossunder(c, sto) alert("c crosses below STO") if ta.crossover(c, bto) alert("c crosses above bto") // Define plot variables plotshape(ta.crossover(c, bto), "bullish arrow", shape.triangleup, location.belowbar, color.green, size = size.small) plotshape(ta.crossunder(c, sto), "bearish Arrow", shape.triangledown , location.abovebar, color.red, size = size.small)
Anchored VWAP (Auto High & Low)
https://www.tradingview.com/script/72stxVxI-Anchored-VWAP-Auto-High-Low/
liquid-trader
https://www.tradingview.com/u/liquid-trader/
224
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/ // © liquid-trader // This script plots, and auto-updates, 3 separate VWAPs: a traditional VWAP, a VWAP anchored to a trends high, // and another anchored to a trends low. Because VWAP is a prominent market maker tool for executing large trades, // day traders can use it to better anticipate trends, mean reversion, and breakouts. // More here: https://www.tradingview.com/script/72stxVxI-Anchored-VWAP-Auto-High-Low/ //@version=5 indicator("Anchored VWAP (Auto High & Low)", "AVWAP (Auto Hi / Lo)", overlay=true, max_bars_back=0) max_bars_back(time, 1440) // Base Colors none = color.new(color.black, 100), clr1 = color.aqua // Groups g1 = "Anchored VWAP", g2 = "Normal VWAP" // High Anchor shoHiA = input.bool(true, "High Anchor           ", "VWAP anchored and weighted to trend highs.", inline="hi", group=g1, display=display.none) hiAnClr = input.color(clr1, "", inline="hi", group=g1, display=display.none) hiWidth = input.int(2, "", 1, inline="hi", group=g1, display=display.none) // Low Anchor shoLoA = input.bool(true, "Low Anchor            ", "VWAP anchored and weighted to trend lows.", inline="lo", group=g1, display=display.none) loAnClr = input.color(clr1, "", inline="lo", group=g1, display=display.none) loWidth = input.int(2, "", 1, inline="lo", group=g1, display=display.none) // Average of Anchors shoMid = input.bool(true, "Avg. of Anchors     ", "The mean (average) between the high and low anchored VWAP's", inline="mid", group=g1, display=display.none) midClr = input.color(color.new(clr1, 50), "", inline="mid", group=g1, display=display.none) mWidth = input.int(2, "", 1, inline="mid", group=g1, display=display.none) // Quarter levels shoQrt = input.bool(true, "Quarter Values       ", "The median (middle) value between the mean (average) and high / low anchors.", inline="quarter", group=g1, display=display.none) qrtClr = input.color(color.new(clr1, 80), "", inline="quarter", group=g1, display=display.none) qWidth = input.int(1,"", 1, inline="quarter", group=g1, display=display.none) // High eighth levels with fill shoHiFil = input.bool(true, "High Interim Bands", inline="hiFill", group=g1, display=display.none) hiEthClr = input.color(color.new(clr1, 93), "", inline="hiFill", group=g1, display=display.none) hiFilClr = input.color(color.new(clr1, 97), "", inline="hiFill", group=g1, display=display.none) // Low eighth levels with fill shoLoFil = input.bool(true, "Low Interim Bands ", inline="loFill", group=g1, display=display.none) loEthClr = input.color(color.new(clr1, 93), "", inline="loFill", group=g1, display=display.none) loFilClr = input.color(color.new(clr1, 97), "", inline="loFill", group=g1, display=display.none) // Smooth Average of Anchors shoMA = input.bool(false, "Smooth Average    ", inline="smooth", group=g1, display=display.none) maSrc = input.string("SMMA (RMA)", "", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "Linear Regression"], inline="smooth", group=g1, display=display.none) maLen = input.int(3, "", 1, inline="smooth", group=g1, display=display.none) // Anchor Reset Settings sessionLimited = input.bool(true, "Limit anchor session continuation to ", "Defines when a given anchor should be reset if its VWAP has not been broken, measured in sessions.", inline="reset", group=g1, display=display.none) anchorMax = input.int(1, "", 1, inline="reset", group=g1, display=display.none) mktHrsOnly = input.bool(false, "Limit anchor resets to only regular trading hours and new sessions.", "Prevents a given VWAP from resetting afhours, overnight, or during the premarket.", group=g1, display=display.none) // 1 Day VWAP O = "open", H = "high", L = "low", C = "close", HL2 = "hl2", HLC3 = "hlc3", OHLC4 = "ohlc4", HLCC4 = "hlcc4" shoVWAP = input.bool(true, "VWAP", "The Volume Weighted Average Price is reset at the beginning of each session.", inline="vwap1", group=g2, display=display.none) vwap1Clr = input.color(color.blue, "", inline="vwap1", group=g2, display=display.none) vWidth1 = input.int(2, "", 1, inline="vwap1", group=g2, display=display.none) source1 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap1", group=g2, display=display.none) // 2 Day VWAP shoDay2 = input.bool(false, "Day 2 ", "Continuation of VWAP into a second day.", inline="vwap2", group=g2, display=display.none) vwap2Clr = input.color(color.new(color.teal, 25), "", inline="vwap2", group=g2, display=display.none) vWidth2 = input.int(2, "", 1, inline="vwap2", group=g2, display=display.none) source2 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap2", group=g2, display=display.none) // 3 Day VWAP shoDay3 = input.bool(false, "Day 3 ", "Continuation of VWAP into a third day.", inline="vwap3", group=g2, display=display.none) vwap3Clr = input.color(color.new(color.red, 50), "", inline="vwap3", group=g2, display=display.none) vWidth3 = input.int(2, "", 1, inline="vwap3", group=g2, display=display.none) source3 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap3", group=g2, display=display.none) // Market Hours Settings mktHrs = input.session("0930-1600", "Start / End Time", tooltip = "A 24 hour format, where 0930 is 9:30 AM, 1600 is 4:00 PM, etc.", group="Market Hours", inline="mkt", display=display.none) zone = input("America/New_York", "Time Zone          ", "Any IANA time zone ID. Ex: America/New_York\n\nYou can also use \"syminfo.timezone\", which inherits the time zone of the exchange of the chart.", group="Market Hours", inline="zone", display=display.none) timezone = zone == "syminfo.timezone" ? syminfo.timezone : zone minutesInDay = "1440", marketHours = time(minutesInDay, mktHrs, timezone) // Put colors into an array. colors = array.from(hiAnClr, loAnClr, midClr, qrtClr, hiEthClr, loEthClr, hiFilClr, loFilClr) // Define new sessions. newSession = timeframe.isdwm ? false : session.isfirstbar // Set core variables. o = open, h = high, l = low, c = close, index = bar_index // Define candle patterns and parts. candleBody = math.abs( c - o ) rising = c > o falling = o > c upWick = rising ? h - c : h - o dnWick = falling ? c - l : o - l doji = (upWick >= candleBody or dnWick >= candleBody) and (h != o and h != c and l != o and l != c) higher = o > o[1] and c > c[1] lower = o < o[1] and c < c[1] risingHigher = rising and higher fallingLower = falling and lower // Anchor variables. var hi = h, var lo = l, var anchoredHi = h, var anchoredLo = l, var hrH = h, var hrL = l, var lrH = h, var lrL = l var resetHiAnchor = false, var resetLoAnchor = false, var bullish = false, var bearish = false var hiSessionCount = 0, var loSessionCount = 0 // Logic for what qualifies as "breaking" the previous anchors. breakingHigher = rising and (c > hi or (c[1] > anchoredHi and c > h[1] and o > anchoredHi and not doji)) breakingLower = falling and (c < lo or (c[1] < anchoredLo and c < l[1] and o < anchoredLo and not doji)) // Logic for when to reset anchors. if newSession and sessionLimited hiSessionCount += 1, loSessionCount += 1 if hiSessionCount == anchorMax hiSessionCount := 0 hi := h, hrH := h, hrL := l resetHiAnchor := true bullish := true if loSessionCount == anchorMax loSessionCount := 0 lo := l, lrH := h, lrL := l resetLoAnchor := true bearish := true else if breakingHigher and (not mktHrsOnly or (marketHours and marketHours)) hiSessionCount := 0 hi := h, hrH := h, hrL := l resetHiAnchor := true bullish := true else if breakingLower and (not mktHrsOnly or (marketHours and marketHours)) loSessionCount := 0 lo := l, lrH := h, lrL := l resetLoAnchor := true bearish := true else resetHiAnchor := false resetLoAnchor := false // Set the Anchored VWAP, and their average. anchoredHi := ta.vwap(h, resetHiAnchor) anchoredLo := ta.vwap(l, resetLoAnchor) anchoredMean = math.avg(anchoredHi, anchoredLo) // Smooth the average according to the traders settings. if shoMA anchoredMean := switch maSrc "SMA" => ta.sma(anchoredMean, maLen) "EMA" => ta.ema(anchoredMean, maLen) "SMMA (RMA)" => ta.rma(anchoredMean, maLen) "WMA" => ta.wma(anchoredMean, maLen) "VWMA" => ta.vwma(anchoredMean, maLen) "Linear Regression" => ta.linreg(anchoredMean, maLen, 0) // Set the anchored quarter values. avg75 = math.avg(anchoredHi, anchoredMean), avg87 = math.avg(anchoredHi, avg75), avg62 = math.avg(anchoredMean, avg75) avg25 = math.avg(anchoredLo, anchoredMean), avg12 = math.avg(anchoredLo, avg25), avg42 = math.avg(anchoredMean, avg25) // Function to get a price. price(a) => switch a O => open H => high L => low C => close HL2 => hl2 HLC3 => hlc3 OHLC4 => ohlc4 HLCC4 => hlcc4 // Function to get yesterdays total volume. ydVol() => request.security(syminfo.tickerid, "1D", volume) // Initialize variables for the VWAP handoff. var vwap1D = 0., var handoff = array.new_float(4, 0) // Handoff VWAP values from the previous day. if newSession handoff.unshift(ydVol()), handoff.pop() handoff.unshift(vwap1D), handoff.pop() // Calc VWAP continuation beyond the first day. for i = 0 to handoff.size() / 2 - 1 j = i * 2 vwap = handoff.get(j) src = switch i 0 => source2 1 => source3 vol = volume cvol = handoff.get(j + 1) newV = cvol + vol newP = (vwap * cvol + price(src) * vol) / newV handoff.set(j, newP) handoff.set(j + 1, newV) // Set VWAP value. vwap1D := ta.vwap(price(source1), timeframe.change("1D")) // Set VWAP colors. v1Clr = newSession ? none : vwap1Clr v2Clr = newSession ? none : vwap2Clr v3Clr = newSession ? none : vwap3Clr // Plot VWAPs plot(vwap1D, "1 Day VWAP", v1Clr, vWidth1, plot.style_linebr, false, na, na, na, false, na, shoVWAP ? display.pane : display.none) plot(handoff.get(0), "2 Day VWAP", v2Clr, vWidth2, plot.style_linebr, false, na, na, na, false, na, shoDay2 ? display.pane : display.none) plot(handoff.get(2), "3 Day VWAP", v3Clr, vWidth3, plot.style_linebr, false, na, na, na, false, na, shoDay3 ? display.pane : display.none) // Function defining abnormal candle move continuation. moveCont(d) => switch d "up" => anchoredHi >= anchoredHi[1] or hlcc4 > avg87 "dn" => anchoredLo <= anchoredLo[1] or hlcc4 < avg12 // Function defining candle consolidation, relative to the previous anchor. consolidating(d, resetHi, resetLo) => doji or (o <= resetHi and c <= resetHi and o >= resetLo and c >= resetLo) // Set the plot and fill colors. var clr = array.new_color(colors.size()) for i = 0 to colors.size() - 1 _c_ = colors.get(i) _ifTrue_ = switch i 0 => bullish and (resetHiAnchor or moveCont("up") or consolidating("up", hrH, hrL)) 1 => bearish and (resetLoAnchor or moveCont("dn") or consolidating("dn", lrH, lrL)) => false clr.set(i, newSession ? none : _ifTrue_ ? color.new(_c_, 75) : _c_) // Toggle the colors reset to be false, if it has been reset back to the user specified color. bullish := clr.get(0) == hiAnClr ? false : bullish bearish := clr.get(1) == loAnClr ? false : bearish // Functions to determine if a plot or fill should display, based on the traders settings. displayPlot(ifTrue) => ifTrue ? display.pane : display.none displayFill(ifTrue) => ifTrue ? display.all : display.none // Plot the top, bottom, and average anchor values. top = plot(anchoredHi, "High Anchor", clr.get(0), hiWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoHiA)) bot = plot(anchoredLo, "Low Anchor", clr.get(1), loWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoLoA)) mid = plot(anchoredMean, "Average of Anchors", clr.get(2), mWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoMid)) // Plot 1/4 values (half way between average and anchor). t25 = plot(avg75, "Top 25% Line", clr.get(3), qWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoQrt)) b25 = plot(avg25, "Bottom 25% Line", clr.get(3), qWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoQrt)) // Plot 1/8 lines. showHideTopLine = displayPlot(shoHiFil) showHideBotLine = displayPlot(shoLoFil) t12 = plot(avg87, "Top 12.5% Line",clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) t252 = plot(avg75, "Top 25% Line", clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) t42 = plot(avg62, "Top 42.5% Line",clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) b42 = plot(avg42, "Bottom 42.5% Line",clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) b252 = plot(avg25, "Bottom 25% Line", clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) b12 = plot(avg12, "Bottom 12.5% Line",clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) // Plot 1/8 fills. showHideTopFill = displayFill(shoHiFil) showHideBotFill = displayFill(shoLoFil) fill(top, t12, clr.get(6), "Top 12.5% Fill", false, display = showHideTopFill) fill(top, t25, clr.get(6), "Top 25% Fill", false, display = showHideTopFill) fill(top, t42, clr.get(6), "Top 42.5% Fill", false, display = showHideTopFill) fill(bot, b42, clr.get(7), "Bottom 42.5% Fill", false, display = showHideBotFill) fill(bot, b25, clr.get(7), "Bottom 25% Fill", false, display = showHideBotFill) fill(bot, b12, clr.get(7), "Bottom 12.5% Fill", false, display = showHideBotFill)
Futures All List / Sell Signal
https://www.tradingview.com/script/bQXoNV5K/
gokhanpirnal
https://www.tradingview.com/u/gokhanpirnal/
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/ // © gokhanpirnal //@version=5 indicator("Futures All List / Sell Signal", shorttitle = "Sell Signal", overlay = false) // | INPUT | // Sorting sortTable = input.string(title="Sort Table by" , defval="High-Low [0]", options=[ "Alphabet", "High-Low [0]", "Low-High [0]"]) // Set Type set = input.string(title="Sector Set Type" , defval="1.LIST", options = ["1.LIST", "2.LIST", "3.LIST", "4.LIST", "5.LIST"]) // Table Position in_table_pos = input.string(title="Table Location", defval= "Top Left", options = [ "Top Right" , "Middle Right" , "Bottom Right" , "Top Center", "Middle Center", "Bottom Center", "Top Left" , "Middle Left" , "Bottom Left" ], group= "Table Styling") // Table Size in_table_size = input.string(title="Table Size", defval="Small", options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group= "Table Styling") // Table Colors cell_lowColor = input.color(color.red, title= "Low Cell", inline="1", group="TableColor") cell_midColor = input.color(color.yellow, title= "Mid Cell", inline="2", group="TableColor") cell_highColor = input.color(color.green, title= "High Cell", inline="3", group="TableColor") background_col = input.color(color.gray, title= "Background Color", inline="1", group="TableColor") title_textCol = input.color(color.white, title="Title Text Color", inline="2", group="TableColor") cell_textCol = input.color(color.black, title="Cell Text Color", inline="3", group="TableColor") // | SYMBOLS | sym_short(s) => str.substring(s, str.pos(s, ":") + 1) symbol(num, req) => if req == "symbols" if set == "1.LIST" symbols = num == 0 ? "BINANCE:1000FLOKIUSDT.P": num == 1 ? "BINANCE:1000LUNCUSDT.P" : num == 2 ? "BINANCE:1000PEPEUSDT.P" : num == 3 ? "BINANCE:1000SHIBUSDT.P" : num == 4 ? "BINANCE:1000XECUSDT.P" : num == 5 ? "BINANCE:1INCHUSDT.P" : num == 6 ? "BINANCE:AAVEUSDT.P" : num == 7 ? "BINANCE:ACHUSDT.P" : num == 8 ? "BINANCE:ADAUSDT.P" : num == 9 ? "BINANCE:AGIXUSDT.P" : num == 10 ? "BINANCE:ALGOUSDT.P" : num == 11 ? "BINANCE:ALICEUSDT.P" : num == 12 ? "BINANCE:ALPHAUSDT.P" : num == 13 ? "BINANCE:AMBUSDT.P" : num == 14 ? "BINANCE:ANKRUSDT.P" : num == 15 ? "BINANCE:ANTUSDT.P" : num == 16 ? "BINANCE:APEUSDT.P" : num == 17 ? "BINANCE:API3USDT.P" : num == 18 ? "BINANCE:APTUSDT.P" : num == 19 ? "BINANCE:ARBUSDT.P" : num == 20 ? "BINANCE:ARPAUSDT.P" : num == 21 ? "BINANCE:ARUSDT.P" : num == 22 ? "BINANCE:ASTRUSDT.P" : num == 23 ? "BINANCE:ATAUSDT.P" : num == 24 ? "BINANCE:ATOMUSDT.P" : num == 25 ? "BINANCE:AUDIOUSDT.P" : num == 26 ? "BINANCE:AVAXUSDT.P" : num == 27 ? "BINANCE:AXSUSDT.P" : num == 28 ? "BINANCE:BAKEUSDT.P" : num == 29 ? "BINANCE:BALUSDT.P" : num == 30 ? "BINANCE:BANDUSDT.P" : num == 31 ? "BINANCE:BATUSDT.P" : num == 32 ? "BINANCE:BCHUSDT.P" : num == 33 ? "BINANCE:BELUSDT.P" : num == 34 ? "BINANCE:BLUEBIRDUSDT.P" : num == 35 ? "BINANCE:BLURUSDT.P" : num == 36 ? "BINANCE:BLZUSDT.P" : num == 37 ? "BINANCE:BNBUSDT.P" : num == 38 ? "BINANCE:BNXUSDT.P" : num == 39 ? "BINANCE:BTCDOMUSDT.P" : na else if set == "2.LIST" symbols = num == 0 ? "BINANCE:BTCUSDT.P" : num == 1 ? "BINANCE:C98USDT.P" : num == 2 ? "BINANCE:CELOUSDT.P" : num == 3 ? "BINANCE:CELRUSDT.P" : num == 4 ? "BINANCE:CFXUSDT.P" : num == 5 ? "BINANCE:CHRUSDT.P" : num == 6 ? "BINANCE:CHZUSDT.P" : num == 7 ? "BINANCE:CKBUSDT.P" : num == 8 ? "BINANCE:COMPUSDT.P" : num == 9 ? "BINANCE:COTIUSDT.P" : num == 10 ? "BINANCE:CRVUSDT.P" : num == 11 ? "BINANCE:CTKUSDT.P" : num == 12 ? "BINANCE:CTSIUSDT.P" : num == 13 ? "BINANCE:CVXUSDT.P" : num == 14 ? "BINANCE:DARUSDT.P" : num == 15 ? "BINANCE:DASHUSDT.P" : num == 16 ? "BINANCE:DEFIUSDT.P" : num == 17 ? "BINANCE:DENTUSDT.P" : num == 18 ? "BINANCE:DGBUSDT.P" : num == 19 ? "BINANCE:DOGEUSDT.P" : num == 20 ? "BINANCE:DOTUSDT.P" : num == 21 ? "BINANCE:DUSKUSDT.P" : num == 22 ? "BINANCE:DYDXUSDT.P" : num == 23 ? "BINANCE:EDUUSDT.P" : num == 24 ? "BINANCE:EGLDUSDT.P" : num == 25 ? "BINANCE:ENJUSDT.P" : num == 26 ? "BINANCE:ENSUSDT.P" : num == 27 ? "BINANCE:EOSUSDT.P" : num == 28 ? "BINANCE:ETCUSDT.P" : num == 29 ? "BINANCE:ETHUSDT.P" : num == 30 ? "BINANCE:FETUSDT.P" : num == 31 ? "BINANCE:FILUSDT.P" : num == 32 ? "BINANCE:FLMUSDT.P" : num == 33 ? "BINANCE:FLOWUSDT.P" : num == 34 ? "BINANCE:FOOTBALLUSDT.P" : num == 35 ? "BINANCE:FTMUSDT.P" : num == 36 ? "BINANCE:FXSUSDT.P" : num == 37 ? "BINANCE:GALAUSDT.P" : num == 38 ? "BINANCE:GALUSDT.P" : num == 39 ? "BINANCE:GMTUSDT.P" : na else if set == "3.LIST" symbols = num == 0 ? "BINANCE:GMXUSDT.P" : num == 1 ? "BINANCE:GRTUSDT.P" : num == 2 ? "BINANCE:GTCUSDT.P" : num == 3 ? "BINANCE:HBARUSDT.P" : num == 4 ? "BINANCE:HFTUSDT.P" : num == 5 ? "BINANCE:HIGHUSDT.P" : num == 6 ? "BINANCE:HOOKUSDT.P" : num == 7 ? "BINANCE:HOTUSDT.P" : num == 8 ? "BINANCE:ICPUSDT.P" : num == 9 ? "BINANCE:ICXUSDT.P" : num == 10 ? "BINANCE:IDEXUSDT.P" : num == 11 ? "BINANCE:IDUSDT.P" : num == 12 ? "BINANCE:IMXUSDT.P" : num == 13 ? "BINANCE:INJUSDT.P" : num == 14 ? "BINANCE:IOSTUSDT.P" : num == 15 ? "BINANCE:IOTAUSDT.P" : num == 16 ? "BINANCE:IOTXUSDT.P" : num == 17 ? "BINANCE:JASMYUSDT.P" : num == 18 ? "BINANCE:JOEUSDT.P" : num == 19 ? "BINANCE:KAVAUSDTPERP" : num == 20 ? "BINANCE:KEYUSDT.P" : num == 21 ? "BINANCE:KLAYUSDT.P" : num == 22 ? "BINANCE:KNCUSDT.P" : num == 23 ? "BINANCE:KSMUSDT.P" : num == 24 ? "BINANCE:LDOUSDT.P" : num == 25 ? "BINANCE:LEVERUSDT.P" : num == 26 ? "BINANCE:LINAUSDT.P" : num == 27 ? "BINANCE:LINKUSDT.P" : num == 28 ? "BINANCE:LITUSDT.P" : num == 29 ? "BINANCE:LPTUSDT.P" : num == 30 ? "BINANCE:LQTYUSDT.P" : num == 31 ? "BINANCE:LRCUSDT.P" : num == 32 ? "BINANCE:LTCUSDT.P" : num == 33 ? "BINANCE:LUNA2USDT.P" : num == 34 ? "BINANCE:MAGICUSDT.P" : num == 35 ? "BINANCE:MANAUSDT.P" : num == 36 ? "BINANCE:MASKUSDT.P" : num == 37 ? "BINANCE:MATICUSDT.P" : num == 38 ? "BINANCE:MINAUSDT.P" : num == 39 ? "BINANCE:MKRUSDT.P" : na else if set == "4.LIST" symbols = num == 0 ? "BINANCE:MTLUSDT.P" : num == 1 ? "BINANCE:NEARUSDT.P" : num == 2 ? "BINANCE:NEOUSDT.P" : num == 3 ? "BINANCE:NKNUSDT.P" : num == 4 ? "BINANCE:OCEANUSDT.P" : num == 5 ? "BINANCE:OGNUSDT.P" : num == 6 ? "BINANCE:OMGUSDT.P" : num == 7 ? "BINANCE:ONEUSDT.P" : num == 8 ? "BINANCE:ONTUSDT.P" : num == 9 ? "BINANCE:OPUSDT.P" : num == 10 ? "BINANCE:PEOPLEUSDT.P" : num == 11 ? "BINANCE:PERPUSDT.P" : num == 12 ? "BINANCE:PHBUSDT.P" : num == 13 ? "BINANCE:QNTUSDT.P" : num == 14 ? "BINANCE:QTUMUSDT.P" : num == 15 ? "BINANCE:RADUSDT.P" : num == 16 ? "BINANCE:RDNTUSDT.P" : num == 17 ? "BINANCE:REEFUSDT.P" : num == 18 ? "BINANCE:RENUSDT.P" : num == 19 ? "BINANCE:RLCUSDT.P" : num == 20 ? "BINANCE:RNDRUSDT.P" : num == 21 ? "BINANCE:ROSEUSDT.P" : num == 22 ? "BINANCE:RSRUSDT.P" : num == 23 ? "BINANCE:RUNEUSDT.P" : num == 24 ? "BINANCE:RVNUSDT.P" : num == 25 ? "BINANCE:SANDUSDT.P" : num == 26 ? "BINANCE:SFPUSDT.P" : num == 27 ? "BINANCE:SKLUSDT.P" : num == 28 ? "BINANCE:SNXUSDT.P" : num == 29 ? "BINANCE:SOLUSDT.P" : num == 30 ? "BINANCE:SPELLUSDT.P" : num == 31 ? "BINANCE:SSVUSDT.P" : num == 32 ? "BINANCE:STGUSDT.P" : num == 33 ? "BINANCE:STMXUSDT.P" : num == 34 ? "BINANCE:STORJUSDT.P" : num == 35 ? "BINANCE:STXUSDT.P" : num == 36 ? "BINANCE:SUIUSDT.P" : num == 37 ? "BINANCE:SUSHIUSDT.P" : num == 38 ? "BINANCE:SXPUSDT.P" : num == 39 ? "BINANCE:THETAUSDT.P" : na else if set == "5.LIST" symbols = num == 0 ? "BINANCE:TLMUSDT.P" : num == 1 ? "BINANCE:TOMOUSDT.P" : num == 2 ? "BINANCE:TRBUSDT.P" : num == 3 ? "BINANCE:TRUUSDT.P" : num == 4 ? "BINANCE:TRXUSDT.P" : num == 5 ? "BINANCE:TUSDT.P" : num == 6 ? "BINANCE:UMAUSDT.P" : num == 7 ? "BINANCE:UNFIUSDT.P" : num == 8 ? "BINANCE:UNIUSDT.P" : num == 9 ? "BINANCE:USDCUSDT.P" : num == 10 ? "BINANCE:VETUSDT.P" : num == 11 ? "BINANCE:WAVESUSDT.P" : num == 12 ? "BINANCE:WOOUSDT.P" : num == 13 ? "BINANCE:XEMUSDT.P" : num == 14 ? "BINANCE:XLMUSDT.P" : num == 15 ? "BINANCE:XMRUSDT.P" : num == 16 ? "BINANCE:XRPUSDT.P" : num == 17 ? "BINANCE:XTZUSDT.P" : num == 18 ? "BINANCE:XVSUSDT.P" : num == 19 ? "BINANCE:YFIUSDT.P" : num == 20 ? "BINANCE:ZECUSDT.P" : num == 21 ? "BINANCE:ZENUSDT.P" : num == 22 ? "BINANCE:ZILUSDT.P" : num == 23 ? "BINANCE:ZRXUSDT.P" : num == 24 ? "BINANCE:BTCUSDT.P" : num == 25 ? "BINANCE:BTCDOMUSDT.P" : na // | CALCULATION | //Order [colMtx, order] = switch sortTable "High-Low [0]" => [1, order.descending] "Low-High [0]" => [1, order.ascending ] => [0, order.ascending] // Matrix sectors = matrix.new<float>(40, 2, na) symbol01 = syminfo.tickerid long = input(title='TSI Long Length', defval=3) short = input(title='TSI Short Length', defval=3) signal = input(title='TSI Signal Length', defval=6) len = input.int(6, minval=1, title='RSI Length') priceopen = open double_smoothopen(srcopen, long, short) => fist_smoothopen = ta.ema(srcopen, long) ta.ema(fist_smoothopen, short) pcopen = ta.change(priceopen) double_smoothed_pcopen = double_smoothopen(pcopen, long, short) double_smoothed_abs_pcopen = double_smoothopen(math.abs(pcopen), long, short) tsi_valueopen = 100 * (double_smoothed_pcopen / double_smoothed_abs_pcopen) srcopen = input(open, 'Source') upopen = ta.rma(math.max(ta.change(srcopen), 0), len) downopen = ta.rma(-math.min(ta.change(srcopen), 0), len) rsiopen = downopen == 0 ? 100 : upopen == 0 ? 0 : 100 - 100 / (1 + upopen / downopen) totalopen = tsi_valueopen + ta.ema(tsi_valueopen, signal) + rsiopen pricehigh = high double_smoothhigh(srchigh, long, short) => fist_smoothhigh = ta.ema(srchigh, long) ta.ema(fist_smoothhigh, short) pchigh = ta.change(pricehigh) double_smoothed_pchigh = double_smoothhigh(pchigh, long, short) double_smoothed_abs_pchigh = double_smoothhigh(math.abs(pchigh), long, short) tsi_valuehigh = 100 * (double_smoothed_pchigh / double_smoothed_abs_pchigh) srchigh = input(high, 'Source') uphigh = ta.rma(math.max(ta.change(srchigh), 0), len) downhigh = ta.rma(-math.min(ta.change(srchigh), 0), len) rsihigh = downhigh == 0 ? 100 : uphigh == 0 ? 0 : 100 - 100 / (1 + uphigh / downhigh) totalhigh = tsi_valuehigh + ta.ema(tsi_valuehigh, signal) + rsihigh pricelow = low double_smoothlow(srclow, long, short) => fist_smoothlow = ta.ema(srclow, long) ta.ema(fist_smoothlow, short) pclow = ta.change(pricelow) double_smoothed_pclow = double_smoothlow(pclow, long, short) double_smoothed_abs_pclow = double_smoothlow(math.abs(pclow), long, short) tsi_valuelow = 100 * (double_smoothed_pclow / double_smoothed_abs_pclow) srclow = input(low, 'Source') uplow = ta.rma(math.max(ta.change(srclow), 0), len) downlow = ta.rma(-math.min(ta.change(srclow), 0), len) rsilow = downlow == 0 ? 100 : uplow == 0 ? 0 : 100 - 100 / (1 + uplow / downlow) totallow = tsi_valuelow + ta.ema(tsi_valuelow, signal) + rsilow priceclose = close double_smoothclose(srcclose, long, short) => fist_smoothclose = ta.ema(srcclose, long) ta.ema(fist_smoothclose, short) pcclose = ta.change(priceclose) double_smoothed_pcclose = double_smoothclose(pcclose, long, short) double_smoothed_abs_pcclose = double_smoothclose(math.abs(pcclose), long, short) tsi_valueclose = 100 * (double_smoothed_pcclose / double_smoothed_abs_pcclose) srcclose = input(close, 'Source') upclose = ta.rma(math.max(ta.change(srcclose), 0), len) downclose = ta.rma(-math.min(ta.change(srcclose), 0), len) rsiclose = downclose == 0 ? 100 : upclose == 0 ? 0 : 100 - 100 / (1 + upclose / downclose) totalclose = (tsi_valueclose + ta.ema(tsi_valueclose, signal) + rsiclose) a = array.from(totalopen, totalhigh, totallow, totalclose) maksdata = array.max(a, 0) // 1 dump=maksdata[0]+totalclose[0] plot(dump,title="Dump",color=color.rgb(255,0,255,0),linewidth=2) hline(600, title='Üst Sınır', color=#00ff00) hline(0,title="Zero", color=#00ffff) hline(-400, title='Alt Sınır', color=#ff0000) // Fill Matrix Function fun_matrix(mtxName, row, adj) => // Symbol Name string sym= symbol(row, "symbols") s = ticker.modify(sym, syminfo.session) // Symbol code matrix.set(mtxName, row + adj, 0, row) // Dump rt0 = request.security(s, timeframe.period, dump[0]) matrix.set(mtxName, row + adj, 1, rt0) //++++++++++ Sector Matrix fun_matrix(sectors, 0, 0) fun_matrix(sectors, 1, 0) fun_matrix(sectors, 2, 0) fun_matrix(sectors, 3, 0) fun_matrix(sectors, 4, 0) fun_matrix(sectors, 5, 0) fun_matrix(sectors, 6, 0) fun_matrix(sectors, 7, 0) fun_matrix(sectors, 8, 0) fun_matrix(sectors, 9, 0) fun_matrix(sectors, 10, 0) fun_matrix(sectors, 11, 0) fun_matrix(sectors, 12, 0) fun_matrix(sectors, 13, 0) fun_matrix(sectors, 14, 0) fun_matrix(sectors, 15, 0) fun_matrix(sectors, 16, 0) fun_matrix(sectors, 17, 0) fun_matrix(sectors, 18, 0) fun_matrix(sectors, 19, 0) fun_matrix(sectors, 20, 0) fun_matrix(sectors, 21, 0) fun_matrix(sectors, 22, 0) fun_matrix(sectors, 23, 0) fun_matrix(sectors, 24, 0) fun_matrix(sectors, 25, 0) fun_matrix(sectors, 26, 0) fun_matrix(sectors, 27, 0) fun_matrix(sectors, 28, 0) fun_matrix(sectors, 29, 0) fun_matrix(sectors, 30, 0) fun_matrix(sectors, 31, 0) fun_matrix(sectors, 32, 0) fun_matrix(sectors, 33, 0) fun_matrix(sectors, 34, 0) fun_matrix(sectors, 35, 0) fun_matrix(sectors, 36, 0) fun_matrix(sectors, 37, 0) fun_matrix(sectors, 38, 0) fun_matrix(sectors, 39, 0) matrix.sort(sectors, colMtx, order) // | Table | // Get Table Position table_pos(p) => switch p "Top Right" => position.top_right "Middle Right" => position.middle_right "Bottom Right" => position.bottom_right "Top Center" => position.top_center "Middle Center" => position.middle_center "Bottom Center" => position.bottom_center "Top Left" => position.top_left "Middle Left" => position.middle_left => position.bottom_left // Get Table Size table_size(s) => switch s "Auto" => size.auto "Huge" => size.huge "Large" => size.large "Normal" => size.normal "Small" => size.small => size.tiny tz = table_size(in_table_size) // Get Title Column fun_titlCol(tbl, col, txtCol) => table.cell(tbl, col, 0, text_halign =text.align_left, text = txtCol, text_color = title_textCol, text_size = tz, bgcolor = background_col) // Get Cell Values fun_cell(tbl, row, mtxName, mtxRow) => loSh = matrix.get(mtxName, mtxRow, 1) bglSColor = ( loSh<0 ? color.rgb(255,106,106,0):color.rgb(106,255,106,0)) table.cell(tbl, 0, row, text_halign=text.align_right, text_valign=text.align_center, text = sym_short(symbol(matrix.get(mtxName, mtxRow, 0), "symbols")), text_color = title_textCol, text_size = tz, bgcolor= background_col) table.cell(tbl, 1, row, text_halign=text.align_right, text_valign=text.align_center, text = str.tostring(matrix.get(mtxName,mtxRow,1),"###.####"), text_color = cell_textCol, text_size = tz, bgcolor = bglSColor) // Create Table var tbl = table.new(table_pos(in_table_pos), 2, 41, frame_width = 5, border_width = 1, border_color = color.new(title_textCol, 100)) // Fill up Cells. if barstate.islast table.clear(tbl, 0, 0, 1, 40) // columns fun_titlCol(tbl, 0, "---SYMBOL---") fun_titlCol(tbl, 1, "DUMP \nPoint=+600") for i = 1 to 40 fun_cell(tbl, i, sectors, i - 1)
Displacement (Two FVGs)
https://www.tradingview.com/script/fgMo64tR-Displacement-Two-FVGs/
elScipio
https://www.tradingview.com/u/elScipio/
177
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/ // © AJ7919 //@version=5 indicator('Displacement (Two FVGs)', overlay=false) bullishFvg = low[1] > high[3] and low[2] > high[4] bearishFvg = high[1] < low[3] and high[2] < low[4] bull=bullishFvg?2:0 bear=bearishFvg?-2:0 plot(bull, color= color.green, title='Bullish Displacement', linewidth=1, style = plot.style_columns ) plot(bear, color= color.red, title='Bearish Displacement', linewidth=1, style = plot.style_columns) bgcolor(bull ? color.new(color.green,90) : bear ? color.new(color.red,90) : na) plot(0, color=color.new(color.black, 0)) alertcondition(bullishFvg, title = "Two Bullish FVGs", message = "Potential Bullish Displacemen") alertcondition(bearishFvg, title = "Two Bearish FVG", message = "Potential Bearish Displacement") if bullishFvg alert("Potential Bullish Displacement", alert.freq_once_per_bar_close) if bearishFvg alert("Potential Bearish Displacement", alert.freq_once_per_bar_close)
Revolution SMA-EMA Divergence
https://www.tradingview.com/script/bXQccHA9-Revolution-SMA-EMA-Divergence/
steffenrg
https://www.tradingview.com/u/steffenrg/
30
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/ // © steffenrg //@version=5 indicator("Revolution SMA-EMA Divergence") len = input(50) sma_short_cycle = ta.sma(close, len) ema_short_cycle = ta.ema(close, len) difference = ema_short_cycle - sma_short_cycle sma_long_cycle = ta.sma(close, len*2) ema_long_cycle = ta.ema(close, len*2) difference2 = ema_long_cycle - sma_long_cycle sma_timing = ta.sma(close, len/2) ema_timing = ta.ema(close, len/2) difference3 = ema_timing - sma_timing hline(0) plot(difference2, color = color.black, style = plot.style_histogram) plot(difference, color = color.orange, style = plot.style_histogram) plot(difference3, color = color.red)
VOLD Ratio (Volume Difference Ratio) by Tenozen
https://www.tradingview.com/script/hqiSDreM-VOLD-Ratio-Volume-Difference-Ratio-by-Tenozen/
Tenozen
https://www.tradingview.com/u/Tenozen/
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/ // © Tenozen //@version=5 indicator("VOLD Ratio",precision = 6) is_new_time = ta.change(time("W")) up_net_volume = close > open? volume: 0 down_net_volume = close < open? volume: 0 var float up_vol = na var float down_vol = na var float [] unv = array.new_float() var float [] dnv = array.new_float() if (is_new_time) up_vol := up_net_volume down_vol := down_net_volume array.push(unv, up_vol) array.push(dnv, down_vol) else if (up_vol == up_vol) up_vol := up_net_volume array.push(unv, up_vol) if (down_vol == down_vol) down_vol := down_net_volume array.push(dnv, down_vol) net_valup = array.sum(unv) net_valdown = array.sum(dnv) vold = net_valup/net_valdown plot(vold, "VOLD Ratio", color.new(color.white, 50)) //Bollinger Bands length = input.int(50, minval=1) src = vold 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.new(color.yellow, 50), offset = offset) p1 = plot(upper, "Upper", color.new(color.white,50), offset = offset) p2 = plot(lower, "Lower", color.new(color.white,50), offset = offset) fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
Nexus Blast Trading Strategy [Kaspricci]
https://www.tradingview.com/script/WkoqnY4e/
Kaspricci
https://www.tradingview.com/u/Kaspricci/
162
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/ // © Kaspricci //@version=5 indicator("Nexus Blast Trading Strategy [Kaspricci]", shorttitle = "Nexus Blast Trading", overlay = true, max_lines_count = 500, max_boxes_count = 500) // ======================================================================================================================================================================== groupGeneral = "General Settings" timeZone = input.string(group = groupGeneral, title = "Timezone", defval = "UTC-4", options = ["UTC-10", "UTC-9", "UTC-8", "UTC-7", "UTC-6", "UTC-5", "UTC-4", "UTC-3", "UTC-2", "UTC-1", "UTC", "UTC+1", "UTC+2", "UTC+3", "UTC+4", "UTC+5", "UTC+6", "UTC+7", "UTC+8", "UTC+9", "UTC+10", "UTC+11", "UTC+12"]) // ======================================================================================================================================================================== groupSessions = "Sessions" londonSession = input.session(group = groupSessions, title = "London", defval = "0000-0800", tooltip = "London session 00:00 - 08:00") amSession = input.session(group = groupSessions, title = "NY am", defval = "0800-1300", tooltip = "NY am session 08:00 - 13:00") pmSession = input.session(group = groupSessions, title = "NY pm", defval = "1300-1900", tooltip = "NY pm session 13:00 - 19:00") asianSession = input.session(group = groupSessions, title = "Asian", defval = "1900-0000", tooltip = "Asian session 19:00 - 00:00") sessionColor = input.color(defval = color.rgb(178, 181, 190, 50), title = "Session Line Color") newDayColor = input.color(defval = color.rgb(33, 149, 243, 50), title = "New Day Line Color") //numberOfDaysBack = input.int(group = groupSessions, title = "Number of Days back", defval = 10, minval = 1, step = 5, maxval = 50, tooltip = "Defines the number of days for which a high and low line will be drawn") numberOfDaysBack = 50 inLondonSession = not na(time("", londonSession, timeZone)) inAmSession = not na(time("", amSession, timeZone)) inPmSession = not na(time("", pmSession, timeZone)) inAsianSession = not na(time("", asianSession, timeZone)) isSunday = dayofweek(time, timeZone) == dayofweek.sunday // ======================================================================================================================================================================== bgcolor(isSunday ? color.rgb(178, 181, 190, 90) : na ) var currentHigh = high var line currentHighLine = na var line[] highLines = array.new_line(0, na) var currentLow = low var line currentLowLine = na var line[] lowLines = array.new_line(0, na) hasBuySideLiquidityTaken(line[] highLines) => flag = false if highLines.size() > 1 for i = 0 to highLines.size() - 2 highLine = highLines.get(i) price = line.get_y1(highLine) lastBar = line.get_x2(highLine) if (bar_index > lastBar and high > price ) highLines.remove(i) flag := true break flag hasSellSideLiquidityTaken(line[] lowLines) => flag = false if lowLines.size() > 1 for i = 0 to lowLines.size() - 2 lowLine = lowLines.get(i) price = line.get_y1(lowLine) lastBar = line.get_x2(lowLine) if (bar_index > lastBar and low < price ) lowLines.remove(i) flag := true break flag handleSession(bool inSession, line[] highLines, line[] lowLines, float maxHigh, float minLow) => if ( not inSession[1] and inSession ) // start of session highLine = line.new(bar_index, high, bar_index + 1, high) lowLine = line.new(bar_index, low, bar_index + 1, low) highLines.push(highLine) lowLines.push(lowLine) if ( inSession and not isSunday ) // during session line.set_y1(highLines.last(), maxHigh) line.set_xy2(highLines.last(), bar_index, maxHigh) line.set_y1(lowLines.last(), minLow) line.set_xy2(lowLines.last(), bar_index, minLow) if ( highLines.size() > numberOfDaysBack * 4) firstLine = highLines.first() line.delete(firstLine) highLines.remove(0) if ( lowLines.size() > numberOfDaysBack * 4 ) firstLine = lowLines.first() line.delete(firstLine) lowLines.remove(0) if highLines.size() > 1 for i = 0 to highLines.size() - 2 highLine = highLines.get(i) price = line.get_y1(highLine) lastBar = line.get_x2(highLine) if (bar_index > lastBar and high > price ) line.set_color(highLine, color.red) if lowLines.size() > 1 for i = 0 to lowLines.size() - 2 lowLine = lowLines.get(i) price = line.get_y1(lowLine) lastBar = line.get_x2(lowLine) if (bar_index > lastBar and low < price ) line.set_color(lowLine, color.red) if ( inLondonSession and not isSunday ) currentHigh := math.max(high, currentHigh) currentLow := math.min(low, currentLow) handleSession(inLondonSession, highLines, lowLines, currentHigh, currentLow) if ( inLondonSession[1] and not inLondonSession ) currentHigh := high currentLow := low line.new(bar_index, high, bar_index, low, extend = extend.both, color = sessionColor) if ( inAmSession and not isSunday) currentHigh := math.max(high, currentHigh) currentLow := math.min(low, currentLow) handleSession(inAmSession, highLines, lowLines, currentHigh, currentLow) if ( inAmSession[1] and not inAmSession ) currentHigh := high currentLow := low line.new(bar_index, high, bar_index, low, extend = extend.both, color = sessionColor) if ( inPmSession and not isSunday ) currentHigh := math.max(high, currentHigh) currentLow := math.min(low, currentLow) handleSession(inPmSession, highLines, lowLines, currentHigh, currentLow) if ( inPmSession[1] and not inPmSession and not isSunday ) currentHigh := high currentLow := low line.new(bar_index, high, bar_index, low, extend = extend.both, color = sessionColor) if ( inAsianSession and not isSunday ) currentHigh := math.max(high, currentHigh) currentLow := math.min(low, currentLow) handleSession(inAsianSession, highLines, lowLines, currentHigh, currentLow) if ( inAsianSession[1] and not inAsianSession and not isSunday ) currentHigh := high currentLow := low if ( ta.change(time("1D", "0000-0000:1234567", timeZone)) ) line.new(bar_index, high, bar_index, low, extend = extend.both, color = newDayColor) alertcondition(hasBuySideLiquidityTaken(highLines), "Buy Side Liquidity Alert", "{{timenow}} - Buy Side Liquidity Alert for {{exchange}}:{{ticker}} at price: {{close}}") alertcondition(hasSellSideLiquidityTaken(lowLines), "Sell Side Liquidity Alert", "{{timenow}} - Sell Side Liquidity Alert for {{exchange}}:{{ticker}} at price: {{close}}") // ======================================================================================================================================================================== groupFVG = "FVG Settings" threshold = input.int(group = groupFVG, defval = 0, minval = 0, step = 5, title = "Threshold in Ticks", tooltip = "Hide fair value gaps (FVG) with a gap smaller then this number of ticks") isBearishFVG = low[2] > high + threshold * syminfo.mintick isBullishFVG = high[2] < low - threshold * syminfo.mintick bullishColor = input.color(defval = color.rgb(33, 149, 243, 70), title = "Bullish FVG Color") bearishColor = input.color(defval = color.rgb(255, 153, 0, 70), title = "Bearish FVG Color") if barstate.isconfirmed and isBearishFVG box.new(bar_index - 2, low[2], bar_index, high, border_color = color.new(bearishColor, 0), bgcolor = bearishColor) if barstate.isconfirmed and isBullishFVG box.new(bar_index - 2, high[2], bar_index, low, border_color = color.new(bullishColor, 0), bgcolor = bullishColor)
Volatility
https://www.tradingview.com/script/AKMU95Wu-Volatility/
weak_hand
https://www.tradingview.com/u/weak_hand/
61
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/ // © weak_hand //@version=5 indicator("Volatility", overlay = false) // ----------------------------------------------} // LIBRARY // ----------------------------------------------{ import weak_hand/RiskManagement/1 as risk_management // ----------------------------------------------} // INPUTS // ----------------------------------------------{ int length = input.int(14, "Length", minval = 1) color col_apc = input.color(#B71C1C, "", inline = "apc") color col_atr = input.color(#F57F17, "", inline = "atr") color col_mpf = input.color(#E65100, "", inline = "mpf") color col_cross = input.color(#4DD0E1, "", inline = "cross") bool show_apc = input.bool(true, "Absolut Price Change" , inline = "apc") bool show_atr = input.bool(true, "Average True Range" , inline = "atr") bool show_mpf = input.bool(true, "Maximum Price Fluctuation", inline = "mpf") bool show_bg = input.bool(true, "MPF > APC Cross" , inline = "cross") //int length_high = input.int(50, "Length", minval = 20) int length_high = 50 bool col_theme = input.bool(false, "Dark Theme" ) // ----------------------------------------------} // CALCULATIONS // ----------------------------------------------{ float apc = risk_management.absolute_price_changes(length) float mpf = risk_management.maximum_price_fluctuation(length) float atr = ta.atr(length) float highest_apc = ta.highest(apc, length_high) float highest_mpf = ta.highest(mpf, length_high) float highest_atr = ta.highest(atr, length_high) color col_cross_gradient = color.from_gradient(mpf, 0, highest_mpf, col_theme ? color.black : color.white, col_cross) // ----------------------------------------------} // OUTPUTS // ----------------------------------------------{ plot_apc = plot(show_apc ? apc : na, "APC", col_apc, 1, editable = false) plot_mpf = plot(show_mpf ? mpf : na, "MPF", col_mpf, 1, editable = false) plot_atr = plot(show_atr ? atr : na, "ATR", col_atr, 1, editable = false) plot_zero = plot(0, "Zero Line", na, editable = false, display = display.none) fill(plot_zero, plot_apc, highest_apc, 0, bottom_color = show_apc ? (col_theme ? color.black : color.white) : na, top_color = show_apc ? col_apc : na, editable = false) fill(plot_zero, plot_mpf, highest_mpf, 0, bottom_color = show_mpf ? (col_theme ? color.black : color.white) : na, top_color = show_mpf ? col_mpf : na, editable = false) fill(plot_zero, plot_atr, highest_atr, 0, bottom_color = show_atr ? (col_theme ? color.black : color.white) : na, top_color = show_atr ? col_atr : na, editable = false) bgcolor(show_bg ? (mpf > apc ? col_cross_gradient : na) : na, editable = false)
Reversal Signals [LuxAlgo]
https://www.tradingview.com/script/qTWl7ZOy-Reversal-Signals-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
4,678
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("Reversal Signals [LuxAlgo]", "LuxAlgo - Reversal Signals", true, max_labels_count = 500, max_bars_back = 5000) //------------------------------------------------------------------------------ // Settings //-----------------------------------------------------------------------------{ bGR = 'Momentum Phase' bTP = 'Momentum phase provides an indication of the initial trend\'s momentum and identifies a point of a likely top or bottom in the ranging markets\n\n' + 'Completed - dislays only completed momentum phases\n' + 'Detailed - displays all counting process of the momentum phases\nNone - disables the display of the momentum phases' bSh = input.string('Completed', 'Display Phases', options = ['Completed', 'Detailed', 'None'], group = bGR, tooltip = bTP) srL = input.bool(true , 'Support & Resistance Levels', inline = 'bSh', group = bGR) ptLT = input.string('Step Line w/ Diamonds', '', options = ['Circles', 'Step Line', 'Step Line w/ Diamonds'], inline = 'bSh', group = bGR) rsB = input.bool(false, 'Momentum Phase Risk Levels', inline = 'bSh2', group = bGR) ptSR = input.string('Circles', '', options = ['Circles', 'Step Line'], inline = 'bSh2', group = bGR) eGR = 'Trend Exhaustion Phase' eTP = 'Trend exhaustion phase aims to identify when the trend is fading/exhausting and possibly starting to reverse. The trend exhaustion phase starts only if a momentum phase is already established\n\n' + 'Completed - dislays only completed trend exhaustion phases\n' + 'Detailed - displays all counting process of the trend exhaustion phases\nNone - disables the display of the trend exhaustion phases' eSh = input.string('Completed', 'Display Phases', options = ['Completed', 'Detailed', 'None'], group = eGR, tooltip = eTP) rsE = input.bool(false, 'Trend Exhaustion Phase Risk Levels', group = eGR) ttE = input.bool(false, 'Trend Exhaustion Phase Target Levels', group = eGR) tGR = 'Trade Setups' tTP = 'All phase specific trade setups, presented as options, are triggered once the selected phase is completed and folowed by a price flip in the direction of the trade setup. Please pay attention to the phase specific risk levels as well as the overall trend direction\n' + '⚠️ Trading is subject to high risk, look first then leap\n\n' + 'Tips : \n' + ' - Momentum trade setups are not recommended setups, and in case applied they best fit in ranging market\n' + ' a trade signal, followed immediately by a warning indication can be assumed as continuation of the underlying trend and can be traded in the opposite direction of the suggested signal\n\n' + ' - Exhaustion / Qualified trade setups best fits in trending market\n' + ' Exhaustion, suggested type of trade setup, buy (sell) when buy (sell) trend exhaustion phase is complete\n' + ' Qualified, trend exhaustion phase followed by momentum phase is assumed as qualified trade setup' tso = input.string('None', 'Phase Specific Trade Setup Options', options = ['Momentum', 'Exhaustion', 'Qualified', 'None'], group = tGR, tooltip = tTP) war = input.bool(false , 'Price Flips against the Phase Specific Trade Setups', group = tGR) //-----------------------------------------------------------------------------} // General Calculations //-----------------------------------------------------------------------------{ var BnoShw = false Bcmpltd = bSh == 'Completed' BnoShw := bSh == 'None' ? false : true var noShw = false cmpltd = eSh == 'Completed' noShw := eSh == 'None' ? false : true //-----------------------------------------------------------------------------} // User Defined Types //-----------------------------------------------------------------------------{ // @type bar properties with their values // // @field o (float) open price of the bar // @field h (float) high price of the bar // @field l (float) low price of the bar // @field c (float) close price of the bar // @field i (int) index of the bar type bar float o = open float h = high float l = low float c = close int i = bar_index // @type momentum phase varaibles // // @field bSC (int) bullish momentum phase count // @field bSH (float) bullish momentum phase high price value // @field bSL (float) bullish momentum phase lowest price value // // @field sSC (int) bearish momentum phase count // @field sSH (float) bearish momentum phase highest price value // @field sSL (float) bearish momentum phase low price value type trb int bSC float bSH float bSL int sSC float sSH float sSL // @type trend exhaustion phase varaibles // // @field bCC (int) bullish trend exhaustion phase count // @field bC8 (float) bullish trend exhaustion phase 8 count's condition // @field bCHt (float) bullish trend exhaustion phase highest price value // @field bCH (float) bullish trend exhaustion phase high price value // @field bCL (float) bullish trend exhaustion phase low price value // @field bCLt (float) bullish trend exhaustion phase lowest price value // @field bCD (float) bullish trend exhaustion phase risk price value // // @field sCC (int) bearish trend exhaustion phase count // @field sC8 (float) bearish trend exhaustion phase 8 count's condition // @field sCHt (float) bearish trend exhaustion phase highest price value // @field sCH (float) bearish trend exhaustion phase high price value // @field sCL (float) bearish trend exhaustion phase low price value // @field sCLt (float) bearish trend exhaustion phase lowest price value // @field sCT (float) bearish trend exhaustion phase target price value type tre int bCC float bC8 float bCHt float bCH float bCL float bCLt float bCD int sCC float sC8 float sCHt float sCH float sCL float sCLt float sCT //-----------------------------------------------------------------------------} // Variables //-----------------------------------------------------------------------------{ bar b = bar.new() var trb S = trb.new() var tre C = tre.new() noC = #00000000 rdC = #f23645 gnC = #089981 whC = #ffffff blC = #2962ff grC = #787b86 bgC = #00bcd4 shpD = shape.labeldown shpU = shape.labelup locA = location.abovebar locB = location.belowbar dspN = false pltL = plot.style_circles pltS = size.tiny //-----------------------------------------------------------------------------} // Functions / Methods //-----------------------------------------------------------------------------{ // @function alert function detecting crosses // // @param _p (float) price value // @param _l (float) checked level value // // return (bool) true if condition mets, false otherwise f_xLX(_p, _l) => (_l > _p and _l < _p[1]) or (_l < _p and _l > _p[1]) // @function plot style function // // @param _p (string) input string value // // return returns enumarated plot style value f_lnS(_s) => s = switch _s 'Circles' => plot.style_circles 'Step Line' => plot.style_steplinebr 'Step Line w/ Diamonds' => plot.style_steplinebr //-----------------------------------------------------------------------------} // Calculations //-----------------------------------------------------------------------------{ ptLB = f_lnS(ptLT) ptRS = f_lnS(ptSR) //-----------------------------------------------------------------------------} // Momentum Phase //-----------------------------------------------------------------------------{ con = b.c < b.c[4] if con S.bSC := S.bSC == 9 ? 1 : S.bSC + 1 S.sSC := 0 else S.sSC := S.sSC == 9 ? 1 : S.sSC + 1 S.bSC := 0 pbS = (b.l <= b.l[3] and b.l <= b.l[2]) or (b.l[1] <= b.l[3] and b.l[1] <= b.l[2]) plotshape(BnoShw and not Bcmpltd and S.bSC == 1, '', shpD, locA, noC, 0, '₁', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 2, '', shpD, locA, noC, 0, '₂', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 3, '', shpD, locA, noC, 0, '₃', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 4, '', shpD, locA, noC, 0, '₄', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 5, '', shpD, locA, noC, 0, '₅', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 6, '', shpD, locA, noC, 0, '₆', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 7, '', shpD, locA, noC, 0, '₇', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 8 and not pbS, '', shpD, locA, noC, 0, '₈', gnC, dspN) plotshape(BnoShw and not Bcmpltd and S.bSC == 8 and pbS, '', shpD, locA, color.new(gnC, 75), 0, 'ᵖ\n₈', whC, dspN) //plotshape(BnoShw and not Bcmpltd and S.bSC == 9, '', shpD, locA, noC, 0, '₉', gnC, dspN) plotshape(BnoShw and S.bSC == 9 and not pbS, 'Bullish Momentum Phases', shpU, locB, color.new(gnC, 25), 0, '', whC, not dspN, pltS) plotshape(BnoShw and S.bSC == 9 and pbS, 'Perfect Bullish Momentum Phases', shpU, locB, color.new(gnC, 25), 0, 'ᵖ', whC, not dspN, pltS) plotshape(BnoShw and S.bSC[1] == 8 and S.sSC == 1, 'Early Bullish Momentum Phases', shpU, locB, color.new(gnC, 25), 0, '', whC, not dspN, pltS) bC8 = S.bSC[1] == 8 and S.sSC == 1 sR = ta.highest(9) bSR = 0.0 bSR := S.bSC == 9 or bC8 ? sR : b.c > bSR[1] ? 0 : bSR[1] plot(srL and bSR > 0 ? bSR : na, "Resistance Levels", color.new(rdC, 50), 2, ptLB) plotshape(srL and bSR > 0 and bSR != bSR[1] and str.contains(ptLT, 'Diamonds') ? bSR : na, '', shape.diamond, location.absolute, rdC, editable = dspN, size = size.tiny) if S.bSC == 1 S.bSL := b.l if S.bSC > 0 S.bSL := math.min(b.l, S.bSL) if b.l == S.bSL S.bSH := b.h bSD = 0.0 bSD := S.bSC == 9 ? 2 * S.bSL - S.bSH : b.c < bSD[1] or S.sSC == 9 ? 0 : bSD[1] plot(rsB and bSD > 0 ? bSD : na, "Bullish Momentum Risk Levels", blC, 1, ptRS) psS = (b.h >= b.h[3] and b.h >= b.h[2]) or (b.h[1] >= b.h[3] and b.h[1] >= b.h[2]) plotshape(BnoShw and not Bcmpltd and S.sSC == 1, '', shpD, locA, noC, 0, '₁', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 2, '', shpD, locA, noC, 0, '₂', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 3, '', shpD, locA, noC, 0, '₃', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 4, '', shpD, locA, noC, 0, '₄', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 5, '', shpD, locA, noC, 0, '₅', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 6, '', shpD, locA, noC, 0, '₆', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 7, '', shpD, locA, noC, 0, '₇', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 8 and not psS, '', shpD, locA, noC, 0, '₈', rdC, dspN) plotshape(BnoShw and not Bcmpltd and S.sSC == 8 and psS, '', shpD, locA, color.new(rdC, 75), 0, 'ᵖ\n₈', whC, dspN) //plotshape(BnoShw and not Bcmpltd and S.sSC == 9, '', shpD, locA, noC, 0, '₉', gnC, dspN) plotshape(BnoShw and S.sSC == 9 and not psS, 'Completed Bearish Momentum Phases' , shpD, locA, color.new(rdC, 25), 0, '' , whC, not dspN, pltS) plotshape(BnoShw and S.sSC == 9 and psS, 'Perfect Bearish Momentum Phases' , shpD, locA, color.new(rdC, 25), 0, 'ᵖ', whC, not dspN, pltS) plotshape(BnoShw and S.sSC[1] == 8 and S.bSC == 1, 'Early Bearish Momentum Phases', shpD, locA, color.new(rdC, 25), 0, '' , whC, not dspN, pltS) sC8 = S.sSC[1] == 8 and S.bSC == 1 sS = ta.lowest(9) sSS = 0.0 sSS := S.sSC == 9 or sC8 ? sS : b.c < sSS[1] ? 0 : sSS[1] plot(srL and sSS > 0 ? sSS : na, "Support Levels", color.new(gnC, 50), 2, ptLB) plotshape(srL and sSS > 0 and sSS != sSS[1] and str.contains(ptLT, 'Diamonds') ? sSS : na, '', shape.diamond, location.absolute, gnC, editable = dspN, size = size.tiny) if S.sSC == 1 S.sSH := b.h if S.sSC > 0 S.sSH := math.max(b.h, S.sSH) if b.h == S.sSH S.sSL := b.l sSD = 0.0 sSD := S.sSC == 9 ? 2 * S.sSH - S.sSL : b.c > sSD[1] or S.bSC == 9 ? 0 : sSD[1] plot(rsB and sSD > 0 ? sSD : na, "Bearish Momentum Risk Levels", blC, 1, ptRS) //-----------------------------------------------------------------------------} // Trend Exhaustion Phase //-----------------------------------------------------------------------------{ bCC = b.c <= b.l[2] b13 = b.c <= b.l[2] and b.l >= C.bC8 var sbC = false sbC := if S.bSC == 9 and C.bCC == 0 and (pbS or pbS[1]) true else if S.sSC == 9 or C.bCC == 13 or b.c > bSR false else sbC[1] C.bCC := sbC ? S.bSC == 9 ? bCC ? 1 : 0 : bCC ? C.bCC + 1 : C.bCC : 0 C.bCC := C.bCC == 13 and b13 ? C.bCC - 1 : C.bCC if C.bCC == 8 and C.bCC != C.bCC[1] C.bC8 := b.c shwBC = noShw and not cmpltd and sbC and C.bCC != C.bCC[1] plotshape(shwBC and C.bCC == 1 , '', shpD, locB, noC, 0, '₁' , gnC, dspN) plotshape(shwBC and C.bCC == 2 , '', shpD, locB, noC, 0, '₂' , gnC, dspN) plotshape(shwBC and C.bCC == 3 , '', shpD, locB, noC, 0, '₃' , gnC, dspN) plotshape(shwBC and C.bCC == 4 , '', shpD, locB, noC, 0, '₄' , gnC, dspN) plotshape(shwBC and C.bCC == 5 , '', shpD, locB, noC, 0, '₅' , gnC, dspN) plotshape(shwBC and C.bCC == 6 , '', shpD, locB, noC, 0, '₆' , gnC, dspN) plotshape(shwBC and C.bCC == 7 , '', shpD, locB, noC, 0, '₇' , gnC, dspN) plotshape(shwBC and C.bCC == 8 , '', shpD, locB, noC, 0, '₈' , gnC, dspN) plotshape(shwBC and C.bCC == 9 , '', shpD, locB, noC, 0, '₉' , gnC, dspN) plotshape(shwBC and C.bCC == 10, '', shpD, locB, noC, 0, '₁₀', gnC, dspN) plotshape(shwBC and C.bCC == 11, '', shpD, locB, noC, 0, '₁₁', gnC, dspN) plotshape(shwBC and C.bCC == 12, '', shpD, locB, noC, 0, '₁₂', gnC, dspN) plotshape(noShw and not cmpltd and sbC and C.bCC == C.bCC[1] and C.bCC == 12 and b13, '', shpD, locB, noC, 0, '₊', gnC, dspN) //plotshape(shwBC and C.bCC == 13, '', shpD, locB, noC, 0, '₁₃', gnC, dspN) plotshape(noShw and sbC and C.bCC != C.bCC[1] and C.bCC == 13, 'Completed Bullish Exhaustions', shpU, locB, color.new(#006400, 25), 0, 'E', whC, not dspN, pltS) if C.bCC == 1 C.bCLt := b.l C.bCHt := b.h if sbC C.bCHt := math.max(b.h, C.bCHt) C.bCLt := math.min(b.l, C.bCLt) if b.h == C.bCHt C.bCL := b.l if b.l == C.bCLt C.bCH := b.h bCT = 2 * C.bCHt - C.bCL bCT := C.bCC == 13 ? bCT : b.c > bCT[1] or (C.bCD == 0 and C.sCC == 13) ? 0. : bCT[1] plot(ttE and bCT > 0 ? bCT : na, "Bullish Exhaustion Target Levels", grC, 1, pltL) bCD = 2 * C.bCLt - C.bCH bCD := C.bCC == 13 ? bCD : b.c < bCD[1] or (bCT == 0 and C.sCC == 13) ? 0. : bCD[1] C.bCD := bCD plot(rsE and bCD > 0 ? bCD : na, "Bullish Exhaustion Risk Levels", bgC, 1, pltL) sCC = b.c >= b.h[2] s13 = b.c >= b.h[2] and b.h <= C.sC8 var ssC = false ssC := if S.sSC == 9 and C.sCC == 0 and (psS or psS[1]) true else if S.bSC == 9 or C.sCC == 13 or b.c < sSS false else ssC[1] C.sCC := ssC ? S.sSC == 9 ? sCC ? 1 : 0 : sCC ? C.sCC + 1 : C.sCC : 0 C.sCC := C.sCC == 13 and s13 ? C.sCC - 1 : C.sCC if C.sCC == 8 and C.sCC != C.sCC[1] C.sC8 := b.c shwSC = noShw and not cmpltd and ssC and C.sCC != C.sCC[1] plotshape(shwSC and C.sCC == 1 , '', shpD, locB, noC, 0, '₁' , rdC, dspN) plotshape(shwSC and C.sCC == 2 , '', shpD, locB, noC, 0, '₂' , rdC, dspN) plotshape(shwSC and C.sCC == 3 , '', shpD, locB, noC, 0, '₃' , rdC, dspN) plotshape(shwSC and C.sCC == 4 , '', shpD, locB, noC, 0, '₄' , rdC, dspN) plotshape(shwSC and C.sCC == 5 , '', shpD, locB, noC, 0, '₅' , rdC, dspN) plotshape(shwSC and C.sCC == 6 , '', shpD, locB, noC, 0, '₆' , rdC, dspN) plotshape(shwSC and C.sCC == 7 , '', shpD, locB, noC, 0, '₇' , rdC, dspN) plotshape(shwSC and C.sCC == 8 , '', shpD, locB, noC, 0, '₈' , rdC, dspN) plotshape(shwSC and C.sCC == 9 , '', shpD, locB, noC, 0, '₉' , rdC, dspN) plotshape(shwSC and C.sCC == 10, '', shpD, locB, noC, 0, '₁₀', rdC, dspN) plotshape(shwSC and C.sCC == 11, '', shpD, locB, noC, 0, '₁₁', rdC, dspN) plotshape(shwSC and C.sCC == 12, '', shpD, locB, noC, 0, '₁₂', rdC, dspN) plotshape(noShw and not cmpltd and ssC and C.sCC == C.sCC[1] and C.sCC == 12 and s13, '', shpD, locB, noC, 0, '₊', rdC, dspN) //plotshape(shwSC and C.sCC == 13, '', shpD, locB, noC, 0, '₁₃', rdC, dspN) plotshape(noShw and ssC and C.sCC != C.sCC[1] and C.sCC == 13, 'Completed Bearish Exhaustions', shpD, locA, color.new(#910000, 25), 0, 'E', whC, not dspN, pltS) if C.sCC == 1 C.sCLt := b.l C.sCHt := b.h if ssC C.sCHt := math.max(b.h, C.sCHt) C.sCLt := math.min(b.l, C.sCLt) if b.h == C.sCHt C.sCL := b.l if b.l == C.sCLt C.sCH := b.h sCD = 2 * C.sCHt - C.sCL sCD := C.sCC == 13 ? 2 * C.sCHt - C.sCL : b.c > sCD[1] or (C.sCT == 0 and C.bCC == 13) ? 0. : sCD[1] plot(rsE and sCD > 0 ? sCD : na, "Bearish Exhaustion Risk Levels", bgC, 1, pltL) sCT = 2 * C.sCLt - C.sCH sCT := C.sCC == 13 ? sCT : b.c < sCT[1] or (sCD == 0 and C.bCC == 13) ? 0. : sCT[1] C.sCT := sCT plot(ttE and sCT > 0 ? sCT : na, "Bearish Exhaustion Target Levels", grC, 1, pltL) //-----------------------------------------------------------------------------} // Trade Setups //-----------------------------------------------------------------------------{ plotshape(bSR > 0 and bSR[1] == 0 ? bSR : na, 'Overall Bearish Trend Mark', shpD, location.absolute, noC, 0, '⇩', rdC, not dspN, size = size.small, display=display.none) plotshape(sSS > 0 and sSS[1] == 0 ? sSS : na, 'Overall Bullish Trend Mark', shpU, location.absolute, noC, 0, '⇧', gnC, not dspN, size = size.small, display=display.none) var sbPF = false, var bPFc = false var ssPF = false, var sPFc = false var lTrd = false, var sTrd = false bBl9 = ta.valuewhen(S.bSC == 9 , b.i, 0) bBp9 = ta.valuewhen(S.bSC == 9 , b.i, 1) bB13 = ta.valuewhen(C.bCC == 13, b.i, 0) sBl9 = ta.valuewhen(S.sSC == 9 , b.i, 0) sBp9 = ta.valuewhen(S.sSC == 9 , b.i, 1) sB13 = ta.valuewhen(C.sCC == 13, b.i, 0) trdS = tso != 'None' sQC = (sBl9 > sB13) and (sB13 > sBp9) and (sBp9 > bBl9) sPFO = tso == 'Momentum' ? S.sSC == 9 or sC8 : tso == 'Exhaustion' ? C.sCC[5] == 13 : S.sSC == 9 and sQC ssPF := if sPFO true else if sPFc false else ssPF[1] sPFc := ssPF and b.c < b.c[4] and b.c[1] > b.c[5] [sTR, sST] = if tso == 'Exhaustion' if sCD == 0 [' - Risky', str.tostring(b.h, format.mintick)] else ['', str.tostring(sCD, format.mintick)] else if sSD == 0 [' - Risky', str.tostring(b.h, format.mintick)] else ['', str.tostring(sSD, format.mintick)] sTT = 'Short Trade Setup' + sTR + '\n Signal : Completed ' + tso + ' plus Bearish Price Flip\n' + ' Stop : ' + sST + '\n Target : ' + str.tostring(tso == 'Exhaustion' ? sCT : sSS, format.mintick) if sPFc and trdS label.new(bar_index, b.h, 'S', xloc.bar_index, yloc.price, color.new(color.yellow, 25), label.style_label_down, color.white, size.small, text.align_center, sTT + '\n\nnot a finacial advice, subject to high risk') alert(syminfo.ticker + ' : ' + sTT + '\n Price : ' + str.tostring(close, format.mintick) + '\n\nnot a finacial advice, subject to high risk') sTrd := true lTrd := false if war and sTrd and b.o < b.c and S.sSC == 2 and not lTrd label.new(bar_index, b.l, '⚠️', xloc.bar_index, yloc.price, color.new(color.yellow, 100), label.style_label_up, color.yellow, size.large, text.align_center, 'Warning\nbullish price flip detected') sTrd := false if war and sTrd and b.o < b.c and ((sSD[1] != 0 and b.c > sSD[1]) or (sCD[1] != 0 and b.c > sCD[1])) label.new(bar_index, b.l, '⚠️', xloc.bar_index, yloc.price, color.new(color.yellow, 100), label.style_label_up, color.yellow, size.large, text.align_center, 'Critical Warning\nstop/risk level breached') sTrd := false bQC = (bBl9 > bB13) and (bB13 > bBp9) and (bBp9 > sBl9) bPFO = tso == 'Momentum' ? S.bSC == 9 or bC8 : tso == 'Exhaustion' ? C.bCC[5] == 13 : S.bSC == 9 and bQC sbPF := if bPFO true else if bPFc false else sbPF[1] bPFc := sbPF and b.c > b.c[4] and b.c[1] < b.c[5] [bTR, bST] = if tso == 'Exhaustion' if bCD == 0 [' - Risky', str.tostring(b.l, format.mintick)] else ['', str.tostring(bCD, format.mintick)] else if bSD == 0 [' - Risky', str.tostring(b.l, format.mintick)] else ['', str.tostring(bSD, format.mintick)] lTT = 'Long Trade Setup' + bTR + '\n Signal : Completed ' + tso + ' plus Bullish Price Flip\n' + ' Stop : ' + bST + '\n Target : ' + str.tostring(tso == 'Exhaustion' ? bCT : bSR, format.mintick) if bPFc and trdS label.new(bar_index, b.l, 'L', xloc.bar_index, yloc.price, color.new(color.blue, 25), label.style_label_up, color.white, size.small, text.align_center, lTT + '\n\nnot a finacial advice, subject to high risk') alert(syminfo.ticker + ' : ' + lTT + '\n Price : ' + str.tostring(close, format.mintick) + '\n\nnot a finacial advice, subject to high risk') lTrd := true sTrd := false if war and lTrd and b.o > b.c and S.bSC == 2 and not sTrd label.new(bar_index, b.h, '⚠️', xloc.bar_index, yloc.price, color.new(color.blue, 100), label.style_label_down, color.yellow, size.large, text.align_center, 'Warning\nbearish price flip detected') lTrd := false if war and lTrd and b.o > b.c and (b.c < bSD[1] or b.c < bCD[1]) label.new(bar_index, b.h, '⚠️', xloc.bar_index, yloc.price, color.new(color.blue, 100), label.style_label_down, color.yellow, size.large, text.align_center, 'Critical Warning\nstop/risk level breached') lTrd := false //-----------------------------------------------------------------------------} // Alerts //-----------------------------------------------------------------------------{ pTxt = str.tostring(b.c, format.mintick) tTxt = syminfo.ticker if f_xLX(b.c, bSR) and srL alert(tTxt + ' crossing resistance level detected, price ' + str.tostring(bSR, format.mintick)) if f_xLX(b.c, bSD) or f_xLX(b.c, sSD) and rsB alert(tTxt + ' crossing momentum risk level detected, price ' + str.tostring(bSD, format.mintick)) if f_xLX(b.c, sSS) and srL alert(tTxt + ' crossing support level detected, price ' + str.tostring(sSS, format.mintick)) if f_xLX(b.c, bCD) or f_xLX(b.c, sCD) and rsE alert(tTxt + ' crossing trend exhaustion risk level detected, price ' + str.tostring(bCD, format.mintick)) if S.bSC == 9 and cmpltd alert(tTxt + ' bullish momentum phase completion detected, price ' + pTxt) if S.sSC == 9 and cmpltd alert(tTxt + ' bearish momentum phase completion detected, price ' + pTxt) if C.bCC == 13 and cmpltd alert(tTxt + ' bullish trend exhaustion phase completion detected, price ' + pTxt) if C.sCC == 13 and cmpltd alert(tTxt + ' bearish trend exhaustion phase completion detected, price ' + pTxt) if bSR > 0 and bSR[1] == 0 alert(tTxt + ' bearish momentum detected, price ' + pTxt) if sSS > 0 and sSS[1] == 0 alert(tTxt + ' bullish momentum detected, price ' + pTxt) //-----------------------------------------------------------------------------}
Normalized Volume Rate of Change
https://www.tradingview.com/script/x3BcF2TG-Normalized-Volume-Rate-of-Change/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
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/ // © LeafAlgo //@version=5 indicator("Normalized Volume Rate of Change", overlay=false) // Calculation Inputs length = input.int(14, "VROC Length") maLength = input.int(9, "Moving Average Length") // Calculate Volume Rate of Change (VROC) vroc = ta.change(volume, length) / ta.sma(volume, length) * 100 // Normalize VROC to -1 to +1 range vrocNormalized = (vroc - ta.lowest(vroc, length)) / (ta.highest(vroc, length) - ta.lowest(vroc, length)) * 2 - 1 // Calculate Moving Averages ma1 = ta.sma(vrocNormalized, maLength) ma2 = ta.sma(vrocNormalized, maLength * 2) // Moving Average Crossover crossoverUp = ta.crossover(ma1, ma2) crossoverDown = ta.crossunder(ma1, ma2) // Bar and Background Colors bColor = vrocNormalized > ma1 and vrocNormalized < ma2 ? color.yellow : vrocNormalized > ma1 or vrocNormalized > ma2 ? color.lime : color.fuchsia barcolor(bColor) bgcolor(bColor, transp=90) // Plotting plot(vrocNormalized, color=bColor, style=plot.style_columns, linewidth=2, title="Normalized VROC") plot(ma1, color=color.aqua, linewidth=4, title="MA1") plot(ma2, color=color.orange, linewidth=4, title="MA2") // Arrows on Moving Average Crossover plotshape(crossoverUp, "Moving Average Crossover Upwards", style = shape.arrowup, location = location.bottom, color=color.lime, size=size.normal) plotshape(crossoverDown, "Moving Average Crossover Downwards", style = shape.arrowdown, location = location.top, color=color.fuchsia, size=size.normal) // Hline Boundaries hline(0.75, "Upper Boundary", color=color.new(color=color.gray, transp=50), linewidth=1, linestyle=hline.style_dashed) hline(-0.75, "Lower Boundary", color=color.new(color=color.gray, transp=50), linewidth=1, linestyle=hline.style_dashed) hline(0.0, "Zero Line", color=color.new(color=color.gray, transp=50), linewidth=1, linestyle=hline.style_dashed)
Prevailing Trend Indicator
https://www.tradingview.com/script/ejTvDyF7-Prevailing-Trend-Indicator/
bjr117
https://www.tradingview.com/u/bjr117/
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/ // © bjr117 //@version=5 indicator(title = "Prevailing Trend Indicator", shorttitle = "PTI", overlay = false) //============================================================================== // Function: Calculate a given type of moving average //============================================================================== get_ma_out(type, src, len, alma_offset, alma_sigma, kama_fastLength, kama_slowLength, vama_vol_len, vama_do_smth, vama_smth, mf_beta, mf_feedback, mf_z, eit_alpha, ssma_pow, ssma_smooth, rsrma_pw, svama_method, svama_vol_or_volatility, wrma_smooth, aarma_gamma) => float baseline = 0.0 if type == "SMA | Simple MA" baseline := ta.sma(src, len) else if type == "EMA | Exponential MA" baseline := ta.ema(src, len) else if type == "DEMA | Double Exponential MA" e = ta.ema(src, len) baseline := 2 * e - ta.ema(e, len) else if type == "TEMA | Triple Exponential MA" e = ta.ema(src, len) baseline := 3 * (e - ta.ema(e, len)) + ta.ema(ta.ema(e, len), len) else if type == "TMA | Triangular MA" // by everget baseline := ta.sma(ta.sma(src, math.ceil(len / 2)), math.floor(len / 2) + 1) else if type == "WMA | Weighted MA" baseline := ta.wma(src, len) else if type == "VWMA | Volume-Weighted MA" baseline := ta.vwma(src, len) else if type == "SMMA | Smoothed MA" w = ta.wma(src, len) baseline := na(w[1]) ? ta.sma(src, len) : (w[1] * (len - 1) + src) / len else if type == "RMA | Rolling MA" baseline := ta.rma(src, len) else if type == "HMA | Hull MA" baseline := ta.wma(2 * ta.wma(src, len / 2) - ta.wma(src, len), math.round(math.sqrt(len))) else if type == "LSMA | Least Squares MA" baseline := ta.linreg(src, len, 0) else if type == "Kijun" //Kijun-sen kijun = math.avg(ta.lowest(len), ta.highest(len)) baseline := kijun else if type == "MD | McGinley Dynamic" mg = 0.0 mg := na(mg[1]) ? ta.ema(src, len) : mg[1] + (src - mg[1]) / (len * math.pow(src / mg[1], 4)) baseline := mg else if type == "JMA | Jurik MA" // by everget DEMAe1 = ta.ema(src, len) DEMAe2 = ta.ema(DEMAe1, len) baseline := 2 * DEMAe1 - DEMAe2 else if type == "ALMA | Arnaud Legoux MA" baseline := ta.alma(src, len, alma_offset, alma_sigma) else if type == "VAR | Vector Autoregression MA" valpha = 2 / (len+1) vud1 = (src > src[1]) ? (src - src[1]) : 0 vdd1 = (src < src[1]) ? (src[1] - src) : 0 vUD = math.sum(vud1, 9) vDD = math.sum(vdd1, 9) vCMO = nz( (vUD - vDD) / (vUD + vDD) ) baseline := nz(valpha * math.abs(vCMO) * src) + (1 - valpha * math.abs(vCMO)) * nz(baseline[1]) else if type == "ZLEMA | Zero-Lag Exponential MA" // by HPotter xLag = (len) / 2 xEMAData = (src + (src - src[xLag])) baseline := ta.ema(xEMAData, len) else if type == "AHMA | Ahrens Moving Average" // by everget baseline := nz(baseline[1]) + (src - (nz(baseline[1]) + nz(baseline[len])) / 2) / len else if type == "EVWMA | Elastic Volume Weighted MA" volumeSum = math.sum(volume, len) baseline := ( (volumeSum - volume) * nz(baseline[1]) + volume * src ) / volumeSum else if type == "SWMA | Sine Weighted MA" // by everget sum = 0.0 weightSum = 0.0 for i = 0 to len - 1 weight = math.sin(i * math.pi / (len + 1)) sum := sum + nz(src[i]) * weight weightSum := weightSum + weight baseline := sum / weightSum else if type == "LMA | Leo MA" baseline := 2 * ta.wma(src, len) - ta.sma(src, len) else if type == "VIDYA | Variable Index Dynamic Average" // by KivancOzbilgic mom = ta.change(src) upSum = math.sum(math.max(mom, 0), len) downSum = math.sum(-math.min(mom, 0), len) out = (upSum - downSum) / (upSum + downSum) cmo = math.abs(out) alpha = 2 / (len + 1) baseline := src * alpha * cmo + nz(baseline[1]) * (1 - alpha * cmo) else if type == "FRAMA | Fractal Adaptive MA" length2 = math.floor(len / 2) hh2 = ta.highest(length2) ll2 = ta.lowest(length2) N1 = (hh2 - ll2) / length2 N2 = (hh2[length2] - ll2[length2]) / length2 N3 = (ta.highest(len) - ta.lowest(len)) / len D = (math.log(N1 + N2) - math.log(N3)) / math.log(2) factor = math.exp(-4.6 * (D - 1)) baseline := factor * src + (1 - factor) * nz(baseline[1]) else if type == "VMA | Variable MA" // by LazyBear k = 1.0/len pdm = math.max((src - src[1]), 0) mdm = math.max((src[1] - src), 0) pdmS = float(0.0) mdmS = float(0.0) pdmS := ((1 - k)*nz(pdmS[1]) + k*pdm) mdmS := ((1 - k)*nz(mdmS[1]) + k*mdm) s = pdmS + mdmS pdi = pdmS/s mdi = mdmS/s pdiS = float(0.0) mdiS = float(0.0) pdiS := ((1 - k)*nz(pdiS[1]) + k*pdi) mdiS := ((1 - k)*nz(mdiS[1]) + k*mdi) d = math.abs(pdiS - mdiS) s1 = pdiS + mdiS iS = float(0.0) iS := ((1 - k)*nz(iS[1]) + k*d/s1) hhv = ta.highest(iS, len) llv = ta.lowest(iS, len) d1 = hhv - llv vI = (iS - llv)/d1 baseline := (1 - k*vI)*nz(baseline[1]) + k*vI*src else if type == "GMMA | Geometric Mean MA" lmean = math.log(src) smean = math.sum(lmean, len) baseline := math.exp(smean / len) else if type == "CMA | Corrective MA" // by everget sma = ta.sma(src, len) baseline := sma v1 = ta.variance(src, len) v2 = math.pow(nz(baseline[1], baseline) - baseline, 2) v3 = v1 == 0 or v2 == 0 ? 1 : v2 / (v1 + v2) var tolerance = math.pow(10, -5) float err = 1 // Gain Factor float kPrev = 1 float k = 1 for i = 0 to 5000 by 1 if err > tolerance k := v3 * kPrev * (2 - kPrev) err := kPrev - k kPrev := k kPrev baseline := nz(baseline[1], src) + k * (sma - nz(baseline[1], src)) else if type == "MM | Moving Median" // by everget baseline := ta.percentile_nearest_rank(src, len, 50) else if type == "QMA | Quick MA" // by everget peak = len / 3 num = 0.0 denom = 0.0 for i = 1 to len + 1 mult = 0.0 if i <= peak mult := i / peak else mult := (len + 1 - i) / (len + 1 - peak) num := num + src[i - 1] * mult denom := denom + mult baseline := (denom != 0.0) ? (num / denom) : src else if type == "KAMA | Kaufman Adaptive MA" // by everget mom = math.abs(ta.change(src, len)) volatility = math.sum(math.abs(ta.change(src)), len) // Efficiency Ratio er = volatility != 0 ? mom / volatility : 0 fastAlpha = 2 / (kama_fastLength + 1) slowAlpha = 2 / (kama_slowLength + 1) alpha = math.pow(er * (fastAlpha - slowAlpha) + slowAlpha, 2) baseline := alpha * src + (1 - alpha) * nz(baseline[1], src) else if type == "VAMA | Volatility Adjusted MA" // by Joris Duyck (JD) mid = ta.ema(src, len) dev = src - mid vol_up = ta.highest(dev, vama_vol_len) vol_down = ta.lowest(dev, vama_vol_len) vama = mid + math.avg(vol_up, vol_down) baseline := vama_do_smth ? ta.wma(vama, vama_smth) : vama else if type == "Modular Filter" // by alexgrover //---- b = 0.0, c = 0.0, os = 0.0, ts = 0.0 //---- alpha = 2/(len+1) a = mf_feedback ? mf_z*src + (1-mf_z)*nz(baseline[1],src) : src //---- b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a) c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a) os := a == b ? 1 : a == c ? 0 : os[1] //---- upper = mf_beta*b+(1-mf_beta)*c lower = mf_beta*c+(1-mf_beta)*b baseline := os*upper+(1-os)*lower else if type == "EIT | Ehlers Instantaneous Trendline" // by Franklin Moormann (cheatcountry) baseline := bar_index < 7 ? (src + (2 * nz(src[1])) + nz(src[2])) / 4 : ((eit_alpha - (math.pow(eit_alpha, 2) / 4)) * src) + (0.5 * math.pow(eit_alpha, 2) * nz(src[1])) - ((eit_alpha - (0.75 * math.pow(eit_alpha, 2))) * nz(src[2])) + (2 * (1 - eit_alpha) * nz(baseline[1])) - (math.pow(1 - eit_alpha, 2) * nz(baseline[2])) else if type == "ESD | Ehlers Simple Decycler" // by everget // High-pass Filter alphaArg = 2 * math.pi / (len * math.sqrt(2)) alpha = 0.0 alpha := math.cos(alphaArg) != 0 ? (math.cos(alphaArg) + math.sin(alphaArg) - 1) / math.cos(alphaArg) : nz(alpha[1]) hp = 0.0 hp := math.pow(1 - (alpha / 2), 2) * (src - 2 * nz(src[1]) + nz(src[2])) + 2 * (1 - alpha) * nz(hp[1]) - math.pow(1 - alpha, 2) * nz(hp[2]) baseline := src - hp else if type == "SSMA | Shapeshifting MA" // by alexgrover //---- ssma_sum = 0.0 ssma_sumw = 0.0 alpha = ssma_smooth ? 2 : 1 power = ssma_smooth ? ssma_pow - ssma_pow % 2 : ssma_pow //---- for i = 0 to len-1 x = i/(len-1) n = ssma_smooth ? -1 + x*2 : x w = 1 - 2*math.pow(n,alpha)/(math.pow(n,power) + 1) ssma_sumw := ssma_sumw + w ssma_sum := ssma_sum + src[i] * w baseline := ssma_sum/ssma_sumw //---- else if type == "RSRMA | Right Sided Ricker MA" // by alexgrover //---- rsrma_sum = 0.0 rsrma_sumw = 0.0 rsrma_width = rsrma_pw/100*len for i = 0 to len-1 w = (1 - math.pow(i/rsrma_width,2))*math.exp(-(i*i/(2*math.pow(rsrma_width,2)))) rsrma_sumw := rsrma_sumw + w rsrma_sum := rsrma_sum + src[i] * w baseline := rsrma_sum/rsrma_sumw //---- else if type == "DSWF | Damped Sine Wave Weighted Filter" // by alexgrover //---- dswf_sum = 0.0 dswf_sumw = 0.0 for i = 1 to len w = math.sin(2.0*math.pi*i/len)/i dswf_sumw := dswf_sumw + w dswf_sum := dswf_sum + w*src[i-1] //---- baseline := dswf_sum/dswf_sumw else if type == "BMF | Blackman Filter" // by alexgrover //---- bmf_sum = 0.0 bmf_sumw = 0.0 for i = 0 to len-1 k = i/len w = 0.42 - 0.5 * math.cos(2 * math.pi * k) + 0.08 * math.cos(4 * math.pi * k) bmf_sumw := bmf_sumw + w bmf_sum := bmf_sum + w*src[i] //---- baseline := bmf_sum/bmf_sumw else if type == "HCF | Hybrid Convolution Filter" // by alexgrover //---- sum = 0. for i = 1 to len sgn = .5*(1 - math.cos((i/len)*math.pi)) sum := sum + (sgn*(nz(baseline[1],src)) + (1 - sgn)*src[i-1]) * ( (.5*(1 - math.cos((i/len)*math.pi))) - (.5*(1 - math.cos(((i-1)/len)*math.pi))) ) baseline := sum //---- else if type == "FIR | Finite Response Filter" // by alexgrover //---- var b = array.new_float(0) if barstate.isfirst for i = 0 to len-1 w = len-i array.push(b,w) den = array.sum(b) //---- sum = 0.0 for i = 0 to len-1 sum := sum + src[i]*array.get(b,i) baseline := sum/den else if type == "FLSMA | Fisher Least Squares MA" // by alexgrover //---- b = 0.0 //---- e = ta.sma(math.abs(src - nz(b[1])),len) z = ta.sma(src - nz(b[1],src),len)/e r = (math.exp(2*z) - 1)/(math.exp(2*z) + 1) a = (bar_index - ta.sma(bar_index,len))/ta.stdev(bar_index,len) * r b := ta.sma(src,len) + a*ta.stdev(src,len) baseline := b else if type == "SVAMA | Non-Parametric Volume Adjusted MA" // by alexgrover and bjr117 //---- h = 0.0 l = 0.0 c = 0.0 //---- a = svama_vol_or_volatility == "Volume" ? volume : ta.tr h := a > nz(h[1], a) ? a : nz(h[1], a) l := a < nz(l[1], a) ? a : nz(l[1], a) //---- b = svama_method == "Max" ? a / h : l / a c := b * close + (1 - b) * nz(c[1], close) baseline := c else if type == "RPMA | Repulsion MA" // by alexgrover baseline := ta.sma(close, len*3) + ta.sma(close, len*2) - ta.sma(close, len) else if type == "WRMA | Well Rounded MA" // by alexgrover //---- alpha = 2/(len+1) p1 = wrma_smooth ? len/4 : 1 p2 = wrma_smooth ? len/4 : len/2 //---- a = float(0.0) b = float(0.0) y = ta.ema(a + b,p1) A = src - y B = src - ta.ema(y,p2) a := nz(a[1]) + alpha*nz(A[1]) b := nz(b[1]) + alpha*nz(B[1]) baseline := y else if type == "HLT | HiLo Trend" // Getting the highest highs / lowest lows in the user-inputted slowLength period and fastLength period hlt_high = ta.highest(src, len) hlt_low = ta.lowest(src, len) // Calculate the HLT Line // If the source (close, hl2, ...) value is greater than the previous HLT line, let the next HLT line value be the source value. baseline := (src > baseline[1]) ? hlt_low : hlt_high else if type == "T3 | Tillson T3" // by HPotter //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 21/05/2014 // This indicator plots the moving average described in the January, 1998 issue // of S&C, p.57, "Smoothing Techniques for More Accurate Signals", by Tim Tillson. // This indicator plots T3 moving average presented in Figure 4 in the article. // T3 indicator is a moving average which is calculated according to formula: // T3(n) = GD(GD(GD(n))), // where GD - generalized DEMA (Double EMA) and calculating according to this: // GD(n,v) = EMA(n) * (1+v)-EMA(EMA(n)) * v, // where "v" is volume factor, which determines how hot the moving average’s response // to linear trends will be. The author advises to use v=0.7. // When v = 0, GD = EMA, and when v = 1, GD = DEMA. In between, GD is a less aggressive // version of DEMA. By using a value for v less than1, trader cure the multiple DEMA // overshoot problem but at the cost of accepting some additional phase delay. // In filter theory terminology, T3 is a six-pole nonlinear Kalman filter. Kalman // filters are ones that use the error — in this case, (time series - EMA(n)) — // to correct themselves. In the realm of technical analysis, these are called adaptive // moving averages; they track the time series more aggres-sively when it is making large // moves. Tim Tillson is a software project manager at Hewlett-Packard, with degrees in // mathematics and computer science. He has privately traded options and equities for 15 years. //////////////////////////////////////////////////////////// xe1 = ta.ema(src, len) xe2 = ta.ema(xe1, len) xe3 = ta.ema(xe2, len) xe4 = ta.ema(xe3, len) xe5 = ta.ema(xe4, len) xe6 = ta.ema(xe5, len) b = 0.7 c1 = -b*b*b c2 = 3*b*b+3*b*b*b c3 = -6*b*b-3*b-3*b*b*b c4 = 1+3*b+b*b*b+3*b*b baseline := c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3 else if type == "ADEMA | Alpha-Decreasing EMA" // by everget alpha = 2 / (int(bar_index) + 1) ema = close ema := alpha * ema + (1 - alpha) * nz(ema[1], ema) baseline := ema else if type == "AARMA | Adaptive Autonomous Recursive MA" // by alexgrover // Calculate an AMA aarma_d = ta.cum(math.abs(src - nz(baseline[1], src))) / bar_index * aarma_gamma er = math.abs(ta.change(src, len)) / math.sum(math.abs(ta.change(src)), len) ama1_constant = src > nz(baseline[1], src) + aarma_d ? src + aarma_d : src < nz(baseline[1], src) - aarma_d ? src - aarma_d : nz(baseline[1], src) ama1 = float(0.0) ama1 := er * ama1_constant + (1 - er) * nz(ama1[1], ama1_constant) //Calculate the AMA of the previous AMA ama2_constant = ama1 ama2 = float(0.0) ama2 := er * ama2_constant + (1 - er) * nz(ama2[1], ama2_constant) // Return the AMA of the first AMA, which is the AARMA baseline := ama2 baseline //============================================================================== //============================================================================== // Inputs //============================================================================== // Main indicator inputs pt_length = input.int(title = "Length", defval = 10, minval = 0, group = "Main Settings") pt_src = input.source(title = "Source", defval = close, group = "Main Settings") pt_ma_type = input.string("SMA | Simple MA", "MA Type", options=[ "EMA | Exponential MA", "SMA | Simple MA", "WMA | Weighted MA", "DEMA | Double Exponential MA", "TEMA | Triple Exponential MA", "TMA | Triangular MA", "VWMA | Volume-Weighted MA", "SMMA | Smoothed MA", "HMA | Hull MA", "LSMA | Least Squares MA", "Kijun", "MD | McGinley Dynamic", "RMA | Rolling MA", "JMA | Jurik MA", "ALMA | Arnaud Legoux MA", "VAR | Vector Autoregression MA", "ZLEMA | Zero-Lag Exponential MA", "T3 | Tillson T3", "AHMA | Ahrens Moving Average", "EVWMA | Elastic Volume Weighted MA", "SWMA | Sine Weighted MA", "LMA | Leo MA", "VIDYA | Variable Index Dynamic Average", "FRAMA | Fractal Adaptive MA", "VMA | Variable MA", "GMMA | Geometric Mean MA", "CMA | Corrective MA", "MM | Moving Median", "QMA | Quick MA", "KAMA | Kaufman Adaptive MA", "VAMA | Volatility Adjusted MA", "Modular Filter", "EIT | Ehlers Instantaneous Trendline", "ESD | Ehlers Simple Decycler", "SSMA | Shapeshifting MA", "RSRMA | Right Sided Ricker MA", "DSWF | Damped Sine Wave Weighted Filter", "BMF | Blackman Filter", "HCF | Hybrid Convolution Filter", "FIR | Finite Response Filter", "FLSMA | Fisher Least Squares MA", "SVAMA | Non-Parametric Volume Adjusted MA", "RPMA | Repulsion MA", "WRMA | Well Rounded MA", "HLT | HiLo Trend", "ADEMA | Alpha-Decreasing EMA", "AARMA | Adaptive Autonomous Recursive MA" ], group = "Main Settings") // Display settings pt_show_sigs = input.bool(title = "Show signals?", defval = false, group = "Display Settings") pt_color_bars = input.bool(title = "Color bars?", defval = false, group = "Display Settings") // Specific nuanced settings for different types of moving averages pt_alma_offset = input.float(title = "Offset", defval = 0.85, step = 0.05, group = "ALMA Settings") pt_alma_sigma = input.int(title = "Sigma", defval = 6, group = "ALMA Settings") pt_kama_fastLength = input(title = "Fast EMA Length", defval=2, group = "KAMA Settings") pt_kama_slowLength = input(title = "Slow EMA Length", defval=30, group = "KAMA Settings") pt_vama_vol_len = input.int(title = "Volatality Length", defval = 51, group = "VAMA Settings") pt_vama_do_smth = input.bool(title = "Do Smoothing?", defval = false, group = "VAMA Settings") pt_vama_smth = input.int(title = "Smoothing length", defval = 5, minval = 1, group = "VAMA Settings") pt_mf_beta = input.float(title = "Beta", defval = 0.8, step = 0.1, minval = 0, maxval=1, group = "Modular Filter Settings") pt_mf_feedback = input.bool(title = "Feedback?", defval = false, group = "Modular Filter Settings") pt_mf_z = input.float(title = "Feedback Weighting", defval = 0.5, step = 0.1, minval = 0, maxval = 1, group = "Modular Filter Settings") pt_eit_alpha = input.float(title = "Alpha", defval = 0.07, step = 0.01, minval = 0.0, group = "Ehlers Instantaneous Trendline Settings") pt_ssma_pow = input.float(title = "Power", defval = 4.0, step = 0.5, minval = 0.0, group = "SSMA Settings") pt_ssma_smooth = input.bool(title = "Smooth", defval = false, group = "SSMA Settings") pt_rsrma_pw = input.float(title = "Percent Width", defval = 60.0, step = 10.0, minval = 0.0, maxval = 100.0, group = "RSRMA Settings") pt_svama_method = input.string(title = "Max", options = ["Max", "Min"], defval = "Max", group = "SVAMA Settings") pt_svama_vol_or_volatility = input.string(title = "Use Volume or Volatility?", options = ["Volume", "Volatility"], defval = "Volatility", group = "SVAMA Settings") pt_wrma_smooth = input.bool(title = "Extra Smoothing?", defval = false, group = "WRMA Settings") pt_aarma_gamma = input.float(title = "Gamma", defval = 3.0, minval = 0.0, step = 0.25, group = "AARMA Settings") //============================================================================== //============================================================================== // Calculating Prevailing Trend Upper and Lower lines //============================================================================== bullish_candle_range = float(0.0) bearish_candle_range = float(0.0) if pt_src > open bullish_candle_range := pt_src - open bearish_candle_range := 0.0 else if pt_src < open bearish_candle_range := open - pt_src bullish_candle_range := 0.0 else bullish_candle_range := 0.0 bearish_candle_range := 0.0 pt_up = get_ma_out(pt_ma_type, bullish_candle_range, pt_length, pt_alma_offset, pt_alma_sigma, pt_kama_fastLength, pt_kama_slowLength, pt_vama_vol_len, pt_vama_do_smth, pt_vama_smth, pt_mf_beta, pt_mf_feedback, pt_mf_z, pt_eit_alpha, pt_ssma_pow, pt_ssma_smooth, pt_rsrma_pw, pt_svama_method, pt_svama_vol_or_volatility, pt_wrma_smooth, pt_aarma_gamma) pt_dn = get_ma_out(pt_ma_type, bearish_candle_range, pt_length, pt_alma_offset, pt_alma_sigma, pt_kama_fastLength, pt_kama_slowLength, pt_vama_vol_len, pt_vama_do_smth, pt_vama_smth, pt_mf_beta, pt_mf_feedback, pt_mf_z, pt_eit_alpha, pt_ssma_pow, pt_ssma_smooth, pt_rsrma_pw, pt_svama_method, pt_svama_vol_or_volatility, pt_wrma_smooth, pt_aarma_gamma) //============================================================================== //============================================================================== // Calculating Prevailing Trend Upper and Lower signals //============================================================================== // Only true on the candle that the upper and lower lines cross bullishly, false otherwise pt_L_trig = ta.crossover(pt_up, pt_dn) // Only true on the candle that the upper and lower lines cross bearishly, false otherwise pt_S_trig = ta.crossunder(pt_up, pt_dn) // True if the upper line is above the lower line pt_L_conf = pt_up > pt_dn // True if the lower line is above the upper line pt_S_conf = pt_up < pt_dn //============================================================================== //============================================================================== // Plotting Prevailing Trend Upper and Lower lines //============================================================================== plot(pt_up, title = "Prevailing Trend Upper Line", color = color.blue) plot(pt_dn, title = "Prevailing Trend Lower Line", color = color.red) //============================================================================== //============================================================================== // Plotting Prevailing Trend signals and coloring bars //============================================================================== plotshape(pt_L_trig and pt_show_sigs ? pt_up : na, title = "Prevailing Trend Long Signal", location = location.top, style = shape.triangleup, size = size.tiny, color = color.new(color.green, 30), textcolor = color.new(color.black, 0)) plotshape(pt_S_trig and pt_show_sigs ? pt_up : na, title = "Prevailing Trend Short Signal", location = location.top, style = shape.triangledown, size = size.tiny, color = color.new(color.red, 30), textcolor = color.new(color.black, 0)) pt_barcolor = pt_L_conf ? color.blue : pt_S_conf ? color.red : color.gray barcolor(pt_color_bars ? pt_barcolor : na, title = "Prevailing Trend Bar Color") //============================================================================== //============================================================================== // Setting up user-activated alerts for Prevailing Trend buy/sell signals //============================================================================== alertcondition(pt_L_trig, title = "Prevailing Trend Long Signal", message = "{{ticker}}: Prevailing Trend Indicator signaled to go long at {{time}}.") alertcondition(pt_S_trig, title = "Prevailing Trend Short Signal", message = "{{ticker}}: Prevailing Trend Indicator signaled to go short at {{time}}.") //==============================================================================
Volatility Percentage Monitor
https://www.tradingview.com/script/4vPmknx0-Volatility-Percentage-Monitor/
Fab_Coin_
https://www.tradingview.com/u/Fab_Coin_/
16
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/ // © Fab_Coin_ // Volatility Percentage Monitor (VPM) //@version=5 indicator("Volatility Percentage Monitor", "VPM", overlay=false) // HMI Inputs // tf = input.timeframe(defval="1D", title="Timeframe", options=['1D', '1W', '1M']) period_study = input(1, title = "Study period       ", tooltip = 'Daily default (1)', inline = 'study') study_bool = input.bool(true, '', inline = 'study') period_short = input(15, title = "Short term average ", tooltip = '10 days default (10)', inline = 'short') short_bool = input.bool(false, '', inline = 'short') period_mid = input(30, title = "Mid term average   ", tooltip = 'Monthly default (30)', inline = 'mid') mid_bool = input.bool(false, '', inline = 'mid') period_long = input(100, title = "Longterm average  ", tooltip = 'Longterm default (100)', inline = 'long') long_bool = input.bool(false, '', inline = 'long') avg_method = input.string(title = "Average method  ", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"], tooltip = 'SMA standard setting') std_dev_bool = input.bool(true, 'Long term Std dev', 'Display Std Dev ON/OFF') BBperiods = input.int(20, title = 'Periods', step = 1, inline = 'BB', group = 'Bollinger Bands Settings') BBstdev = input.float(1.1, title = 'Std Dev', step = 0.1, inline = 'BB', group = 'Bollinger Bands Settings') BB_bool = input(true, 'BB ON/OFF', inline = 'BB', group = 'Bollinger Bands Settings') // Vars var study_series = 0.0 var short_series = 0.0 var mid_series = 0.0 var long_series = 0.0 var stdev_series = 0.0 // Functions and calc avg_type(source, length) => switch avg_method "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "WMA" => ta.wma(source, length) study_series := avg_type(ta.tr(true) / close * 100, period_study) short_series := avg_type(ta.tr(true) / close * 100, period_short) mid_series := avg_type(ta.tr(true) / close * 100, period_mid) long_series := avg_type(ta.tr(true) / close * 100, period_long) stdev_series := ta.stdev(study_series, period_long) // Bollinger calc [mid, top, bottom] = ta.bb(study_series, BBperiods, BBstdev) // Plot stuff plot(study_bool ? study_series : na, title = "Study period", color = color.new(color.orange, 10), linewidth = 2, style = plot.style_linebr) plot(short_bool ? short_series : na, title = "Short term", color = color.new(color.green, 20), linewidth = 2, style = plot.style_linebr) plot(mid_bool ? mid_series : na, title = "Mid term", color = color.new(color.blue, 20), linewidth = 2, style = plot.style_linebr) plot(long_bool ? long_series : na, title = "Long term", color = color.new(color.gray, 0), linewidth = 2, style = plot.style_linebr) plot(std_dev_bool ? stdev_series : na, title = "Std dev Long term", color = color.new(color.red, 30), linewidth = 2, style = plot.style_linebr) BBup = plot(BB_bool ? top : na, title='Top BB', color = color.new(color.aqua, 45), linewidth=1, style=plot.style_linebr) BBdown = plot(BB_bool ? bottom : na, title='Bottom BB', color = color.new(color.blue, 45), linewidth=1, style=plot.style_linebr) BBmid = plot(BB_bool ? mid : na, title='Middle BB', color = color.new(color.white, 50), linewidth=1, style=plot.style_linebr) fill(BBup, BBmid, title = 'Volatility above average', color = color.new(color.aqua, 85)) fill(BBdown, BBmid, title = 'Volatility below average', color = color.new(color.navy, 85)) // Alerts if close > mid alert('Mid volatility reach') if close > top alert('Top Volatility reach') // ...TheEnd...
Session Tick-Box
https://www.tradingview.com/script/w30PubRf-Session-Tick-Box/
sosso_bott
https://www.tradingview.com/u/sosso_bott/
53
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/ // © mbome237 //@version=5 indicator('Session Tick-Box', overlay=true) import sosso_bott/SAT_LIB/45 as sat groupset = '  ▶︎ ===========  Session Settings  =========== ◀︎' groupset2 = '  ▶︎ ===========  Display Settings  =========== ◀︎' // ========================================================================================================================================================================================================================================================================================== separateDays = input.bool(true, title="Show New Daily Session", inline="00", group=groupset2) color Day_Bg = input.color(color.new(color.black, 45), "New Session BG", inline="00", group=groupset2) colorDays = input.bool(false, title="Color Dayz Background", inline="00", group=groupset2) colorSess = input.bool(true, title="", inline="000", group=groupset2) color cash_xo = input.color(color.new(color.blue, 20), "Cash", inline="000", group=groupset2) color asian_xo = input.color(color.new(color.olive, 20), "Asian  ", inline="000", group=groupset2) color europe_xo = input.color(color.new(color.orange, 20), "Europe", inline="000", group=groupset2) color offset_xo = input.color(color.new(color.red, 20), "Offset", inline="000", group=groupset2) offset_xo_fill = input.int(87, "fill", inline="000", group=groupset2) newsessionPerc = input.float(0.50, title="Session drawing Percentage", group=groupset2) // ========================================================================================================================================================================================================================================================================================== ref_res = input.timeframe(title='Reference Resolution', defval='D', group=groupset) rth_ses = input.session(title='Cash Session', defval='0830-1500', group=groupset) rth_ses2 = input.session(title='Asian Session', defval='1500-0400', group=groupset) rth_ses3 = input.session(title='European Session', defval='0400-0830', group=groupset) rth_ses4 = input.session(title='offset Session', defval='0400-0830', group=groupset) color lundi = input.color(color.new(color.yellow, 95), "Monday   ", inline="1", group=groupset) color mardi = input.color(color.new(color.navy, 95), "Tuesday  ", inline="1", group=groupset) color mercredi = input.color(color.new(color.olive, 95), "Wednesday ", inline="1", group=groupset) color jeudi = input.color(color.new(color.purple, 95), "Thursday  ", inline="2", group=groupset) color vendredi = input.color(color.new(color.silver, 95), "Friday    ", inline="2", group=groupset) color weekend = input.color(color.new(color.teal, 95), "Weekend   ", inline="2", group=groupset) timeIsAllowed1 = time(timeframe.period, rth_ses) timeIsAllowed2 = time(timeframe.period, rth_ses2) timeIsAllowed3 = time(timeframe.period, rth_ses3) timeIsAllowed4 = time(timeframe.period, rth_ses4) [rth_low, rth_high, rth_fill_color, rth_open_bar, rth_is_open] = sat.session_tick( rth_ses, cash_xo, ref_res) [rth_low2, rth_high2, rth_fill_color2, rth_open_bar2, rth_is_open2] = sat.session_tick( rth_ses2, asian_xo, ref_res) [rth_low3, rth_high3, rth_fill_color3, rth_open_bar3, rth_is_open3] = sat.session_tick( rth_ses3, europe_xo, ref_res) [rth_low4, rth_high4, rth_fill_color4, rth_open_bar4, rth_is_open4] = sat.session_tick( rth_ses4, offset_xo, ref_res) low_route = float(na) high_route = float(na) low_route := timeIsAllowed1 ? rth_low : timeIsAllowed2 ? rth_low2 : timeIsAllowed3 ? rth_low3 : low_route[1] high_route := timeIsAllowed1 ? rth_high : timeIsAllowed2 ? rth_high2 : timeIsAllowed3 ? rth_high3 : high_route[1] route_color = timeIsAllowed1 ? cash_xo : timeIsAllowed2 ? asian_xo : timeIsAllowed3 ? europe_xo : timeIsAllowed4 ? offset_xo : na retxt_color = rth_open_bar ? "CASH" : rth_open_bar2 ? "ASIAN" : rth_open_bar3 ? "EUROPE" : rth_open_bar4 ? "OFFSET" : na route_color2 = rth_open_bar ? cash_xo : rth_open_bar2 ? asian_xo : rth_open_bar3 ? europe_xo : rth_open_bar4 ? offset_xo : na route_cond = rth_open_bar ? true : rth_open_bar2 ? true : rth_open_bar3 ? true : rth_open_bar4 ? true : na mid = sat.lineBetweenLines(high_route, low_route, 0.5) low_route_perc = sat.AbsPercentChange(low_route) high_route_perc = sat.AbsPercentChange(high_route) // ========================================================================================================================================================================================================================================================================================== lol2 = dayofweek(time) == dayofweek.monday ? lundi : dayofweek(time) == dayofweek.tuesday ? mardi : dayofweek(time) == dayofweek.wednesday ? mercredi : dayofweek(time) == dayofweek.thursday? jeudi : dayofweek(time) == dayofweek.friday ? vendredi : weekend xxx = sat.is_newbar(ref_res) ? 1 : 0 bgcolor(color=colorDays ? lol2:na) bgcolor(color=not separateDays ? na : xxx==1 ?Day_Bg:na) label lb_high = na label lb_low = na label lb_high2 = na label lb_low2 = na float ylow = na float yhigh = na float ylow2 = na float yhigh2 = na if route_cond and colorSess ylow := ( low_route[1] * (1 - ( newsessionPerc / 100) ) ) yhigh := ( high_route[1] * (1 + ( newsessionPerc / 100) ) ) ylow2 := ( low_route[1] * (1 - ( (newsessionPerc + (newsessionPerc)/2) / 100) ) ) yhigh2 := ( high_route[1] * (1 + ( (newsessionPerc + (newsessionPerc)/2) / 100) ) ) lb_high := label.new(bar_index, yhigh, color=route_color2, textcolor=route_color2, style=label.style_triangledown, xloc = xloc.bar_index, textalign=text.align_center, size=size.tiny) lb_low := label.new(bar_index, ylow, color=route_color2, textcolor=route_color2, style=label.style_triangleup, xloc = xloc.bar_index, textalign=text.align_center, size=size.tiny) lb_high2 := label.new(bar_index, yhigh2, color=route_color2, textcolor=color.white, text=retxt_color, style=label.style_label_down, textalign=text.align_center, size=size.normal) lb_low2 := label.new(bar_index, ylow2, color=route_color2, textcolor=color.white, text=retxt_color, style=label.style_label_up, textalign=text.align_center, size=size.normal) line.new(x1=bar_index, y1=ylow, x2=bar_index, y2=yhigh, color=route_color2, width=1, style=line.style_solid) // plot(route_cond ? high_route[1]: na, color=color.red) // plot(route_cond ? low_route[1] : na, color=color.red) // plot(mid, linewidth = 2) // plotchar(low_route_perc) // plotchar(high_route_perc) rth_plot_low5 = plot(low_route, title='RTH Low5', color=route_color, linewidth=2) rth_plot_high5 = plot(high_route, title='RTH High5', color=route_color, linewidth=2) fill(rth_plot_low5, rth_plot_high5, title='RTH Range5', color=color.new(route_color, offset_xo_fill), transp=90)
Trading Session Template
https://www.tradingview.com/script/Z7Evd8Yo-Trading-Session-Template/
its_zezooo
https://www.tradingview.com/u/its_zezooo/
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/ // © its_zezooo // CODE FROM ZEN FREE COURSE //@version=5 indicator("Trading Session Template", shorttitle = "MySession", overlay = true) // Import Zen Library import ZenAndTheArtOfTrading/ZenLibrary/2 as zen // user inputs //{ // Time settings var g_time = "════════════ Session Time Settings ═════════════" useSess = input.bool(title="use session window?", defval=true, tooltip = "When turned on, the script will change the background color (script deafult is red) when in-session", group=g_time) string sessionInput = input.session("0800-1600", "session hours", tooltip = "set the hour range of your target session", group = g_time) string daysInput = input.string("1234567","session days", tooltip = "Day range: 1 = Sunday, 7 = Saturday", group = g_time) // ATR settings var g_ATR = "═════════════ ATR filter Settings ══════════════" ATRswitch = input.bool(title="ATR based SL/TP?",defval=false, tooltip = "when turned on, ATR based SL & TP according to user inputs ATR settings will be displayed ", group = g_ATR) ATR_length = input.int(title = "ATR length", defval = 14, group = g_ATR) multiplier = input.float(title="ATR SL Multiplier", defval = 1, tooltip = "this number will be multiplied by the ATR of the previous 14 candles to set an ATR based SL", group = g_ATR) rr = input.float(title="R:R - using ATR", defval = 1, tooltip = "this number will be multiplied by the multiplier to set a TP based on SL", group = g_ATR) // Candles var g_candles = "════════════ Candle Patterns Settings ════════════" switchDoji = input.bool(title = "Doji Candles?", defval = false, tooltip = "when turned on will detect Doji candles", group = g_candles) switchEC = input.bool(title="EC Candles pattern?",defval=false, tooltip = "when turned on will detect Engulfing candles", group = g_candles) switchHammer_Stars = input.bool(title="Hammer/Star Candles?",defval=true , tooltip = "when turned on will detect Hammer/Star candles", group = g_candles) fib_input = input.float(title="Hammer & Star fib", defval = 0.333, minval = 0, maxval = 1,step = 0.1, tooltip = "thow large is the body of the candle in relation to the distance between its high and low", group = g_candles) lookback = input.int(title = "Lookback period", defval = 10, tooltip = "lookback for highest high / Lowest Low", group = g_candles) atrMinFilterSize = input.float(title=">= ATR Filter", defval=0.0, minval=0.0, step= 0.1 ,group=g_candles, tooltip="Minimum size of entry candle compared to ATR") atrMaxFilterSize = input.float(title="<= ATR Filter", defval=3.0, minval=0.0, step= 0.1, group=g_candles, tooltip="Maximum size of entry candle compared to ATR") //} //atr function atr=ta.atr(ATR_length) // Engulfing calndles bullEC = zen.isBullishEC() and switchEC bearEC = zen.isBearishEC() and switchEC // Hammer and star isHammer = zen.isHammer(fib_input) and switchHammer_Stars isStar =zen.isStar(fib_input) and switchHammer_Stars // doji doji = zen.isDoji() and switchDoji // highest/lowest over lookback highest_high = ta.highest(high, lookback) lowest_low= ta.lowest(low, lookback) isHighest = high == highest_high? true:false isLowest = low == lowest_low? true:false // bar size in aTR // Check ATR filter atrMinFilter = high - low >= (atrMinFilterSize * atr) or atrMinFilterSize == 0.0 atrMaxFilter = high - low <= (atrMaxFilterSize * atr) or atrMaxFilterSize == 0.0 atrFilter = atrMinFilter and atrMaxFilter and not na(atr) // time sessionString = sessionInput + ":" + daysInput inSession = not na(time(timeframe.period, sessionString)) // buy and sell conditions buy = (isHammer or bullEC or doji) and isLowest and atrFilter and barstate.isconfirmed and inSession sell = (isStar or bearEC or doji) and isHighest and atrFilter and barstate.isconfirmed and inSession bgcolor(inSession and useSess? color.new(color.red,90):na) // TP and SL for longs longSL = ta.lowest(low, lookback) - (atr*multiplier) longDistance = close - longSL longTP = close + (longDistance*rr) /// TP and SL for longs shortSL= ta.highest(high, lookback)+ (atr*multiplier) shortDistance = shortSL-close shortTP= close - (shortDistance*rr) // plot function buy&sell signal plotshape(buy, title="buy signal", style = shape.labelup, location = location.belowbar, color=color.lime, size = size.normal) plotshape(sell, title="sell signal", style = shape.labeldown, location = location.abovebar, color=color.red, size = size.normal) // plot long SL and TP plot(buy and ATRswitch?longSL:na, "Long SL", color=color.red, style=plot.style_linebr, linewidth = 3) plot(buy and ATRswitch?longTP:na, "Long TP", color=color.lime, style=plot.style_linebr, linewidth = 3) // plot short SL and TP plot(sell and ATRswitch?shortSL:na, "Long SL", color=color.red, style=plot.style_linebr, linewidth = 3) plot(sell and ATRswitch?shortTP:na, "Long TP", color=color.lime, style=plot.style_linebr, linewidth = 3) // Alerts //{ if switchDoji if doji and isLowest and atrFilter and barstate.isconfirmed and inSession alert("A DOJI was detected at a LOW") if doji and isHighest and atrFilter and barstate.isconfirmed and inSession alert("A DOJI was detected at a HIGH") if switchEC if bullEC and isLowest and atrFilter and barstate.isconfirmed and inSession alert("A BULLISH ENGULFING Candle was detected at a LOW") if bearEC and isHighest and atrFilter and barstate.isconfirmed and inSession alert("A BEARISH ENGULFING Candle was detected at a HIGH") if switchHammer_Stars if isHammer and isLowest and atrFilter and barstate.isconfirmed and inSession alert("A HAMMER was detected at a LOW") if isStar and isHighest and atrFilter and barstate.isconfirmed and inSession alert("A STAR candle was detected at a HIGH")
Parabolic SAR + EMA 200 + MACD Signals
https://www.tradingview.com/script/eevVxLxD-Parabolic-SAR-EMA-200-MACD-Signals/
Saleh_Toodarvari
https://www.tradingview.com/u/Saleh_Toodarvari/
1,175
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/ // © Saleh_Toodarvari //@version=5 indicator(title="Parabolic SAR + EMA 200 + MACD Signals", shorttitle="SAR EMA MACD", overlay=true, timeframe="", timeframe_gaps=true) // Inputs sar_start = input(0.02) sar_increment = input(0.02) sar_maximum = input(0.2, "Max Value") ema_len = input.int(200, minval=1, title="Length") ema_src = input(close, title="Source") ema_offset = input.int(title="Offset", defval=0, minval=-500, maxval=500) macd_fast_length = input(title="Fast Length", defval=12) macd_slow_length = input(title="Slow Length", defval=26) macd_src = input(title="Source", defval=close) signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) // Colors 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") // Parabolic SAR SAR = ta.sar(sar_start, sar_increment, sar_maximum) plot(SAR, "ParabolicSAR", style=plot.style_circles, color=#2962FF) // EMA 200 EMA_200 = ta.ema(ema_src, ema_len) plot(EMA_200, title="EMA", color=color.blue, offset=ema_offset) // MACD fast_ma = sma_source == "SMA" ? ta.sma(macd_src, macd_fast_length) : ta.ema(macd_src, macd_fast_length) slow_ma = sma_source == "SMA" ? ta.sma(macd_src, macd_slow_length) : ta.ema(macd_src, macd_slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) delta = macd - signal // Conditions main_trend=if ohlc4<EMA_200 "Bearish" else "Bullish" sar_long = if SAR<low true else false sar_short = if SAR>high true else false macd_long = if (ta.crossover(delta, 0)) true else false macd_short = if (ta.crossunder(delta, 0)) true else false // Long buy_signal= sar_long and macd_long and (main_trend=="Bullish") // Short sell_signal= sar_short and macd_short and (main_trend=="Bearish") // Plots plotshape(buy_signal, title="Buy Label", text="Buy", location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white) plotshape(sell_signal, title="Sell Label", text="Sell", location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)
Machine Learning : Torben's Moving Median KNN Bands
https://www.tradingview.com/script/dUC0uIWr-Machine-Learning-Torben-s-Moving-Median-KNN-Bands/
Ankit_1618
https://www.tradingview.com/u/Ankit_1618/
126
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/ // © Ankit_1618 //@version=5 indicator('Machine Learning : Torben Moving Median KNN', overlay=true) length_fast = input(8) length_slow = input(13) price = input(hlc3) // //====== TORBEAN MOVING MEDIAN //====== http://ndevilla.free.fr/median/median/index.html // torbean_moving_median(price, length) => smin = ta.lowest(price, length) smax = ta.highest(price, length) //initial declarations median = 0. guess = 0. less = 0. greater = 0. equal = 0. maxltguess = 0. mingtguess = 0. for j = 0 to 10000000 by 1 //a greater value signifying infinite loop guess := (smin + smax) / 2 //guesstimate less := 0 greater := 0 equal := 0 maxltguess := smin mingtguess := smax for i = 0 to length - 1 by 1 if price[i] < guess less += 1 if price[i] > maxltguess maxltguess := price[i] maxltguess else if price[i] > guess greater += 1 if price[i] < mingtguess mingtguess := price[i] mingtguess else equal += 1 equal if less <= (length + 1) / 2 and greater <= (length + 1) / 2 break else if less > greater smax := maxltguess continue else smin := mingtguess continue if less >= (length + 1) / 2 median := maxltguess median else if less + equal >= (length + 1) / 2 median := guess median else median := mingtguess median tmm_fast = torbean_moving_median(price, length_fast) tmm_slow = torbean_moving_median(price, length_slow) // plot(tmm_fast, color=close > tmm_fast ? color.green : color.red, linewidth=1) // plot(tmm_slow, color=close > tmm_slow ? color.green : color.red, linewidth=1) // //====================== // // Knn Calculated from Referenced TOBEAN MOVING MEDIAN //====================== knn(data) => N = 10, K=100 nearest_neighbors = array.new_float(0) distances = array.new_float(0) for i = 0 to N-1 float d = math.abs(data[i] - data[i+1]) array.push(distances, d) int size = array.size(distances) float new_neighbor = d<array.min(distances, size>K?K:0)?data[i+1]:data[i] array.push(nearest_neighbors, new_neighbor) nearest_neighbors predict(neighbors, data) => //-- predict the expected price and calculate next bar's direction float prediction = array.avg(neighbors) int direction = prediction < data[0] ? 1 : prediction > data[0] ? -1 : 0 [prediction, direction] _nn_fast = knn(tmm_fast) _nn_slow = knn(tmm_slow) [knn_line_fast,knn_dir_fast] = predict(_nn_fast, tmm_fast) [knn_line_slow,knn_dir_slow] = predict(_nn_slow, tmm_slow) // //====== PLOTS // c_green = color.new(color.green, 80) c_red = color.new(color.red, 80) // plot(knn_line_fast, color=knn_dir_fast == 1 ? color.green : knn_dir_fast == -1 ? color.red : color.gray, linewidth = 2) // plot(knn_line_slow, color=knn_dir_slow == 1 ? color.green : knn_dir_slow == -1 ? color.red : color.gray, linewidth = 2) p_knn_line_fast = plot(knn_line_fast, color=color.rgb(76, 175, 79, 78.6) , linewidth = 1) p_knn_line_slow = plot(knn_line_slow, color=color.rgb(255, 82, 82, 78.6), linewidth = 1) fill_color_knn_fast_slow = knn_line_fast > knn_line_slow ? color.green : knn_line_fast < knn_line_slow ? color.red : color.gray fill(p_knn_line_fast, p_knn_line_slow, color=color.new(fill_color_knn_fast_slow, 90)) // //======STANDARD DEVIATIONS // std_fast_u = knn_line_fast + ta.stdev(close, length_fast) std_fast_l = knn_line_fast - ta.stdev(close, length_fast) std_slow_u = knn_line_slow + ta.stdev(close, length_slow) std_slow_l = knn_line_slow - ta.stdev(close, length_slow) plot(std_fast_u, color = color.new(color.blue, 70)) plot(std_fast_l, color = color.new(color.blue, 70)) plot(std_slow_u, color = color.new(color.orange, 70)) plot(std_slow_l, color = color.new(color.orange, 70))
MACD Normalized [ChartPrime]
https://www.tradingview.com/script/pV1vMscr-MACD-Normalized-ChartPrime/
ChartPrime
https://www.tradingview.com/u/ChartPrime/
568
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/ // © ChartPrime //@version=5 indicator("MACD Normalized [ChartPrime]", explicit_plot_zorder = true, timeframe = '', timeframe_gaps = false) enable_fill = input.bool(true, "Enable Ribbon ") fast_length = input.int(10, "Fast Length", 1) slow_length = input.int(22, "Slow Length", 1) average_length = input.int(42, "Average Length", 1) deviation = input.float(2, "Upper Deviation", 0, 100, 0.125) middle_deviation = input.float(1, "Middle Deviation", 0, 100, 0.125) enable_candle = input.bool(true, "Enable Candle Color") ema(src, len) => //{ alpha = 2 / (len + 1) sum = 0.0 sum := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1]) dema(float src, float len) => e = ema(src, len) dema = 2 * e - ema(e, len) dema ema(source)=> var float ema = 0.0 var int count = 0 count := nz(count[1]) + 1 ema := (1.0 - 2.0 / (count + 1.0)) * nz(ema[1]) + 2.0 / (count + 1.0) * source ema tma(src, int len) => //{ //src is an input.source //len is an input.int ema1 = ema(src, len) ema2 = ema(ema1, len) ema3 = ema(ema2, len) tma = 3 * (ema1 - ema2) + ema3 grad_high(values)=> switch values 39 => #2ec28c 38 => color.rgb(53, 194, 142) 37 => color.rgb(59, 195, 143) 36 => color.rgb(65, 195, 145) 35 => color.rgb(70, 195, 146) 34 => color.rgb(75, 196, 148) 33 => color.rgb(79, 196, 150) 32 => color.rgb(84, 196, 151) 31 => color.rgb(88, 197, 153) 30 => color.rgb(92, 197, 154) 29 => color.rgb(95, 197, 156) 28 => color.rgb(99, 198, 157) 27 => color.rgb(102, 198, 159) 26 => color.rgb(106, 198, 160) 25 => color.rgb(109, 199, 161) 24 => color.rgb(112, 199, 163) 23 => color.rgb(115, 199, 164) 22 => color.rgb(118, 200, 166) 21 => color.rgb(121, 200, 167) 20 => color.rgb(124, 200, 168) 19 => color.rgb(127, 201, 170) 18 => color.rgb(129, 201, 171) 17 => color.rgb(132, 201, 173) 16 => color.rgb(135, 202, 174) 15 => color.rgb(137, 202, 175) 14 => color.rgb(140, 202, 177) 13 => color.rgb(142, 203, 178) 12 => color.rgb(145, 203, 179) 11 => color.rgb(147, 203, 180) 10 => color.rgb(149, 204, 182) 9 => color.rgb(152, 204, 183) 8 => color.rgb(154, 204, 184) 7 => color.rgb(156, 205, 185) 6 => color.rgb(158, 205, 187) 5 => color.rgb(161, 205, 188) 4 => color.rgb(163, 206, 189) 3 => color.rgb(165, 206, 190) 2 => color.rgb(167, 206, 192) 1 => color.rgb(169, 207, 193) 0 => color.rgb(171, 207, 194) grad_low(values)=> switch 39 - values 39 => #eb0027 38 => color.rgb(235, 30, 50) 37 => color.rgb(235, 43, 58) 36 => color.rgb(235, 52, 66) 35 => color.rgb(234, 60, 73) 34 => color.rgb(234, 67, 79) 33 => color.rgb(234, 74, 84) 32 => color.rgb(234, 80, 90) 31 => color.rgb(234, 85, 95) 30 => color.rgb(234, 90, 100) 29 => color.rgb(234, 95, 104) 28 => color.rgb(234, 100, 109) 27 => color.rgb(233, 104, 113) 26 => color.rgb(233, 109, 117) 25 => color.rgb(233, 113, 121) 24 => color.rgb(233, 117, 125) 23 => color.rgb(233, 120, 128) 22 => color.rgb(233, 124, 132) 21 => color.rgb(233, 128, 136) 20 => color.rgb(233, 131, 139) 19 => color.rgb(232, 135, 142) 18 => color.rgb(232, 138, 146) 17 => color.rgb(232, 141, 149) 16 => color.rgb(232, 144, 152) 15 => color.rgb(232, 147, 155) 14 => color.rgb(232, 151, 158) 13 => color.rgb(232, 154, 161) 12 => color.rgb(232, 156, 164) 11 => color.rgb(231, 159, 167) 10 => color.rgb(231, 162, 169) 9 => color.rgb(231, 165, 172) 8 => color.rgb(231, 168, 175) 7 => color.rgb(231, 170, 177) 6 => color.rgb(231, 173, 180) 5 => color.rgb(231, 176, 183) 4 => color.rgb(231, 178, 185) 3 => color.rgb(230, 181, 188) 2 => color.rgb(230, 183, 190) 1 => color.rgb(230, 186, 193) 0 => color.rgb(230, 188, 195) atan2(y, x) => var float angle = 0.0 if x > 0 angle := math.atan(y / x) else if x < 0 and y >= 0 angle := math.atan(y / x) + math.pi else if x < 0 and y < 0 angle := math.atan(y / x) - math.pi else if x == 0 and y > 0 angle := math.pi / 2 else if x == 0 and y < 0 angle := -math.pi / 2 angle degrees(float source) => source * 180 / math.pi trend_angle(source, length) => atr = ema(ta.highest(source, length) - ta.lowest(source, length)) slope = (source - source[length]) / (atr/(length) * length) angle_rad = atan2(slope, 1) degrees = degrees(angle_rad) normalized = int((90 + degrees)/180 * 39) noise_gate(signal, ratio, level, knee_type) => // Calculate the absolute value of the signal abs_signal = math.abs(signal) // Check the value of the knee_type parameter if knee_type == "hard" // If the knee_type is "hard", apply a hard knee if abs_signal > level out = signal else out = signal / ratio else // If the knee_type is not "hard", apply a soft knee if (abs_signal > level) or level == 0 // If the absolute value is above the threshold, return the signal as is out = signal else // If the absolute value is below the threshold, calculate the soft knee ratio soft_knee_ratio = 1 - (level - abs_signal) / level // Reduce the amplitude of the signal by the soft knee ratio out = signal * soft_knee_ratio // ALPHA = color.new(color.black, 100) High = ta.sma(high, average_length) Low = ta.sma(low, average_length) signal = tma(hl2, fast_length) signal_2 = dema(hl2, slow_length) avg = math.avg(High, Low) top = High - avg bot = Low - avg fast = signal - avg slow = signal_2 - avg stdev_up = ta.stdev(high, average_length) stdev_down = ta.stdev(low, average_length) stdev_center = ta.stdev(hl2, average_length) stdev_avg = nz(math.avg(stdev_up, stdev_down, stdev_center)) stdev_percent = ta.percentrank(stdev_avg, int(average_length)) max = top + stdev_up * deviation up_med = top + stdev_up * middle_deviation down_med = bot - stdev_down * middle_deviation min = bot - stdev_down * deviation signal_fast = ((fast - min) / (max - min)) * 100 signal_slow = ((slow - min) / (max - min)) * 100 mid_top = ((up_med - min) / (max - min)) * 100 mid_bottom = ((down_med - min) / (max - min)) * 100 macd = noise_gate(signal_fast - signal_slow, 5, 0.03, "hard") macd_angle = trend_angle(macd, 2) macd_color = color.new(macd > 0 ? grad_high(macd_angle) : grad_low(macd_angle), 10) plot_center = plot(50, color = ALPHA) m_top = plot(mid_top, color = ALPHA) m_bot = plot(mid_bottom, color = ALPHA) top_plot = plot(100, color = #D31F3D) bottom_plot = plot(0, color = #006159) fill(m_top, top_plot, bottom_color = ALPHA, top_color = color.new(#DB2732, 60), top_value = 100, bottom_value = mid_top) fill(m_bot, bottom_plot, top_color = ALPHA, bottom_color = color.new(#006C58, 60), top_value = mid_bottom, bottom_value = 0) plot(macd + 50, "MACD", macd_color, style = plot.style_columns, histbase = 50) fast_plot = plot(signal_fast, color = color.new(#0085FF, enable_fill ? 76 : 0), linewidth = enable_fill ? 1 : 2) slow_plot = plot(signal_slow, color = color.new(#F3A712, enable_fill ? 76 : 0), linewidth = enable_fill ? 1 : 2) fill(fast_plot, slow_plot, top_value = enable_fill ? signal_fast : na, bottom_value = enable_fill ? signal_slow : na, top_color = color.new(#0085FF, 18), bottom_color = color.new(#F3A712, 50)) barcolor(enable_candle ? macd_color : na)
info
https://www.tradingview.com/script/KJq6nu4T-info/
aseem64
https://www.tradingview.com/u/aseem64/
0
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/ // © aseem64 //@version=5 indicator("info", overlay=true) symbol_position = input.string(title='Symbol Position', options=["top_center", "middle_right", "None"], defval="top_center") rsi_vix_position = input.string(title='RSI VIX Position', options=["top_center", "middle_right", "bottom_right", "None"], defval="bottom_right") india_vix = request.security("NSE:INDIAVIX", "D", close, lookahead = barmerge.lookahead_on) india_vix:=math.round(india_vix,1) us_vix = request.security("CBOE:VIX", timeframe.period, close) us_vix:=math.round(us_vix,1) //symbol tables var table top_center = table.new(position.top_center , 2, 2, border_width = 1) var table middle_right = table.new(position.middle_right , 2, 2, border_width = 1) //vix and rsi tables var table bottom_right = table.new(position.bottom_right , 2, 2, border_width = 1) //display symbol and timeframe if symbol_position == 'top_center' table.cell(top_center, 0, 0, syminfo.ticker, text_color=color.red, text_size=size.auto) table.cell(top_center, 1, 0, timeframe.period, text_color=color.red, text_size=size.auto) table.cell(top_center, 0, 1, "ST 10,2", text_color=color.red, text_size=size.auto) if symbol_position == 'middle_right' table.cell(middle_right, 0, 0, syminfo.ticker, text_color=color.red, text_size=size.auto) table.cell(middle_right, 1, 0, timeframe.period, text_color=color.red, text_size=size.auto) table.cell(middle_right, 0, 1, "ST 10,2", text_color=color.red, text_size=size.auto) if symbol_position == 'None' table.cell(top_center, 0, 0, '1', text_color=color.red, text_size=size.auto) //display rsi and indiavix rsi=ta.rsi(close, 14) rsi:=math.round(rsi,1) if rsi_vix_position == 'bottom_right' //table.cell(bottom_right, 0, 0, "INDIAVIX", text_color=color.red, text_size=size.auto) table.cell(bottom_right, 1, 0, str.tostring(india_vix), text_color=color.red, text_size=size.auto) //table.cell(bottom_right, 0, 1, "RSI", text_color=color.red, text_size=size.auto) table.cell(bottom_right, 1, 1, str.tostring(rsi), text_color=color.red, text_size=size.auto)
Fibonacci Levels on Any Indicator [By MUQWISHI]
https://www.tradingview.com/script/fOYvs9sf-Fibonacci-Levels-on-Any-Indicator-By-MUQWISHI/
MUQWISHI
https://www.tradingview.com/u/MUQWISHI/
401
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/ // © MUQWISHI //@version=5 indicator("Fibonacci Levels on Any Indicator", overlay = true, max_bars_back = 500, max_labels_count = 500, max_lines_count = 500) s = " ‏" srtNme = input.string("Long", "Start Drawing Condition", inline = "1", group = "Signal Conditions") lngCol = input.color(color.green, "", inline = "1", group = "Signal Conditions") lngCon = input.string("Value(1) New Phase", " ", inline = "1", group = "Signal Conditions", options = ["Value(1) New Phase", "Value(1) Crosses Above Value(2)", "Value(1) Crosses Below Value(2)", "Value(1) Reversal Up", "Value(1) Reversal Down", "First Bar"], tooltip = "This section is to specify conditions for when to start drawing Fibonacci levels.\n\nParameters:\n● Name of the signal\n● Color of the signal\n● Condition of the signal") lngVT1 = input.string("Source", "   Value(1)", ["Source", "Numerical"], inline = "2", group = "Signal Conditions") lngVS1 = input.source(close, "", inline = "2", group = "Signal Conditions") lngVN1 = input.float(0, "||", inline = "2", group = "Signal Conditions", tooltip = "Parameters:\n● Type of the value(1)\n● Source: Valid for {Value(1)} = 'Source'\n● Numerical: Valid for {Value(1)} = 'Numerical'") lngVT2 = input.string("Source", "   Value(2)", ["Source", "Numerical"], inline = "3", group = "Signal Conditions") lngVS2 = input.source(close, "", inline = "3", group = "Signal Conditions") lngVN2 = input.float(0, "||", inline = "3", group = "Signal Conditions", tooltip = "Parameters:\n● Type of the value(2)\n● Source: Valid for {Value(2)} = 'Source'\n● Numerical: Valid for {Value(2)} = 'Numerical'") endNme = input.string("Short", "End Drawing Condition" +s+s, inline = "1") shtCol = input.color(color.red, "", inline = "1") shtCon = input.string("Value(1) New Phase", " ", inline = "1", options = ["Value(1) New Phase", "Value(1) Crosses Above Value(2)", "Value(1) Crosses Below Value(2)", "Value(1) Reversal Up", "Value(1) Reversal Down", "Last Bar"], tooltip = "This section is to specify conditions for when to end drawing Fibonacci levels.\n\nParameters:\n● Name of the signal\n● Color of the signal\n● Condition of the signal") shtVT1 = input.string("Source", "   Value(1)", ["Source", "Numerical"], inline = "2") shtVS1 = input.source(close, "", inline = "2") shtVN1 = input.float(0, "||", inline = "2", tooltip = "Parameters:\n● Type of the value(1)\n● Source: Valid for {Value(1)} = 'Source'\n● Numerical: Valid for {Value(1)} = 'Numerical'") shtVT2 = input.string("Source", "   Value(2)", ["Source", "Numerical"], inline = "3") shtVS2 = input.source(close, "", inline = "3") shtVN2 = input.float(0, "||", inline = "3", tooltip = "Parameters:\n● Type of the value(2)\n● Source: Valid for {Value(2)} = 'Source'\n● Numerical: Valid for {Value(2)} = 'Numerical'") // Fibonacci Pivots upFibT = input.string("ATR Upper Band", "Upper Pivot ", ["Source", "ATR Upper Band", "Numerical"], inline = "10", group = "Fibonacci Pivots") upFibS = input.source(close, "", inline = "10", group = "Fibonacci Pivots") upFibN = input.float(0, "||", inline = "10", group = "Fibonacci Pivots", tooltip = "Upper Pivot is Fibonacci 100% Level for Long Side. It considers being Fibonacci 0% level for Short Side.\n\nParameters:\n● Type of Upper Fibonacci Pivot\n● Source: Valid for {Upper Pivot} = 'Source'\n● Numerical: Valid for {Upper Pivot} = 'Numerical'\n\nNote:\nATR Upper choice is an arbitrary default value, and it's changeable by choosing source or number.") lwFibT = input.string("ATR Lower Band", "Lower Pivot ", ["Source", "ATR Lower Band", "Numerical"], inline = "11", group = "Fibonacci Pivots") lwFibS = input.source(close, "", inline = "11", group = "Fibonacci Pivots") lwFibN = input.float(0, "||", inline = "11", group = "Fibonacci Pivots", tooltip = "Upper Pivot is Fibonacci 0% Level for Long Side. It considers being Fibonacci 100% level for Short Side.\n\nParameters:\n● Type of Lower Fibonacci Pivot\n● Source: Valid for {Lower Pivot} = 'Source'\n● Numerical: Valid for {Lower Pivot} = 'Numerical'\n\n\nNote:\nATR Lower choice is an arbitrary default value, and it's changeable by choosing source or number.") entFrc = input.bool(false, "Force to Set Fibonacci 100% Level at Close of Bar", group = "Fibonacci Pivots") // ATR atrLen = input.int(24, "ATR", 0, inline = "10") atrMlt = input.float(1, "‏ ‏ Mult", 0, inline = "10") upACol = input.color(color.new(#5255ff, 50), "", inline = "10") dnACol = input.color(color.new(#5255ff, 50), "", inline = "10") pltAtr = input.bool(false, "Plot", inline = "10", tooltip = "ATR Bands Valid When\n {Upper Pivot} = 'ATR Upper Band'\n {Lower Pivot} = 'ATR Lower Band'\n\nParameters:\n● ATR Length\n● ATR Multiplier\n● Upper Band Color\n● Lower Band Color\n● Show/Hide Plot") // Line Style linChk = input.bool(true, "Lines"+s+s, group = "Line & Label Style", inline = "line") linExt = input.string("None Extend", ""+s+s+s, ["Hide", "Right Extend", "Left Extend", "Both Extend", "None Extend"], group = "Line & Label Style", inline = "line") linSty = input.string("________", ""+s+s+s, ["________", "-----------", "..........."], group = "Line & Label Style", inline = "line") linSiz = input.int(2, "" +s+s+s, 1, tooltip = "Parameters:\n● Show/Hide Lines\n● Line Extend\n● Line Style\n● Line Size", group = "Line & Label Style", inline = "line") // Label Style lblChk = input.bool(true, "Labels", group = "Line & Label Style", inline = "label") lblPos = input.string("Right", ""+s+s+s, ["Right"], group = "Line & Label Style", inline = "label") lblSty = input.string("Percent & Price", ""+s+s+s, ["Percent", "Value", "Price", "Percent & Price", "Value & Price"], group = "Line & Label Style", inline = "label") lblSiz = input.string("Small", ""+s+s+s, ["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group = "Line & Label Style", inline = "label", tooltip = "Parameters:\n● Show/Hide Labels\n● Label Position\n● Label Style\n● Label Size") // Fibonacci showSig = input.bool(true, "Show Signals Labels", group = "Fibonacci Levels") lastSet = input.bool(true, "Show Only Last Direction of Fibonacci Levels", group = "Fibonacci Levels") reverse = input.bool(false, "Reverse Fibonacci Levels", group = "Fibonacci Levels") confrim = input.bool(true, "Apply Fibonacci Levels After Confirmed Signal", group = "Fibonacci Levels") bgTrans = input.int(85, "Background Transparency", 0, 100, group = "Fibonacci Levels") lnTrans = input.int(25, "Line Transparency          ", 0, 100, group = "Fibonacci Levels") trndChk = input.bool(true, "Show Trend Line", group = "Fibonacci Levels", inline = "0") trndCol = input.color(color.new(#64b5f6, 50), "   ", group = "Fibonacci Levels", inline = "0") shw01 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level00") val01 = input.float(0.0, " ", group = "Fibonacci Levels", inline = "Level00") col01 = input.color(#787b86, " ", group = "Fibonacci Levels", inline = "Level00") shw02 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level00") val02 = input.float(0.236, " ", group = "Fibonacci Levels", inline = "Level00") col02 = input.color(#f44336," ", group = "Fibonacci Levels", inline = "Level00") shw03 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level01") val03 = input.float(0.382, " ", group = "Fibonacci Levels", inline = "Level01") col03 = input.color(#81c784, " ", group = "Fibonacci Levels", inline = "Level01") shw04 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level01") val04 = input.float(0.5, " ", group = "Fibonacci Levels", inline = "Level01") col04 = input.color(#4caf50, " ", group = "Fibonacci Levels", inline = "Level01") shw05 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level02") val05 = input.float(0.618, " ", group = "Fibonacci Levels", inline = "Level02") col05 = input.color(#009688, " ", group = "Fibonacci Levels", inline = "Level02") shw06 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level02") val06 = input.float(0.786, " ", group = "Fibonacci Levels", inline = "Level02") col06 = input.color(#009688, " ", group = "Fibonacci Levels", inline = "Level02") shw07 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level03") val07 = input.float(1.0, " ", group = "Fibonacci Levels", inline = "Level03") col07 = input.color(#64b5f6, " ", group = "Fibonacci Levels", inline = "Level03") shw08 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level03") val08 = input.float(1.618, " ", group = "Fibonacci Levels", inline = "Level03") col08 = input.color(#da7d31, " ", group = "Fibonacci Levels", inline = "Level03") shw09 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level04") val09 = input.float(2.1618, " ", group = "Fibonacci Levels", inline = "Level04") col09 = input.color(#81c784, " ", group = "Fibonacci Levels", inline = "Level04") shw10 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level04") val10 = input.float(3.618, " ", group = "Fibonacci Levels", inline = "Level04") col10 = input.color(#f44336, " ", group = "Fibonacci Levels", inline = "Level04") shw11 = input.bool(true, "", group = "Fibonacci Levels", inline = "Level05") val11 = input.float(4.236, " ", group = "Fibonacci Levels", inline = "Level05") col11 = input.color(#809ef0, " ", group = "Fibonacci Levels", inline = "Level05") shw12 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level05") val12 = input.float(1.272, " ", group = "Fibonacci Levels", inline = "Level05") col12 = input.color(#2962ff, " ", group = "Fibonacci Levels", inline = "Level05") shw13 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level06") val13 = input.float(1.414, " ", group = "Fibonacci Levels", inline = "Level06") col13 = input.color(#e97527, " ", group = "Fibonacci Levels", inline = "Level06") shw14 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level06") val14 = input.float(2.272, " ", group = "Fibonacci Levels", inline = "Level06") col14 = input.color(#f44336, " ", group = "Fibonacci Levels", inline = "Level06") shw15 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level07") val15 = input.float(2.414, " ", group = "Fibonacci Levels", inline = "Level07") col15 = input.color(#9c27b0, " ", group = "Fibonacci Levels", inline = "Level07") shw16 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level07") val16 = input.float(2.0, " ", group = "Fibonacci Levels", inline = "Level07") col16 = input.color(#b54df1, " ", group = "Fibonacci Levels", inline = "Level07") shw17 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level08") val17 = input.float(3.0, " ", group = "Fibonacci Levels", inline = "Level08") col17 = input.color(#e91e63, " ", group = "Fibonacci Levels", inline = "Level08") shw18 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level08") val18 = input.float(3.272, " ", group = "Fibonacci Levels", inline = "Level08") col18 = input.color(#81c784, " ", group = "Fibonacci Levels", inline = "Level08") shw19 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level09") val19 = input.float(3.414, " ", group = "Fibonacci Levels", inline = "Level09") col19 = input.color(#f44336, " ", group = "Fibonacci Levels", inline = "Level09") shw20 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level09") val20 = input.float(4.0, " ", group = "Fibonacci Levels", inline = "Level09") col20 = input.color(#81c784, " ", group = "Fibonacci Levels", inline = "Level09") shw21 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level10") val21 = input.float(4.272, " ", group = "Fibonacci Levels", inline = "Level10") col21 = input.color(#009688, " ", group = "Fibonacci Levels", inline = "Level10") shw22 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level10") val22 = input.float(4.414, " ", group = "Fibonacci Levels", inline = "Level10") col22 = input.color(#436d87, " ", group = "Fibonacci Levels", inline = "Level10") shw23 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level11") val23 = input.float(4.618, " ", group = "Fibonacci Levels", inline = "Level11") col23 = input.color(#002396, " ", group = "Fibonacci Levels", inline = "Level11") shw24 = input.bool(false, "", group = "Fibonacci Levels", inline = "Level11") val24 = input.float(4.764, " ", group = "Fibonacci Levels", inline = "Level11") col24 = input.color(#006696, " ", group = "Fibonacci Levels", inline = "Level11") // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | CALCULATION | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // ++++++++++++ ATR Bands upAtr = ta.ema(high, atrLen) + ta.atr(atrLen) * atrMlt lwAtr = ta.ema(low, atrLen) - ta.atr(atrLen) * atrMlt plot(pltAtr ? upAtr : na, "Atr Upper Band", upACol, 2) plot(pltAtr ? lwAtr : na, "Atr Lower Band", dnACol, 2) // ++++++++++++ Set Direction var shfBr = lngVT1 != "Source" and lngCon == "First Bar" and lngVN1 > 0 ? lngVN1 : 0 terminal(val1, val2, typ) => switch typ "Value(1) New Phase" => na(val1[1]) and val1 "Value(1) Crosses Above Value(2)" => val1 > val2 and val1[1] <= (na(val2[1]) ? val2 : val2[1]) "Value(1) Crosses Below Value(2)" => val1 < val2 and val1[1] >= (na(val2[1]) ? val2 : val2[1]) "Value(1) Reversal Up" => val1 > val1[1] "Value(1) Reversal Down" => val1 < val1[1] "First Bar" => lngVT1 != "Source" and val1 > 0 ? barstate.islastconfirmedhistory ? true : false : barstate.isfirst ? true : false => false // Long Direction lVal1 = lngVT1 == "Source" ? lngVS1 : lngVN1 lVal2 = lngVT2 == "Source" ? lngVS2 : lngVN2 lDirc = terminal(lVal1, lVal2, lngCon) ? 1 : 0 // Short Direction sVal1 = shtVT1 == "Source" ? shtVS1 : shtVN1 sVal2 = shtVT2 == "Source" ? shtVS2 : shtVN2 sDirc = terminal(sVal1, sVal2, shtCon) ? 1 : 0 // Direction var dirc = int(na) dirc := lDirc == 1 ? (reverse ? 1: -1) : sDirc == 1 ? (reverse ? -1: 1) : dirc // Set Values For Fib(0%) and Fib(100%) var baseFib = float(na), var rangFib = float(na) if dirc != nz(dirc[1]) upFibVal = upFibT != "Numerical" and entFrc and dirc < 0 ? close[shfBr] : upFibT == "Source" ? (na(upFibS[shfBr]) ? upFibS[shfBr+1] : upFibS[shfBr]) : upFibT == "ATR Upper Band" ? upAtr[shfBr] : upFibN dnFibVal = lwFibT != "Numerical" and entFrc and dirc > 0 ? close[shfBr] : lwFibT == "Source" ? (na(lwFibS[shfBr]) ? lwFibS[shfBr+1] : lwFibS[shfBr]) : lwFibT == "ATR Lower Band" ? lwAtr[shfBr] : lwFibN dirc := upFibVal < dnFibVal ? dirc * -1 : dirc baseFib := dirc < 0 ? math.min(upFibVal, dnFibVal) : math.max(upFibVal, dnFibVal) rangFib := math.abs(upFibVal - dnFibVal) // Calculate Fib Levels Function fibLev(x) => baseFib + (dirc == -1 ? rangFib : - rangFib) * x levFib(x) => (x - baseFib)/ (dirc == -1 ? rangFib : - rangFib) // ++++++++++++ Entered Fibonacci Levels var usVal = array.new<float>(na) var usCol = array.new<color>(na) usValFun(val, col, flg) => if flg array.push(usVal, val) array.push(usCol, col) if barstate.isfirst usValFun(val01, col01, shw01), usValFun(val02, col02, shw02), usValFun(val03, col03, shw03), usValFun(val04, col04, shw04), usValFun(val05, col05, shw05), usValFun(val06, col06, shw06), usValFun(val07, col07, shw07), usValFun(val08, col08, shw08), usValFun(val09, col09, shw09), usValFun(val10, col10, shw10), usValFun(val11, col11, shw11), usValFun(val12, col12, shw12), usValFun(val13, col13, shw13), usValFun(val14, col14, shw14), usValFun(val15, col15, shw15), usValFun(val16, col16, shw16), usValFun(val17, col17, shw17), usValFun(val18, col18, shw18), usValFun(val19, col19, shw19), usValFun(val20, col20, shw20), usValFun(val21, col21, shw21), usValFun(val22, col22, shw22), usValFun(val23, col23, shw23), usValFun(val24, col24, shw24), inVal = array.new<float>(na) for i = 0 to array.size(usVal) - 1 array.push(inVal, fibLev(array.get(usVal, i))) array.sort(inVal, dirc < 1 ? order.ascending : order.descending) // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // | DRAWING | // |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++| // ++++++++++++ Get Line Style styLine(s) => switch s "..........." => line.style_dotted "-----------" => line.style_dashed "________" => line.style_solid // ++++++++++++ Get Line Extention extLine(l) => switch l "Right Extend" => extend.right "Left Extend" => extend.left "Both Extend" => extend.both => extend.none // ++++++++++++ Get Text Label txtLab(x) => prt1 = str.contains(lblSty, "Percent") ? str.tostring(levFib(x) * 100, format.percent) + " ": str.contains(lblSty, "Value" ) ? str.tostring(levFib(x) , "#.###") + " " : "" prt2 = str.contains(lblSty, "Price") ? "(" + str.tostring(x, format.mintick) + ")" : "" (dirc > 0 ? "‏ \n" : "") + prt1 + prt2 + (dirc < 0 ? " \n‏" : "") // ++++++++++++ Line Function linFunc(x1, y, x2, col) => line.new(x1, y, x2, y, xloc.bar_index, extLine(linExt), color.new(col, lnTrans), styLine(linSty), linSiz) // ++++++++++++ Label Function labFun(y, col) => label.new(bar_index, y, txtLab(y), color = color.new(col, 100), size = str.lower(lblSiz), textcolor = color.new(col, lnTrans), style = label.style_label_left, textalign = text.align_left) // ++++++++++++ Drawing Fibonacci var linArr = array.new<line>(na) var labArr = array.new<label>(na) var linTrd = array.new<line>(na) var trndBr = 0 if array.size(inVal) > 0 if rangFib > 0 and dirc != (lngCon == "First Bar" ? nz(dirc[1]) : dirc[1]) if confrim ? barstate.isconfirmed : true if lastSet while array.size(linTrd) > 0 line.delete(array.shift(linTrd)) while array.size(linArr) > 0 line.delete(array.shift(linArr)) while array.size(labArr) > 0 label.delete(array.shift(labArr)) else if array.size(linArr) > 0 for i = 0 to array.size(linArr) - 1 line.set_extend(array.get(linArr, i), extend.none) if array.size(labArr) > 0 for i = 0 to array.size(labArr) - 1 label.set_style(array.get(labArr, i), label.style_label_right) array.clear(linArr) array.clear(labArr) array.clear(linTrd) trndBr := 0 for i = 0 to array.size(inVal) - 1 if not na(array.get(inVal, i)) linCol = array.get(usCol, array.indexof(usVal, levFib(array.get(inVal, i)))) // Line if linChk array.push(linArr, linFunc(bar_index[shfBr], array.get(inVal, i), bar_index, linCol)) if array.size(linArr) > 1 linefill.new(array.get(linArr, array.size(linArr)-2), array.get(linArr, array.size(linArr)-1), color.new(linCol, bgTrans)) if trndChk and trndBr == 0 array.push(linTrd, line.new(bar_index[shfBr], fibLev(1), bar_index, fibLev(0), xloc.bar_index, extend.none, trndCol, line.style_dashed, 1)) trndBr := 1 // Label if lblChk array.push(labArr, labFun(array.get(inVal, i), linCol)) else if array.size(linArr) > 0 for i = 0 to array.size(linArr) - 1 line.set_x2(array.get(linArr, i), bar_index) if array.size(labArr) > 0 for i = 0 to array.size(labArr) - 1 label.set_x(array.get(labArr, i), bar_index) if trndChk if array.size(linTrd) > 0 line.set_x2(array.get(linTrd, 0), bar_index) if showSig and array.size(inVal) > 0 if dirc != (lngCon == "First Bar" ? nz(dirc[1]) : dirc[1]) label.new(bar_index[shfBr], baseFib, (reverse and dirc > 0) or (not reverse and dirc < 0) ? srtNme : endNme, xloc.bar_index, yloc.price, (reverse and dirc > 0) or (not reverse and dirc < 0) ? lngCol : shtCol, dirc < 0 ? label.style_label_up : label.style_label_down, color.white)
Reversal
https://www.tradingview.com/script/bxZXAUpf-Reversal/
HasanRifat
https://www.tradingview.com/u/HasanRifat/
1,544
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/ // © HasanRifat //@version=5 indicator("Reversal", overlay = true) look_back = input.int(defval = 20, title = "Candle Lookback") confirm_in = input.int(defval = 3, title = "Confirm Within") bull_candle = 0 bear_candle = 0 v_up = false v_dn = false var bull_active_candle = false var bull_active_candle_low = 0.0 var bull_active_candle_high = 0.0 var bull_signal_active = false var bull_candle_count = 0 var bear_active_candle = false var bear_active_candle_low = 0.0 var bear_active_candle_high = 0.0 var bear_signal_active = false var bear_candle_count = 0 for i = 0 to (look_back - 1) if close < low[i] bull_candle := bull_candle + 1 if close > high[i] bear_candle := bear_candle + 1 if bull_candle == (look_back - 1) bull_active_candle := true bull_active_candle_low := low bull_active_candle_high := high bull_signal_active := false bull_candle_count := 0 if bull_active_candle == true bull_candle_count := bull_candle_count + 1 if bear_candle == (look_back - 1) bear_active_candle := true bear_active_candle_low := low bear_active_candle_high := high bear_signal_active := false bear_candle_count := 0 if bear_active_candle == true bear_candle_count := bear_candle_count + 1 if close < bull_active_candle_low bull_active_candle := false if close > bear_active_candle_high bear_active_candle := false if bull_active_candle == true and close > bull_active_candle_high and bull_signal_active == false and bull_candle_count <= (confirm_in+1) and barstate.isconfirmed bull_signal_active := true v_up := true if bear_active_candle == true and close < bear_active_candle_low and bear_signal_active == false and bear_candle_count <= (confirm_in+1) and barstate.isconfirmed bear_signal_active := true v_dn := true plotshape(v_up, title = "V Up", style = shape.triangleup, location = location.belowbar, color = color.green, size = size.small) plotshape(v_dn, title = "V Dn", style = shape.triangledown, location = location.abovebar, color = color.red, size = size.small) alertcondition(v_up, "Bullish Revarsal", "Bullish Revarsal") alertcondition(v_dn, "Bearish Revarsal", "Bearish Revarsal")
Central Bank Balance Sheets
https://www.tradingview.com/script/hWxnwKHp-Central-Bank-Balance-Sheets/
andr3w321
https://www.tradingview.com/u/andr3w321/
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/ // © andr3w321 //@version=5 indicator("Central Bank Balance Sheets", format=format.volume, precision=3) display_option = input.string(title="Display", defval="Central Bank Assets", options=["Central Bank Assets", "Central Bank Assets as % of GDP", "Total Central Bank Assets"]) fed = request.security('USCBBS', timeframe.period, close) ccb = request.security('CNCBBS', timeframe.period, close) ecb = request.security('ECBASSETSW', timeframe.period, close) jcb = request.security('JPCBBS', timeframe.period, close) cny = request.security('CNYUSD', timeframe.period, close) euro = request.security('EURUSD', timeframe.period, close) jpy = request.security('JPYUSD', timeframe.period, close) us_gdp = request.security('USGDP', timeframe.period, close) china_gdp = request.security('CNGDP', timeframe.period, close) eu_gdp = request.security('EUGDP', timeframe.period, close) japan_gdp = request.security('JPGDP', timeframe.period, close) total_assets = fed + ccb * cny + ecb * euro + jcb * jpy us_val = fed china_val = ccb * cny eu_val = ecb * euro japan_val = jcb * jpy if display_option == "Central Bank Assets as % of GDP" us_val := us_val / us_gdp china_val := china_val / china_gdp eu_val := eu_val / eu_gdp japan_val := japan_val / japan_gdp plot(display_option == "Central Bank Assets" or display_option == "Central Bank Assets as % of GDP" ? us_val : na, title='FED', color=color.blue) plot(display_option == "Central Bank Assets" or display_option == "Central Bank Assets as % of GDP" ? china_val : na, title='China CB', color=color.orange) plot(display_option == "Central Bank Assets" or display_option == "Central Bank Assets as % of GDP" ? eu_val : na, title='Europe CB', color=color.red) plot(display_option == "Central Bank Assets" or display_option == "Central Bank Assets as % of GDP" ? japan_val : na, title='Japan CB', color=color.green) plot(display_option == "Total Central Bank Assets" ? total_assets : na, title='Total Central Bank Assets', color=color.purple) if display_option == "Central Bank Assets" or display_option == "Central Bank Assets as % of GDP" label1 = label.new(chart.right_visible_bar_time, us_val, "FED", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none) label2 = label.new(chart.right_visible_bar_time, china_val, "China", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none) label3 = label.new(chart.right_visible_bar_time, eu_val, "EU", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none) label4 = label.new(chart.right_visible_bar_time, japan_val, "Japan", xloc=xloc.bar_time, yloc=yloc.price, style=label.style_none) label.delete(label1[1]) label.delete(label2[1]) label.delete(label3[1]) label.delete(label4[1])
Real Dominance
https://www.tradingview.com/script/S7uZ2POz-real-dominance/
ProHorizon
https://www.tradingview.com/u/ProHorizon/
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/ // © ProHorizon //@version=5 indicator("Real Dominance", format = format.percent) //set dominance symbols for single stablecoins var main_symbol = input.symbol("CRYPTOCAP:BTC",title = "Choose ticker of the coin for which we will calculate dominance",tooltip = "Выберите график кэпа монеты для которой считаем реальную доминацию", inline = "Main symbol") var maincolor = input.color(defval=color.gray,title="",inline = "Main symbol") var compare_symbol = input.symbol("CRYPTOCAP:BTC.D",title = "Choose dominance ticker for above chosen coin to compare", tooltip = "Выберите график доминации монеты для сравнения", inline = "Comparable symbol") var comparecolor = input.color(defval=color.red,title="",inline = "Comparable symbol") var usdc = input.symbol("CRYPTOCAP:USDC",title = "Cap of USDC",group = "Choose another tickers if default will change") var usdt = input.symbol("CRYPTOCAP:USDT",title = "Cap of USDT",group = "Choose another tickers if default will change") var tusd = input.symbol("CRYPTOCAP:TUSD",title = "Cap of TUSD",group = "Choose another tickers if default will change") var dai = input.symbol("CRYPTOCAP:DAI",title = "Cap of DAI",group = "Choose another tickers if default will change") var busd = input.symbol("GLASSNODE:BUSD_MARKETCAP",title = "Cap of BUSD",group = "Choose another tickers if default will change") var usdp = input.symbol("CRYPTOCAP:USDP",title = "Cap of USDP",group = "Choose another tickers if default will change") var gusd = input.symbol("GLASSNODE:GUSD_MARKETCAP",title = "Cap of GUSD",group = "Choose another tickers if default will change") var eurs = input.symbol("GLASSNODE:EURS_MARKETCAP",title = "Cap of EURS",group = "Choose another tickers if default will change") var susd = input.symbol("GLASSNODE:SUSD_MARKETCAP",title = "Cap of SUSD",group = "Choose another tickers if default will change") var usdk = input.symbol("GLASSNODE:USDK_MARKETCAP",title = "Cap of USDK",group = "Choose another tickers if default will change") var husd = input.symbol("GLASSNODE:HUSD_MARKETCAP",title = "Cap of HUSD",group = "Choose another tickers if default will change") var total = input.symbol("CRYPTOCAP:TOTAL",title = "Символ общей капы крипты",group = "Choose another tickers if default will change") var usdd = input.symbol("",title = "Cap of USDD",group = "Tickers are not available for coins below at the moment of publication") var ustc = input.symbol("",title = "Cap of USTC",group = "Tickers are not available for coins below at the moment of publication") var tribe = input.symbol("",title = "Cap of TRIBE",group = "Tickers are not available for coins below at the moment of publication") var frax = input.symbol("",title = "Cap of FRAX",group = "Tickers are not available for coins below at the moment of publication") var usdj = input.symbol("",title = "Cap of USDJ",group = "Tickers are not available for coins below at the moment of publication") var lusd = input.symbol("",title = "Cap of LUSD",group = "Tickers are not available for coins below at the moment of publication") var vusdc = input.symbol("",title = "Cap of vUSDC",group = "Tickers are not available for coins below at the moment of publication") var usdx = input.symbol("",title = "Cap of USDX",group = "Tickers are not available for coins below at the moment of publication") var xsgd = input.symbol("",title = "Cap of XSGD",group = "Tickers are not available for coins below at the moment of publication") var vbusd = input.symbol("",title = "Cap of vBUSD",group = "Tickers are not available for coins below at the moment of publication") var vai = input.symbol("",title = "Cap of VAI",group = "Tickers are not available for coins below at the moment of publication") var euroc = input.symbol("",title = "Cap of EUROC",group = "Tickers are not available for coins below at the moment of publication") var cusd = input.symbol("",title = "Cap of CUSD",group = "Tickers are not available for coins below at the moment of publication") var ousd = input.symbol("",title = "Cap of OUSD",group = "Tickers are not available for coins below at the moment of publication") var fei = input.symbol("",title = "Cap of FEI",group = "Tickers are not available for coins below at the moment of publication") var vusdt = input.symbol("",title = "Cap of vUSDT",group = "Tickers are not available for coins below at the moment of publication") var sbd = input.symbol("",title = "Cap of SBD",group = "Tickers are not available for coins below at the moment of publication") var rsv = input.symbol("",title = "Cap of RSV",group = "Tickers are not available for coins below at the moment of publication") var krt = input.symbol("",title = "Cap of KRT",group = "Tickers are not available for coins below at the moment of publication") var gyen = input.symbol("",title = "Cap of GYEN",group = "Tickers are not available for coins below at the moment of publication") var ceur = input.symbol("",title = "Cap of CEUR",group = "Tickers are not available for coins below at the moment of publication") var bidr = input.symbol("",title = "Cap of BIDR",group = "Tickers are not available for coins below at the moment of publication") var idrt = input.symbol("",title = "Cap of IDRT",group = "Tickers are not available for coins below at the moment of publication") var vdai = input.symbol("",title = "Cap of vDAI",group = "Tickers are not available for coins below at the moment of publication") var float domination = na //calculate dominance using Close data from other stablecoins' caps domination := 100*request.security(main_symbol, timeframe = timeframe.period, expression = close) / ((request.security(total, timeframe = timeframe.period, expression = close)) - (request.security(usdt, timeframe = timeframe.period, expression = close)) - (request.security(usdc, timeframe = timeframe.period, expression = close)) - (request.security(dai, timeframe = timeframe.period, expression = close)) - (request.security(tusd, timeframe = timeframe.period, expression = close)) - (request.security(usdp, timeframe = timeframe.period, expression = close)) - (request.security(gusd, timeframe = timeframe.period, expression = close)) - (request.security(eurs, timeframe = timeframe.period, expression = close)) - (request.security(susd, timeframe = timeframe.period, expression = close)) - (request.security(usdk, timeframe = timeframe.period, expression = close)) - (request.security(husd, timeframe = timeframe.period, expression = close)) - (request.security(usdd, timeframe = timeframe.period, expression = close)) - (request.security(ustc, timeframe = timeframe.period, expression = close)) - (request.security(tribe, timeframe = timeframe.period, expression = close)) - (request.security(frax, timeframe = timeframe.period, expression = close)) - (request.security(usdj, timeframe = timeframe.period, expression = close)) - (request.security(lusd, timeframe = timeframe.period, expression = close)) - (request.security(vusdc, timeframe = timeframe.period, expression = close)) - (request.security(usdx, timeframe = timeframe.period, expression = close)) - (request.security(xsgd, timeframe = timeframe.period, expression = close)) - (request.security(vbusd, timeframe = timeframe.period, expression = close)) - (request.security(vai, timeframe = timeframe.period, expression = close)) - (request.security(euroc, timeframe = timeframe.period, expression = close)) - (request.security(cusd, timeframe = timeframe.period, expression = close)) - (request.security(ousd, timeframe = timeframe.period, expression = close)) - (request.security(fei, timeframe = timeframe.period, expression = close)) - (request.security(vusdt, timeframe = timeframe.period, expression = close)) - (request.security(sbd, timeframe = timeframe.period, expression = close)) - (request.security(rsv, timeframe = timeframe.period, expression = close)) - (request.security(krt, timeframe = timeframe.period, expression = close)) - (request.security(gyen, timeframe = timeframe.period, expression = close)) - (request.security(ceur, timeframe = timeframe.period, expression = close)) - (request.security(bidr, timeframe = timeframe.period, expression = close)) - (request.security(idrt, timeframe = timeframe.period, expression = close)) - (request.security(vdai, timeframe = timeframe.period, expression = close)) - (request.security(busd, timeframe = timeframe.period, expression = close))) //draw dominance line plot(domination, color = maincolor, trackprice = true) //draw comparable line plot(request.security(compare_symbol, timeframe = timeframe.period, expression = close), color = comparecolor, trackprice = true)
Seasonal Performance for Stocks & Crypto
https://www.tradingview.com/script/FC74fu5f-Seasonal-Performance-for-Stocks-Crypto/
Amphibiantrading
https://www.tradingview.com/u/Amphibiantrading/
132
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/ // © Amphibiantrading //@version=5 indicator("Seasonal Performance") JAN = month == 1, FEB = month == 2, MAR = month == 3, APR = month == 4, MAY = month == 5, JUN = month == 6 JUL = month == 7, AUG = month == 8, SEP = month == 9, OCT = month == 10, NOV = month == 11, DEC = month == 12 Q1 = JAN or FEB or MAR, Q2 = APR or MAY or JUN, Q3 = JUL or AUG or SEP, Q4 = OCT or NOV or DEC if timeframe.isintraday or timeframe.isweekly runtime.error('Please use a daily or monthly timeframe chart') if syminfo.type == 'futures' or syminfo.type == 'forex' or syminfo.type == 'cfd' runtime.error('Select a stock, crypto, index, or etf. Not a futures/forex market') //inputs yPos = input.string('Bottom', 'Table Position', options = ['Top', 'Middle', 'Bottom'], inline = '1') xPos = input.string('Center', ' ' , options = ['Right', 'Center', 'Left'], inline = '1') headerBg = input.color(color.rgb(188, 188, 188), 'Header Background', inline = '2') textColor = input.color(color.rgb(0,0,0), 'Text Color', inline = '2') posColor = input.color(color.lime, 'Positive Return', inline = '3') negColor = input.color(color.red, 'Negative Return', inline = '3') showMonthly = input.bool(true, 'Show Monthly Performance') showQuarterly = input.bool(true, 'Show Quarterly Performance') showCurrent = input.bool(true, 'Show Current Period Performance') showCounts = input.bool(true, 'Show Bull/Bear Counts') var table pTable = table.new(str.lower(yPos) + '_' + str.lower(xPos), 18, 6, color.new(color.white,100), color.new(color.white,100), 2, color.new(color.white,100), 2) var lastJan = 0.0, var lastFeb = 0.0, var lastMar = 0.0, var lastApr = 0.0, var lastMay = 0.0, var lastJun = 0.0 var lastJul = 0.0, var lastAug = 0.0, var lastSep = 0.0, var lastOct = 0.0, var lastNov = 0.0, var lastDec = 0.0 var lastQ1 = 0.0, var lastQ2 = 0.0, var lastQ3 = 0.0, var lastQ4 = 0.0 var janBull = 0, var janBear = 0, var febBull = 0, var febBear = 0, var marBull = 0, var marBear = 0, var aprBull = 0, var aprBear = 0 var mayBull = 0, var mayBear = 0, var junBull = 0, var junBear = 0, var julBull = 0, var julBear = 0, var augBull = 0, var augBear = 0 var sepBull = 0, var sepBear = 0, var octBull = 0, var octBear = 0, var novBull = 0, var novBear = 0, var decBull = 0, var decBear = 0 var q1Bull = 0, var q1Bear = 0, var q2Bull = 0, var q2Bear = 0, var q3Bull = 0, var q3Bear = 0, var q4Bull = 0, var q4Bear = 0, newMonth = ta.change(time('M')) newQuarter = ta.change(time('3M')) isJan = newMonth and JAN isFeb = newMonth and FEB isMar = newMonth and MAR isApr = newMonth and APR isMay = newMonth and MAY isJun = newMonth and JUN isJul = newMonth and JUL isAug = newMonth and AUG isSep = newMonth and SEP isOct = newMonth and OCT isNov = newMonth and NOV isDec = newMonth and DEC calcReturn(o,c)=> ret = 100 * (c - o ) / o ret // arrays string[] monthArray = array.from('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec') string [] qtrArray = array.from('Q1', 'Q2', 'Q3', 'Q4') var float[] JanArray = array.new<float>() var float[] FebArray = array.new<float>() var float[] MarArray = array.new<float>() var float[] AprArray = array.new<float>() var float[] MayArray = array.new<float>() var float[] JunArray = array.new<float>() var float[] JulArray = array.new<float>() var float[] AugArray = array.new<float>() var float[] SepArray = array.new<float>() var float[] OctArray = array.new<float>() var float[] NovArray = array.new<float>() var float[] DecArray = array.new<float>() var float[] Q1Array = array.new<float>() var float[] Q2Array = array.new<float>() var float[] Q3Array = array.new<float>() var float[] Q4Array = array.new<float>() monthOC = request.security(syminfo.tickerid, 'M', close[1], lookahead = barmerge.lookahead_on) quarterOC = request.security(syminfo.tickerid, '3M', close[1], lookahead = barmerge.lookahead_on) yearOC = request.security(syminfo.tickerid, '12M', close[1], lookahead = barmerge.lookahead_on) currentMTD = calcReturn(monthOC, close) currentQTD = calcReturn(quarterOC, close) ytd = calcReturn(yearOC, close) // monthly returns if isJan performance = calcReturn(monthOC[1], monthOC) DecArray.unshift(performance) lastDec := performance if performance > 0 decBull += 1 else decBear += 1 if isFeb performance = calcReturn(monthOC[1], monthOC) JanArray.unshift(performance) lastJan := performance if performance > 0 janBull += 1 else janBear += 1 if isMar performance = calcReturn(monthOC[1], monthOC) FebArray.unshift(performance) lastFeb := performance if performance > 0 febBull += 1 else febBear += 1 if isApr performance = calcReturn(monthOC[1], monthOC) MarArray.unshift(performance) lastMar := performance if performance > 0 marBull += 1 else marBear += 1 if isMay performance = calcReturn(monthOC[1], monthOC) AprArray.unshift(performance) lastApr := performance if performance > 0 aprBull += 1 else aprBear += 1 if isJun performance = calcReturn(monthOC[1], monthOC) MayArray.unshift(performance) lastMay := performance if performance > 0 mayBull += 1 else mayBear += 1 if isJul performance = calcReturn(monthOC[1], monthOC) JunArray.unshift(performance) lastJun:= performance if performance > 0 junBull += 1 else junBear += 1 if isAug performance = calcReturn(monthOC[1], monthOC) JulArray.unshift(performance) lastJul := performance if performance > 0 julBull += 1 else julBear += 1 if isSep performance = calcReturn(monthOC[1], monthOC) AugArray.unshift(performance) lastAug := performance if performance > 0 augBull += 1 else augBear += 1 if isOct performance = calcReturn(monthOC[1], monthOC) SepArray.unshift(performance) lastSep := performance if performance > 0 sepBull += 1 else sepBear += 1 if isNov performance = calcReturn(monthOC[1], monthOC) OctArray.unshift(performance) lastOct := performance if performance > 0 octBull += 1 else octBear += 1 if isDec performance = calcReturn(monthOC[1], monthOC) NovArray.unshift(performance) lastNov := performance if performance > 0 novBull += 1 else novBear += 1 //quarterly returns if newQuarter and JAN performance = calcReturn(quarterOC[1], quarterOC) Q4Array.unshift(performance) lastQ4 := performance if performance > 0 q4Bull += 1 else q4Bear += 1 if newQuarter and APR performance = calcReturn(quarterOC[1], quarterOC) Q1Array.unshift(performance) lastQ1 := performance if performance > 0 q1Bull += 1 else q1Bear += 1 if newQuarter and JUL performance = calcReturn(quarterOC[1], quarterOC) Q2Array.unshift(performance) lastQ2 := performance if performance > 0 q2Bull += 1 else q2Bear += 1 if newQuarter and OCT performance = calcReturn(quarterOC[1], quarterOC) Q3Array.unshift(performance) lastQ3 := performance if performance > 0 q3Bull += 1 else q3Bear += 1 // plot the table if barstate.islast // table headers pTable.cell(0,0, showMonthly ? 'Month:' : showQuarterly ? 'Quarter: ' : na, bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) pTable.cell(0,1, 'Avg:', bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) pTable.cell(0,2, 'Best:', bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) pTable.cell(0,3, 'Worst:', bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) if showMonthly or showQuarterly pTable.cell(0,4, 'Last:', bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) if (showMonthly or showQuarterly) and showCounts pTable.cell(0,5, 'Bull/Bear:', bgcolor = headerBg, text_halign = text.align_left, text_color = textColor) if showMonthly for i = 0 to 11 pTable.cell(i+1,0, monthArray.get(i), bgcolor = headerBg, text_color = textColor) if showQuarterly for i = 0 to 3 pTable.cell(i+13,0, qtrArray.get(i), bgcolor = headerBg, text_color = textColor) if showCurrent pTable.cell(17,0, 'Current', bgcolor = headerBg, text_color = textColor, text_valign = text.align_center) //data if showMonthly pTable.cell(1,1, str.tostring(JanArray.avg(), format.percent), bgcolor = JanArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(1,2, str.tostring(JanArray.max(), format.percent), bgcolor = JanArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(1,3, str.tostring(JanArray.min(), format.percent), bgcolor = JanArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(1,4, str.tostring(lastJan, format.percent), bgcolor = lastJan > 0 ? posColor : negColor, text_color = textColor) pTable.cell(2,1, str.tostring(FebArray.avg(), format.percent), bgcolor = FebArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(2,2, str.tostring(FebArray.max(), format.percent), bgcolor = FebArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(2,3, str.tostring(FebArray.min(), format.percent), bgcolor = FebArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(2,4, str.tostring(lastFeb, format.percent), bgcolor = lastFeb > 0 ? posColor : negColor, text_color = textColor) pTable.cell(3,1, str.tostring(MarArray.avg(), format.percent), bgcolor = MarArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(3,2, str.tostring(MarArray.max(), format.percent), bgcolor = MarArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(3,3, str.tostring(MarArray.min(), format.percent), bgcolor = MarArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(3,4, str.tostring(lastMar, format.percent), bgcolor = lastMar > 0 ? posColor : negColor, text_color = textColor) pTable.cell(4,1, str.tostring(AprArray.avg(), format.percent), bgcolor = AprArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(4,2, str.tostring(AprArray.max(), format.percent), bgcolor = AprArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(4,3, str.tostring(AprArray.min(), format.percent), bgcolor = AprArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(4,4, str.tostring(lastApr, format.percent), bgcolor = lastApr > 0 ? posColor : negColor, text_color = textColor) pTable.cell(5,1, str.tostring(MayArray.avg(), format.percent), bgcolor = MayArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(5,2, str.tostring(MayArray.max(), format.percent), bgcolor = MayArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(5,3, str.tostring(MayArray.min(), format.percent), bgcolor = MayArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(5,4, str.tostring(lastMay, format.percent), bgcolor = lastMay > 0 ? posColor : negColor, text_color = textColor) pTable.cell(6,1, str.tostring(JunArray.avg(), format.percent), bgcolor = JunArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(6,2, str.tostring(JunArray.max(), format.percent), bgcolor = JunArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(6,3, str.tostring(JunArray.min(), format.percent), bgcolor = JunArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(6,4, str.tostring(lastJun, format.percent), bgcolor = lastJun > 0 ? posColor : negColor, text_color = textColor) pTable.cell(7,1, str.tostring(JulArray.avg(), format.percent), bgcolor = JulArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(7,2, str.tostring(JulArray.max(), format.percent), bgcolor = JulArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(7,3, str.tostring(JulArray.min(), format.percent), bgcolor = JulArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(7,4, str.tostring(lastJul, format.percent), bgcolor = lastJul > 0 ? posColor : negColor, text_color = textColor) pTable.cell(8,1, str.tostring(AugArray.avg(), format.percent), bgcolor = AugArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(8,2, str.tostring(AugArray.max(), format.percent), bgcolor = AugArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(8,3, str.tostring(AugArray.min(), format.percent), bgcolor = AugArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(8,4, str.tostring(lastAug, format.percent), bgcolor = lastAug > 0 ? posColor : negColor, text_color = textColor) pTable.cell(9,1, str.tostring(SepArray.avg(), format.percent), bgcolor = SepArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(9,2, str.tostring(SepArray.max(), format.percent), bgcolor = SepArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(9,3, str.tostring(SepArray.min(), format.percent), bgcolor = SepArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(9,4, str.tostring(lastSep, format.percent), bgcolor = lastSep > 0 ? posColor : negColor, text_color = textColor) pTable.cell(10,1, str.tostring(OctArray.avg(), format.percent), bgcolor = OctArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(10,2, str.tostring(OctArray.max(), format.percent), bgcolor = OctArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(10,3, str.tostring(OctArray.min(), format.percent), bgcolor = OctArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(10,4, str.tostring(lastOct, format.percent), bgcolor = lastOct > 0 ? posColor : negColor, text_color = textColor) pTable.cell(11,1, str.tostring(NovArray.avg(), format.percent), bgcolor = NovArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(11,2, str.tostring(NovArray.max(), format.percent), bgcolor = NovArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(11,3, str.tostring(NovArray.min(), format.percent), bgcolor = NovArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(11,4, str.tostring(lastNov, format.percent), bgcolor = lastNov > 0 ? posColor : negColor, text_color = textColor) pTable.cell(12,1, str.tostring(DecArray.avg(), format.percent), bgcolor = DecArray.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(12,2, str.tostring(DecArray.max(), format.percent), bgcolor = DecArray.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(12,3, str.tostring(DecArray.min(), format.percent), bgcolor = DecArray.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(12,4, str.tostring(lastDec, format.percent), bgcolor = lastDec > 0 ? posColor : negColor, text_color = textColor) if showCounts pTable.cell(1,5, str.tostring(janBull) + '/' + str.tostring(janBear), bgcolor = janBull > janBear ? posColor : negColor, text_color = textColor) pTable.cell(2,5, str.tostring(febBull) + '/' + str.tostring(febBear), bgcolor = febBull > febBear ? posColor : negColor, text_color = textColor) pTable.cell(3,5, str.tostring(marBull) + '/' + str.tostring(marBear), bgcolor = marBull > marBear ? posColor : negColor, text_color = textColor) pTable.cell(4,5, str.tostring(aprBull) + '/' + str.tostring(aprBear), bgcolor = aprBull > aprBear ? posColor : negColor, text_color = textColor) pTable.cell(5,5, str.tostring(mayBull) + '/' + str.tostring(mayBear), bgcolor = mayBull > mayBear ? posColor : negColor, text_color = textColor) pTable.cell(6,5, str.tostring(junBull) + '/' + str.tostring(junBear), bgcolor = junBull > junBear ? posColor : negColor, text_color = textColor) pTable.cell(7,5, str.tostring(julBull) + '/' + str.tostring(julBear), bgcolor = julBull > julBear ? posColor : negColor, text_color = textColor) pTable.cell(8,5, str.tostring(augBull) + '/' + str.tostring(augBear), bgcolor = augBull > augBear ? posColor : negColor, text_color = textColor) pTable.cell(9,5, str.tostring(sepBull) + '/' + str.tostring(sepBear), bgcolor = sepBull > sepBear ? posColor : negColor, text_color = textColor) pTable.cell(10,5, str.tostring(octBull) + '/' + str.tostring(octBear), bgcolor = octBull > octBear ? posColor : negColor, text_color = textColor) pTable.cell(11,5, str.tostring(novBull) + '/' + str.tostring(novBear), bgcolor = novBull > novBear ? posColor : negColor, text_color = textColor) pTable.cell(12,5, str.tostring(decBull) + '/' + str.tostring(decBear), bgcolor = decBull > decBear ? posColor : negColor, text_color = textColor) // quaretrly if showQuarterly pTable.cell(13,1, str.tostring(Q1Array.avg(), format.percent), bgcolor = Q1Array.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(13,2, str.tostring(Q1Array.max(), format.percent), bgcolor = Q1Array.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(13,3, str.tostring(Q1Array.min(), format.percent), bgcolor = Q1Array.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(13,4, str.tostring(lastQ1, format.percent), bgcolor = lastQ1 > 0 ? posColor : negColor, text_color = textColor) pTable.cell(14,1, str.tostring(Q2Array.avg(), format.percent), bgcolor = Q2Array.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(14,2, str.tostring(Q2Array.max(), format.percent), bgcolor = Q2Array.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(14,3, str.tostring(Q2Array.min(), format.percent), bgcolor = Q2Array.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(14,4, str.tostring(lastQ2, format.percent), bgcolor = lastQ2 > 0 ? posColor : negColor, text_color = textColor) pTable.cell(15,1, str.tostring(Q3Array.avg(), format.percent), bgcolor = Q3Array.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(15,2, str.tostring(Q3Array.max(), format.percent), bgcolor = Q3Array.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(15,3, str.tostring(Q3Array.min(), format.percent), bgcolor = Q3Array.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(15,4, str.tostring(lastQ3, format.percent), bgcolor = lastQ3 > 0 ? posColor : negColor, text_color = textColor) pTable.cell(16,1, str.tostring(Q4Array.avg(), format.percent), bgcolor = Q4Array.avg() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(16,2, str.tostring(Q4Array.max(), format.percent), bgcolor = Q4Array.max() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(16,3, str.tostring(Q4Array.min(), format.percent), bgcolor = Q4Array.min() > 0 ? posColor : negColor, text_color = textColor) pTable.cell(16,4, str.tostring(lastQ4, format.percent), bgcolor = lastQ4 > 0 ? posColor : negColor, text_color = textColor) if showCounts pTable.cell(13,5, str.tostring(q1Bull) + '/' + str.tostring(q1Bear), bgcolor = q1Bull > q1Bear ? posColor : negColor, text_color = textColor) pTable.cell(14,5, str.tostring(q2Bull) + '/' + str.tostring(q2Bear), bgcolor = q2Bull > q2Bear ? posColor : negColor, text_color = textColor) pTable.cell(15,5, str.tostring(q3Bull) + '/' + str.tostring(q3Bear), bgcolor = q3Bull > q3Bear ? posColor : negColor, text_color = textColor) pTable.cell(16,5, str.tostring(q4Bull) + '/' + str.tostring(q4Bear), bgcolor = q4Bull > q4Bear ? posColor : negColor, text_color = textColor) if showCurrent pTable.cell(17, 1, 'MTD: ' + str.tostring(currentMTD, format.percent), bgcolor = currentMTD > 0 ? posColor : negColor, text_color = textColor) pTable.cell(17, 2, 'QTD: ' + str.tostring(currentQTD, format.percent), bgcolor = currentQTD > 0 ? posColor : negColor, text_color = textColor) pTable.cell(17, 3, 'YTD: ' + str.tostring(ytd, format.percent), bgcolor = ytd > 0 ? posColor : negColor, text_color = textColor)
Daily data info
https://www.tradingview.com/script/UHwYYf7W/
GiovanniRielli
https://www.tradingview.com/u/GiovanniRielli/
16
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/ // © GiovanniRielli //@version=5 indicator('Daily data info' , overlay = true , precision = 0 , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500 , max_bars_back = 5000) Timezone = 'America/New_York' DOMD_D = (timeframe.isdaily) Day_look_backs = input.int(defval = 500 , title = 'Day Look backs' , inline = 'back' , group = 'Data') Dati_sum = input.bool(defval = false , title = '+ or' , inline = 'back' , group = 'Data') Dati_per = input.bool(defval = false , title = '%' , inline = 'back' , group = 'Data') labl_data = input.bool(defval = false , title = 'Label' , inline = 'Data' , group = 'Data') Monday = input.bool(defval = false , title = 'Monday' , inline = 'Data' , group = 'Data') Tuesday = input.bool(defval = false , title = 'Tuesday' , inline = 'Data' , group = 'Data') Wednesday = input.bool(defval = false , title = 'Wednesday' , inline = 'Data' , group = 'Data') Thursday = input.bool(defval = false , title = 'Thursday' , inline = 'Data' , group = 'Data') Friday = input.bool(defval = false , title = 'Friday' , inline = 'Data' , group = 'Data') highW = request.security(syminfo.tickerid, 'W', high , barmerge.gaps_off , barmerge.lookahead_on) lowW = request.security(syminfo.tickerid, 'W', low , barmerge.gaps_off , barmerge.lookahead_on) highD = request.security(syminfo.tickerid, 'D', high , barmerge.gaps_off , barmerge.lookahead_on) lowD = request.security(syminfo.tickerid, 'D', low , barmerge.gaps_off , barmerge.lookahead_on) //---High //---Low Highmonday = dayofweek(time_close) == dayofweek.monday ? highD : na , Lowmonday = dayofweek(time_close) == dayofweek.monday ? lowD : na Hightuesday = dayofweek(time_close) == dayofweek.tuesday ? highD : na , Lowtuesday = dayofweek(time_close) == dayofweek.tuesday ? lowD : na Highwednesday = dayofweek(time_close) == dayofweek.wednesday ? highD : na , Lowwednesday = dayofweek(time_close) == dayofweek.wednesday ? lowD : na Highthursday = dayofweek(time_close) == dayofweek.thursday ? highD : na , Lowthursday = dayofweek(time_close) == dayofweek.thursday ? lowD : na Highfriday = dayofweek(time_close) == dayofweek.friday ? highD : na , Lowfriday = dayofweek(time_close) == dayofweek.friday ? lowD : na //---High Week //---Low Week higMon = Highmonday == math.max(high , highW) , lowMon = Lowmonday == math.min(low , lowW) higTue = Hightuesday == math.max(high , highW) , lowTue = Lowtuesday == math.min(low , lowW) higWed = Highwednesday == math.max(high , highW) , lowWed = Lowwednesday == math.min(low , lowW) higThu = Highthursday == math.max(high , highW) , lowThu = Lowthursday == math.min(low , lowW) higFri = Highfriday == math.max(high , highW) , lowFri = Lowfriday == math.min(low , lowW) //Label info if DOMD_D and labl_data if Monday if higMon label.new(x = bar_index , y = highD , text = 'Mon.' , xloc = xloc.bar_index , yloc = yloc.abovebar , color = color.rgb(33, 149, 243, 50) , style = label.style_label_down , textcolor = color.white , size = size.small) if lowMon label.new(x = bar_index , y = lowD , text = 'Mon.' , xloc = xloc.bar_index , yloc = yloc.belowbar , color = color.rgb(33, 149, 243, 50) , style = label.style_label_up , textcolor = color.white , size = size.small) if Tuesday if higTue label.new(x = bar_index , y = highD , text = 'Tue.' , xloc = xloc.bar_index , yloc = yloc.abovebar , color = color.rgb(189, 236, 18, 50) , style = label.style_label_down , textcolor = color.white , size = size.small) if lowTue label.new(x = bar_index , y = lowD , text = 'Tue.' , xloc = xloc.bar_index , yloc = yloc.belowbar , color = color.rgb(189, 236, 18, 50) , style = label.style_label_up , textcolor = color.white , size = size.small) if Wednesday if higWed label.new(x = bar_index , y = highD , text = 'Wed.' , xloc = xloc.bar_index , yloc = yloc.abovebar , color = color.rgb(122, 15, 113, 50) , style = label.style_label_down , textcolor = color.white , size = size.small) if lowWed label.new(x = bar_index , y = lowD , text = 'Wed.' , xloc = xloc.bar_index , yloc = yloc.belowbar , color = color.rgb(122, 15, 113, 50) , style = label.style_label_up , textcolor = color.white , size = size.small) if Thursday if higThu label.new(x = bar_index , y = highD , text = 'Thu.' , xloc = xloc.bar_index , yloc = yloc.abovebar , color = color.rgb(9, 67, 226, 50) , style = label.style_label_down , textcolor = color.white , size = size.small) if lowThu label.new(x = bar_index , y = lowD , text = 'Thu.' , xloc = xloc.bar_index , yloc = yloc.belowbar , color = color.rgb(9, 67, 226, 50) , style = label.style_label_up , textcolor = color.white , size = size.small) if Friday if higFri label.new(x = bar_index , y = highD , text = 'Fri.' , xloc = xloc.bar_index , yloc = yloc.abovebar , color = color.rgb(54, 69, 56, 50) , style = label.style_label_down , textcolor = color.white , size = size.small) if lowFri label.new(x = bar_index , y = lowD , text = 'Fri.' , xloc = xloc.bar_index , yloc = yloc.belowbar , color = color.rgb(54, 69, 56, 50) , style = label.style_label_up , textcolor = color.white , size = size.small) //----Tabel show_TAB = input.bool(defval = false , title = '' , inline = 'Tabel' , group = 'Tabel') cho_Pos_TAB = input.string(title = '', defval = '←↓', options = ['↑', '←↑', '↑→', '↓', '←↓', '↓→'] , inline = 'Tabel' , group = 'Tabel') posi_TAB = cho_Pos_TAB == '↑→' ? position.top_right : cho_Pos_TAB == '←↑' ? position.top_left : cho_Pos_TAB == '↑→' ? position.top_right : cho_Pos_TAB == '↓' ? position.bottom_center : cho_Pos_TAB == '←↓' ? position.bottom_left : cho_Pos_TAB == '↓→' ? position.bottom_right : na widt_TAB = input(defval = 2 , title = '←→' , inline = 'Tabel' , group = 'Tabel') heigt_TAB = input(defval = 1 , title = '↑' , inline = 'Tabel' , group = 'Tabel') //---Text input_text_H = Dati_sum ? 'High + ' : Dati_per ? 'High % ' : na input_text_L = Dati_sum ? 'Low + ' : Dati_per ? 'Low % ' : na // Count Total High // Low count_H_Mon = math.sum(higMon ? 1 : 0 , Day_look_backs) , count_L_Mon = math.sum(lowMon ? 1 : 0 , Day_look_backs) count_H_Tue = math.sum(higTue ? 1 : 0 , Day_look_backs) , count_L_Tue = math.sum(lowTue ? 1 : 0 , Day_look_backs) count_H_Wed = math.sum(higWed ? 1 : 0 , Day_look_backs) , count_L_Wed = math.sum(lowWed ? 1 : 0 , Day_look_backs) count_H_Thu = math.sum(higThu ? 1 : 0 , Day_look_backs) , count_L_Thu = math.sum(lowThu ? 1 : 0 , Day_look_backs) count_H_Fri = math.sum(higFri ? 1 : 0 , Day_look_backs) , count_L_Fri = math.sum(lowFri ? 1 : 0 , Day_look_backs) // % Total per_H_Mon = count_H_Mon / Day_look_backs * 100 , per_L_Mon = count_L_Mon / Day_look_backs * 100 per_H_Tue = count_H_Tue / Day_look_backs * 100 , per_L_Tue = count_L_Tue / Day_look_backs * 100 per_H_Wed = count_H_Wed / Day_look_backs * 100 , per_L_Wed = count_L_Wed / Day_look_backs * 100 per_H_Thu = count_H_Thu / Day_look_backs * 100 , per_L_Thu = count_L_Thu / Day_look_backs * 100 per_H_Fri = count_H_Fri / Day_look_backs * 100 , per_L_Fri = count_L_Fri / Day_look_backs * 100 var table tableData = table.new(position = posi_TAB , columns = 6 , rows = 15 , frame_color = color.new(color.black, 0) , frame_width = 1, border_color = color.new(color.black, 0) , border_width = 1) if show_TAB table.cell(tableData , 0 , 0 , str.tostring(Day_look_backs) , bgcolor = color.new(color.blue, 80) , tooltip = 'ToT count Bars') table.cell(tableData , 1 , 0 , input_text_H , bgcolor = color.new(color.blue, 80)) table.cell(tableData , 2 , 0 , input_text_L , bgcolor = color.new(color.blue, 80)) if Monday table.cell(tableData , 0 , 1 , 'Mon.', bgcolor=color.new(color.yellow, 80)) if Dati_sum and not Dati_per table.cell(tableData , 1 , 1 , str.tostring(count_H_Mon) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 1 , str.tostring(count_L_Mon) , bgcolor = color.new(color.yellow, 80)) if Dati_per and not Dati_sum table.cell(tableData , 1 , 1 , str.tostring(per_H_Mon , format.percent) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 1 , str.tostring(per_L_Mon , format.percent) , bgcolor = color.new(color.yellow, 80)) if Tuesday table.cell(tableData , 0 , 2 , 'Tue.', bgcolor=color.new(color.yellow, 80)) if Dati_sum and not Dati_per table.cell(tableData , 1 , 2 , str.tostring(count_H_Tue), bgcolor=color.new(color.yellow, 80)) table.cell(tableData , 2 , 2 , str.tostring(count_L_Tue), bgcolor=color.new(color.yellow, 80)) if Dati_per and not Dati_sum table.cell(tableData , 1 , 2 , str.tostring(per_H_Tue , format.percent) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 2 , str.tostring(per_L_Tue , format.percent) , bgcolor = color.new(color.yellow, 80)) if Wednesday table.cell(tableData , 0 , 3 , 'Wed.', bgcolor=color.new(color.yellow, 80)) if Dati_sum and not Dati_per table.cell(tableData , 1 , 3 , str.tostring(count_H_Wed), bgcolor=color.new(color.yellow, 80)) table.cell(tableData , 2 , 3 , str.tostring(count_L_Wed), bgcolor=color.new(color.yellow, 80)) if Dati_per and not Dati_sum table.cell(tableData , 1 , 3 , str.tostring(per_H_Wed , format.percent) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 3 , str.tostring(per_L_Wed , format.percent) , bgcolor = color.new(color.yellow, 80)) if Thursday table.cell(tableData , 0 , 4 , 'Thu.', bgcolor=color.new(color.yellow, 80)) if Dati_sum and not Dati_per table.cell(tableData , 1 , 4 , str.tostring(count_H_Thu), bgcolor=color.new(color.yellow, 80)) table.cell(tableData , 2 , 4 , str.tostring(count_L_Thu), bgcolor=color.new(color.yellow, 80)) if Dati_per and not Dati_sum table.cell(tableData , 1 , 4 , str.tostring(per_H_Thu , format.percent) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 4 , str.tostring(per_L_Thu , format.percent) , bgcolor = color.new(color.yellow, 80)) if Friday table.cell(tableData , 0 , 5 , 'Fri.', bgcolor=color.new(color.yellow, 80)) if Dati_sum and not Dati_per table.cell(tableData , 1 , 5 , str.tostring(count_H_Fri), bgcolor=color.new(color.yellow, 80)) table.cell(tableData , 2 , 5 , str.tostring(count_L_Fri), bgcolor=color.new(color.yellow, 80)) if Dati_per and not Dati_sum table.cell(tableData , 1 , 5 , str.tostring(per_H_Fri , format.percent) , bgcolor = color.new(color.yellow, 80)) table.cell(tableData , 2 , 5 , str.tostring(per_L_Fri , format.percent) , bgcolor = color.new(color.yellow, 80))
Position Size Calculator (EzAlgo)
https://www.tradingview.com/script/AacIDtSH-Position-Size-Calculator-EzAlgo/
EzAlgo
https://www.tradingview.com/u/EzAlgo/
943
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/ // @ EzAlgo //@version=5 indicator("Position Size Calculator (EzAlgo)", overlay=true) table_location_input = input.string("Top Right", title="Location", options=["Bottom Right", "Bottom Left", "Bottom Center", "Top Left", "Top Center", "Top Right", "Middle left", "Middle Center", "Middle Right" ], group='Table Settings') size = input.string(size.small, title='Text Size', options=[size.normal, size.small, size.tiny]) grp1 = 'Price Points' entry_price = input.price(27000, title='Entry Price', group=grp1, inline='line1') sl_price = input.price(26000, title='Stop Loss', group=grp1, inline='line2') showtp1 = input(true, title='', inline='line3', group=grp1) showtp2 = input(true, title='', inline='line4', group=grp1) showtp3 = input(true, title='', inline='line5', group=grp1) showtp4 = input(true, title='', inline='line6', group=grp1) tp1_price = input.price(27400, title='Take Profit 1', group=grp1, inline='line3') tp2_price = input.price(28000, title='Take Profit 2', group=grp1, inline='line4') tp3_price = input.price(28800, title='Take Profit 3', group=grp1, inline='line5') tp4_price = input.price(29800, title='Take Profit 4', group=grp1, inline='line6') dca_sw = input.bool(true, title='', group=grp1, inline='line1') auto_leverage_info="Auto Leverage automatically determines the optimal leverage level for a trade based on the user's Stop Loss price distance from the Entry point and the user-defined risk percentage per Entry. It also considers a user-defined Liquidation Buffer, which is a preset percentage determining how close to the Stop Loss a position can get before it's liquidated. This tool allows traders to optimize their leverage amount according to their risk tolerance." dca_price_info='This is the value at which you initiate your second, equally-sized and leveraged position when employing Dollar-Cost Averaging (DCA) strategy. Upon reaching the DCA Price, your Entry Price adjusts to the Avg Price (Gray Line), calculated as the midpoint between your initial and DCA entries.' liq_buff_infp='This is a pre-set percentage that determines how close to your Stop Loss your position can get before its liquidated. By manually setting this buffer, you control your comfort level of risk, and it assists the Auto Leverage feature in optimizing the leverage amount according to your risk tolerance.' risk_info="This refers to the proportion of your account, expressed as a % or a fixed dollar amount, that you're willing to risk for each trading position. If DCA is checked, this will assume you are entering with half of the total position size per entry." max_lev_info="This is the highest leverage level you are willing to use, even if the exchange permits higher. This limit applies when the Auto Leverage feature is enabled, ensuring your leverage does not exceed your comfort zone." mmr_info="Maintenance Margin Rate" dca_price = input.price(26500, title='DCA Price', group=grp1, inline='line1',tooltip = dca_price_info) liq_buff = input.float(1.0, title='Liquidation Buffer%', group=grp1, inline='line2',tooltip = liq_buff_infp) tp1_perc = input.float(40, title='Position %', maxval=100, minval=0, group=grp1, inline='line3') tp2_perc = input.float(30, title='Position %', maxval=100, minval=0, group=grp1, inline='line4') tp3_perc = input.float(20, title='Position %', maxval=100, minval=0, group=grp1, inline='line5') tp4_perc = input.float(10, title='Position %', maxval=100, minval=0, group=grp1, inline='line6') extend = input(true, title='Extend Lines') final_tp = (showtp1?tp1_perc:0) + (showtp2?tp2_perc:0) + (showtp3?tp3_perc:0) + (showtp4?tp4_perc:0) grp2 = 'Risk Management' acc_size = input.float(1000, title='Account Size', group=grp2) risk = input.float(5.00, title='Risk per Entry', step=0.01, group=grp2, inline='risk',tooltip = risk_info) risk_sw = input.string('%', title='', inline='risk', options=['$', '%'], group=grp2) lev = input.float(25, title='Manual Leverage', inline='lev', group=grp2) lev_sw = input.bool(true, title='Use Auto Leverage', inline='lev', group=grp2, tooltip = auto_leverage_info) max_lev = input.float(50, title='Max Leverage', inline='lev2', group=grp2,tooltip = max_lev_info) // mmr = input.float(0.5, title='MMR%', inline='lev2', group=grp2,tooltip = mmr_info) lvg_txt = lev_sw? ' (A)' : ' (M)' draw_level(x, txt, col) => var L = line.new(bar_index, x, bar_index+1, x, extend=extend.both, color=col) var LBL = label.new(bar_index, x, color=color.white, textcolor=col, textalign=text.align_left, style=label.style_none, text=txt + ' (' + str.tostring(x, format.mintick) + ')') label.set_x(LBL, bar_index+70) if extend==false line.set_x1(L, bar_index) line.set_x2(L, bar_index+1) line.set_extend(L, extend.right) draw_level2(x, txt, col) => var L = line.new(bar_index, x, bar_index+1, x, extend=extend.both, color=col, style=line.style_dashed) var LBL = label.new(bar_index, x, color=color.white, textcolor=col, textalign=text.align_left, style=label.style_none, text=txt + ' (' + str.tostring(x, format.mintick) + ')') label.set_x(LBL, bar_index+70) if extend==false line.set_x1(L, bar_index) line.set_x2(L, bar_index+1) line.set_extend(L, extend.right) draw_level(entry_price, 'Entry', #ffffff) draw_level(sl_price , 'Stop Loss', #e91e63) if showtp1 draw_level(tp1_price , str.tostring(tp1_perc) + '% @ TP1', #00e676) if showtp2 draw_level(tp2_price , str.tostring(tp2_perc) + '% @ TP2', #00e676) if showtp3 draw_level(tp3_price , str.tostring(tp3_perc) + '% @ TP3', #00e676) if showtp4 draw_level(tp4_price , str.tostring(tp4_perc) + '% @ TP4', #00e676) if dca_sw draw_level(dca_price, 'DCA Entry', #ffee58) draw_level2(math.avg(dca_price,entry_price), 'Avg Entry', #787b86) liq_price1 = lev_sw? sl_price * (1-liq_buff/100) : entry_price * (1-(100/lev)/100) draw_level(liq_price1 , 'Liquidation', #8f20ff) // RISK entry_price := dca_sw==false? entry_price : math.avg(entry_price, dca_price) SL_value = math.abs(entry_price-liq_price1) dollar_risk = risk_sw =='%'? acc_size * risk/100 : risk lev_val = lev_sw? dollar_risk / SL_value*entry_price/dollar_risk : lev lev_val := math.min(lev_val, max_lev) QTY = lev_sw? dollar_risk / SL_value : (dollar_risk * lev_val)/entry_price value = lev_sw? QTY*entry_price : dollar_risk * lev margin = risk_sw =='%'? risk/100 * acc_size : risk sl_loss = (sl_price/entry_price-1) * lev_val * margin tp1_val = showtp1? tp1_perc/100 * (tp1_price/entry_price - 1) * (QTY * entry_price) : 0 tp2_val = showtp2? tp2_perc/100 * (tp2_price/entry_price - 1) * (QTY * entry_price) : 0 tp3_val = showtp3? tp3_perc/100 * (tp3_price/entry_price - 1) * (QTY * entry_price) : 0 tp4_val = showtp4? tp4_perc/100 * (tp4_price/entry_price - 1) * (QTY * entry_price) : 0 tp_val = tp1_val + tp2_val + tp3_val + tp4_val tp_total1 = tp1_val + tp2_val tp_total2 = tp1_val + tp2_val + tp3_val tp_total3 = tp1_val + tp2_val + tp3_val + tp4_val // TABLE string table_location = switch table_location_input "Bottom Right" => position.bottom_right "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 => position.bottom_right table_color = color.new(#07071f, 5 )//input(color.new(#07071f, 5 ), title='Table Color', group='Table Settings') table_borderColor = color.new(#d1d1d1, 34)//input(color.new(#d1d1d1, 34), title="Table BorderColor", group='Table Settings') var table dashboard = table.new(table_location, rows=15, columns=15, bgcolor=table_color , frame_color=color.gray, frame_width=2, border_color=table_borderColor, border_width = 0) table.cell(dashboard, text_size=size, column=1, row=1, text_color=#ffffff, text_halign=text.align_left, text="Wallet: " + str.tostring(acc_size) + ' 💵') table.cell(dashboard, text_size=size, column=1, row=2, text_color=#ffffff, text_halign=text.align_left, text="Margin: " + str.tostring(margin) + ' 💵') table.cell(dashboard, text_size=size, column=1, row=3, text_color=#ffffff, text_halign=text.align_left, text="Value: " + str.tostring(value, format.mintick) + ' 💵') table.cell(dashboard, text_size=size, column=2, row=1, text_color=#ffffff, text_halign=text.align_left, text="Risk per Entry: " + str.tostring(risk) + risk_sw) table.cell(dashboard, text_size=size, column=2, row=2, text_color=#ffffff, text_halign=text.align_left, text="Leverage: " + str.tostring(lev_val, "#.##") + lvg_txt) table.cell(dashboard, text_size=size, column=2, row=3, text_color=#ffffff, text_halign=text.align_left, text="Qty: " + str.tostring(QTY, "#.#####")) table.cell(dashboard, text_size=size, column=1, row=5, text_color=#ffffff, text_halign=text.align_left, text='Entry: ') table.cell(dashboard, text_size=size, column=1, row=4, text_color=#ffffff, text_halign=text.align_center, text='──────────────') table.cell(dashboard, text_size=size, column=1, row=6, text_color=#e91e63, text_halign=text.align_left, text='Stop Loss: ') table.cell(dashboard, text_size=size, column=1, row=7, text_color=#8f20ff, text_halign=text.align_left, text='Liquidation: ') table.cell(dashboard, text_size=size, column=2, row=5, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(entry_price, format.mintick)) table.cell(dashboard, text_size=size, column=2, row=4, text_color=#ffffff, text_halign=text.align_center, text='──────────────') table.cell(dashboard, text_size=size, column=2, row=6, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(sl_price, format.mintick) + ' (' + str.tostring(sl_loss, format.mintick) + ' 💵' + ')') table.cell(dashboard, text_size=size, column=2, row=7, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(liq_price1, format.mintick) + ' (-' + str.tostring(margin, format.mintick) + ' 💵' + ')') table.cell(dashboard, text_size=size, column=1, row=8, text_color=#ffffff, text_halign=text.align_center, text='──────────────') table.cell(dashboard, text_size=size, column=2, row=8, text_color=#ffffff, text_halign=text.align_center, text='──────────────') table.cell(dashboard, text_size=size, column=1, row=9 , text_color=#ffffff, text_halign=text.align_left, text='TP Orders: ') if showtp1 table.cell(dashboard, text_size=size, column=1, row=10 , text_color=#ffffff, text_halign=text.align_left, text=str.tostring(tp1_perc) + '% @ ' + str.tostring(tp1_price, format.mintick)) if showtp2 table.cell(dashboard, text_size=size, column=1, row=11 , text_color=#ffffff, text_halign=text.align_left, text=str.tostring(tp2_perc) + '% @ ' + str.tostring(tp2_price, format.mintick)) if showtp3 table.cell(dashboard, text_size=size, column=1, row=12, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(tp3_perc) + '% @ ' + str.tostring(tp3_price, format.mintick)) if showtp4 table.cell(dashboard, text_size=size, column=1, row=13, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(tp4_perc) + '% @ ' + str.tostring(tp4_price, format.mintick)) table.cell(dashboard, text_size=size, column=1, row=14, text_color=#ffffff, text_halign=text.align_left, text=str.tostring(final_tp) + '%') table.cell(dashboard, text_size=size, column=2, row=9 , text_color=#ffffff, text_halign=text.align_left, text='Profit (Total)') if showtp1 table.cell(dashboard, text_size=size, column=2, row=10 , text_color=#ffffff, text_halign=text.align_left, text='+' + str.tostring(tp1_val, "#.##")) if showtp2 table.cell(dashboard, text_size=size, column=2, row=11 , text_color=#ffffff, text_halign=text.align_left, text='+' + str.tostring(tp2_val, "#.##") + '(' + str.tostring(tp_total1, "#.##") + ')') if showtp3 table.cell(dashboard, text_size=size, column=2, row=12, text_color=#ffffff, text_halign=text.align_left, text='+' + str.tostring(tp3_val, "#.##") + '(' + str.tostring(tp_total2, "#.##") + ')') if showtp4 table.cell(dashboard, text_size=size, column=2, row=13, text_color=#ffffff, text_halign=text.align_left, text='+' + str.tostring(tp4_val, "#.##") + '(' + str.tostring(tp_total3, "#.##") + ')') table.cell(dashboard, text_size=size, column=2, row=14, text_color=#ffffff, text_halign=text.align_left, text='Total: ' + str.tostring(tp_val, '#.##') + ' 💵')
Positive Volatility and Volume Gauge
https://www.tradingview.com/script/8LUlnPhV-Positive-Volatility-and-Volume-Gauge/
JohnCabernet
https://www.tradingview.com/u/JohnCabernet/
15
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/ // © JohnCabernet //@version=5 indicator("Positive Volatility and Volume Gauge with True Momentum Oscillator", overlay=false) // Input parameters atr_length = input(14, "ATR Length") signal_threshold = input(1.5, "Signal Threshold") mom_length = input(14, title="Momentum Length") mom_oversold = input(-1, title="Oversold Level") mom_overbought = input(1, title="Overbought Level") // Calculate real volatility realVolatility = ta.tr(true) // Filter out negative values of real volatility positiveVolatility = realVolatility >= 0 ? realVolatility : na // Calculate signal lines upperSignal = ta.sma(positiveVolatility, atr_length) * signal_threshold // Calculate volume gauge volumeGauge = volume / 25000 // Divide by a factor for better visualization // Calculate true momentum oscillator mom = ta.mom(close, mom_length) // Plot positive real volatility as a line plot(positiveVolatility, color=color.blue, title="Positive Volatility") // Plot upper signal line plot(upperSignal, color=color.orange, title="Upper Signal Line") // Plot volume gauge as a histogram at the bottom of the indicator plot(volumeGauge, style=plot.style_columns, color=color.yellow, title="Volume Gauge") // Plot true momentum oscillator plot(mom, color=color.green, title="True Momentum Oscillator") hline(mom_oversold, "Oversold", color=color.red) hline(mom_overbought, "Overbought", color=color.green)
Currency Converter
https://www.tradingview.com/script/UVicAQAD-Currency-Converter/
ronylts
https://www.tradingview.com/u/ronylts/
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/ // © ronylts //@version=5 indicator("Currency Converter",overlay = true) //input for main inm1=input.string("USD","Main Currency",group = "From") //input for other currency in1=input.string("GBP","Currency 1",group = "To") in2=input.string("AUD","Currency 2",group = "To") in3=input.string("EUR","Currency 3",group = "To") in4=input.string("CAD","Currency 4",group = "To") in5=input.string("JPY","Currency 5",group = "To") // Rate main calculation rate1 = request.currency_rate(inm1, in1) rate2 = request.currency_rate(inm1, in2) rate3 = request.currency_rate(inm1, in3) rate4 = request.currency_rate(inm1, in4) rate5 = request.currency_rate(inm1, in5) //table var table rateT = table.new(position.top_right, 2, 6, border_width = 1,bgcolor = color.new(color.yellow,10), border_color = color.gray ,frame_width = 2, frame_color = color.gray ) if barstate.islast table.cell(rateT, 0, 0, "Currency") table.cell(rateT, 1, 0, "Values") table.cell(rateT, 0, 1, inm1+" to "+in1) table.cell(rateT, 1, 1, str.tostring(rate1)) table.cell(rateT, 0, 2, inm1+" to "+in2) table.cell(rateT, 1, 2, str.tostring(rate2)) table.cell(rateT, 0, 3, inm1+" to "+in3) table.cell(rateT, 1, 3, str.tostring(rate3)) table.cell(rateT, 0, 4, inm1+" to "+in4) table.cell(rateT, 1, 4, str.tostring(rate4)) table.cell(rateT, 0, 5, inm1+" to "+in5) table.cell(rateT, 1, 5, str.tostring(rate5))
Accumulation & Distribution - Simple
https://www.tradingview.com/script/Ot1Gl2Hc-Accumulation-Distribution-Simple/
jadeja_rajdeep
https://www.tradingview.com/u/jadeja_rajdeep/
44
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/ // © jadeja_rajdeep //@version=5 indicator("Acc & Dist - Simple") no_of_days = input.int(42, "No of Days / Length", minval=5, maxval=252, step=1) up = 0.0 down =0.0 vsum =0.0 for x=0 to (no_of_days - 1) avg=(high[x]+low[x]+close[x])/3 if(close[x]>=avg) up := up + ((close[x] - avg)*volume[x]) else down := down + ((avg - close[x])*volume[x]) vsum := vsum + volume[x] up := (up / vsum)*100 down := (down / vsum)*100 AccDist=((up-down)*100)/down colorcode = (AccDist >=0 ? color.green : color.red) plot(AccDist,color=colorcode,style =plot.style_histogram) ema = AccDist >= 0 ? AccDist : AccDist/2 half_ema_days=math.ceil(no_of_days * 0.25) ema1=ta.ema(ema,half_ema_days) ema2=ta.ema(ema,no_of_days) plot(ema1, color=color.white) plot(ema2,color=color.gray) bgcolor=color.black if(ema1>=ema2 and AccDist >= ema2) bgcolor := color.new(color.green,90) else if(ema1>=ema2 and AccDist < ema2) bgcolor := color.new(color.red,90) else if(ema1 < ema2 and AccDist >= ema1) bgcolor := color.new(color.green,90) else if(ema1 < ema2 and AccDist < ema1) bgcolor := color.new(color.red,90) bgcolor(bgcolor) if(AccDist < math.max(ema1,ema2) and AccDist[1] >= math.max(ema1[1],ema2[1]) and AccDist[2] >= math.max(ema1[2],ema2[2]) and AccDist[3] >= math.max(ema1[3],ema2[3]) and AccDist >= 0) label.new(bar_index,math.max(high,high[1]),str.tostring(math.round(math.max(high,high[1]),2)),color = color.yellow)
Support & Resistance Parser
https://www.tradingview.com/script/uPrpkhDV-Support-Resistance-Parser/
CaptainBrett
https://www.tradingview.com/u/CaptainBrett/
55
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/ // © CaptainBrett //@version=5 indicator("S&R Parser", overlay=true) supportString = input.string("", title = "Support: ") supportColor = input.color(color.red, title = "Support Color") resistanceString = input.string("", title = "Resistance: ") resistanceColor = input.color(color.green, title = "Resistance Color") labelAlignment = input.int(10, "Label Align (-: left, +: right)", minval=-1000, maxval=1000, step=5) if barstate.islast // Parse comma seperated strings supportArray = str.split(supportString, ",") resistanceArray = str.split(resistanceString, ",") // Draw lines for each array if array.size(supportArray) > 0 for i = 0 to array.size(supportArray) - 1 supportNumber = str.tonumber(array.get(supportArray, i)) line.new(bar_index, supportNumber, bar_index+1, supportNumber, extend = extend.both, color = supportColor) label.new(bar_index+labelAlignment, supportNumber, text=str.tostring(supportNumber) + " S", style=labelAlignment>=0?label.style_label_left:label.style_label_right, color = supportColor, textcolor = color.new(color.white, 0), size = size.small) if array.size(resistanceArray) > 0 for i = 0 to array.size(resistanceArray) - 1 resistanceNumber = str.tonumber(array.get(resistanceArray, i)) line.new(bar_index, resistanceNumber, bar_index+1, resistanceNumber, extend = extend.both, color = resistanceColor) label.new(bar_index+labelAlignment, resistanceNumber, text=str.tostring(resistanceNumber) + " R", style=labelAlignment>=0?label.style_label_left:label.style_label_right, color = resistanceColor, textcolor = color.new(color.white, 0), size = size.small)
Range Deviations @joshuuu
https://www.tradingview.com/script/bo56LlEd-Range-Deviations-joshuuu/
joshuuu
https://www.tradingview.com/u/joshuuu/
357
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/ // © joshuuu //@version=5 indicator("Range Deviations @joshuuu", overlay = true, max_lines_count = 500, max_boxes_count = 500) //#region[Inputs and Variables] show_boxes = input.bool(true, "Show Boxes", group = "general", inline = "bool") vertical_lines = input.bool(false, "Start/End Lines", group = "general", inline = "bool") line_style_ = input.string("Solid", "Line Style", options = ["Solid", "Dotted", "Dashed"], group = "general") wicks_bodies = input.string("Wicks", "STDV Anchor Point", options = ["Wicks","Bodies"], group = "general") line_style = switch line_style_ 'Dashed' => line.style_dashed 'Dotted' => line.style_dotted 'Solid' => line.style_solid show_asia = input.bool(true, "Show asia", group = "asia", inline = "1") asia_color = input.color(color.new(color.red, 60), "", group = "asia", inline = "1") asia_eq = input.bool(false, "Show Equlibrium", group = "asia", inline = "1") asia_count = input.int(3, "", minval = 1, group = "asia", inline = "2") asia_type = input.string("Full Deviations", "", options = ["Full Deviations", "Half Deviations"] ,group = "asia", inline = "2") show_cbdr = input.bool(true, "Show cbdr", group = "cbdr", inline = "1") cbdr_color = input.color(color.new(color.orange, 60), "", group = "cbdr", inline = "1") cbdr_eq = input.bool(false, "Show Equlibrium", group = "cbdr", inline = "1") cbdr_count = input.int(3, "", minval = 1, group = "cbdr", inline = "2") cbdr_type = input.string("Full Deviations", "", options = ["Full Deviations", "Half Deviations"] ,group = "cbdr", inline = "2") show_flout = input.bool(false, "Show flout", group = "flout", inline = "1") flout_color = input.color(color.new(color.purple, 60), "", group = "flout", inline = "1") flout_eq = input.bool(true, "Show Equlibrium", group = "flout", inline = "1") flout_count = input.int(3, "", minval = 1, group = "flout", inline = "2") flout_type = input.string("Half Deviations", "", options = ["Full Deviations", "Half Deviations"] ,group = "flout", inline = "2") show_ons = input.bool(false, "Show ons", group = "ons", inline = "1") ons_color = input.color(color.new(color.blue, 60), "", group = "ons", inline = "1") ons_eq = input.bool(true, "Show Equlibrium", group = "ons", inline = "1") ons_count = input.int(3, "", minval = 1, group = "ons", inline = "2") ons_type = input.string("Full Deviations", "", options = ["Full Deviations", "Half Deviations"] ,group = "ons", inline = "2") show_custom = input.bool(false, "Show custom", group = "custom", inline = "1") custom_color= input.color(color.new(color.gray, 60), "", group = "custom", inline = "1") custom_eq = input.bool(true, "Show Equlibrium", group = "custom", inline = "1") custom_count= input.int(3, "", minval = 1, group = "custom", inline = "2") custom_type = input.string("Full Deviation", "", options = ["Full Deviation", "Half Deviation"] ,group = "custom", inline = "2") custom = input.session("2000-0000", "Session") asia = "2000-0000" cbdr = "1400-2000" flout = "1500-0000" ons = "0500-0900" na_color = color.new(color.gray,100) //#endregion //#region[Functions] is_newbar(string sess) => t = time('D', sess, timezone = "America/New_York") na(t[1]) and not na(t) or t[1] < t is_session(string sess) => not na(time('D', sess, timezone = "America/New_York")) is_over(string sess) => sess_index = 0 sess_over = false if is_session(sess) sess_index := bar_index if bar_index[1] == sess_index[1] and bar_index > sess_index sess_over := true else sess_over := false session_high_low(string session, bool previous = false, bool bodies = false) => var float p_high = na var float p_low = na var float s_high = na var float s_low = na _high = bodies ? math.max(open, close) : high _low = bodies ? math.min(open,close) : low if is_newbar(session) p_high := s_high p_low := s_low s_high := _high s_low := _low else if is_session(session) if _high > s_high s_high := _high if _low < s_low s_low := _low var float x_high = na var float x_low = na if previous x_high := p_high x_low := p_low else x_high := s_high x_low := s_low [x_high, x_low] range_box(string session = "2000-0000", color color = color.red, string bodies_wicks = "Wicks") => _high = bodies_wicks == "Wicks" ? high : math.max(open,close) _low = bodies_wicks == "Wicks" ? low : math.min(open,close) var box s_box = na if is_newbar(session) s_box := box.new(bar_index, _high, bar_index, _low, border_color = na_color, bgcolor = color) else if is_session(session) if _high > box.get_top(s_box) box.set_top(s_box, _high) if _low < box.get_bottom(s_box) box.set_bottom(s_box, _low) box.set_right(s_box, bar_index) s_box deviations(string session = "2000-0000", bool half_deviations = true, int deviation_number = 3, color color, bool show_eq ) => s_start = fixnan(is_newbar(session) ? bar_index : na) [s_high, s_low] = session_high_low(session, bodies = wicks_bodies == "Bodies") s_range = s_high - s_low if is_over(session) for i = 0 to deviation_number * (half_deviations ? 2 : 1) line.new(s_start, s_high + i * (half_deviations? 0.5 : 1) * s_range, bar_index, s_high + i * (half_deviations? 0.5 : 1) * s_range, style = line_style, color = color) line.new(s_start, s_low - i * (half_deviations? 0.5 : 1) * s_range, bar_index, s_low - i * (half_deviations? 0.5 : 1) * s_range, style = line_style, color = color) if vertical_lines line.new(s_start, s_high + deviation_number * s_range, s_start, s_low - deviation_number * s_range, style = line_style, color = color, extend = extend.both) line.new(bar_index, s_high + deviation_number * s_range, bar_index, s_low - deviation_number * s_range, style = line_style, color = color, extend = extend.both) if show_eq line.new(s_start, math.avg(s_high, s_low), bar_index, math.avg(s_high, s_low), style = line_style, color = color) //#endregion //#region[Plot] if show_asia if show_boxes range_box(asia, color.new(asia_color, 90), wicks_bodies) deviations(asia, asia_type == "Half Deviations", asia_count, color = asia_color, show_eq = asia_eq) if show_cbdr if show_boxes range_box(cbdr, color.new(cbdr_color, 90), wicks_bodies) deviations(cbdr, cbdr_type == "Half Deviations", cbdr_count, color = cbdr_color, show_eq = cbdr_eq) if show_flout if show_boxes range_box(flout, color.new(flout_color, 90), wicks_bodies) deviations(flout, flout_type == "Half Deviations", flout_count, color = flout_color, show_eq = flout_eq) if show_ons if show_boxes range_box(ons, color.new(ons_color, 90), wicks_bodies) deviations(ons, ons_type == "Half Deviations", ons_count, color = ons_color, show_eq = ons_eq) if show_custom if show_boxes range_box(custom, color.new(custom_color, 90), wicks_bodies) deviations(custom, custom_type == "Half Deviations", custom_count, color = custom_color, show_eq = custom_eq) //#endregion
Bollinger Bands and SMA Channel Buy and Sell
https://www.tradingview.com/script/oDJXybep-Bollinger-Bands-and-SMA-Channel-Buy-and-Sell/
ivandra447
https://www.tradingview.com/u/ivandra447/
127
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/ // © ivandra447 // This Indicator is a combination of a standard BB indicator incorporated with a SSL Channel by ErwinBeckers which is Simple Moving average with a length of set at 10 (Default) and calculates the high and low set for the default 10 to form a Channel. //The Settings for the Bollinger Band is the standard settings on a normal Bollinger Band - Length 20, souce close and Standard dev 2 // The setting for the SMA is length 10 and high and low calculated or that lentht to form a channel. //The SMA Channel gives a green line for the Up channel and the Red line for the down Channel. //The basis of the indicator is that the Candle close above the Basis line of the BB and the SMA green line will give a buy indicator //and the same for Sell indicator the candle close below the basis BB and the SMA line Red will give a Sell indicator. // timeframe used is as per chart and using standard candles. // Thanks for ASteyn idea and trading strategy and inspiration for the script // This code will be open source for anyone to use or back test or use it for whatever they want. // This code is for my own personal trading and cannot be relied upon. This indicator cannot be used and cannot guarantee anything, and caution should always be taken when trading. Use this with other indicators to give certanty. //Again use this for Paper Trading only. // I want to thank TradingView for its platform that facilitates development and learning. //@version=4 study(shorttitle="IV BBSMA Buy & Sell", title="Bollinger Bands and SMA Channel Buy and Sell", overlay=true) // //Colours blue = #2196F3 green = #3fff00 red = #ff1100 orange = #ffae00 // Bollinger Bands length = input(20, "Bollinger Band Length", minval=1) src = input(close, "Bollinger Band Source") mult = input(2.0, "Bollinger Band StdDev", minval=0.001, maxval=50) showBasis = input(true, "Show Bollinger Band Basis") showUpper = input(false, "Show Bollinger Band Upper") showLower = input(false, "Show Bollinger Band Lower") basis = sma(src, length) dev = mult * stdev(src, length) upper = basis + dev lower = basis - dev plot(showBasis ? basis : na, "Bollinger Band Basis", color= orange,linewidth =2) plot(showUpper ? upper : na, "Bollinger Band Upper", color=blue ) plot(showLower ? lower : na, "Bollinger Band Lower", color=blue) // SSL Channel len = input(10, title="SMA Length") scr1 = input(close, "SMA Source") showSSLDown = input(true, "Show SMA Down") showSSLUp = input(true, "Show SMA UP") showFill = input(true, "Show SMA Fill") smaHigh = sma(high, len) smaLow = sma(low, len) var float Hlv = na Hlv := scr1 > smaHigh ? 1 : scr1 < smaLow ? -1 : Hlv[1] sslDown = Hlv < 0 ? smaHigh : smaLow sslUp = Hlv < 0 ? smaLow : smaHigh p1 = plot(showSSLDown ? sslDown : na, "SMA Down", linewidth=2, color=red) p2 = plot(showSSLUp ? sslUp : na, "SMA Up", linewidth=2, color=green) fillCondition = showFill ? (sslUp > sslDown ? green : red) : na fill(p1, p2, color=fillCondition, title = "SMA Fill", transp=65) // Buy and Sell Conditions basisCrossUp = crossover(close, basis) sslUpCondition = close > sslUp buyCondition = basisCrossUp and sslUpCondition sellCondition = crossunder(close, basis) // Plot Buy and Sell Characters plotshape(buyCondition ? close : na, title="Buy", location=location.belowbar,textcolor = color.white, color = color.green, style=shape.labelup, text="BUY") plotshape(sellCondition ? close : na, title="Sell", location=location.abovebar,textcolor = color.white, color = color.red, style=shape.labeldown, text="SELL")
Divergence V2
https://www.tradingview.com/script/TrQdhwlp-Divergence-V2/
seba34e
https://www.tradingview.com/u/seba34e/
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/ // © seba34e //@version=5 indicator("Divergence V2", overlay = true, max_labels_count=500, max_lines_count=500, max_bars_back=100) //SQ Inputs length = 20 //SQ functions bband(length, mult) => ta.sma(close, length) + mult * ta.stdev(close, length) keltner(length, mult) => ta.ema(close, length) + mult * ta.ema(ta.tr, length) //SQ calculations e1 = (ta.highest(high, length) + ta.lowest(low, length)) / 2 + ta.sma(close, length) osc = ta.linreg(close - e1 / 2, length, 0) diff = bband(length, 2) - keltner(length, 1) squeezeDn = osc[1] > osc [0] squeezeUp = osc[1] < osc [0] //************************************************ backTesting = input.int (1000, title = "Backtesting Bars", minval=1, maxval=5000) tolerance = input.int(2, title='Tolerance', minval=0, maxval=3) minBarsDivergence = input.int(30, title="Min Bars to Detect") maxbars = input.int(100, title="Max Bars to Detect", minval=0, maxval=150) closeOrHigh = input.source(close, title='Source Highs') closeOrLow = input.source(close, title='Source Lows') useSqueeze = input.bool(true, title='Use Squeze Parameter') valueInLine (x, x1, y1, x2, y2) => ((y1-y2)/(x1-x2)) * (x-x1) + y1 miRSIHigh = ta.rsi (close, 14) miRSILow = ta.rsi (close, 14) cantDivergenciasUp = 0 cantDivergenciasDn = 0 bgcolor (bar_index == last_bar_index - backTesting ? color.blue : na) if bar_index >= last_bar_index - backTesting for a = maxbars to 1 //searching highs if closeOrHigh[a] < closeOrHigh [0] and a > minBarsDivergence contActivoPuntos = 0 contRSIPuntos = 0 for b=0 to a g = valueInLine (bar_index[b],bar_index[a],closeOrHigh[a],bar_index[0], closeOrHigh[0]) h = valueInLine (bar_index[b],bar_index[a],miRSIHigh[a],bar_index[0], miRSIHigh[0]) if g < closeOrHigh [b] contActivoPuntos := contActivoPuntos + 1 if h < miRSIHigh [b] contRSIPuntos := contRSIPuntos + 1 if useSqueeze ? contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSIHigh [0] < miRSIHigh [a] and squeezeDn : contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSIHigh [0] < miRSIHigh [a] cantDivergenciasUp := cantDivergenciasUp + 1 linea1 = line.new (bar_index[a],closeOrHigh[a],bar_index[0], closeOrHigh [0] , color=color.red) lb1 = label.new(bar_index[0], high [0], text= str.tostring(cantDivergenciasUp, "0"), textcolor=color.white, color=color.red, style=label.style_label_down) // searching lows if closeOrLow [a] > closeOrLow [0] and a > minBarsDivergence contActivoPuntos = 0 contRSIPuntos = 0 for b=0 to a g = valueInLine (bar_index[b], bar_index[a], closeOrLow[a], bar_index[0], closeOrLow[0]) h = valueInLine (bar_index[b], bar_index[a], miRSILow[a] , bar_index[0], miRSILow[0]) if g > closeOrLow [b] contActivoPuntos := contActivoPuntos + 1 if h > miRSILow [b] contRSIPuntos:=contRSIPuntos + 1 if useSqueeze ? contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSILow [0] > miRSILow [a] and squeezeUp : contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSILow [0] > miRSILow [a] cantDivergenciasDn := cantDivergenciasDn + 1 linea2 = line.new(bar_index[a],closeOrLow[a],bar_index[0], closeOrLow[0] , color=color.green) lb2 = label.new(bar_index[0], low[0], text= str.tostring(cantDivergenciasDn, "0"), textcolor=color.white, color=color.green, style=label.style_label_up) longSignal = cantDivergenciasDn > 0 shortSignal = cantDivergenciasUp > 0 bothSignal = cantDivergenciasDn > 0 or cantDivergenciasUp > 0 alertcondition(bothSignal , "Divergence (any way)") alertcondition(shortSignal, "Divergence (Sell)") alertcondition(longSignal , "Divergence (Buy)")
Divergence RSI V2
https://www.tradingview.com/script/ADKw2Gnn-Divergence-RSI-V2/
seba34e
https://www.tradingview.com/u/seba34e/
85
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("Divergence RSI V2", overlay = false, max_labels_count=300, max_lines_count=500, max_bars_back=100) //SQ Inputs length = 20 //SQ functions bband(length, mult) => ta.sma(close, length) + mult * ta.stdev(close, length) keltner(length, mult) => ta.ema(close, length) + mult * ta.ema(ta.tr, length) //SQ calculations e1 = (ta.highest(high, length) + ta.lowest(low, length)) / 2 + ta.sma(close, length) osc = ta.linreg(close - e1 / 2, length, 0) diff = bband(length, 2) - keltner(length, 1) squeezeDn = osc[1] > osc [0] squeezeUp = osc[1] < osc [0] //************************************************ backTesting = input.int (1000, title = "Backtesting Bars", minval=1, maxval=1000) tolerance = input.int(2, title='Tolerance', minval=0, maxval=3) minBarsDivergence = input.int(30, title="Min Bars to Detect") maxbars = input.int(100, title="Max Bars to Detect", minval=0, maxval=100) closeOrHigh = input.source(close, title='Source Highs') closeOrLow = input.source(close, title='Source Lows') useSqueeze = input.bool(true, title='Use Squeze Parameter') valueInLine (x, x1, y1, x2, y2) => ((y1-y2)/(x1-x2)) * (x-x1) + y1 fun_line_slope(x1,y1,x2,y2) => (y2 - y1) / (x2 - x1) fun_slope_angle(slope) => x_axis_slope=0.5 angle_radians = math.atan((slope-x_axis_slope)/(1+(slope*x_axis_slope))) pi_number = 3.1415926535897 angle_degrees = (angle_radians * 180) / pi_number angle_degrees miRSIHigh = ta.rsi (close, 14) miRSILow = ta.rsi (close, 14) cantDivergenciasUp = 0 cantDivergenciasDn = 0 l1 = hline(70, color=color.white, linestyle=hline.style_dashed) l2 = hline(30, color=color.white, linestyle=hline.style_dashed) fill(l1, l2, color=color.new(color.purple, 90)) plot(miRSIHigh, color=color.new(color.purple, 0)) bgcolor (bar_index == last_bar_index - backTesting ? color.blue : na) if bar_index >= last_bar_index - backTesting for a = maxbars to 1 //searching highs if closeOrHigh[a] < closeOrHigh [0] and a > minBarsDivergence contActivoPuntos = 0 contRSIPuntos = 0 for b=0 to a g = valueInLine (bar_index[b],bar_index[a],closeOrHigh[a],bar_index[0], closeOrHigh[0]) h = valueInLine (bar_index[b],bar_index[a],miRSIHigh[a],bar_index[0], miRSIHigh[0]) if g < closeOrHigh [b] contActivoPuntos := contActivoPuntos + 1 if h < miRSIHigh [b] contRSIPuntos := contRSIPuntos + 1 if useSqueeze ? contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSIHigh [0] < miRSIHigh [a] and squeezeDn : contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSIHigh [0] < miRSIHigh [a] cantDivergenciasUp := cantDivergenciasUp + 1 linea1 = line.new (bar_index[a],miRSIHigh[a],bar_index[0], miRSIHigh [0] , color=color.red) lb1 = label.new(bar_index[0], miRSIHigh [0], text= str.tostring(cantDivergenciasUp, "0"), textcolor=color.white, color=color.red, style=label.style_label_down) // buscando lows if closeOrLow [a] > closeOrLow [0] and a > minBarsDivergence contActivoPuntos = 0 contRSIPuntos = 0 for b=0 to a g = valueInLine (bar_index[b], bar_index[a], closeOrLow[a], bar_index[0], closeOrLow[0]) h = valueInLine (bar_index[b], bar_index[a], miRSILow[a] , bar_index[0], miRSILow[0]) if g > closeOrLow [b] contActivoPuntos := contActivoPuntos + 1 if h > miRSILow [b] contRSIPuntos:=contRSIPuntos + 1 if useSqueeze ? contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSILow [0] > miRSILow [a] and squeezeUp : contActivoPuntos <= tolerance and contRSIPuntos <= tolerance and miRSILow [0] > miRSILow [a] cantDivergenciasDn := cantDivergenciasDn + 1 linea2 = line.new(bar_index[a],miRSILow[a],bar_index[0], miRSILow[0] , color=color.green) lb2 = label.new(bar_index[0], miRSILow[0], text= str.tostring(cantDivergenciasDn, "0"), textcolor=color.white, color=color.green, style=label.style_label_up)
Dual_MACD_trending
https://www.tradingview.com/script/znXfZwAd-Dual-MACD-trending/
vpirinski
https://www.tradingview.com/u/vpirinski/
6
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/ // © vpirinski //@version=5 //#region *********** DESCRIPTION *********** // ================================================== INFO ================================================== // This indicator is useful for trending assets, as my preference is for low-frequency trading, thus using BTCUSD on 1D/1W chart // In the current implementation I find two possible use cases for the indicator: // - as a stand-alone indicator on the chart which can also fire alerts that can help to determine if we want to manually enter/exit trades based on the signals from it (1D/1W is good for non-automated trading) // - can be used to connect to the Signal input of the TTS (TempalteTradingStrategy) by jason5480 in order to backtest it, thus effectively turning it into a strategy (instructions below in TTS CONNECTIVITY section) // Trading period can be selected from the indicator itself to limit to more interesting periods. // Arrow indications are drawn on the chart to indicate the trading conditions met in the script - light green for HTF crossover, dark green for LTF crossover and orange for LTF crossunder. // Note that the indicator performs best in trending assets and markets, and it is advisable to use additional indicators to filter the trading conditions when market/asset is expected to move sideways. // ================================================== DETAILS ================================================== // It uses a couple of MACD indicators - one from the current timeframe and one from a higher timeframe, as the crossover/crossunder cases of the MACD line and the signal line indicate the potential entry/exit points. // The strategy has the following flow: // - If the weekly MACD is positive (MACD line is over the signal line) we have a trading window. // - If we have a trading window, we buy when the daily macd line crosses AND closes above the signal line. // - If we are in a position, we await the daily MACD to cross AND close under the signal line, and only then place a stop loss under the wick of that closing candle. // The user can select both the higher (HTF) and lower (LTF) timeframes. Preferably the lower timeframe should be the one that the Chart is on for better visualization. // If one to decide to use the indicator as a strategy, it implements the following buy and sell criterias, which are feed to the TTS, but can be also manually managed via adding alerts from this indicator. // Since usually the LTF is preceeding the crossover compared to the HTF, then my interpretation of the strategy and flow that it follows is allowing two different ways to enter a trade: // - crossover (and bar close) of the macd over the signal line in the HIGH TIMEFRAME (no need to look at the LOWER TIMEFRMAE) // - crossover (and bar close) of the macd over the signal line in the LOW TIMEFRAME, as in this case we need to check also that the macd line is over the signal line for the HIGH TIMEFRAME as well (like a regime filter) // The exit of the trade is based on the lower timeframe MACD only, as we create a stop loss eqaual to the lower wick of the bar, once the macd line crosses below the signal line on that timeframe // ================================================== SETTINGS ================================================== // Leaving all of the settings as in vanilla use case. // User can set all of the MACD parameters for both the higher and lower (current) timeframes, currently left to default of the MACD stand-alone indicator itself. // The start-end date is a time filter that can be extermely usefull when backtesting different time periods. // ================================================== TTS SETTINGS (NEEDED IF USED TO BACKTEST WITH TTS) ================================================== // The TempalteTradingStrategy is a strategy script developed in Pine by jason5480, which I recommend for quick turn-around of testing different ideas on a proven and tested framework // I cannot give enough credit to the developer for the efforts put in building of the infrastructure, so I advice everyone that wants to use it first to get familiar with the concept and by checking // by checking jason5480's profile https://www.tradingview.com/u/jason5480/#published-scripts // The TTS itself is extremely functional and have a lot of properties, so its functionality is beyond the scope of the current script - // Again, I strongly recommend to be thoroughly epxlored by everyone that plans on using it. // In the nutshell it is a script that can be feed with buy/sell signals from an external indicator script and based on many configuration options it can determine how to execute the trades. // The TTS has many settings that can be applied, so below I will cover only the ones that differ from the default ones, at least according to my testing - do your own research, you may find something even better :) // The current/latest version that I've been using as of writing and testing this script is TTSv48 // Settings which differ from the default ones: // - from - False (time filter is from the indicator script itself) // - Deal Conditions Mode - External (take enter/exit conditions from an external script) // - 🔌Signal 🛈➡ - Dual_MACD: 🔌Signal to TTSv48 (this is the output from the indicator script, according to the TTS convention) // - Sat/Sun - true (for crypto, in order to trade 24/7) // - Order Type​​ - STOP (perform stop order) // - Distance Method​​ - HHLL (HigherHighLowerLow - in order to set the SL according to the strategy definition from above) // // The next are just personal preferenes, you can feel free to experiment according to your trading style // - Take Profit Targets - 0 (either 100% in or out, no incremental stepping in or out of positions) //   - Dist Mul|Len Long/Short- 10 (make sure that we don't close on profitable trades by any reason) // - Quantity Method - EQUITY (personal backtesting preference is to consider each backtest as a separate portfolio, so determine the position size by 100% of the allocated equity size) // - Equity %         - 100 (note above) // ================================================== TODO ================================================== // 1. Seems that if we change the source of the MA for the MACD from close to low for BTC we get better results, and even better for ohlc4 - room to explore further. //#endregion ======================================================================================================== //#region *********** STRATEGY_SETUP *********** indicator(title = 'Dual_MACD_trending', shorttitle = 'Dual_MACD', overlay = true, explicit_plot_zorder = true ) //#endregion ======================================================================================================== //#region *********** LIBRARIES *********** import HeWhoMustNotBeNamed/enhanced_ta/14 as eta import jason5480/tts_convention/3 as tts_conv //#endregion ======================================================================================================== //#region *********** USER_INPUT *********** var string MACD_GROUP_STR = "MACD" i_macd_high_timeframe = input.timeframe(title = "High timeframe", defval = "W", group = MACD_GROUP_STR) i_macd_low_timeframe = input.timeframe(title = "Low timeframe", defval = "", group = MACD_GROUP_STR) i_macd_ma_source = input.source (title = "Source", defval = close, group = MACD_GROUP_STR) i_macd_osc_ma_type = input.string (title = "Osc MA type", defval = "ema", group = MACD_GROUP_STR, options = ["ema", "sma", "rma", "hma", "wma", "vwma", "swma"]) i_macd_signal_line_ma_type = input.string (title = "Signal MA type", defval = "ema", group = MACD_GROUP_STR, options = ["ema", "sma", "rma", "hma", "wma", "vwma", "swma"]) i_macd_fast_ma_length = input.int (title = "Fast MA Length", defval = 12, group = MACD_GROUP_STR) i_macd_slow_ma_length = input.int (title = "Slow MA Length", defval = 26, group = MACD_GROUP_STR) i_macd_signal_length = input.int (title = "Low MACD Hist", defval = 9, group = MACD_GROUP_STR) i_macd_repaint_en = true // input.bool (title = "MACD Repainting On/Off", defval = true, group = MACD_GROUP_STR, tooltip="Off for use as an Indicator to avoid repainting. On for use in Strategies so that trades can respond to realtime data.") - always on since used as an indicator var string TIME_GROUP_STR = "Start and End Time" i_start_time = input.time (title="Start Date", defval=timestamp("01 Jan 2016 13:30 +0000"), group=TIME_GROUP_STR) i_end_time = input.time (title="End Date", defval=timestamp("1 Jan 2099 19:30 +0000"), group=TIME_GROUP_STR) var string GENERAL_GROUP_STR = "GENERAL" i_general_gaps_on = input.bool (title = "Gaps On/Off", defval = false, group = GENERAL_GROUP_STR, tooltip = "When enabled set gaps to barmerge.gaps_on in the security function") i_general_lookahead_on = input.bool (title = "Looakahead On/Off", defval = false, group = GENERAL_GROUP_STR, tooltip = "When enabled set looakahead to barmerge.lookahead_off in the security function") //#endregion ======================================================================================================== //#region *********** COMMON_FUNCTIONS *********** // Function offering a repainting/no-repainting version of the HTF data (but does not work on tuples). // It has the advantage of using only one `security()` call for both. // The built-in MACD function behaves identically to Repainting On in the custom function below. In other words _repaint = TRUE. // https://www.tradingview.com/script/cyPWY96u-How-to-avoid-repainting-when-using-security-PineCoders-FAQ/ f_security(_symbol, _tf, _src, _repaint) => request.security(symbol = _symbol, timeframe = _tf, expression = _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0], gaps = i_general_gaps_on ? barmerge.gaps_on : barmerge.gaps_off, lookahead = i_general_lookahead_on ? barmerge.lookahead_on : barmerge.lookahead_off)[_repaint ? 0 : barstate.isrealtime ? 0 : 1] //#endregion ======================================================================================================== //#region *********** LOGIC *********** // Get the current TF MACD lines and then interpolate them for the HTF and LTF (and SL TF) fast_ma = eta.ma(source = i_macd_ma_source, maType = i_macd_osc_ma_type, length = i_macd_fast_ma_length) slow_ma = eta.ma(source = i_macd_ma_source, maType = i_macd_osc_ma_type, length = i_macd_slow_ma_length) ctf_macd_line = fast_ma - slow_ma ctf_signal_line = eta.ma(source = ctf_macd_line, maType = i_macd_signal_line_ma_type, length = i_macd_signal_length) ctf_hist_line = ctf_macd_line - ctf_signal_line htf_macd_line = f_security(syminfo.tickerid, i_macd_high_timeframe, ctf_macd_line, i_macd_repaint_en) htf_signal_line = f_security(syminfo.tickerid, i_macd_high_timeframe, ctf_signal_line, i_macd_repaint_en) htf_hist_line = f_security(syminfo.tickerid, i_macd_high_timeframe, ctf_hist_line, i_macd_repaint_en) ltf_macd_line = f_security(syminfo.tickerid, i_macd_low_timeframe, ctf_macd_line, i_macd_repaint_en) ltf_signal_line = f_security(syminfo.tickerid, i_macd_low_timeframe, ctf_signal_line, i_macd_repaint_en) ltf_hist_line = f_security(syminfo.tickerid, i_macd_low_timeframe, ctf_hist_line, i_macd_repaint_en) // Determine the strategy trading conditions htf_crossover = ta.crossover (htf_macd_line, htf_signal_line) ltf_crossover = ta.crossover (ltf_macd_line, ltf_signal_line) ltf_crossunder = ta.crossunder (ltf_macd_line, ltf_signal_line) // Filters htf_regime_filter = htf_macd_line > htf_signal_line time_and_bar_filter = barstate.isconfirmed and ((time >= i_start_time) and (time <= i_end_time)) //#endregion ======================================================================================================== //#region *********** BUY_&_SELL_SIGNALS *********** htf_buy_signal = time_and_bar_filter and htf_crossover ltf_buy_signal = time_and_bar_filter and ltf_crossover and htf_regime_filter buy_signal = htf_buy_signal or ltf_buy_signal set_sl_signal = time_and_bar_filter and ltf_crossunder //#endregion ======================================================================================================== //#region *********** BUY_&_SELL_SIGNALS TO TTS *********** tts_deal_conditions = tts_conv.DealConditions.new( startLongDeal = buy_signal, startShortDeal = false, endLongDeal = set_sl_signal, endShortDeal = false, cnlStartLongDeal = false, cnlStartShortDeal = false, cnlEndLongDeal = false, cnlEndShortDeal = false) plot(series = tts_conv.getSignal(tts_deal_conditions), title = '🔌Signal to TTS', color = color.olive, display = display.data_window + display.status_line) //#endregion ======================================================================================================== //#region *********** DEBUG_&_PLOTS *********** plotshape(htf_buy_signal, style=shape.triangleup, location=location.bottom, size = size.tiny, color=htf_buy_signal ? color.rgb(19, 231, 26) : na) plotshape(ltf_buy_signal, style=shape.triangleup, location=location.bottom, size = size.tiny, color=ltf_buy_signal ? color.rgb(9, 97, 82) : na) plotshape(set_sl_signal, style=shape.triangledown, location=location.top, size = size.tiny, color=set_sl_signal ? color.rgb(216, 129, 71) : na) //#endregion ======================================================================================================== //#region *********** ALERTS *********** alertcondition(htf_buy_signal, "DualMacdHTFCrossOver", "MACD HTF line xOver signal line for {{ticker}} at price {{close}}") alertcondition(ltf_buy_signal, "DualMacdLTFCrossOver", "MACD LTF line xUnder signal line for {{ticker}} at price {{close}}") alertcondition(set_sl_signal, "DualMacdLTFCrossOver", "MACD LTF line xUnder signal line for {{ticker}} at price {{close}}") // Better to keep them as part of the TTS, since in the indicator we cannot detect if we're already in a trade or not... //#endregion ========================================================================================================
[KVA]Donchian Channel Percentage
https://www.tradingview.com/script/wqbc2TtE-KVA-Donchian-Channel-Percentage/
Kamvia
https://www.tradingview.com/u/Kamvia/
6
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/ // © Kamvia //@version=5 indicator("[KVA]Donchian Channel Percentage", shorttitle="DC%", overlay=false) // User-defined input for the lookback period of the Donchian Channel length = input(20, title="Length") // Calculating the Donchian Channels upper = ta.highest(high, length) lower = ta.lowest(low, length) // Calculate Donchian Channel Percentage dc_percent = (close - lower) / (upper - lower) * 100 // Plotting the Donchian Channel Percentage plot(dc_percent, title="DC%", color=color.blue, linewidth=2) hline(0, "Lower Bound", color=color.red) hline(100, "Upper Bound", color=color.green)
AIR Supertrend (Average Interpercentile Range)
https://www.tradingview.com/script/tuuXNlu9-AIR-Supertrend-Average-Interpercentile-Range/
alphaXiom
https://www.tradingview.com/u/alphaXiom/
195
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/ // ╭━━╮╱╱╱╱╱╱╭╮╱╱╱╭━┳╮ // ┃╭╮┣━┳━╮╭┳┫╰┳━╮┃━┫╰╮ // ┃╭╮┃┻┫╋╰┫╭┫╋┃╋╰╋━┃┃┃ // ╰━━┻━┻━━┻╯╰━┻━━┻━┻┻╯ @ Woody_Bearbash //@version=5 indicator('Average Interpercentile Range AIR Supertrend','AIR Supertrend', overlay=true, format=format.price) // Moving Averages Types var string SMA = 'Simple Moving Average' var string EMA = 'Exponential Moving Average' var string WMA = 'Weighted Moving Average' var string VWMA = 'Volume Weighted Moving average' var string ALMA = 'Arnaud Legoux Moving Average' var string JURIK = 'Jurik Moving Average' var string T3 = 'Tillson T3 Moving Average' var string RSIMA = 'RSI Moving Average' var string MEDIAN = 'Median' var string SS = 'Super Smoother Moving Average' var string HANN = 'Ehlers Hann Moving Average' var M1 = 'Urban' var M2 = 'Night' var M3 = 'Earth' var M4 = 'Classic' var M5 = 'Wood' var M6 = 'Pop' src = input.source(hl2, title = 'Source', inline = '1') period = input.int(title = 'Length', defval = 28, inline = '1') multiplier = input.float(title = 'Multiplier', step = 0.1, defval = 3.3, inline = '1') var string GRP_RF = '══════ Range mix ══════' atrActive = input.bool(true, 'ATR,', inline='42', group=GRP_RF) atrMult = input.float(0.5, 'Mult', step=0.1, inline='42', group=GRP_RF) atr_move = input.string(T3, 'MA', options=[SMA, EMA, WMA, VWMA, ALMA, JURIK, T3, RSIMA, MEDIAN, SS, HANN], group=GRP_RF, inline='42') airActive = input.bool(true, 'AIR,', inline='44', group=GRP_RF) airMult = input.float(0.7, 'Mult', step=0.1, inline='44', group=GRP_RF) air_move = input.string(T3, 'MA', options=[SMA, EMA, WMA, VWMA, ALMA, JURIK, T3, RSIMA, MEDIAN, SS, HANN], group=GRP_RF, inline='44') spacer = input.int(16, '%', inline='44', group=GRP_RF) var string GRP_MA = 'Global MA Settings' inputAlmaOffset_T = input.float(defval = 0.86, title = "Alma Offset", step = 0.01, inline = '1a', group = GRP_MA) inputAlmaSigma_T = input.int(defval = 3, title = "... Sigma", inline = '1a', group = GRP_MA) phase_T = input.int(defval = 2, title = "Jurik Phase", step = 1, inline = '1j', group = GRP_MA) power_T = input.float(defval = 0.9, title = "... Power", step = 0.1, inline = '1j', group = GRP_MA) fac_t3_T = input.float(0.3, step = 0.1, title = 'Tillson T3 Volume Factor', inline = '1t', group = GRP_MA) var string GRP_UI = '══════ UI ══════' the_m = input.string(M4, "theme", options = [M1, M2, M3, M4, M5, M6], inline ='ez', group=GRP_UI) i_bullColor_t = input.color(#e5cc42, 'Up', inline='COLOR' , group=GRP_UI) i_bearColor_t = input.color(#5ea4ff, 'Down', inline='COLOR', group=GRP_UI) i_bullColor_a = input.color(#ffcc80, "Up", inline='COLORa' , group=GRP_UI) i_bearColor_a = input.color(#ba68c8, "Down", inline='COLORa', group=GRP_UI) i_bullColor_m = input.color(#81c784, 'Up', inline='COLORb' , group=GRP_UI) i_bearColor_m = input.color(#5ea4ff, 'Down', inline='COLORb', group=GRP_UI) i_bullColor_c = input.color(#48e71d, "Up", inline='COLORc' , group=GRP_UI) i_bearColor_c = input.color(#ff0303, "Down", inline='COLORc', group=GRP_UI) i_bullColor_s = input.color(#81c784, 'Up', inline='COLORs' , group=GRP_UI) i_bearColor_s = input.color(#ffa726, 'Down', inline='COLORs', group=GRP_UI) i_bullColor_p = input.color(#a9c346, "Up", inline='COLORcp' , group=GRP_UI) i_bearColor_p = input.color(#aa9eed, "Down", inline='COLORcp', group=GRP_UI) up_ = the_m == M1 ? i_bullColor_t : the_m == M2 ? i_bullColor_a : the_m == M3 ? i_bullColor_m : the_m == M4 ? i_bullColor_c : the_m == M5 ? i_bullColor_s : the_m == M6 ? i_bullColor_p : na dn_ = the_m == M1 ? i_bearColor_t : the_m == M2 ? i_bearColor_a : the_m == M3 ? i_bearColor_m : the_m == M4 ? i_bearColor_c : the_m == M5 ? i_bearColor_s : the_m == M6 ? i_bearColor_p : na bkgrnd = input.bool(title = 'Fill, fade', defval = true, inline='f', group = GRP_UI) fader = input.int(85, '', inline = 'f', group = GRP_UI) bar_it = input.bool(true, 'Color candles, fade', inline = 'f1', group = GRP_UI) fader_c = input.int(39, '', inline = 'f1', group = GRP_UI) // =========================================================================================================== // Functions // =========================================================================================================== // @function Jurik Moving Average - TradingView: Moving Averages Jurik(src, simple int len, jurik_phase, jurik_power) => phaseRatio_l = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5 beta_l = 0.45 * (len - 1) / (0.45 * (len - 1) + 2) alpha_l = math.pow(beta_l, jurik_power) jma_l = 0.0 e0_l = 0.0 e0_l := (1 - alpha_l) * src + alpha_l * nz(e0_l[1]) e1_l = 0.0 e1_l := (src - e0_l) * (1 - beta_l) + beta_l * nz(e1_l[1]) e2_l = 0.0 e2_l := (e0_l + phaseRatio_l * e1_l - nz(jma_l[1])) * math.pow(1 - alpha_l, 2) + math.pow(alpha_l, 2) * nz(e2_l[1]) jma_l := e2_l + nz(jma_l[1]) // @function T3 MA from Tilson3Average © KioseffTrading t(src, x, a1_t3) => y1 = ta.ema(src,x) y2 = ta.ema(y1, x) y3 = ta.ema(y2, x) y4 = ta.ema(y3, x) y5 = ta.ema(y4, x) y6 = ta.ema(y5, x) v = -a1_t3 * math.pow(a1_t3,2) v2 = 3 * math.pow(a1_t3,2) + 3 * math.pow(a1_t3,3) v3 = -6 * math.pow(a1_t3, 2) - 3 * a1_t3 - 3 * math.pow(a1_t3, 3) v4 = 1 + 3 * a1_t3 + a1_t3 * math.pow(a1_t3, 2) + 3 * math.pow(a1_t3, 2) v1 = v * y6 + v2 * y5 + v3 * y4 + v4 * y3 v1 // Super Smoother Function ss(Series, Period) => // Super Smoother Function var PI = 2.0 * math.asin(1.0) var SQRT2 = math.sqrt(2.0) lambda = PI * SQRT2 / Period a1 = math.exp(-lambda) coeff2 = 2.0 * a1 * math.cos(lambda) coeff3 = -math.pow(a1, 2.0) coeff1 = 1.0 - coeff2 - coeff3 filt1 = 0.0 filt1 := coeff1 * (Series + nz(Series[1])) * 0.5 + coeff2 * nz(filt1[1]) + coeff3 * nz(filt1[2]) filt1 // Hann Window Smoothing – Credits to @cheatcountry doHannWindow(float _series, float _hannWindowLength) => sum = 0.0, coef = 0.0 for i = 1 to _hannWindowLength cosine = 1 - math.cos(2 * math.pi * i / (_hannWindowLength + 1)) sum := sum + (cosine * nz(_series[i - 1])) coef := coef + cosine h = coef != 0 ? sum / coef : 0 // Choose MA type MA_Calc(_data, _len, MAOption) => value = MAOption == SMA ? ta.sma(_data, _len) : MAOption == EMA ? ta.ema(_data, _len) : MAOption == WMA ? ta.wma(_data, _len) : MAOption == VWMA ? ta.vwma(_data, _len) : MAOption == ALMA ? ta.alma(_data, _len, inputAlmaOffset_T, inputAlmaSigma_T) : MAOption == JURIK ? Jurik(_data, _len, phase_T, power_T) : MAOption == T3 ? t(_data, _len, fac_t3_T) : MAOption == RSIMA ? ta.rma(_data, _len) : MAOption == MEDIAN ? ta.median(_data, _len) : MAOption == SS ? ss(_data, _len) : MAOption == HANN ? doHannWindow(_data, _len) : na ipr_array(len, dnny, uppy) => float[] hiArray = array.new_float (0) float[] loArray = array.new_float (0) float[] cmArray = array.new_float (0) for i = 0 to len - 1 array.push (hiArray, high[i]) array.push (loArray, low[i]) array.push (cmArray, hlcc4[i]) hlArray = array.concat (hiArray, loArray) hlcmArray = array.concat (hlArray, cmArray) q1 = array.percentile_linear_interpolation (hlcmArray, dnny) q3 = array.percentile_linear_interpolation (hlcmArray, uppy) iqr = (q3 - q1) / 2 // ================================================================================================= // Calculations // ================================================================================================= atrFactor = atrActive ? atrMult * MA_Calc(ta.tr(true), period, atr_move) : 0 airFactor = airActive ? airMult * MA_Calc(ipr_array(period, spacer, 100 - spacer), period, air_move) : 0 blender = nz(atrFactor) + nz(airFactor) ipr_supertrend(source, len, multi) => up = source - multi * blender up1 = nz(up[1], up) up := close[1] > up1 ? math.max(up, up1) : up dn = source + multi * blender dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? math.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 [up, dn, trend] [upper, lower, supertrend] = ipr_supertrend(src, period, multiplier) // ================================================================================================= // Plots // ================================================================================================= upPlot = plot(supertrend == 1 ? upper : na, title='Uptrend', style=plot.style_linebr, linewidth=2, color=color.new(up_, 0)) buySignal = supertrend == 1 and supertrend[1] == -1 dnPlot = plot(supertrend == 1 ? na : lower, title='Downtrend', style=plot.style_linebr, linewidth=2, color=color.new(dn_, 0)) sellSignal = supertrend == -1 and supertrend[1] == 1 plotshape(buySignal ? upper : na, title='Uptrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(up_, 0)) plotshape(sellSignal ? lower : na, title='Downtrend Begins', location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(dn_, 0)) midPlot = plot(ohlc4, title = '', style = plot.style_circles, display = display.none) fill(midPlot, upPlot, title = 'Uptrend Fill', color = bkgrnd ? color.new(up_, fader) : na) fill(midPlot, dnPlot, title = 'Downtrend Fill', color = bkgrnd ? color.new(dn_, fader) : na) color_b = supertrend == 1 ? up_ : dn_ barcolor(bar_it ? color.new(color_b, fader_c) : na) // ================================================================================================= // Alerts // ================================================================================================= alertcondition(buySignal, title='.Supertrend Buy 🟢', message='Supertrend Buy 🟢') alertcondition(sellSignal, title='.Supertrend Sell 🔴', message='Supertrend Sell 🔴') changeCond = supertrend != supertrend[1] alertcondition(changeCond, title='Supertrend Direction Change 🟢/🔴', message='Supertrend has changed direction 🟢/🔴') // ( __)( ( \( \ // ) _) / / ) D ( // (____)\_)__)(____/ //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Trendline Pivots [QuantVue]
https://www.tradingview.com/script/YbPHHN8X-Trendline-Pivots-QuantVue/
QuantVue
https://www.tradingview.com/u/QuantVue/
997
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/ // © QuantVue Team //@version=5 indicator("Trendline Pivots [QuantVue]", overlay = true) //inputs dtlColor = input.color(color.red, 'Down Trend Line Color', inline = '0') utlColor = input.color(color.green, 'Up Trend Line Color', inline = '1') pastColor = input.color(color.orange, 'Crossed Line Color', inline = '2') extendLine = input.bool(false, 'Extend Lines Until Crossed', inline = '3') onlyLast = input.bool(false, 'Most Recent Line Only', inline = '3', tooltip = 'If multiple lines share pivot points, checking this will only show the most recent line.') hideCrossed = input.bool(false, 'Hide Crossed Lines', inline = '4') showCross = input.bool(true, 'Show Crosses', inline ='4', tooltip = 'Hiding crossed lines will only leave trend lines on the chart that have not been breached by your selected source. Showing crosses will plot an "X" where price crosses the trendline based on your selected source.') crossDown = input.color(color.red, 'Cross Below Color', inline = '5') crossUp = input.color(color.lime, 'Cross Above Color', inline = '5') maxLines = input.int(4, 'Max Number of Crossed Lines to Show', step = 2, minval = 0, maxval = 50) crossSrc = input.string('Close', 'Cross Source', options = ['Close', 'High/Low']) maxLineLen = input.int(252, 'Max Line Length', tooltip = 'Will remove line if it is not crossed after selected amount of bars') pivLen = input.int(9, 'Pivot Length', step = 1, minval = 1) maxLines := hideCrossed ? 0 : maxLines isLog = input.bool(false, 'Log Scale', tooltip = 'Select this option if using a log chart.') type pivot string pivType int x1 float y1 int x2 float y2 // arrays var line[] dtlArray = array.new_line() var line[] utlArray = array.new_line() //functions createLine(ptype, x1, y1, x2, y2)=> piv = pivot.new(ptype, x1, y1, x2, y2) trendline = line.new(x1, y1, x2, y2, extend = extendLine ? extend.right : extend.none, color = ptype == 'ph' ? dtlColor : utlColor, width = 2) if ptype == 'ph' dtlArray.unshift(trendline) else if ptype == 'pl' utlArray.unshift(trendline) piv getSlope(line)=> slopePh = (line.get_y2(line) - line.get_y1(line))/(line.get_x2(line) -line.get_x1(line)) extendedPh = line.get_y2(line) - slopePh * (line.get_x2(line) - bar_index) extendedPh getSlopeLog(line)=> slopePh = (math.log(line.get_y2(line)) - math.log(line.get_y1(line)))/(line.get_x2(line) -line.get_x1(line)) extendedPh = math.exp(math.log(line.get_y2(line)) - slopePh * (line.get_x2(line) - bar_index)) extendedPh // variables ph = ta.pivothigh(high, pivLen, pivLen) pl = ta.pivotlow(low, pivLen, pivLen) var int utlX1 = na, var float utlY1 = na var int utlX2 = na, var float utlY2 = na var int dtlX2 = na, var float dtlY2 = na var int dtlX1 = na, var float dtlY1 = na if pl utlX1 := utlX2, utlY1 := utlY2 utlX2 := bar_index[pivLen], utlY2 := low[pivLen] if utlY1 < utlY2 createLine('pl', utlX1, utlY1, utlX2, utlY2) if ph dtlX1 := dtlX2, dtlY1 := dtlY2 dtlX2 := bar_index[pivLen], dtlY2 := high[pivLen] if dtlY1 > dtlY2 createLine('ph', dtlX1, dtlY1, dtlX2, dtlY2) for l in utlArray src = crossSrc == 'Close' ? close : low first = l == utlArray.get(0) extended = not isLog ? getSlope(l) : getSlopeLog(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > maxLineLen l.delete() if src > line.get_price(l, bar_index) and not first and onlyLast l.delete() var line [] tempUtl = array.new_line(maxLines/2) var label [] tempUL = array.new_label(maxLines/2) if src < line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color = pastColor, style = line.style_dashed, width = 1) crossLabel = showCross ? label.new(bar_index, low, ' ', yloc = yloc.belowbar, color = crossDown, style = label.style_xcross, size = size.tiny) : na alert(str.tostring(syminfo.ticker) + ' crossing below trendline', alert.freq_once_per_bar) line.delete(l) tempUtl.unshift(newLine) tempUL.unshift(crossLabel) if tempUtl.size() > (maxLines/2) line.delete(tempUtl.pop()) label.delete(tempUL.pop()) for l in dtlArray first = l == dtlArray.get(0) src = crossSrc == 'Close' ? close : high extended = not isLog ? getSlope(l) : getSlopeLog(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > maxLineLen l.delete() if src < line.get_price(l, bar_index) and not first and onlyLast l.delete() var line [] tempDtl = array.new_line(maxLines/2) var label [] tempDL = array.new_label(maxLines/2) if src > line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color = pastColor, style = line.style_dashed, width = 1) crossLabel = showCross ? label.new(bar_index, high, '', yloc = yloc.abovebar, style = label.style_xcross, color = crossUp, size = size.tiny) : na alert(str.tostring(syminfo.ticker) + ' crossing above trendline', alert.freq_once_per_bar) line.delete(l) tempDtl.unshift(newLine) tempDL.unshift(crossLabel) if tempDtl.size() > (maxLines/2) line.delete(tempDtl.pop()) label.delete(tempDL.pop())
TrendingNow
https://www.tradingview.com/script/ZR76EZIi-TrendingNow/
jac001
https://www.tradingview.com/u/jac001/
39
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/ // © jac001 //@version=5 indicator("TrendingNow", overlay=true) // Define input parameters length = input.int(14, minval=1, title="Length") multiplier = input.float(2.0, minval=0.1, title="Multiplier") trailPercent = input.float(1.0, title="Trailing Stop Percentage") confirmationLength = input.int(10, minval=1, title="Confirmation Length") momentumLength = input.int(14, minval=1, title="Momentum Length") overboughtLevel = input(70, title="Overbought Level") oversoldLevel = input(30, title="Oversold Level") volumeThreshold = input(2.0, title="Volume Threshold") volatilityMultiplier = input.float(1.5, minval=0.1, title="Volatility Multiplier") // Calculate the moving average sma = ta.sma(close, length) // Calculate the deviation from the moving average deviation = multiplier * ta.stdev(close, length) // Calculate the upper and lower bands upperBand = sma + deviation lowerBand = sma - deviation // Calculate price reversal reversedUpperBand = ta.crossunder(close, upperBand) reversedLowerBand = ta.crossover(close, lowerBand) // Determine if the current price is above the upper band (uptrend) isUptrend = close > upperBand // Determine if the current price is below the lower band (downtrend) isDowntrend = close < lowerBand isSideways = (isUptrend ==isDowntrend ==false) // Define trailing stop variables trailingStopLong = high * (1 - trailPercent / 100) trailingStopShort = low * (1 + trailPercent / 100) // Calculate trend confirmation using moving average maConfirmation = ta.sma(close, confirmationLength) // Calculate momentum oscillator momentum = ta.rsi(close, momentumLength) // Calculate volume average volumeAvg = ta.sma(volume, length) // Calculate volume trend confirmation isVolumeTrendingUp = ta.change(volume) > 0 and volume > volumeAvg // Calculate volatility filter volatility = ta.atr(length) volatilityThreshold = volatility * volatilityMultiplier //alert plotshape((isUptrend and (ta.crossover(high, upperBand) or momentum < oversoldLevel) or (ta.crossover(close, maConfirmation) and maConfirmation < sma and isVolumeTrendingUp) or (reversedLowerBand and isVolumeTrendingUp)), title = "Buy", text = 'Buy', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, size = size.tiny) plotshape((isDowntrend and (ta.crossunder(low,lowerBand) or momentum > overboughtLevel) or (ta.crossunder(close, maConfirmation) and maConfirmation > sma and isVolumeTrendingUp) or (reversedUpperBand and isVolumeTrendingUp)), title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, size = size.tiny) alertcondition((isUptrend and (ta.crossover(high, upperBand) or momentum < oversoldLevel) or (ta.crossover(close, maConfirmation) and maConfirmation < sma and isVolumeTrendingUp) or (reversedLowerBand and isVolumeTrendingUp)), title='Buy', message='Buy') alertcondition((isDowntrend and (ta.crossunder(low,lowerBand) or momentum > overboughtLevel) or (ta.crossunder(close, maConfirmation) and maConfirmation > sma and isVolumeTrendingUp) or (reversedUpperBand and isVolumeTrendingUp)), title='Sell', message='Sell') // Plotting plot(sma, color=color.blue, title="SMA") plot(upperBand, color=color.red, title="Upper Band") plot(lowerBand, color=color.green, title="Lower Band") plot(maConfirmation, color=color.orange, title="MA Confirmation")
Simple Ichimoku Kinko Hyo Cloud
https://www.tradingview.com/script/kFVSX9pe-Simple-Ichimoku-Kinko-Hyo-Cloud/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
20
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/ // © RozaniGhani-RG //@version=5 indicator('Simple Ichimoku Kinko Hyo Cloud', 'SIKHC', true) // 0. Inputs // 1. Type // 2. Custom Function // 3. Variables // 4. Constructs //#region ———————————————————— 0. Inputs G0 = 'Tick to hide/show and input length' boolTenkan = input.bool(true, '', group = G0, inline = '0') boolKijun = input.bool(true, '', group = G0, inline = '1') boolSenkouB = input.bool(true, '', group = G0, inline = '2') lenTenkan = input.int( 9, 'Tenkan', group = G0, inline = '0', tooltip = 'Also known as Base Line') lenKijun = input.int( 26, 'Kijun', group = G0, inline = '1', tooltip = 'Also known as Conversion Line') lenSenkouB = input.int( 52, 'Senkou B', group = G0, inline = '2', tooltip = 'Also known as Leading Span B') lenOffset = input.int( 26, 'Offset', group = G0, tooltip = 'Also known as Lagging Span.\nValue used to offset Senkou A, Senkou B and Chikou') G1 = 'Tick to hide/show' boolSenkouA = input.bool(true, 'Senkou A', group = G1, tooltip = 'Also known as Leading Span A') boolChikou = input.bool(true, 'Chikou', group = G1, tooltip = 'Also known as Close') //#endregion //#region ———————————————————— 1. Type // @type Used for range // @field upper float value for upper // @field lower float value for lower // @field sen float value for sen type rng float upper = na float lower = na float sen = na //#endregion //#region ———————————————————— 2. Custom Function // @function createRng // @param len // @returns newRng createRng(int len) => newRng = rng.new() newRng.upper := ta.highest(high, len) newRng.lower := ta.lowest( low, len) newRng.sen := math.avg(newRng.upper, newRng.lower) newRng //#endregion //#region ———————————————————— 3. Variables tenkan = createRng(lenTenkan) // Also known as Base Line kijun = createRng(lenKijun) // Also known as Conversion Line senkouA = math.avg( tenkan.sen, kijun.sen) // Also known as Leading Span A senkouB = createRng(lenSenkouB) // Also known as Leading Span B chikou = close // Also known as close //#endregion //#region ———————————————————— 4. Constructs TS = plot(boolTenkan ? tenkan.sen : na, 'Tenkan Sen') KS = plot(boolKijun ? kijun.sen : na, 'Kijun sen', color.red) SA = plot(boolSenkouA ? senkouA : na, 'Senkou A', color.teal, linewidth = 4, offset = lenOffset - 1) SB = plot(boolSenkouA ? senkouB.sen : na, 'Senkou B', color.red, linewidth = 2, offset = lenOffset - 1) PC = plot(boolChikou ? chikou : na, 'Chikou', color.green, linewidth = 4, offset = -lenOffset + 1) fill(SA, SB, senkouA > senkouB.sen ? color.new(color.teal, 90) : color.new(color.red, 90)) //#endregion
Visible Range Linear Regression Channel [vnhilton]
https://www.tradingview.com/script/Bwd3wDPL-Visible-Range-Linear-Regression-Channel-vnhilton/
vnhilton
https://www.tradingview.com/u/vnhilton/
92
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/ // © vnhilton // Inspired by TradingView's Linear Regression Channel & Visible Average Price Code //@version=5 indicator("Visible Range Linear Regression Channel [vnhilton]", "VRLRC", true) //Getting access to functions from PineCoders' "VisibleChart" library import PineCoders/VisibleChart/4 as PCVC //Parameters source = input(close, "Source") extendRightInput = input.bool(false, "Extend Lines Right", group="Display Settings") showBasis = input.bool(true, "Show Basis Line", group="Display Settings") showBands1 = input.bool(true, "", inline="Band toggles", group="Display Settings") showBands2 = input.bool(true, "", inline="Band toggles", group="Display Settings") showBands3 = input.bool(true, "Show Bands 1, 2, 3", inline="Band toggles", group="Display Settings") showFill1 = input.bool(true, "", inline="Fill toggles", group="Display Settings") showFill2 = input.bool(true, "", inline="Fill toggles", group="Display Settings") showFill3 = input.bool(true, "Show Band Fills 1, 2, 3", inline="Fill toggles", group="Display Settings") multi1 = input.float(1, "Standard Deviations 1, 2, 3", 0, inline="Standard Deviations", group="Display Settings") multi2 = input.float(2, "", 0, inline="Standard Deviations", group="Display Settings") multi3 = input.float(3, "", 0, inline="Standard Deviations", group="Display Settings") basisLineStyle = input.string("Solid", "Basis Line style", ["Arrow Right", "Dashed", "Dotted", "Solid"], group="Display Settings") bandsLineStyle = input.string("Solid", "Bands Line style", ["Arrow Right", "Dashed", "Dotted", "Solid"], group="Display Settings") widthBasis = input.int(1, "Basis Line Width", 1, group="Width Settings") widthBands1 = input.int(1, "Band Lines 1, 2, 3", 1, inline="Width Settings", group="Width Settings") widthBands2 = input.int(1, "", 1, inline="Width Settings", group="Width Settings") widthBands3 = input.int(1, "", 1, inline="Width Settings", group="Width Settings") colorBasis = input.color(color.purple, "Basis Line", group="Color Settings") colorUpper1 = input.color(color.yellow, "Upper Lines 1, 2, 3", inline="Upper Color Settings", group="Color Settings") colorUpper2 = input.color(color.orange, "", inline="Upper Color Settings", group="Color Settings") colorUpper3 = input.color(color.red, "", inline="Upper Color Settings", group="Color Settings") colorLower1 = input.color(color.yellow, "Lower Lines 1, 2, 3", inline="Lower Color Settings", group="Color Settings") colorLower2 = input.color(color.orange, "", inline="Lower Color Settings", group="Color Settings") colorLower3 = input.color(color.red, "", inline="Lower Color Settings", group="Color Settings") upperFill1 = input.color(color.new(color.yellow, 95), "Upper Band Fills 1, 2, 3", inline="Upper Fill Settings", group="Fill Settings") upperFill2 = input.color(color.new(color.orange, 95), "", inline="Upper Fill Settings", group="Fill Settings") upperFill3 = input.color(color.new(color.red, 95), "", "Ensure successive multiples are increasing for non-overlapping fills", inline="Upper Fill Settings", group="Fill Settings") lowerFill1 = input.color(color.new(color.yellow, 95), "Lower Band Fills 1, 2, 3", inline="Lower Fill Settings", group="Fill Settings") lowerFill2 = input.color(color.new(color.orange, 95), "", inline="Lower Fill Settings", group="Fill Settings") lowerFill3 = input.color(color.new(color.red, 95), "", inline="Lower Fill Settings", group="Fill Settings") //Extending lines extendStyle = switch extendRightInput => extend.right => extend.none //Line Style Selection basisStyling(choice) => switch basisLineStyle "Arrow Right" => line.style_arrow_right "Dashed" => line.style_dashed "Dotted" => line.style_dotted "Solid" => line.style_solid bandsStyling(choice) => switch bandsLineStyle "Arrow Right" => line.style_arrow_right "Dashed" => line.style_dashed "Dotted" => line.style_dotted "Solid" => line.style_solid basisStyle = basisStyling(basisLineStyle) bandsStyle = bandsStyling(bandsLineStyle) //Getting indices leftIndex = PCVC.leftBarIndex() rightIndex = PCVC.rightBarIndex() length = (rightIndex - leftIndex) + 1 //Getting prices var float[] prices = array.new<float>() leftTime = chart.left_visible_bar_time rightTime = chart.right_visible_bar_time if time >= leftTime and time <= rightTime array.push(prices, source) //Standard deviation (Sample) stddev = array.stdev(prices, false) //Least Squares Moving Average formulae function LSMA() => if not barstate.islast or length == 1 [float(na), float(na)] else sumX = 0.0 sumY = array.sum(prices) sumXSqr = 0.0 sumXY = 0.0 for i = 0 to (length - 1) x = i + 1.0 sumX += x sumXSqr += x * x sumXY += x * (array.get(prices, i)) gradient = ((length * sumXY) - (sumX * sumY)) / ((length * sumXSqr) - (sumX * sumX)) intercept = (array.avg(prices)) - (gradient * (sumX / length)) [gradient, intercept] //Getting gradient and intercept [m, c] = LSMA() //Y basis values leftY = c rightY = (m * (length - 1)) + c //Plot lines line basisLine = na line upperLine1 = na line upperLine2 = na line upperLine3 = na line lowerLine1 = na line lowerLine2 = na line lowerLine3 = na if not na(leftY) if showBasis basisLine := line.new(leftIndex, leftY, rightIndex, rightY, extend=extendStyle, color=colorBasis, style=basisStyle, width=widthBasis) if showBands1 upperLine1 := line.new(leftIndex, leftY + (stddev * multi1), rightIndex, rightY + (stddev * multi1), extend=extendStyle, color=colorUpper1, style=bandsStyle, width=widthBands1) lowerLine1 := line.new(leftIndex, leftY - (stddev * multi1), rightIndex, rightY - (stddev * multi1), extend=extendStyle, color=colorLower1, style=bandsStyle, width=widthBands1) if showBands2 upperLine2 := line.new(leftIndex, leftY + (stddev * multi2), rightIndex, rightY + (stddev * multi2), extend=extendStyle, color=colorUpper2, style=bandsStyle, width=widthBands2) lowerLine2 := line.new(leftIndex, leftY - (stddev * multi2), rightIndex, rightY - (stddev * multi2), extend=extendStyle, color=colorLower2, style=bandsStyle, width=widthBands2) if showBands3 upperLine3 := line.new(leftIndex, leftY + (stddev * multi3), rightIndex, rightY + (stddev * multi3), extend=extendStyle, color=colorUpper3, style=bandsStyle, width=widthBands3) lowerLine3 := line.new(leftIndex, leftY - (stddev * multi3), rightIndex, rightY - (stddev * multi3), extend=extendStyle, color=colorLower3, style=bandsStyle, width=widthBands3) //Plot fills linefill upperBand1Fill = na linefill upperBand2Fill = na linefill upperBand3Fill = na linefill lowerBand1Fill = na linefill lowerBand2Fill = na linefill lowerBand3Fill = na if showFill1 upperBand1Fill := linefill.new(basisLine, upperLine1, upperFill1) lowerBand1Fill := linefill.new(basisLine, lowerLine1, lowerFill1) if showFill2 upperBand2Fill := linefill.new(upperLine1, upperLine2, upperFill2) lowerBand2Fill := linefill.new(lowerLine1, lowerLine2, lowerFill2) if showFill3 upperBand3Fill := linefill.new(upperLine2, upperLine3, upperFill3) lowerBand3Fill := linefill.new(lowerLine2, lowerLine3, lowerFill3)
Monday_Weekly_Range/ErkOzi/Deviation Level/V1
https://www.tradingview.com/script/ih9L87Sb/
ErkOzi
https://www.tradingview.com/u/ErkOzi/
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/ // © ErkOzi //@version=5 indicator(title='Monday_Weekly_Range/ErkOzi/Deviation Level/V1', shorttitle='Monday_Range/ErkOzi', overlay=true) // holds the daily price levels openPrice = request.security(syminfo.tickerid, 'D', open) highPrice = request.security(syminfo.tickerid, 'D', high) lowPrice = request.security(syminfo.tickerid, 'D', low) midPrice = math.avg(highPrice, lowPrice) //function which is called by plot to establish if it is Monday isMonday() => dayofweek(time) == dayofweek.monday ? 1 : 0 // store the Monday range levels var float mondayHighRange = na var float mondayLowRange = na if isMonday() mondayHighRange := highPrice mondayLowRange := lowPrice mondayLowRange // plot the Monday levels plot(isMonday() and midPrice ? midPrice : na, title='Monday Eq / midPrice', style=plot.style_circles, linewidth=2, color=color.new(color.black, 0)) plot(isMonday() and openPrice ? openPrice : na, title='Monday Eq / openPrice', style=plot.style_circles, linewidth=2, color=color.new(color.purple, 0)) plot(isMonday() and highPrice ? highPrice : na, title='Monday High', style=plot.style_circles, linewidth=2, color=color.new(color.green, 0)) plot(isMonday() and lowPrice ? lowPrice : na, title='Monday Low', style=plot.style_circles, linewidth=2, color=color.new(color.green, 0)) // extend the lines until the next Monday var float nextMondayHigh = na var float nextMondayLow = na if isMonday() nextMondayHigh := highPrice nextMondayLow := lowPrice nextMondayLow else nextMondayHigh := nz(nextMondayHigh[1], mondayHighRange) nextMondayLow := nz(nextMondayLow[1], mondayLowRange) nextMondayLow plot(nextMondayHigh, title='Next Monday High Range', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0)) plot(nextMondayLow, title='Next Monday Low Range', style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0)) // plot the 0.50 line plot((nextMondayHigh + nextMondayLow) / 2, title='0.50', style=plot.style_linebr, linewidth=1, color=color.new(color.red, 0)) // Calculate Fibonacci levels fib272 = nextMondayHigh + 0.272 * (nextMondayHigh - nextMondayLow) fib414 = nextMondayHigh + 0.414 * (nextMondayHigh - nextMondayLow) fib500 = nextMondayHigh + 0.5 * (nextMondayHigh - nextMondayLow) fib618 = nextMondayHigh + 0.618 * (nextMondayHigh - nextMondayLow) fibNegative272 = nextMondayLow - 0.272 * (nextMondayHigh - nextMondayLow) fibNegative414 = nextMondayLow - 0.414 * (nextMondayHigh - nextMondayLow) fibNegative500 = nextMondayLow - 0.5 * (nextMondayHigh - nextMondayLow) fibNegative618 = nextMondayLow - 0.618 * (nextMondayHigh - nextMondayLow) fibNegative1 = nextMondayLow - 1 * (nextMondayHigh - nextMondayLow) fib2 = nextMondayHigh + 1 * (nextMondayHigh - nextMondayLow) // Plot Fibonacci levels plot(fib272, title='0.272 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.blue, 0)) plot(fib414, title='0.414 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.blue, 0)) plot(fib500, title='0.500 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.red, 0)) plot(fib618, title='0.618 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.yellow, 0)) plot(fibNegative272, title='-0.272 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.blue, 0)) plot(fibNegative414, title='-0.414 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.blue, 0)) plot(fibNegative500, title='-0.500 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.red, 0)) plot(fibNegative618, title='-0.618 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.yellow, 0)) plot(fibNegative1, title='-1 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.white, 0)) plot(fib2, title='1 Fibonacci', style=plot.style_linebr, linewidth=1, color=color.new(color.white, 0)) // Calculate the values for lines 0.25 above and below var float lineAbove = na var float lineBelow = na lineAbove := (nextMondayHigh + nextMondayLow) / 2 + 0.25 * (nextMondayHigh - nextMondayLow) lineBelow := (nextMondayHigh + nextMondayLow) / 2 - 0.25 * (nextMondayHigh - nextMondayLow) // Plot lines 0.25 above and below with dashed line style plot(lineAbove, title='0.25 Above', color=color.new(color.yellow, 0), linewidth=0, style=plot.style_circles) plot(lineBelow, title='0.25 Below', color=color.new(color.yellow, 0), linewidth=0, style=plot.style_circles)
Simple Ultimate Oscillator
https://www.tradingview.com/script/JNuk1mF6-Simple-Ultimate-Oscillator/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
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/ // © RozaniGhani-RG //@version=5 indicator('Simple Ultimate Oscillator', 'SUO', false, format.price, precision=2, timeframe="", timeframe_gaps=true) // 0. Inputs // 1. Type // 2. Custom Function // 3. Variables // 4. Constructs //#region ———————————————————— 0. Inputs lenFast = input.int( 7, 'Fast', minval = 1) lenMid = input.int(14, 'Middle', minval = 1) lenSlow = input.int(28, 'Slow', minval = 1) //#endregion //#region ———————————————————— 1. Type // @type Used for hl // @field max float value for max // @field min float value for min // @field bp float value for bp // @field tr float value for tr type hl float max = na float min = na float bp = na float tr = na //#endregion //#region ———————————————————— 2. Custom Function // @function calculate average price from UO variable // @param common, len // @returns average price from UO variable createUoVar(hl common = na, int len = na) => math.sum(common.bp, len) / math.sum(common.tr, len) //#endregion //#region ———————————————————— 3. Variables common = hl.new() common.max := math.max(high, close[1]) common.min := math.min( low, close[1]) common.bp := close - common.min common.tr := common.max - common.min uoFast = createUoVar(common, lenFast) uoMid = createUoVar(common, lenMid) uoSlow = createUoVar(common, lenSlow) uo = 100 * (4*uoFast + 2*uoMid + uoSlow) / 7 //#endregion //#region ———————————————————— 4. Constructs p_UO = plot( uo, 'UO', chart.fg_color, 2) UO050 = hline( 50, 'Middle Line', color.silver, hline.style_dashed, 2, false) OB100 = hline(100, 'OVERBOUGHT', color.red, hline.style_solid, 1, false, display.none) OB070 = hline( 70, 'OVERBOUGHT', color.red, hline.style_solid, 1, false, display.none) OS030 = hline( 30, 'OVERSOLD', color.red, hline.style_solid, 1, false, display.none) OS000 = hline( 0, 'OVERSOLD', color.red, hline.style_solid, 1, false, display.none) fill(OB070, OB100, color.new(color.red, 90), 'OVERBOUGHT') fill(OS000, OS030, color.new(color.lime, 90), 'OVERSOLD') //#endregion
Liquidity Proxy : China
https://www.tradingview.com/script/M6OU4tpa-Liquidity-Proxy-China/
dharmatech
https://www.tradingview.com/u/dharmatech/
39
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/ // © dharmatech //@version=5 indicator("Liquidity Proxy : China", overlay = false, timeframe = "M") // ECONOMICS:CNCBBS+ECONOMICS:CNM1+ECONOMICS:CNFER-ECONOMICS:CNGRES line_cbbs = request.security("ECONOMICS:CNCBBS", "M", close) line_m1 = request.security("ECONOMICS:CNM1", "M", close) line_fer = request.security("ECONOMICS:CNFER", "M", close) line_gres = request.security("ECONOMICS:CNGRES", "M", close) line_sse = request.security("SSE:000001", "M", close) total = line_cbbs + line_m1 + line_fer - line_gres yoy_chg_pct = (total - total[12]) / total[12] sse_yoy_chg_pct = (line_sse - line_sse[12]) / line_sse[12] // plot(series=yoy_chg_pct*10-0.5, title = 'Proxy YoY Change %', color = color.red) plot(series=yoy_chg_pct*9-0.5, title = 'Proxy YoY Change %', color = color.red) plot(series=sse_yoy_chg_pct, title = 'SSE YoY Change %', color = color.green)
Regularized-Moving-Average Oscillator Suite
https://www.tradingview.com/script/LAFDETZX-Regularized-Moving-Average-Oscillator-Suite/
QuantiLuxe
https://www.tradingview.com/u/QuantiLuxe/
342
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/ // © EliCobra //@version=5 indicator("Regularized-MA Oscillator Suite", "{Ʌ} - MA Osc. Suite", false) f_kama(src, len, kamaf, kamas) => white = math.abs(src - src[1]) ama = 0.0 nsignal = math.abs(src - src[len]) nnoise = math.sum(white, len) nefratio = nnoise != 0 ? nsignal / nnoise : 0 nsmooth = math.pow(nefratio * (kamaf - kamas) + kamas, 2) ama := nz(ama[1]) + nsmooth * (src - nz(ama[1])) ama f_t3(src, len) => x1 = ta.ema(src, len) x2 = ta.ema(x1, len) x3 = ta.ema(x2, len) x4 = ta.ema(x3, len) x5 = ta.ema(x4, len) x6 = ta.ema(x5, len) b = 0.7 c1 = - math.pow(b, 3) c2 = 3 * math.pow(b, 2) + 3 * math.pow(b, 3) c3 = -6 * math.pow(b, 2) - 3 * b - 3 * math.pow(b, 3) c4 = 1 + 3 * b + math.pow(b, 3) + 3 * math.pow(b, 2) c1 * x6 + c2 * x5 + c3 * x4 + c4 * x3 f_ehma(src, length) => ta.ema(2 * ta.ema(src, length / 2) - ta.ema(src, length), math.round(math.sqrt(length))) f_thma(src, length) => ta.wma(ta.wma(src, length / 3) * 3 - ta.wma(src, length / 2) - ta.wma(src, length), length) f_tema(src, len) => x = ta.ema(src, len) y = ta.ema(x, len) z = ta.ema(y, len) 3 * x - 3 * y + z f_dema(src, len) => x = ta.ema(src, len) y = ta.ema(x, len) 2 * x - y f_ma(src, len, type, kamaf, kamas, offset, sigma) => x = switch type "SMA" => ta.sma(src, len) "EMA" => ta.ema(src, len) "HMA" => ta.hma(src, len) "RMA" => ta.rma(src, len) "WMA" => ta.wma(src, len) "VWMA" => ta.vwma(src, len) "ALMA" => ta.alma(src, len, offset, sigma) "DEMA" => f_dema(src, len) "TEMA" => f_tema(src, len) "EHMA" => f_ehma(src, len) "THMA" => f_thma(src, len) "T3" => f_t3(src, len) "KAMA" => f_kama(src, len, kamaf, kamas) "LSMA" => ta.linreg(src, len, 0) x matype = input.string("EMA", "Type", ["SMA", "EMA", "DEMA", "TEMA", "HMA", "EHMA", "THMA", "RMA", "WMA", "VWMA", "T3", "KAMA", "ALMA", "LSMA"], group = "MA Settings") src = input.source(close, "Source", inline = "1", group = "MA Settings") len = input.int(14, "Length", inline = "1", group = "MA Settings") kamaf = input.float(0.666, "Kaufman Fast", group = "MA Settings") kamas = input.float(0.0645, "Kaufman Slow", group = "MA Settings") offset = input.float(0.85, "ALMA Offset", group = "MA Settings") sigma = input.int(6, "ALMA Sigma", group = "MA Settings") norm = input.int(30, "Regularize Length", group = "Oscillator Settings") revt = input.int(3, "Reversion Threshold", options = [1, 2, 3], group = "Oscillator Settings") revshow = input.bool(true, "Show Reversal Signals", group = "UI Options") colbar = input.string("None", "Bar Coloring", ["None", "Trend", "Extremities", "Reversions", "Slope"], group = "UI Options") ma = f_ma(src, len, matype, kamaf, kamas, offset, sigma) mean = ta.sma(ma, norm) dev = ta.stdev(ma, norm) zmean = (ma - mean) / dev hline(0, "Mid Line", #ffffff80, hline.style_solid) max = hline(4, display = display.none) hh = hline(3, display = display.none) lh = hline(2, display = display.none) fill(lh, hh, color = #bb001028) fill(hh, max, color = #bb00104d) min = hline(-4, display = display.none) ll = hline(-3, display = display.none) hl = hline(-2, display = display.none) fill(ll, hl, color = #00b35128) fill(ll, min, color = #00b35144) z = plot(zmean, "Z", zmean > 0 ? #00b350 : #bb0010) mid = plot(0, display = display.none, editable = false) fill(z, mid, zmean > 0 ? zmean : 0, zmean > 0 ? 0 : zmean, zmean > 0 ? #00b351a1 : #00000000, zmean > 0 ? #00000000 : #bb0010b9) plotchar(revshow ? zmean > revt and zmean < zmean[1] and not (zmean[1] < zmean[2]) ? zmean + 0.5 : na : na, "OB", "⚬", location.absolute, #bb0010, size = size.tiny) plotchar(revshow ? zmean < -revt and zmean > zmean[1] and not (zmean[1] > zmean[2]) ? zmean - 0.5 : na : na, "OS", "⚬", location.absolute, #00b350, size = size.tiny) color col = switch colbar "None" => na "Trend" => zmean > 0 ? #00b350 : #bb0010 "Extremities" => zmean > 2 ? #00b350 : zmean < -2 ? #bb0010 : #b3b3b3c2 "Reversions" => zmean > revt and zmean < zmean[1] and not (zmean[1] < zmean[2]) ? #bb0010 : zmean < -revt and zmean > zmean[1] and not (zmean[1] > zmean[2]) ? #00b350 : #b3b3b3c2 "Slope" => zmean > zmean[1] ? #00b350 : #bb0010 barcolor(col) if zmean < -revt and zmean > zmean[1] and not (zmean[1] > zmean[2]) alert("OverSold") if zmean > revt and zmean < zmean[1] and not (zmean[1] < zmean[2]) alert("OverBought")
Logarithmic Volatility
https://www.tradingview.com/script/PRGiVQQm/
gvcinstitute
https://www.tradingview.com/u/gvcinstitute/
30
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/ // © gvcinstitute //@version=5 indicator("Logarithmic Volatility") high_t = math.log(high)- math.log(open) low_t = math.log(low)- math.log(open) close_t = math.log(close)- math.log(open) vol_t = math.sqrt(0.5 * math.pow((high_t - low_t), 2) - (2 * math.log(2) - 1) * math.pow(close_t,2)) slow_length = input(21, title="Slow EMA Length") fast_length = input(9, title="Fast EMA Length") media_length = input(14, title="Media EMA Length") slow = ta.ema(vol_t, slow_length) fast = ta.ema(vol_t, fast_length) // Añadimos la nueva media media = ta.ema(vol_t, media_length) color_media = fast < slow ? color.green : color.red plot(media, color=color_media, linewidth=2) // Grosor de la línea definido en 3 plot(media, color=color_media, style=plot.style_histogram, linewidth=2)
CANDLE STICK HEATMAP
https://www.tradingview.com/script/f5GmZiTY-CANDLE-STICK-HEATMAP/
traderharikrishna
https://www.tradingview.com/u/traderharikrishna/
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/ // © traderharikrishna //@version=5 indicator("CANDLE STICK HEATMAP",overlay=true) bullco=input.color(color.green,'', group='Log',inline='1') bearco=input.color(color.red,'', group='Log',inline='1') txtco=input.color(color.white,'', group='Log',inline='1') hide=input.bool(true,'Indicator Stats') log_show_msg = input.int(60, title='Candles to show', group='Log')//rows col= input.int(12, title='Split', group='Log')//rows log_offset = input.int(0, title='# Candles offset', group='Log', step=1) //geo=input.string("Asia/Kolkata",'TimeZone',options=['Asia/Kolkata','America/New_York'],tooltip='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones') geo=input.string("GMT+5:30", "Timezone", options=["GMT+0", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+5:30","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","GMT-1", "GMT-2", "GMT-3","GMT-4","GMT-5","GMT-6","GMT-7","GMT-8","GMT-9","GMT-10","GMT-11","GMT-12"]) format= "yyyy-MM-dd" format2='HH:mm' tm=str.tostring(str.format_time( time(timeframe.period, '', ''),format,geo)) tm:=tm+'\n'+str.tostring(str.format_time( time(timeframe.period, '', ''),format2,geo)) malen=input.int(200,'EMA Length') ma=ta.ema(close,malen) plot(ma,color=color.blue,linewidth=4,title = 'EMA200') var bar_arr = array.new_int(0) var time_arr = array.new_string(0) var msg_arr = array.new_string(0) var type_arr = array.new_string(0) log_msg(message, type, times) => array.push(bar_arr, bar_index) array.push(time_arr,times) array.push(msg_arr, message) array.push(type_arr, type) msg()=> rsi=ta.rsi(close,14) [p,m,adx]=ta.dmi(14,14) [macd,signal,hist]=ta.macd(close,12,26,9) vma=ta.ema(volume,20) updn=close>ma?'upTrend':'DnTrend' msg='\n----\n'+str.tostring(updn)+'\n' msg:=msg+'RSI:'+str.tostring(math.round(rsi))+'\n' msg:=msg+'ADX:'+str.tostring(math.round(adx))+'\n' msg:=msg+'MACD:'+str.tostring(hist>0?'UP':'DN')+'\n' msg:=msg+'Vol:'+str.tostring(volume>vma?'Good':'Low') msg if open<close log_msg(hide?msg():na,'bullish',tm) if open>close log_msg(hide?msg():na,'bearish',tm) /////////////////////////////////// // 2. Create and fill log table // var log_tbl = table.new(position.bottom_right, log_show_msg +1, col+1, border_width=1) if barstate.islast for i = 1 to log_show_msg by 1 arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset if arr_i < 0 break type = array.get(type_arr, arr_i) msg_color = type =='bullish'? bullco :type =='bearish'?bearco :type == 'message' ? #a19f9f :type == 'warning' ? #F5AC4E :type == 'error' ? #2996fe :type == 'buy' ? #03a903 :type == 'sell' ? #ff0000 :color.gray for e=0 to col if i>col*e and i<=col*e+col ///table.cell(log_tbl,i-col*e, e,str.tostring(i)+','+str.tostring(0) +'\n'+ array.get(time_arr, arr_i), bgcolor=msg_color, text_size=size.small,text_color=color.white) table.cell(log_tbl,i-col*e, e, array.get(time_arr, arr_i)+array.get(msg_arr, arr_i)+'\n', bgcolor=msg_color, text_size=size.small,text_color=txtco)
Trend Reversal Indicator (Bull/Bear)
https://www.tradingview.com/script/q87gRfGA-Trend-Reversal-Indicator-Bull-Bear/
Crunchster1
https://www.tradingview.com/u/Crunchster1/
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/ // © Crunchster1 //@version=5 indicator("Trend Reversal Indicator (Bull/Bear)", shorttitle="TRI", timeframe="W", timeframe_gaps=false) length = input.int(52, 'Momo length (slow MA)', inline='01') flength = input.int(13, 'Fast MA length', inline='01') price = close momentum(seria, length) => mom = seria[1] - seria[length + 1] mom mom0 = momentum(price, length) mom1 = momentum(price, flength) mom0n = mom0 / ta.ema(mom0, length) mom1n = mom1 / ta.ema(mom1, flength) s_mom0n = math.sign(mom0) * 2 s_mom1n = math.sign(mom1) signal = s_mom0n + s_mom1n smaMom = ta.sma(mom0[1], length) fmaMom = ta.sma(mom0[1], flength) bull = signal > 1 corr = signal > 0 and signal <= 1 bear = signal < -1 rebnd = signal < 0 and signal >= -1 plot(mom0n, 'Normalised Slow Momentum', color=color.blue, display=display.none) plot(signal, 'Signal', color = (bull ? color.green : corr ? color.yellow : rebnd ? color.orange : bear ? color.red : na), style = plot.style_area) plot(smaMom, 'sMA Momentum', color=color.rgb(20, 164, 20), display=display.none) plot(fmaMom, 'fMA Momentum', color=color.rgb(13, 14, 13), display=display.none) hline(0, "Middle Band", color=color.new(#787B86, 50))
Volume Spread Analysis Candle Patterns
https://www.tradingview.com/script/0Cl7mEzy-Volume-Spread-Analysis-Candle-Patterns/
deepu0010
https://www.tradingview.com/u/deepu0010/
71
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/ // © deepu0010 //@version=4 study(title="Volume Spread Analysis Candle Patterns", shorttitle="VSA Candle Patterns", overlay=true) // Define the inputs barColorUp = input(color.green, title="Up Bar Color") barColorDown = input(color.red, title="Down Bar Color") barColorNeutral = input(color.gray, title="Neutral Bar Color") barWidth = input(2, title="Bar Width") ultraHighVolumeThreshold = input(500000, title="Ultra High Volume Threshold") // Calculate the spread spread = high - low // Determine the bar color based on spread barColor = spread > spread[1] ? barColorUp : (spread < spread[1] ? barColorDown : barColorNeutral) // Calculate the buying and selling volume buyVolume = barColor == barColorUp ? volume : 0 sellVolume = barColor == barColorDown ? volume : 0 // Calculate the cumulative buying and selling volume cumulativeBuyVolume = cum(buyVolume) cumulativeSellVolume = cum(sellVolume) // Determine VSA candle patterns noDemand = close < open and volume < volume[1] noSupply = close > open and volume < volume[1] hiddenBuying = close > open and volume > volume[1] and close == high hiddenSelling = close < open and volume > volume[1] and close == low upThrust = high > high[1] and close < low[1] and close < open[1] and close < (low[1] + high[1]) / 2 spring = low < low[1] and close > low[1] and close > open[1] and close > (low[1] + high[1]) / 2 ultraHighVolume = volume > ultraHighVolumeThreshold // Plotting the bars and VSA candle patterns plot(spread, title="Spread", color=barColor, linewidth=barWidth) // Plotting VSA candle patterns on the chart plotshape(noDemand, title="No Demand", style=shape.labelup, location=location.abovebar, color=color.blue, text="ND") plotshape(noSupply, title="No Supply", style=shape.labeldown, location=location.belowbar, color=color.orange, text="NS") plotshape(hiddenBuying, title="Hidden Buying", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small) plotshape(hiddenSelling, title="Hidden Selling", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) plotshape(upThrust, title="Upthrust", style=shape.triangleup, location=location.belowbar, color=color.purple, size=size.small) plotshape(spring, title="Spring", style=shape.triangledown, location=location.abovebar, color=color.teal, size=size.small) plotshape(ultraHighVolume, title="Ultra High Volume", style=shape.diamond, location=location.belowbar, color=color.yellow, size=size.small)
VWAP Reset Zones
https://www.tradingview.com/script/JoQo9get/
Demech
https://www.tradingview.com/u/Demech/
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/ // © Demech //@version=5 // The indicator function initializes the indicator settings. indicator(title="VWAP Reset Zones", shorttitle="VWAP RZ", overlay = true, timeframe = "", timeframe_gaps = false) //VWAP 1 // Input options for the anchor period var anchor = input.string(defval = "Session", title="Anchor Period", options=["None", "Session", "Week", "Month", "Year"], group="VWAP 1 Settings") // Source is set to the close price of the bar src = input(title = "Source", defval = close, group="VWAP 1 Settings") // Source 2 is set to the open price of the bar src2 = input(title = "Source 2", defval = open, group="VWAP 1 Settings") // Checkboxes for Band values Resetzone = input(true, title="Reset Zone", group="VWAP 1 Settings", inline="Reset Zone") Startzone = input(true, title="Start Zone", group="VWAP 1 Settings", inline="Start Zone") Band_1 = input(false, title="", group="VWAP 1 Settings", inline="band_1") Zones_1 = input(true, title = "Zones 1", group="VWAP 1 Settings", inline="Zones_1") Band_2 = input(false, title="", group="VWAP 1 Settings", inline="band_2") Zones_2 = input(true, title = "Zones 2", group="VWAP 1 Settings", inline="Zones_2") Band_3 = input(false, title="", group="VWAP 1 Settings", inline="band_3") Zones_3 = input(true, title = "Zones 3", group="VWAP 1 Settings", inline="Zones_3") stdevMult_1 = input(1.618, title="Bands 1", group="VWAP 1 Settings", inline="band_1") stdevMult_2 = input(2.618, title="Bands 2", group="VWAP 1 Settings", inline="band_2") stdevMult_3 = input(3.618, title="Bands 3", group="VWAP 1 Settings", inline="band_3") // Check for availability of volume data if barstate.islast and ta.cum(volume) == 0 runtime.error("No volume is provided by the data vendor.") // Define timeframes for calculating VWAP isNewPeriod = switch anchor "Session" => timeframe.change("D") "Week" => timeframe.change("W") "Month" => timeframe.change("M") "Year" => timeframe.change("12M") => false // Initialize VWAP values float vwapValue = na float vwapValue2 = na float upperBandValue1 = na float lowerBandValue1 = na float upperBandValue2 = na float lowerBandValue2 = na float upperBandValue3 = na float lowerBandValue3 = na float upperBandValue1o = na float lowerBandValue1o = na float upperBandValue2o = na float lowerBandValue2o = na float upperBandValue3o = na float lowerBandValue3o = na // Calculate VWAP values [_vwap, _stdevUpper, _] = ta.vwap(src, isNewPeriod, 1) [_vwap2, _stdevUpper2, _] = ta.vwap(src2, isNewPeriod, 1) stdev = _stdevUpper - _vwap stdevc = _stdevUpper2 - _vwap2 vwapValue := _vwap vwapValue2 := _vwap2 upperBandValue1 := _vwap + stdev * stdevMult_1 lowerBandValue1 := _vwap - stdev * stdevMult_1 upperBandValue2 := _vwap + stdev * stdevMult_2 lowerBandValue2 := _vwap - stdev * stdevMult_2 upperBandValue3 := _vwap + stdev * stdevMult_3 lowerBandValue3 := _vwap - stdev * stdevMult_3 upperBandValue1o := _vwap2 + stdevc * stdevMult_1 lowerBandValue1o := _vwap2 - stdevc * stdevMult_1 upperBandValue2o := _vwap2 + stdevc * stdevMult_2 lowerBandValue2o := _vwap2 - stdevc * stdevMult_2 upperBandValue3o := _vwap2 + stdevc * stdevMult_3 lowerBandValue3o := _vwap2 - stdevc * stdevMult_3 // Define colors for plot upper_color = input(color.new (color.rgb(0, 255, 8), 0),"bull") lower_color = input(color.new (color.rgb(255, 0, 0), 0),"bear") resetcolor = input(color.new (color.yellow, 0), "Reset VWAP1", group="VWAP 1 Settings", inline="Reset Zone") startzone = input(color.new (color.blue, 0), "Reset VWAP1", group="VWAP 1 Settings", inline="Start Zone") zone1lower = input(color.new(color.gray, 50), "VWAP 1 Lower Zone 1", group="VWAP 1 Settings", inline="Zones_1") zone2lower = input(color.new(color.gray, 50), "VWAP 1 Lower Zone 2", group="VWAP 1 Settings", inline="Zones_2") zone3lower = input(color.new(color.gray, 50), "VWAP 1 Lower Zone 3", group="VWAP 1 Settings", inline="Zones_3") zone1upper = input(color.new(color.gray, 50), "VWAP 1 Upper Zone 1", group="VWAP 1 Settings", inline="Zones_1") zone2upper = input(color.new(color.gray, 50), "VWAP 1 Upper Zone 2", group="VWAP 1 Settings", inline="Zones_2") zone3upper = input(color.new(color.gray, 50), "VWAP 1 Upper Zone 3", group="VWAP 1 Settings", inline="Zones_3") // Plot VWAP lines and fill area between them linecolor = _vwap > _vwap2 ? upper_color : lower_color w1 = plot(vwapValue, title="VWAP 1 Source 1", color=linecolor) w2 = plot(vwapValue2, title="VWAP 1 Source 2", color=linecolor) fillcolor = _vwap > _vwap2 ? upper_color : lower_color fill(w1, w2, color=fillcolor, title = "Fill VWAP 1") // Plot Bands b1 = plot(upperBandValue1, title="Upper Band Close 1 VWAP 1", color=color.new(color.red, 100)) b3 = plot(upperBandValue2, title="Upper Band Close 2 VWAP 1", color=color.new(color.red, 100)) b5 = plot(upperBandValue3, title="Upper Band Close 3 VWAP 1", color=color.new(color.red, 100)) b7 = plot(lowerBandValue1, title="Lower Band Close 1 VWAP 1", color=color.new(color.green, 100)) b9 = plot(lowerBandValue2, title="Lower Band Close 2 VWAP 1", color=color.new(color.green, 100)) b11 = plot(lowerBandValue3, title="Lower Band Close 3 VWAP 1", color=color.new(color.green, 100)) var float lastVWAPValue = na var float lastVWAPValue2 = na var float lastUpperBandValue1 = na var float lastLowerBandValue1 = na var float lastUpperBandValue2 = na var float lastLowerBandValue2 = na var float lastUpperBandValue3 = na var float lastLowerBandValue3 = na var float lastUpperBandValue1o = na var float lastLowerBandValue1o = na var float lastUpperBandValue2o = na var float lastLowerBandValue2o = na var float lastUpperBandValue3o = na var float lastLowerBandValue3o = na var float closing_vwapValuee = na var float closing_vwapValue2e = na if isNewPeriod lastVWAPValue := vwapValue[1] lastVWAPValue2 := vwapValue2[1] closing_vwapValuee := vwapValue closing_vwapValue2e := vwapValue2 lastUpperBandValue1 := upperBandValue1[1] lastLowerBandValue1 := lowerBandValue1[1] lastUpperBandValue2 := upperBandValue2[1] lastLowerBandValue2 := lowerBandValue2[1] lastUpperBandValue3 := upperBandValue3[1] lastLowerBandValue3 := lowerBandValue3[1] lastUpperBandValue1o := upperBandValue1o[1] lastLowerBandValue1o := lowerBandValue1o[1] lastUpperBandValue2o := upperBandValue2o[1] lastLowerBandValue2o := lowerBandValue2o[1] lastUpperBandValue3o := upperBandValue3o[1] lastLowerBandValue3o := lowerBandValue3o[1] // Plot today's closing VWAP values p1 = plot(lastVWAPValue, color=color.new(color.yellow, 100), title = "last Period close VWAP 1", display = Resetzone ? display.all : display.none) p2 = plot(lastVWAPValue2, color=color.new(color.yellow, 100), title = "last Period open VWAP 1", display = Resetzone ? display.all : display.none) fill(p1, p2, color=resetcolor ,title = "last Period VWAP 1", display = Resetzone ? display.all : display.none) // Fill area between today's closing VWAP lines p3 = plot(closing_vwapValuee, color=color.new(color.blue, 100), title = "start new Persiod close VWAP 1", display = Startzone ? display.all : display.none) p4 = plot(closing_vwapValue2e, color=color.new(color.blue, 100), title = "start new Persiod open VWAP 1", display = Startzone ? display.all : display.none) fill(p3, p4, color=startzone, title = "Fill Start New Periode VWAP 1", display = Startzone ? display.all : display.none) // Fill area between today's closing VWAP lines // Plot today's closing VWAP Band Zones values p5 = plot(lastLowerBandValue1, color=color.new(color.gray, 100), title = "Lower Band Close VWAP 1", display = Zones_1 ? display.all : display.none) p6 = plot(lastLowerBandValue1o, color=color.new(color.gray, 100), title = "Lower Band Open VWAP 1", display = Zones_1 ? display.all : display.none) fill(p5, p6, color=zone1lower, display = Zones_1 ? display.all : display.none , title = "Fill Lower Zone 1 VWAP 1") // Fill area between today's closing VWAP lines p7 = plot(lastLowerBandValue2, color=color.new(color.gray, 100), title = "Lower Band 2 Close VWAP 1", display = Zones_2 ? display.all : display.none) p8 = plot(lastLowerBandValue2o, color=color.new(color.gray, 100), title = "Lower Band 2 Open VWAP 1", display = Zones_2 ? display.all : display.none) fill(p7, p8, color=zone2lower, display = Zones_2 ? display.all : display.none, title = "Fill Lower Zone 2 VWAP 1") // Fill area between today's closing VWAP lines p9 = plot(lastLowerBandValue3, color=color.new(color.gray, 100), title = "Lower Band 3 Close VWAP 1", display = Zones_3 ? display.all : display.none) p10 = plot(lastLowerBandValue3o, color=color.new(color.gray, 100), title = "Lower Band 3 Open VWAP 1", display = Zones_3 ? display.all : display.none) fill(p9, p10, color=zone3lower, display = Zones_3 ? display.all : display.none, title = "Fill Lower Zone 3 VWAP 1") // Fill area between today's closing VWAP lines p11 = plot(lastUpperBandValue1, color=color.new(color.gray, 100), title = "Upper Band Close VWAP 1", display = Zones_1 ? display.all : display.none) p12 = plot(lastUpperBandValue1o, color=color.new(color.gray, 100), title = "Upper Band Open VWAP 1", display = Zones_1 ? display.all : display.none) fill(p11, p12, color=zone1upper, display = Zones_1 ? display.all : display.none, title = "Fill Upper Zone 1 VWAP 1") // Fill area between today's closing VWAP lines p13 = plot(lastUpperBandValue2, color=color.new(color.gray, 100), title = "Upper Band 2 Close VWAP 1", display = Zones_2 ? display.all : display.none) p14 = plot(lastUpperBandValue2o, color=color.new(color.gray, 100), title = "Upper Band 2 Open VWAP 1",display = Zones_2 ? display.all : display.none) fill(p13, p14, color=zone2upper, display = Zones_2 ? display.all : display.none, title = "Fill Upper Zone 2 VWAP 1") // Fill area between today's closing VWAP lines p15 = plot(lastUpperBandValue3, color=color.new(color.gray, 100), title = "Upper Band 3 Close VWAP 1", display = Zones_3 ? display.all : display.none) p16= plot(lastUpperBandValue3o, color=color.new(color.gray, 100), title = "Upper Band 3 Open VWAP 1", display = Zones_3 ? display.all : display.none) fill(p15, p16, color=zone3upper, display = Zones_3 ? display.all : display.none, title = "Fill Upper Zone 3 VWAP 1") // Fill area between today's closing VWAP lines // Plot VWAP Band values upperBand_1 = plot(upperBandValue1, title="Upper Band VWAP 1 #1", color=color.green, display = Band_1 ? display.all : display.none) lowerBand_1 = plot(lowerBandValue1, title="Lower Band VWAP 1 #1", color=color.green, display = Band_1 ? display.all : display.none) upperBand_2 = plot(upperBandValue2, title="Upper Band VWAP 1 #2", color=color.olive, display = Band_2 ? display.all : display.none) lowerBand_2 = plot(lowerBandValue2, title="Lower Band VWAP 1#2", color=color.olive, display = Band_2 ? display.all : display.none) upperBand_3 = plot(upperBandValue3, title="Upper Band VWAP 1 #3", color=color.teal, display = Band_3 ? display.all : display.none) lowerBand_3 = plot(lowerBandValue3, title="Lower Band VWAP 1 #3", color=color.teal, display = Band_3 ? display.all : display.none) // Fill Bands fill(w1, upperBand_1, title="Bands Fill VWAP 1 #1", color= color.new(color.green, 95) , display = Band_1 ? display.all : display.none) fill(w1, lowerBand_1, title="Bands Fill VWAP 1 #1", color= color.new(color.green, 95) , display = Band_1 ? display.all : display.none) fill(upperBand_1, upperBand_2, title="Bands Fill VWAP 1 #2", color= color.new(color.olive, 95) , display = Band_2 ? display.all : display.none) fill(lowerBand_1, lowerBand_2, title="Bands Fill VWAP 1 #2", color= color.new(color.olive, 95) , display = Band_2 ? display.all : display.none) fill(upperBand_2, upperBand_3, title="Bands Fill VWAP 1 #3", color= color.new(color.teal, 95) , display = Band_3 ? display.all : display.none) fill(lowerBand_2, lowerBand_3, title="Bands Fill VWAP 1 #3", color= color.new(color.teal, 95) , display = Band_3 ? display.all : display.none) //VWAP 2 // Input options for the anchor period var anchor2 = input.string(defval = "Week", title="Anchor Period 2", options=["None", "Session", "Week", "Month", "Year"], group="VWAP 2 Settings") // Source is set to the close price of the bar srcvwap2 = input(title = "Source", defval = close, group="VWAP 2 Settings") // Source 2 is set to the open price of the bar src2vwap2 = input(title = "Source 2", defval = open, group="VWAP 2 Settings") // Checkboxes for Band values Resetzonevwap2 = input(true, title="Reset Zone", group="VWAP 2 Settings", inline="Reset Zone") Startzonevwap2 = input(true, title="Start Zone", group="VWAP 2 Settings", inline="Start Zone") // Check for availability of volume data if barstate.islast and ta.cum(volume) == 0 runtime.error("No volume is provided by the data vendor.") // Define timeframes for calculating VWAP isNewPeriodvwap2 = switch anchor2 "Session" => timeframe.change("D") "Week" => timeframe.change("W") "Month" => timeframe.change("M") "Year" => timeframe.change("12M") => false // Initialize VWAP values float vwapValuevwap2 = na float vwapValue2vwap2 = na // Calculate VWAP values [_vwapvwap2, _stdevUppervwap2, _] = ta.vwap(srcvwap2, isNewPeriodvwap2, 1) [_vwap2vwap2, _stdevUpper2vwap2, _] = ta.vwap(src2vwap2, isNewPeriodvwap2, 1) stdevvwap2 = _stdevUppervwap2 - _vwapvwap2 stdevcvwap2 = _stdevUpper2vwap2 - _vwap2vwap2 vwapValuevwap2 := _vwapvwap2 vwapValue2vwap2 := _vwap2vwap2 // Define colors for plot upper_colorvwap2 = input(color.new (color.rgb(66, 6, 94), 0),"bull VWAP 2") lower_colorvwap2 = input(color.new (color.rgb(243, 16, 186), 0),"bear VWAP 2") resetcolorvwap2 = input(color.new (color.rgb(131, 1, 253), 0), "Reset VWAP2", group="VWAP 2 Settings", inline="Reset Zone") startzonevwap2 = input(color.new (color.rgb(253, 0, 241), 0), "Reset VWAP2", group="VWAP 2 Settings", inline="Start Zone") // Plot VWAP lines and fill area between them linecolorvwap2 = _vwapvwap2 > _vwap2vwap2 ? upper_colorvwap2 : lower_colorvwap2 w1vwap2 = plot(vwapValuevwap2, title="VWAP 2 Source 1", color=linecolorvwap2) w2vwap2 = plot(vwapValue2vwap2, title="VWAP 2 Source 2", color=linecolorvwap2) fillcolorvwap2 = _vwapvwap2 > _vwap2vwap2 ? upper_colorvwap2 : lower_colorvwap2 fill(w1vwap2, w2vwap2, color=fillcolorvwap2, title = "Fill VWAP 2") var float lastVWAPValuevwap2 = na var float lastVWAPValue2vwap2 = na var float closing_vwapValueevwap2 = na var float closing_vwapValue2evwap2 = na if isNewPeriodvwap2 lastVWAPValuevwap2 := vwapValuevwap2[1] lastVWAPValue2vwap2 := vwapValue2vwap2[1] closing_vwapValueevwap2 := vwapValuevwap2 closing_vwapValue2evwap2 := vwapValue2vwap2 // Plot today's closing VWAP values p1vwap2 = plot(lastVWAPValuevwap2, color=color.new(color.red, 100), title = "last Period close VWAP 2") p2vwap2 = plot(lastVWAPValue2vwap2, color=color.new(color.red, 100), title = "last Period open VWAP 2") fill(p1vwap2, p2vwap2, color=resetcolorvwap2, title = "Fill last Period VWAP 2", display = Resetzonevwap2 ? display.all : display.none) p3vwap2 = plot(closing_vwapValueevwap2, color=color.new(color.green, 100), title = "start new Persiod close VWAP 2") p4vwap2 = plot(closing_vwapValue2evwap2, color=color.new(color.green,100), title = "start new Persiod open VWAP 2") fill(p3vwap2, p4vwap2, color=startzonevwap2, title = "Fill Start New Periode VWAP 2", display = Startzonevwap2 ? display.all : display.none)
Scalp Tool
https://www.tradingview.com/script/Un8fvP5C/
Demech
https://www.tradingview.com/u/Demech/
101
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/ // © Demech //@version=5 indicator("Scalp Tool", overlay=true, format=format.price, precision = 2, timeframe = "", timeframe_gaps = false) import PineCoders/Time/3 // Parameters length = input(96, title="Length") slength = input(96, title="slength") threshold = input.float(1, title="Treshold") threshold2 = input.float(4, title="Threshold 2") resistance_length = input(96, title = "Resistance") support_length = input(96, title = "Support") resistance_length2 = input(16, title = "Resistance Length BK") support_length2 = input(16, title = "Support Length BK") vwmalength = input(200, title = "vwma" ) rsi1_period = input(title='RSI Period 1', defval=14) rsi1_buy_level = input(title='RSI Buy Level', defval=29) rsi1_sell_level = input(title='RSI Sell Level', defval=71) rsi2_period = input(title='RSI Period 2', defval=14) rsi2_buy_level = input(title='RSI Buy Level 2', defval=38) rsi2_sell_level = input(title='RSI Sell Level 2', defval=62) ma1_type = input.string(title='Moving Average Type for RSI 1', defval='NONE', options=['SMA', 'EMA', 'VWMA', 'NONE']) ma1_period = input(title='Moving Average Period for RSI 1', defval=14) ma2_type = input.string(title='Moving Average Type for RSI 2', defval='VWMA', options=['SMA', 'EMA', 'VWMA', 'NONE']) ma2_period = input(title='Moving Average Period for RSI 2', defval=192) rsi_period = input(14, title = "RSI Periode for Bar Color") upperBound = input(70, title='Upper Bound') lowerBound = input(30, title='Lower Bound') midUpperBound = input(53, title='Mid Upper Bound') midLowerBound = input(47, title='Mid Lower Bound') extremeUpperBound = input(80, title='Extreme Upper Bound') extremeLowerBound = input(20, title='Extreme Lower Bound') // Parameter Bands lengthb = input(16, title='Bands') mult = input.float(1, title = "mult") mult2 = input.float(2, title = "mult 2") mult3 = input.float(3, title = "mult 3") upper_color = input(color.new (color.rgb(1, 250, 10),80),"bull") lower_color = input(color.new (color.rgb(255, 0, 0),80),"bear") middle_color = input(color.new(color.gray,100), "neutral") // Calculat Bands vwmac = ta.vwma(close, lengthb) vwmao = ta.vwma(open, lengthb) vwmah = ta.vwma(high, lengthb) vwmal = ta.vwma(low, lengthb) // Calculate the upper and lower bands upper = vwmah + ((vwmah - vwmac) * mult) lower = vwmal - ((vwmac - vwmal) * mult) upper2 = vwmah + ((vwmah - vwmac) * mult2) lower2 = vwmal - ((vwmac - vwmal) * mult2) upper3 = vwmah + ((vwmah - vwmac) * mult3) lower3 = vwmal - ((vwmac - vwmal) * mult3) // VWMA vwma = ta.vwma(close, vwmalength) // Function to calculate the standard deviation pstdev(Series, Period) => mean = ta.sma(Series, Period) summation = 0.0 for i=0 to Period-1 sampleMinusMean = nz(Series[i]) - mean summation := summation + sampleMinusMean * sampleMinusMean math.sqrt(summation / Period) length := length > bar_index + 1 ? bar_index + 1 : length slength := slength > bar_index + 1 ? bar_index + 1 : slength mean = ta.sma(volume, length) std = pstdev(volume, slength) stdbar = (volume - mean) / std dir = close > open // Calculations from second script rsi = ta.rsi(close, rsi_period) rsi1 = ta.rsi(close, rsi1_period) rsi2 = ta.rsi(close, rsi2_period) ma1_RSI = ma1_type == 'SMA' ? ta.sma(close, ma1_period) : ma1_type == 'EMA' ? ta.ema(close, ma1_period) : ma1_type == 'VWMA' ? ta.vwma(close, ma1_period) : close ma2_RSI = ma2_type == 'SMA' ? ta.sma(close, ma2_period) : ma2_type == 'EMA' ? ta.ema(close, ma2_period) : ma2_type == 'VWMA' ? ta.vwma(close, ma2_period) : close barcolor(rsi > extremeUpperBound ? color.new(color.red, 0) : rsi > upperBound and rsi <= extremeUpperBound ? color.new(color.red, 0) : rsi > midUpperBound and rsi <= upperBound ? color.new(color.rgb(43, 255, 0), 0) : rsi > midLowerBound and rsi <= midUpperBound ? color.new(color.gray, 0) : rsi > lowerBound and rsi <= midLowerBound ? color.new(color.rgb(235, 9, 9), 0) : rsi > extremeLowerBound and rsi <= lowerBound ? color.new(color.green, 0) : color.new(color.green, 0)) // Resistance and Support resistance = ta.highest(close, resistance_length) support = ta.lowest(close, support_length) resistanceh = ta.highest(high, resistance_length) supportl = ta.lowest(low, support_length) resistance_bk = ta.highest(open, support_length2) support_bk = ta.lowest(open, resistance_length2) // Breakout bullish_breakout = ta.crossover(close, resistance_bk) bearish_breakout = ta.crossunder(close, support_bk) // Bounce logic bu = low <= low[1] and low < support_bk or (low < support_bk and support) su = high >= high[1] and high > resistance_bk or (high > resistance_bk and resistance) bullish_bounce = low < support and low < lower3 and close > lower2 and close > support bearish_bounce = high > resistance and high > upper3 and close < upper2 and close < resistance // Buy and Sell Signals based on RSI Crossover with Moving Average filter rsi1_buy_signal = ta.crossover(rsi1, rsi1_buy_level) and (ma1_type == 'NONE' or close > ma1_RSI) rsi1_sell_signal = ta.crossunder(rsi1, rsi1_sell_level) and (ma1_type == 'NONE' or close < ma1_RSI) rsi2_buy_signal = ta.crossover(rsi2, rsi2_buy_level) and (ma2_type == 'NONE' or close > ma2_RSI) rsi2_sell_signal = ta.crossunder(rsi2, rsi2_sell_level) and (ma2_type == 'NONE' or close < ma2_RSI) // Buy and Sell Signal bk_bull_signal = stdbar > threshold2 and dir and bullish_breakout bk_bear_signal = stdbar > threshold2 and not dir and bearish_breakout buy_signal = stdbar > threshold and bullish_bounce sell_signal = stdbar > threshold and bearish_bounce buy = bu and support == support_bk and rsi1_buy_signal and buy_signal or (bu and rsi1_buy_signal) sell = su and resistance == resistance_bk and rsi1_sell_signal and sell_signal or (su and rsi1_sell_signal) Crossup = ta.crossover(vwmac, vwma) Crossdown = ta.crossunder(vwmac, vwma) buyb = open < lower and close > lower or ta.crossover(rsi1, 25) sellb = open > upper and close < upper or ta.crossunder(rsi1, 75) big_bull = buy and buyb big_sell = sell and sellb // Draw support and resistance lines and signals r1 = plot(resistance, color=color.new(color.rgb(253, 0, 241), 100), title = "Resistance") s1 = plot(support, color=color.new(color.rgb(253, 0, 241), 100), title = "Support") r2 = plot(resistanceh, color=color.new(color.rgb(253, 0, 241), 100), title = "Resistance") s2 = plot(supportl, color=color.new(color.rgb(253, 0, 241), 100), title = "Support") fill(r1, r2, color = color.new(color.purple, 80), title = "Resistance") fill(s1, s2, color = color.new(color.purple, 80), title = "Support") plot(resistance_bk, color=color.new(color.gray, 100), title = "Resistance BK") plot(support_bk, color=color.new(color.gray, 100), title = "Support BK") // Drawing the bands and the moving average plot(vwmac, color=color.new(color.aqua, 0), title = "vwmac") plot(vwmao, color=color.new(color.yellow, 0), title = "vwmao") plot(vwma, color=color.new(color.black, 0), title = "vwma" ) b1 = plot(upper, color=color.new(color.green, 100), title = "Upper Band") b2 = plot(lower, color=color.new(color.red, 100), title = "Lower Band") b3 = plot(upper2, color=color.new(color.aqua, 100), title = "Upper Band 2") b4 = plot(lower2, color=color.new(color.maroon, 100), title = "Lower Band 2") b5 = plot(upper3, color=color.new(color.yellow, 100), title = "Upper Band 3") b6 = plot(lower3, color=color.new(color.yellow, 100), title = "Lower Band 3") fillcolor = vwmac > vwma and vwmac > vwmao ? upper_color : vwmac < vwma and vwmac < vwmao ? lower_color : middle_color fill(b1, b2, color=fillcolor, title = "Fill Upper Lower Band") fill(b1, b3, color=color.new(color.gray, 50), title = "Fill Upper to Upper 2 Band") fill(b2, b4, color=color.new(color.gray,50), title = "Fill Lower to Lower 2 Band") fill(b3, b5, color=color.new(color.yellow,100), title = "Fill Lower to Lower 3 Band") fill(b4, b6, color=color.new(color.yellow,100), title = "Fill Lower to Lower 2 Band") // Create priority levels priority_5 = rsi1_buy_signal or rsi1_sell_signal or rsi2_buy_signal or rsi2_sell_signal priority_4 = bk_bull_signal or bk_bear_signal priority_3 = buy_signal or sell_signal priority_2 = buy or sell or buyb or sellb priority_1 = big_bull or big_sell // Enable oder disable Signals p5_enabled = input(true, title="enable RSI Signals") p4_enabled = input(true, title="enable Breakout Signals") p3_enabled = input(true, title="enable Long or Short Signals") p2_enabled = input(true, title="enable buy, sell , buy Band and sell Band") p1_enabled = input(true, title="enable Big Bull or Big Sell") // If a priority is not enabled, its signals become part of the next lower priority level if not p5_enabled priority_4 := priority_4 or priority_5 priority_5 := na if not p4_enabled priority_3 := priority_3 or priority_4 priority_4 := na if not p3_enabled priority_2 := priority_2 or priority_3 priority_3 := na if not p2_enabled priority_1 := priority_1 or priority_2 priority_2 := na if not p1_enabled priority_1 := na // Check if a higher priority signal is present p5 = priority_5 and not (priority_4 or priority_3 or priority_2 or priority_1) and p5_enabled p4 = priority_4 and not (priority_3 or priority_2 or priority_1) and p4_enabled p3 = priority_3 and not (priority_2 or priority_1) and p3_enabled p2 = priority_2 and not priority_1 and p2_enabled p1 = priority_1 and p1_enabled // Plot for Prioriti 5 plotshape(series=p5 and rsi1_buy_signal, style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), size=size.small, title='RSI 1 Buy Signal') plotshape(series=p5 and rsi1_sell_signal, style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), size=size.small, title='RSI 1 Sell Signal') plotshape(series=p5 and rsi2_buy_signal, style=shape.triangleup, location=location.belowbar, color=color.new(color.blue, 0), size=size.small, title='RSI 2 Buy Signal') plotshape(series=p5 and rsi2_sell_signal, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0), size=size.small, title='RSI 2 Sell Signal') // Plot for Prioriti 4 plotshape(series=p4 and bk_bull_signal, title="Buy Signal Breakout", location=location.belowbar, color=color.rgb(3, 139, 250), style=shape.labelup, text="Bull", textcolor = color.white) plotshape(series=p4 and bk_bear_signal, title="Sell Signal Breakout", location=location.abovebar, color=color.rgb(252, 2, 2), style=shape.labeldown, text="Bear", textcolor = color.white) // Plot for Prioriti 3 plotshape(series=p3 and buy_signal, title="Long", location=location.belowbar, color=color.green, style=shape.labelup, text="Long", textcolor = color.white) plotshape(series=p3 and sell_signal, title="Short", location=location.abovebar, color=color.red, style=shape.labeldown, text="Short", textcolor = color.white) // Plot for Prioriti 2 plotshape(series=p2 and buy, title="buy", location=location.belowbar, color=color.green, style=shape.labelup, text="buy", textcolor = color.white) plotshape(series=p2 and sell, title="sell", location=location.abovebar, color=color.red, style=shape.labeldown, text="sell", textcolor = color.white) plotshape(series=p2 and buyb, title="buy Band", location=location.belowbar, color=color.green, style=shape.labelup, text="b", textcolor = color.white) plotshape(series=p2 and sellb, title="sell Band", location=location.abovebar, color=color.red, style=shape.labeldown, text="s", textcolor = color.white) // Plot for Prioriti 1 plotshape(series=p1 and big_bull, title="BIG BUY", location=location.belowbar, color=color.green, style=shape.labelup, text="Big", textcolor = color.white) plotshape(series=p1 and big_sell, title="BIG SELL", location=location.abovebar, color=color.red, style=shape.labeldown, text="Big", textcolor = color.white) // Alerts for Buy and Sell Signals alertcondition(condition=bk_bull_signal, title='Bullish Breakout', message='Bull Breakout') alertcondition(condition=bk_bear_signal, title='Bearish Breakout', message='Bear Breakout') alertcondition(condition=buy, title='Buy', message='Buy') alertcondition(condition=sell, title='Sell', message='Sell') alertcondition(condition=buyb, title='Band Buy', message='Buy Band') alertcondition(condition=sellb, title='Band Sell', message='Sell Band') alertcondition(condition=buy_signal, title='Volume and Bounce Buy', message='Volume and Bounce Buy') alertcondition(condition=sell_signal, title='Volume and Bounce Sell', message='Volume and Bounce Sell') alertcondition(condition=big_bull, title='Big Bull', message='Big Bull') alertcondition(condition=big_sell, title='Big Sell', message='Big Sell') // Alerts RSI alertcondition(condition=rsi1_buy_signal, title='RSI 1 Buy Signal', message='RSI 1 Buy Signal') alertcondition(condition=rsi1_sell_signal, title='RSI 1 Sell Signal', message='RSI 1 Sell Signal') alertcondition(condition=rsi2_buy_signal, title='RSI 2 Buy Signal', message='RSI 2 Buy Signal') alertcondition(condition=rsi2_sell_signal, title='RSI 2 Sell Signal', message='RSI 2 Sell Signal') combined_alert = bk_bull_signal or bk_bear_signal or buy or sell or buy_signal or sell_signal or rsi1_buy_signal or rsi1_sell_signal or rsi2_buy_signal or rsi2_sell_signal or big_bull or big_sell or buyb or sellb alertcondition(combined_alert, title='Combined Alert', message='A signal has triggered!')
Sector/Industry
https://www.tradingview.com/script/zQZG6IEH-Sector-Industry/
SelfUnmade
https://www.tradingview.com/u/SelfUnmade/
204
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/ // © SelfUnmade //@version=5 indicator("Sector/Industry", overlay = true) sector = syminfo.sector industry = syminfo.industry group_pos = 'Table Position' string i_tableYpos = input.string('top', 'X', inline='01', group=group_pos, options=['top', 'middle', 'bottom']) string i_tableXpos = input.string('right', 'Y', inline='01', group=group_pos, options=['left', 'center', 'right'], tooltip='Position on the chart.') string i_textSize = input.string('Small', 'Panel Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], inline = '02', group=group_pos) string textSize = i_textSize == 'Auto' ? size.auto : i_textSize == 'Tiny' ? size.tiny : i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : i_textSize == 'Large' ? size.large : size.huge string tablelayout = input.string('Vertical', 'Table Layout', options=['Vertical', 'Horizontal'], inline = '03', group=group_pos) int l = tablelayout == 'Vertical' ? 1 : 2 bgColor = input.color(color.new(color.black, 0), "BG Color ", inline= '04', group=group_pos) textColor = input.color(color.new(color.white,0), " Text Color ", inline = '04', group=group_pos) var table= table.new(i_tableYpos + '_' + i_tableXpos, columns =2, rows=2, border_width=1 ) if l == 1 table.cell(table, 0, 0, industry, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0) table.cell(table, 0, 1, sector, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0) if l == 2 table.cell(table, 0, 0, industry, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0) table.cell(table, 1, 0, sector, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0)
Market Time Cycle (Expo)
https://www.tradingview.com/script/u872lNTM-Market-Time-Cycle-Expo/
Zeiierman
https://www.tradingview.com/u/Zeiierman/
548
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/ // © Zeiierman //@version=5 indicator("Market Time Cycle (Expo)",max_lines_count=500, precision=0) //~~~~~~~~~~~~~~~~~~~~~~~} // Inputs { marketcycle = input.bool(true, title="Market Cycle", group="Market Cycle",inline="Market Cycle",tooltip="") NumbOfBars = input.float(200.0,minval=1,title="",step=10, group="Market Cycle",inline="Market Cycle",tooltip="Set the Nbr bars for the Market Cycle.")/2 overlap = input.bool(false,title="Overlap Cycles", group="Market Cycle",inline="c",tooltip="") bg = input.bool(true, title="Cycle divider", group="Market Cycle",inline="c",tooltip="The overlap variable lets traders choose whether they want overlapping cycles or not. If the overlap option is selected, the next cycle starts right after the previous one, otherwise, it starts after the period equal to the Market Cycle Period") sine = input.bool(true, title="Sine Wave Cycle", group="Sine Wave Cycle",inline="Sine Wave Cycle",tooltip="") sineWavePeriod = input.int(20, minval=1,title="", group="Sine Wave Cycle",inline="Sine Wave Cycle",tooltip="Set the sine wave period.") //~~~~~~~~~~~~~~~~~~~~~~~} // Initialize Variables { b = bar_index Dec = (NumbOfBars-0.0)/NumbOfBars //~~~~~~~~~~~~~~~~~~~~~~~} // Code { // Compute cycle period and counter var c = 0 c := c+1 var a1 = NumbOfBars a1 := a1 - Dec // If period is out of bounds, reset cycle period and counter if a1+(overlap?0:NumbOfBars)<=0.0 a1 := NumbOfBars c := 0 cycle() => if c == 0 float prev_y = na int prev_x = na var float max_height = na var int max_height_index = na for j = -90 to 90 by 10 x = (NumbOfBars) * math.sin(math.toradians(j)) y = (NumbOfBars) * math.cos(math.toradians(j)) var color lineColor = na if j < -60 lineColor := color.red else if j < -30 lineColor := color.orange else if j < 0 lineColor := color.yellow else if j < 30 lineColor := color.green else if j < 60 lineColor := color.blue else lineColor := color.purple line.new(prev_x, prev_y, bar_index + math.round(x), y, color = marketcycle?lineColor:na, width = 2) prev_y := y prev_x := bar_index + math.round(x) if na(max_height) or y > max_height max_height := y max_height max_height = cycle() height_scale = math.round((fixnan(ta.valuewhen(fixnan(max_height)==fixnan(max_height[1]),fixnan(max_height),1))),1) // Function to generate a sine wave generateSineWave(height, duration) => pi = 3.14159265359 waveSpeed = 2 * pi / duration sineWave = height * math.sin(waveSpeed * bar_index) sineWave sineWave = generateSineWave(100, math.atan(sineWavePeriod)) // Function to generate cycle signals generateSignal(sineWave, signalThreshold, entryLimit, direction) => signal = 0. entry = 0. if (direction and sineWave > signalThreshold) or (not direction and sineWave < signalThreshold) signal := height_scale/2 for i = 0 to 5 if (direction and signal[i] and sineWave > entryLimit) or (not direction and signal[i] and sineWave < entryLimit) entry := height_scale/2 entry //~~~~~~~~~~~~~~~~~~~~~~~} // Plot cycle cycle_1 = sine?generateSignal(sineWave, 99.6, 80, true):na cycle_2 = sine?generateSignal(sineWave, -99.6, -80, false):na plot(cycle_1, style=plot.style_area, color=color.new(color.green, 0), title='Sine Wave Cycle 1') plot(cycle_2, style=plot.style_area, color=color.new(#ffcb7e, 0), title='Sine Wave Cycle 2') // Plot cycle divider { bgcolor(color=bg and c==NumbOfBars?color.navy:na, title="BG Divider Market Cycle 1") bgcolor(color=overlap and bg and c==0?color.navy:na, title="BG Divider Market Cycle 2") //~~~~~~~~~~~~~~~~~~~~~~~~~}
Open Interest Chart [LuxAlgo]
https://www.tradingview.com/script/xGnUhodO-Open-Interest-Chart-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
1,639
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('Open Interest Chart [LuxAlgo]', shorttitle='LuxAlgo - Open Interest Chart', max_bars_back=1000) cm = ' - CME' co = ' - COMEX' ny = ' - NYMEX' cb = ' - CBOT' cbo = ' - CBOE' us = ' - ICE U.S.' mg = ' - MGEX' a = ' - Futures - Open Interest (All)' old = ' - Futures - Open Interest (Old)' oth = ' - Futures - Open Interest (Other)' c = 'COT' c2 = 'COT2' c3 = 'COT3' c4 = 'COT4' c5 = 'COT5' f = '_F_OI' fold = '_F_OI_OLD' foth = '_F_OI_OTHER' //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ ac1 = input.bool (true , '' , inline='1', group='Tickers') ch1 = input.string(c +':Bitcoin'+cm+a , '1' , inline='1', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm1 = input.symbol ('' , '' , inline='1', group='Tickers') res1 = input.timeframe ('D' , '' , inline='1', group='Tickers') ac2 = input.bool (true , '' , inline='2', group='Tickers') ch2 = input.string(c +':U.S. Dollar Index'+us+a , '2' , inline='2', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm2 = input.symbol ('' , '' , inline='2', group='Tickers') res2 = input.timeframe ('D' , '' , inline='2', group='Tickers') ac3 = input.bool (true , '' , inline='3', group='Tickers') ch3 = input.string(c +':Gold'+co+a , '3' , inline='3', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm3 = input.symbol ('' , '' , inline='3', group='Tickers') res3 = input.timeframe ('D' , '' , inline='3', group='Tickers') ac4 = input.bool (true , '' , inline='4', group='Tickers') ch4 = input.string(c +':Natural Gas'+ny+a , '4' , inline='4', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm4 = input.symbol ('' , '' , inline='4', group='Tickers') res4 = input.timeframe ('D' , '' , inline='4', group='Tickers') ac5 = input.bool (true , '' , inline='5', group='Tickers') ch5 = input.string(c +':S&P 500 Stock Index'+cm+a , '5' , inline='5', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm5 = input.symbol ('' , '' , inline='5', group='Tickers') res5 = input.timeframe ('D' , '' , inline='5', group='Tickers') ac6 = input.bool (true , '' , inline='6', group='Tickers') ch6 = input.string(c +':Russell 2000 Index'+cm+a , '6' , inline='6', group='Tickers' , options = [ c +':30-Day Federal Funds'+cb+a , c3+':30-Day Federal Funds'+cb+a , c +':30-Day Federal Funds'+cb+old , c +':1-Month SOFR'+cm+a , c3+':1-Month SOFR'+cm+a , c +':1-Month SOFR'+cm+old , c +':3-Month SOFR'+cm+a , c3+':3-Month SOFR'+cm+a , c +':3-Month SOFR'+cm+old , c +':Bitcoin'+cm+a , c3+':Bitcoin'+cm+a , c +':Bitcoin'+cm+old , c +':Brazilian Real'+cm+a , c3+':Brazilian Real'+cm+a , c +':Brazilian Real'+cm+old , c +':Canadian Dollar'+cm+a , c3+':Canadian Dollar'+cm+a , c +':Canadian Dollar'+cm+old , c +':Canola'+us+a , c2+':Canola'+us+a , c +':Canola'+us+old , c2+':Canola'+us+old , c +':CME Milk IV'+cm+a , c2+':CME Milk IV'+cm+a , c +':CME Milk IV'+cm+old , c2+':CME Milk IV'+cm+old , c +':Cocoa'+us+a , c2+':Cocoa'+us+a , c +':Cocoa'+us+old , c2+':Cocoa'+us+old , c +':Coffee C'+us+a , c2+':Coffee C'+us+a , c +':Coffee C'+us+old , c2+':Coffee C'+us+old , c +':Corn'+cb+a , c2+':Corn'+cb+a , c +':Corn'+cb+old , c2+':Corn'+cb+old , c +':Cotton No. 2'+us+a , c2+':Cotton No. 2'+us+a , c +':Cotton No. 2'+us+old , c2+':Cotton No. 2'+us+old , c +':Dry Whey'+cm+a , c2+':Dry Whey'+cm+a , c +':Dry Whey'+cm+old , c2+':Dry Whey'+cm+old , c +':Euro FX'+cm+a , c3+':Euro FX'+cm+a , c +':Euro FX'+cm+old , c +':Gold'+co+a , c +':Gold'+co+old , c +':Japanese Yen'+cm+a , c3+':Japanese Yen'+cm+a , c +':Japanese Yen'+cm+old , c +':Lean Hogs'+cm+a , c2+':Lean Hogs'+cm+a , c +':Lean Hogs'+cm+old , c2+':Lean Hogs'+cm+old , c +':Live Cattle'+cm+a , c2+':Live Cattle'+cm+a , c +':Live Cattle'+cm+old , c2+':Live Cattle'+cm+old , c +':Mexican Peso'+cm+a , c3+':Mexican Peso'+cm+a , c +':Mexican Peso'+cm+old , c +':Micro Bitcoin'+cm+a , c3+':Micro Bitcoin'+cm+a , c +':Micro Bitcoin'+cm+old , c +':Micro Gold'+co+a , c +':Micro Gold'+co+old , c +':Milk Class III'+cm+a , c2+':Milk Class III'+cm+a , c +':Milk Class III'+cm+old , c2+':Milk Class III'+cm+old , c +':Nasdaq-100 Consolidated'+cm+a, c3+':Nasdaq-100 Consolidated'+cm+a, c +':Nasdaq-100 Consolidated'+cm+old , c +':Nasdaq-100 Stock Index'+cm+a , c3+':Nasdaq-100 Stock Index'+cm+a , c +':Nasdaq-100 Stock Index'+cm+old , c +':Natural Gas'+ny+a , c2+':Natural Gas'+ny+a , c +':Natural Gas'+ny+old , c2+':Natural Gas'+ny+old , c +':Non Fat Dry Milk'+cm+a , c2+':Non Fat Dry Milk'+cm+a , c +':Non Fat Dry Milk'+cm+old , c2+':Non Fat Dry Milk'+cm+old , c +':Oats'+cb+a , c2+':Oats'+cb+a , c +':Oats'+cb+old , c2+':Oats'+cb+old , c +':Palladium'+ny+a , c +':Palladium'+ny+old , c +':Platinum'+ny+a , c2+':Platinum'+ny+a , c +':Platinum'+ny+old , c2+':Platinum'+ny+old , c +':Rough Rice'+cb+a , c2+':Rough Rice'+cb+a , c +':Rough Rice'+cb+old , c2+':Rough Rice'+cb+old , c +':Russell 2000 Index'+cm+a , c3+':Russell 2000 Index'+cm+a , c +':Russell 2000 Index'+cm+old , c +':Russian Ruble'+cm+a , c3+':Russian Ruble'+cm+a , c +':Russian Ruble'+cm+old , c +':S&P 500 Consolidated'+cm+a , c3+':S&P 500 Consolidated'+cm+a , c +':S&P 500 Consolidated'+cm+old , c +':S&P 500 Stock Index'+cm+a , c3+':S&P 500 Stock Index'+cm+a , c +':S&P 500 Stock Index'+cm+old , c +':Silver'+co+a , c2+':Silver'+co+a , c +':Silver'+co+old , c2+':Silver'+co+old , c +':Soybeans'+cb+a , c2+':Soybeans'+cb+a , c +':Soybeans'+cb+old , c2+':Soybeans'+cb+old , c +':Sugar No. 11'+us+a , c2+':Sugar No. 11'+us+a , c +':Sugar No. 11'+us+old , c2+':Sugar No. 11'+us+old , c +':Swiss Franc'+cm+a , c3+':Swiss Franc'+cm+a , c +':Swiss Franc'+cm+old , c +':U.S. Dollar Index'+us+a , c3+':U.S. Dollar Index'+us+a , c +':U.S. Dollar Index'+us+old , c +':U.S. Treasury Bonds'+cb+a , c3+':U.S. Treasury Bonds'+cb+a , c +':U.S. Treasury Bonds'+cb+old , c +':VIX Futures'+cbo+a , c3+':VIX Futures'+cbo+a , c +':VIX Futures'+cbo+old , c +':Wheat HRW'+co+a , c2+':Wheat HRW'+co+a , c +':Wheat HRW'+co+old , c2+':Wheat HRW'+co+old , c +':Wheat HRSPRING'+mg+a , c2+':Wheat HRSPRING'+mg+a , c +':Wheat HRSPRING'+mg+old , c2+':Wheat HRSPRING'+mg+old , c +':Wheat SRW'+co+a , c2+':Wheat SRW'+co+a , c +':Wheat SRW'+co+old , c2+':Wheat SRW'+co+old ] ) sm6 = input.symbol ('' , '' , inline='6', group='Tickers') res6 = input.timeframe ('D' , '' , inline='6', group='Tickers') sw = input.bool (true , '          from middle   ' , group='style', tooltip='plots from:\n• middle line\n• center of circle' ) sz_ = input.string ('normal' , 'size' , group='style', tooltip='Size circle',options=['tiny','small','normal','large','huge']) ang = input.float ( 1. , 'angle' , minval= 0, maxval= 2, step=0.05, group='style', tooltip='When "From middle" is disabled:\n• Sets the angle of shapes') addT = input.bool (false , '           Show Ticker   ' , group='style', tooltip='Show Ticker on label' ) cTx1 = input.color (#10be37 , '+' , inline='1' , group='      text   -   fill' ) cTx5 = input.color (#f23645 , '- ' , inline='5' , group='      text   -   fill' ) col1 = input.color (#10be3787 , '' , inline='1' , group='      text   -   fill' , tooltip='colour positive percentage' ) col5 = input.color (#f236457c , '' , inline='5' , group='      text   -   fill' , tooltip='colour negative percentage' ) txt1 = input.color (#04c3c3 , '   ' , inline='2' , group='      table' ) txt2 = input.color (#d40ecee5 , '' , inline='2' , group='      table' , tooltip='table colours text' ) tSz = input.string (size.small, 'size', options=[size.tiny, size.small, size.normal, size.large]) tPos = input.string (position.top_right, 'position', options= [ position.top_left , position.top_center , position.top_right , position.middle_left, position.middle_center, position.middle_right , position.bottom_left, position.bottom_center, position.bottom_right ] ) cP0 = input.color (color.new(color.aqua , 25), title='Edge' , group='      circles') cP1 = input.color (color.new(color.silver, 95), title='circle 1' , group='      circles') cP2 = input.color (color.new(color.aqua , 75), title='circle 2' , group='      circles') cP3 = input.color (color.new(color.aqua , 25), title='circle 3' , group='      circles') cP4 = input.color (color.new(color.aqua , 75), title='circle 4' , group='      circles') //-----------------------------------------------------------------------------} //General Calculations //-----------------------------------------------------------------------------{ cC = chart.fg_color n = bar_index lbi = last_bar_index barsTillEnd = lbi - n change = ((close / close[1]) - 1) * 100 sz1 = switch sz_ 'tiny' => 44 'small' => 64 'normal'=> 80 'large' => 101 'huge' => 152 //-----------------------------------------------------------------------------} //UDT's //-----------------------------------------------------------------------------{ type val int x float h float l type values val[] _1 val[] _2 val[] _3 val[] _4 var values values = values.new( array.new<val>() , array.new<val>() , array.new<val>() , array.new<val>() ) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ // % rise/fall of _OI futures/tickers set(n, i) => max = math.ceil(n / i) * i part = max / i [max, part] createOuterCircle(radius) => var int end = na var int start = na var basis = 0. barsFromNearestEdgeCircle = 0. barsTillEndFromCircleStart = radius startCylce = barsTillEnd % barsTillEndFromCircleStart == 0 // start circle bars = ta.barssince(startCylce) barsFromNearestEdgeCircle := barsTillEndFromCircleStart -1 basis := math.min(startCylce ? -1 : basis + 1 / barsFromNearestEdgeCircle * 2, 1) // 0 -> 1 shape = math.sqrt(1 - basis * basis) rad = radius / 2 isOK = barsTillEnd <= barsTillEndFromCircleStart and barsTillEnd > 0 hi = isOK ? (rad + shape * radius) - rad : na lo = isOK ? (rad - shape * radius) - rad : na start := barsTillEnd == barsTillEndFromCircleStart ? n -1 : start end := barsTillEnd == 0 ? start + radius : end // n -1 : end if isOK values._1.unshift(val.new(n, hi, lo)) [hi, lo, start +1, end] [hi1, lo1, start1, end1] = createOuterCircle(sz1) createInnerCircle(num, e) => piece = math.round(sz1 / e) start = start1 + piece end = start1 + sz1 - piece var basis = 0. barsFromNearestEdgeCircle = 0. barsTillEndFromCirclesEnd = piece barsTillEndFromCircleStart = sz1 - piece * 2 startCylce = (barsTillEnd - piece) % (barsTillEndFromCircleStart) == 0 bars = ta.barssince(startCylce) barsFromNearestEdgeCircle := barsTillEndFromCircleStart -1 basis := math.min(startCylce ? -1 : basis + 1 / barsFromNearestEdgeCircle * 2, 1) shape = math.sqrt(1 - basis * basis) rad = sz1 / 2 isOK = barsTillEnd <= (barsTillEndFromCircleStart + piece) and barsTillEnd > barsTillEndFromCirclesEnd hi = isOK ? (rad + shape * barsTillEndFromCircleStart) - rad : na lo = isOK ? (rad - shape * barsTillEndFromCircleStart) - rad : na if isOK switch num 2 => values._2.unshift(val.new(n, hi, lo)) 3 => values._3.unshift(val.new(n, hi, lo)) 4 => values._4.unshift(val.new(n, hi, lo)) [hi, lo, start, end] c(val, o) => cl = color(na) cl := switch val > 0 => (o == 't' ? cTx1 : col1) val < 0 => (o == 't' ? cTx5 : col5) val == 0 => color.blue => color.gray lab() => label.new( na , na , style=label.style_label_center , textcolor=color.rgb(223, 51, 253) , color=color(na) , size=size.tiny , text='●') f_lb() => label.new( na, na, color= color.new(color.silver, 85) , textcolor= color.fuchsia , size = size.small ) units() => label.new( na, na , style=label.style_label_center , color=color(na), textcolor=cC) f_ln(i) => line.new( na, na , na, na , style=line.style_dotted , color=color.new(color.silver, i)) f_lf() => linefill.new( line.new(na, na, na, na, color=color.new(cC, 50)) , line.new(na, na, na, na, color=color.new(cC, 50)) , color(na)) tab(tab, t, p, d, v, i) => col = i % 2 == 0 ? color.new(color.gray, 90) : color.new(color.silver, 90) colt = i % 2 == 0 ? color.new(#b027a9 , 0) : color.new(color.aqua , 0) colv = c(v, 't'), _v = str.tostring(math.round(v, 2)) table.cell(tab, 0, i, text = t, bgcolor = col, text_color=cC , text_size=tSz) table.cell(tab, 1, i, text = p, bgcolor = col, text_color=colt, text_size=tSz) table.cell(tab, 2, i, text = d, bgcolor = col, text_color=colt, text_size=tSz) table.cell(tab, 3, i, text =_v, bgcolor = col, text_color=colv, text_size=tSz) f_str(i, val, res, des) => r = res != '' ? '\n(TF: ' + res + ')' : '' d = addT ? '\n' + des : '' out = str.format("{0}{1}\n{2}{3}", i, d, math.round(val, 2), r) //-----------------------------------------------------------------------------} //Methods //-----------------------------------------------------------------------------{ method style(label lb, val, neg, pos) => lb.set_style(val > 0 or not sw ? pos : neg) method replace(string s) => str.replace_all(str.replace_all(s, "Futures", "F"), 'Open Interest', 'OI') method pick(simple string ch) => p = '', t = '' switch ch c +':30-Day Federal Funds'+cb+a => p := c , t := '045601'+f c3+':30-Day Federal Funds'+cb+a => p := c3, t := '045601'+f c +':30-Day Federal Funds'+cb+old => p := c , t := '045601'+fold c +':1-Month SOFR'+cm+a => p := c , t := '134742'+f c3+':1-Month SOFR'+cm+a => p := c3, t := '134742'+f c +':1-Month SOFR'+cm+old => p := c , t := '134742'+fold c +':3-Month SOFR'+cm+a => p := c , t := '134741'+f c3+':3-Month SOFR'+cm+a => p := c3, t := '134741'+f c +':3-Month SOFR'+cm+old => p := c , t := '134741'+fold c +':Bitcoin'+cm+a => p := c , t := '133741'+f c3+':Bitcoin'+cm+a => p := c3, t := '133741'+f c +':Bitcoin'+cm+old => p := c , t := '133741'+fold c +':Brazilian Real'+cm+a => p := c , t := '102741'+f c3+':Brazilian Real'+cm+a => p := c3, t := '102741'+f c +':Brazilian Real'+cm+old => p := c , t := '102741'+fold c +':Coffee C'+us+a => p := c , t := '083731'+f c2+':Coffee C'+us+a => p := c2, t := '083731'+f c +':Coffee C'+us+old => p := c , t := '083731'+fold c2+':Coffee C'+us+old => p := c2, t := '083731'+fold c +':Canadian Dollar'+cm+a => p := c , t := '090741'+f c3+':Canadian Dollar'+cm+a => p := c3, t := '090741'+f c +':Canadian Dollar'+cm+old => p := c , t := '090741'+fold c +':Canola'+us+a => p := c , t := '135731'+f c2+':Canola'+us+a => p := c2, t := '135731'+f c +':Canola'+us+old => p := c , t := '135731'+fold c2+':Canola'+us+old => p := c2, t := '135731'+fold c +':CME Milk IV'+cm+a => p := c , t := '052644'+f c2+':CME Milk IV'+cm+a => p := c2, t := '052644'+f c +':CME Milk IV'+cm+old => p := c , t := '052644'+fold c2+':CME Milk IV'+cm+old => p := c2, t := '052644'+fold c +':Cocoa'+us+a => p := c , t := '073732'+f c2+':Cocoa'+us+a => p := c2, t := '073732'+f c +':Cocoa'+us+old => p := c , t := '073732'+fold c2+':Cocoa'+us+old => p := c2, t := '073732'+fold c +':Corn'+cb+a => p := c , t := '002602'+f c2+':Corn'+cb+a => p := c2, t := '002602'+f c +':Corn'+cb+old => p := c , t := '002602'+fold c2+':Corn'+cb+old => p := c2, t := '002602'+fold c +':Cotton No. 2'+us+a => p := c , t := '033661'+f c2+':Cotton No. 2'+us+a => p := c2, t := '033661'+f c +':Cotton No. 2'+us+old => p := c , t := '033661'+fold c2+':Cotton No. 2'+us+old => p := c2, t := '033661'+fold c +':Dry Whey'+cm+a => p := c , t := '052645'+f c2+':Dry Whey'+cm+a => p := c , t := '052645'+f c +':Dry Whey'+cm+old => p := c , t := '052645'+fold c2+':Dry Whey'+cm+old => p := c , t := '052645'+fold c +':Euro FX'+cm+a => p := c , t := '099741'+f c3+':Euro FX'+cm+a => p := c3, t := '099741'+f c +':Euro FX'+cm+old => p := c , t := '099741'+fold c +':Gold'+co+a => p := c , t := '088691'+f c +':Gold'+co+old => p := c , t := '088691'+fold c +':Japanese Yen'+cm+a => p := c , t := '097741'+f c3+':Japanese Yen'+cm+a => p := c3, t := '097741'+f c +':Japanese Yen'+cm+old => p := c , t := '097741'+fold c +':Lean Hogs'+cm+a => p := c , t := '054642'+f c2+':Lean Hogs'+cm+a => p := c2, t := '054642'+f c +':Lean Hogs'+cm+old => p := c , t := '054642'+fold c2+':Lean Hogs'+cm+old => p := c2, t := '054642'+fold c +':Live Cattle'+cm+a => p := c , t := '057642'+f c2+':Live Cattle'+cm+a => p := c2, t := '057642'+f c +':Live Cattle'+cm+old => p := c , t := '057642'+fold c2+':Live Cattle'+cm+old => p := c2, t := '057642'+fold c +':Mexican Peso'+cm+a => p := c , t := '095741'+f c3+':Mexican Peso'+cm+a => p := c3, t := '095741'+f c +':Mexican Peso'+cm+old => p := c , t := '095741'+fold c +':Micro Bitcoin'+cm+a => p := c , t := '133742'+f c3+':Micro Bitcoin'+cm+a => p := c3, t := '133742'+f c +':Micro Bitcoin'+cm+old => p := c , t := '133742'+fold c +':Micro Gold'+co+a => p := c , t := '088695'+f c +':Micro Gold'+co+old => p := c , t := '088695'+fold c +':Milk Class III'+cm+a => p := c , t := '052641'+f c2+':Milk Class III'+cm+a => p := c2, t := '052641'+f c +':Milk Class III'+cm+old => p := c , t := '052641'+fold c2+':Milk Class III'+cm+old => p := c2, t := '052641'+fold c +':Nasdaq-100 Consolidated'+cm+a => p := c , t := '20974+'+f c3+':Nasdaq-100 Consolidated'+cm+a => p := c3, t := '20974+'+f c +':Nasdaq-100 Consolidated'+cm+old=> p := c , t := '20974+'+fold c +':Nasdaq-100 Stock Index'+cm+a => p := c , t := '209742'+f c3+':Nasdaq-100 Stock Index'+cm+a => p := c3, t := '209742'+f c +':Nasdaq-100 Stock Index'+cm+old => p := c , t := '209742'+fold c +':Natural Gas'+ny+a => p := c , t := '023651'+f c2+':Natural Gas'+ny+a => p := c2, t := '023651'+f c +':Natural Gas'+ny+old => p := c , t := '023651'+fold c2+':Natural Gas'+ny+old => p := c2, t := '023651'+fold c +':Non Fat Dry Milk'+cm+a => p := c , t := '052642'+f c2+':Non Fat Dry Milk'+cm+a => p := c2, t := '052642'+f c +':Non Fat Dry Milk'+cm+old => p := c , t := '052642'+fold c2+':Non Fat Dry Milk'+cm+old => p := c2, t := '052642'+fold c +':Oats'+cb+a => p := c , t := '004603'+f c2+':Oats'+cb+a => p := c2, t := '004603'+f c +':Oats'+cb+old => p := c , t := '004603'+fold c2+':Oats'+cb+old => p := c2, t := '004603'+fold c +':Palladium'+ny+a => p := c , t := '075651'+f c +':Palladium'+ny+old => p := c , t := '075651'+fold c +':Platinum'+ny+a => p := c , t := '076651'+f c2+':Platinum'+ny+a => p := c2, t := '076651'+f c +':Platinum'+ny+old => p := c , t := '076651'+fold c2+':Platinum'+ny+old => p := c2, t := '076651'+fold c +':Rough Rice'+cb+a => p := c , t := '039601'+f c2+':Rough Rice'+cb+a => p := c2, t := '039601'+f c +':Rough Rice'+cb+old => p := c , t := '039601'+fold c2+':Rough Rice'+cb+old => p := c2, t := '039601'+fold c +':Russell 2000 Index'+cm+a => p := c , t := '239742'+f c3+':Russell 2000 Index'+cm+a => p := c3, t := '239742'+f c +':Russell 2000 Index'+cm+old => p := c , t := '239742'+fold c +':Russian Ruble'+cm+a => p := c , t := '089741'+f c3+':Russian Ruble'+cm+a => p := c3, t := '089741'+f c +':Russian Ruble'+cm+old => p := c , t := '089741'+fold c +':S&P 500 Consolidated'+cm+a => p := c , t := '13874+'+f c3+':S&P 500 Consolidated'+cm+a => p := c3, t := '13874+'+f c +':S&P 500 Consolidated'+cm+old => p := c , t := '13874+'+fold c +':S&P 500 Stock Index'+cm+a => p := c , t := '138741'+f c3+':S&P 500 Stock Index'+cm+a => p := c3, t := '138741'+f c +':S&P 500 Stock Index'+cm+old => p := c , t := '138741'+fold c +':Silver'+co+a => p := c , t := '084691'+f c2+':Silver'+co+a => p := c2, t := '084691'+f c +':Silver'+co+old => p := c , t := '084691'+fold c2+':Silver'+co+old => p := c2, t := '084691'+fold c +':Soybeans'+cb+a => p := c , t := '005602'+f c2+':Soybeans'+cb+a => p := c2, t := '005602'+f c +':Soybeans'+cb+old => p := c , t := '005602'+fold c2+':Soybeans'+cb+old => p := c2, t := '005602'+fold c +':Sugar No. 11'+us+a => p := c , t := '080732'+f c2+':Sugar No. 11'+us+a => p := c2, t := '080732'+f c +':Sugar No. 11'+us+old => p := c , t := '080732'+fold c2+':Sugar No. 11'+us+old => p := c2, t := '080732'+fold c +':Swiss Franc'+cm+a => p := c , t := '092741'+f c3+':Swiss Franc'+cm+a => p := c3, t := '092741'+f c +':Swiss Franc'+cm+old => p := c , t := '092741'+fold c +':U.S. Dollar Index'+us+a => p := c , t := '098662'+f c3+':U.S. Dollar Index'+us+a => p := c3, t := '098662'+f c +':U.S. Dollar Index'+us+old => p := c , t := '098662'+fold c +':U.S. Treasury Bonds'+cb+a => p := c , t := '020601'+f c3+':U.S. Treasury Bonds'+cb+a => p := c3, t := '020601'+f c +':U.S. Treasury Bonds'+cb+old => p := c , t := '020601'+fold c +':VIX Futures'+cbo+a => p := c , t := '1170E1'+f c3+':VIX Futures'+cbo+a => p := c3, t := '1170E1'+f c +':VIX Futures'+cbo+old => p := c , t := '1170E1'+fold c +':Wheat SRW'+co+a => p := c , t := '001602'+f c2+':Wheat SRW'+co+a => p := c2, t := '001602'+f c +':Wheat SRW'+co+old => p := c , t := '001602'+fold c2+':Wheat SRW'+co+old => p := c2, t := '001602'+fold c +':Wheat HRW'+co+a => p := c , t := '001612'+f c2+':Wheat HRW'+co+a => p := c2, t := '001612'+f c +':Wheat HRW'+co+old => p := c , t := '001612'+fold c2+':Wheat HRW'+co+old => p := c2, t := '001612'+fold c +':Wheat HRSPRING'+mg+a => p := c , t := '001626'+f c2+':Wheat HRSPRING'+mg+a => p := c2, t := '001626'+f c +':Wheat HRSPRING'+mg+old => p := c , t := '001626'+fold c2+':Wheat HRSPRING'+mg+old => p := c2, t := '001626'+fold [p, t] //-----------------------------------------------------------------------------} //Variables //-----------------------------------------------------------------------------{ var line ln1 = f_ln(75), var line l_1 = f_ln(15), var label lb1 = lab(), var label tx1 = f_lb(), var label un1 = units() var line ln2 = f_ln(75), var line l_2 = f_ln(15), var label lb2 = lab(), var label tx2 = f_lb(), var label un2 = units() var line ln3 = f_ln(75), var line l_3 = f_ln(15), var label lb3 = lab(), var label tx3 = f_lb(), var label un3 = units() var line ln4 = f_ln(75), var line l_4 = f_ln(15), var label lb4 = lab(), var label tx4 = f_lb(), var label un4 = units() var line ln5 = f_ln(75), var line l_5 = f_ln(15), var label lb5 = lab(), var label tx5 = f_lb(), var label un5 = units() var line ln6 = f_ln(75), var line l_6 = f_ln(15), var label lb6 = lab(), var label tx6 = f_lb(), var label un6 = units() var linefill lf1 = f_lf(), var linefill lf5 = f_lf(), var linefill lf9 = f_lf () var linefill lf2 = f_lf(), var linefill lf6 = f_lf(), var linefill lf10 = f_lf () var linefill lf3 = f_lf(), var linefill lf7 = f_lf(), var linefill lf11 = f_lf () var linefill lf4 = f_lf(), var linefill lf8 = f_lf(), var linefill lf12 = f_lf () //-----------------------------------------------------------------------------} //Calculations //-----------------------------------------------------------------------------{ [hi2, lo2, start2, end2] = createInnerCircle(2, sz1 / (sz1 * 0.105)) [hi3, lo3, start3, end3] = createInnerCircle(3, sz1 / (sz1 * 0.25 )) [hi4, lo4, start4, end4] = createInnerCircle(4, sz1 / (sz1 * 0.375)) [p1, t1] = ch1.pick(), sym1 = ac1 ? ticker.new(p1, t1) : sm1 [p2, t2] = ch2.pick(), sym2 = ac2 ? ticker.new(p2, t2) : sm2 [p3, t3] = ch3.pick(), sym3 = ac3 ? ticker.new(p3, t3) : sm3 [p4, t4] = ch4.pick(), sym4 = ac4 ? ticker.new(p4, t4) : sm4 [p5, t5] = ch5.pick(), sym5 = ac5 ? ticker.new(p5, t5) : sm5 [p6, t6] = ch6.pick(), sym6 = ac6 ? ticker.new(p6, t6) : sm6 [val1, pre1, des1] = request.security(sym1, res1, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) [val2, pre2, des2] = request.security(sym2, res2, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) [val3, pre3, des3] = request.security(sym3, res3, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) [val4, pre4, des4] = request.security(sym4, res4, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) [val5, pre5, des5] = request.security(sym5, res5, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) [val6, pre6, des6] = request.security(sym6, res6, [change, syminfo.prefix, syminfo.description], ignore_invalid_symbol = true) naV1 = val1, val1 := nz(val1) naV2 = val2, val2 := nz(val2) naV3 = val3, val3 := nz(val3) naV4 = val4, val4 := nz(val4) naV5 = val5, val5 := nz(val5) naV6 = val6, val6 := nz(val6) max = math.max(math.abs(val1), math.abs(val2), math.abs(val3), math.abs(val4), math.abs(val5), math.abs(val6)) [m, p] = set(max, 1) // input.float(0.5, '', step=0.5)) if ta.change(chart.left_visible_bar_time ) or ta.change(chart.right_visible_bar_time) n := bar_index //-----------------------------------------------------------------------------} //Execution //-----------------------------------------------------------------------------{ if barstate.islast and lbi - n < 500 size_1 = values._1.size() size_3 = values._3.size() deg0_1_get = values._1.get(math.round(size_1 * .5 )) deg30_1_get = values._1.get(math.round(size_1 * .275)) deg60_1_get = values._1.get(math.round(size_1 * .1 )) deg210_1_get = values._1.get(math.round(size_1 * .725)) deg240_1_get = values._1.get(math.round(size_1 * .9 )) deg270_1_get = values._1.get( size_1 -1 ) deg0_3_get = values._3.get(math.round(size_3 * .5 )) deg30_3_get = values._3.get(math.round(size_3 * .275)) deg60_3_get = values._3.get(math.round(size_3 * .1 )) deg210_3_get = values._3.get(math.round(size_3 * .725)) deg240_3_get = values._3.get(math.round(size_3 * .9 )) deg270_3_get = values._3.get( size_3 -1 ) // Circle 1 (largest) deg0_1_x = deg0_1_get.x , deg0_1_h = deg0_1_get.h , deg0_1_l = deg0_1_get.l // 0° - 180° deg30_1_x = deg30_1_get.x , deg30_1_h = deg30_1_get.h , deg30_1_l = deg30_1_get.l // 30° - 150° deg60_1_x = deg60_1_get.x , deg60_1_h = deg60_1_get.h , deg60_1_l = deg60_1_get.l // 60° - 120° deg90_1_x = end1 , deg90_1_h = 0 // 90° deg210_1_x = deg210_1_get.x, deg210_1_h = deg210_1_get.h, deg210_1_l = deg210_1_get.l // 210° - 330° deg240_1_x = deg240_1_get.x, deg240_1_h = deg240_1_get.h, deg240_1_l = deg240_1_get.l // 240° - 300° deg270_1_x = deg270_1_get.x, deg270_1_h = 0 // 270° // Circle 3 (Mid) deg0_3_x = deg0_3_get.x , deg0_3_h = deg0_3_get.h , deg0_3_l = deg0_3_get.l // 0° - 180° deg30_3_x = deg30_3_get.x , deg30_3_h = deg30_3_get.h , deg30_3_l = deg30_3_get.l // 30° - 150° deg60_3_x = deg60_3_get.x , deg60_3_h = deg60_3_get.h , deg60_3_l = deg60_3_get.l // 60° - 120° deg90_3_x = end3 -1 , deg90_3_h = 0 // 90° deg210_3_x = deg210_3_get.x, deg210_3_h = deg210_3_get.h, deg210_3_l = deg210_3_get.l // 210° - 330° deg240_3_x = deg240_3_get.x, deg240_3_h = deg240_3_get.h, deg240_3_l = deg240_3_get.l // 240° - 300° deg270_3_x = deg270_3_get.x, deg270_3_h = 0 // 270° // axis lines l_1.set_xy1(deg0_1_x, 0), l_1.set_xy2(deg0_1_x , deg0_1_h ) // 0° ln1.set_xy1(deg0_1_x, 0), ln1.set_xy2(deg30_1_x , deg30_1_h ) // 30° l_2.set_xy1(deg0_1_x, 0), l_2.set_xy2(deg60_1_x , deg60_1_h ) // 60° ln2.set_xy1(deg0_1_x, 0), ln2.set_xy2(deg90_1_x , deg90_1_h ) // 90° l_3.set_xy1(deg0_1_x, 0), l_3.set_xy2(deg60_1_x , deg60_1_l ) // 120° ln3.set_xy1(deg0_1_x, 0), ln3.set_xy2(deg30_1_x , deg30_1_l ) // 150° l_4.set_xy1(deg0_1_x, 0), l_4.set_xy2(deg0_1_x , deg0_1_l ) // 180° ln4.set_xy1(deg0_1_x, 0), ln4.set_xy2(deg210_1_x, deg210_1_l) // 210° l_5.set_xy1(deg0_1_x, 0), l_5.set_xy2(deg240_1_x, deg240_1_l) // 240° ln5.set_xy1(deg0_1_x, 0), ln5.set_xy2(deg270_1_x, 0 ) // 270° l_6.set_xy1(deg0_1_x, 0), l_6.set_xy2(deg240_1_x, deg240_1_h) // 300° ln6.set_xy1(deg0_1_x, 0), ln6.set_xy2(deg210_1_x, deg210_1_h) // 330° // text labels tx1.set_xy(deg30_1_x , deg30_1_h ), tx1.set_textcolor(c(naV1, 't')), tx1.set_text(f_str(1, naV1, res1, des1.replace())), tx1.set_style(label.style_label_lower_left ) tx2.set_xy(deg90_1_x , deg90_1_h ), tx2.set_textcolor(c(naV2, 't')), tx2.set_text(f_str(2, naV2, res2, des2.replace())), tx2.set_style(label.style_label_left ) tx3.set_xy(deg30_1_x , deg30_1_l ), tx3.set_textcolor(c(naV3, 't')), tx3.set_text(f_str(3, naV3, res3, des3.replace())), tx3.set_style(label.style_label_upper_left ) tx4.set_xy(deg210_1_x, deg210_1_l), tx4.set_textcolor(c(naV4, 't')), tx4.set_text(f_str(4, naV4, res4, des4.replace())), tx4.set_style(label.style_label_upper_right) tx5.set_xy(deg270_1_x, 0 ), tx5.set_textcolor(c(naV5, 't')), tx5.set_text(f_str(5, naV5, res5, des5.replace())), tx5.set_style(label.style_label_right ) tx6.set_xy(deg210_1_x, deg210_1_h), tx6.set_textcolor(c(naV6, 't')), tx6.set_text(f_str(6, naV6, res6, des6.replace())), tx6.set_style(label.style_label_lower_right) xMid30 = sw ? math.round(math.avg(deg0_1_x, deg30_1_x)) : deg0_1_x yMid30 = sw ? deg30_3_h : 0 xMid90 = sw ? end3 -1 : deg0_1_x yMid90 = 0 xMid150 = sw ? xMid30 : deg0_1_x yMid150 = sw ? deg30_3_l : 0 xMid210 = sw ? math.round(math.avg(deg0_1_x, deg210_1_x)) : deg0_1_x yMid210 = sw ? deg210_3_l : 0 xMid270 = sw ? start3 : deg0_1_x yMid270 = 0 xMid330 = sw ? xMid210 : deg0_1_x yMid330 = sw ? deg210_3_h : 0 A1x1 = deg0_1_x // Lside 1 A1y1 = sw ? deg0_3_h : deg0_3_h * (math.abs(val1 * ang) / m) // Lside 1 A1x2 = sw ? xMid30 : deg0_1_x A1y2 = sw ? yMid30 : 0 A2x1 = A1x1 A2y1 = A1y1 A2x2 = sw ? math.round(deg30_3_x + (deg30_1_x - deg30_3_x) * (val1 / m)) : math.round(deg0_1_x + (deg30_1_x - deg0_1_x ) * (math.abs(val1) / m)) // POINT 1 A2y2 = ln1.get_price(A2x2) // POINT 1 B1x1 = sw ? deg60_3_x : math.round(deg0_1_x + ((deg60_1_x - deg60_3_x) * (math.abs(val1 * ang) / m))) // Rside 1 B1y1 = l_2.get_price(B1x1) // Rside 1 B1x2 = A1x2 B1y2 = A1y2 B2x1 = B1x1 B2y1 = B1y1 B2x2 = A2x2 B2y2 = A2y2 C1x1 = sw ? deg60_3_x : math.round(deg0_1_x + ((deg60_1_x - deg60_3_x) * (math.abs(val2 * ang) / m))) // Lside 2 C1y1 = l_2.get_price(C1x1) // Lside 2 C1x2 = sw ? xMid90 : deg0_1_x C1y2 = sw ? yMid90 : 0 C2x1 = C1x1 C2y1 = C1y1 C2x2 = sw ? math.round(deg90_3_x + ( (n -1) - deg90_3_x) * (val2 / m)) : math.round(deg0_1_x + (deg90_1_x - deg0_1_x ) * (math.abs(val2) / m)) // POINT 2 C2y2 = 0 // 90° // POINT 2 D1x1 = sw ? deg60_3_x : math.round(deg0_1_x + ((deg60_1_x - deg60_3_x) * (math.abs(val2 * ang) / m))) // Rside 2 D1y1 = l_3.get_price(D1x1) // Rside 2 D1x2 = C1x2 D1y2 = C1y2 D2x1 = D1x1 D2y1 = D1y1 D2x2 = C2x2 D2y2 = C2y2 E1x1 = sw ? deg60_3_x : math.round(deg0_1_x + ((deg60_1_x - deg60_3_x) * (math.abs(val3 * ang) / m))) // Lside 3 E1y1 = l_3.get_price(E1x1) // Lside 3 E1x2 = sw ? xMid150 : deg0_1_x E1y2 = sw ? yMid150 : 0 E2x1 = E1x1 E2y1 = E1y1 E2x2 = sw ? math.round(deg30_3_x + (deg30_1_x - deg30_3_x) * (val3 / m)) : math.round(deg0_1_x + (deg30_1_x - deg0_1_x ) * (math.abs(val3) / m)) // POINT 3 E2y2 = ln3.get_price(E2x2) // POINT 3 F1x1 = deg0_1_x // Rside 3 F1y1 = sw ? deg0_3_l : deg0_3_l * (math.abs(val3 * ang) / m) // 180° // Rside 3 F1x2 = E1x2 F1y2 = E1y2 F2x1 = F1x1 F2y1 = F1y1 F2x2 = E2x2 F2y2 = E2y2 G1x1 = deg0_1_x G1y1 = sw ? deg0_3_l : deg0_3_l * (math.abs(val4 * ang) / m) // 180° // Lside 4 G1x2 = sw ? xMid210 : deg0_1_x // Lside 4 G1y2 = sw ? yMid210 : 0 G2x1 = G1x1 G2y1 = G1y1 G2x2 = sw ? math.round(deg210_3_x - (deg210_3_x - deg210_1_x) * (val4 / m)) : math.round(deg0_1_x - (deg0_1_x - deg210_1_x ) * (math.abs(val4) / m)) // POINT 4 G2y2 = ln4.get_price(G2x2) // POINT 4 H1x1 = math.round( sw ? math.avg(deg0_1_x, deg240_1_x) : deg0_1_x - ((deg0_1_x - deg240_3_x) * (math.abs(val4 * ang) / m))) // Rside 4 H1y1 = l_5.get_price(H1x1) // Rside 4 H1x2 = G1x2 H1y2 = G1y2 H2x1 = H1x1 H2y1 = H1y1 H2x2 = G2x2 H2y2 = G2y2 I1x1 = math.round( sw ? math.avg(deg0_1_x, deg240_1_x) : deg0_1_x - ((deg0_1_x - deg240_3_x) * (math.abs(val5 * ang) / m))) // Lside 5 I1y1 = l_5.get_price(I1x1) // Lside 5 I1x2 = sw ? xMid270 : deg0_1_x I1y2 = sw ? yMid270 : 0 I2x1 = I1x1 I2y1 = I1y1 I2x2 = sw ? math.round(deg270_3_x - (deg270_3_x - start1) * (val5 / m)) : math.round(deg0_1_x - (deg0_1_x - start1) * (math.abs(val5) / m)) // POINT 5 I2y2 = ln5.get_price(I2x2) // POINT 5 J1x1 = math.round( sw ? math.avg(deg0_1_x, deg240_1_x) : deg0_1_x - ((deg0_1_x - deg240_3_x) * (math.abs(val5 * ang) / m))) // Rside 5 J1y1 = l_6.get_price(J1x1) // Rside 5 J1x2 = I1x2 // 0/mid 5 J1y2 = I1y2 // 0/mid 5 J2x1 = J1x1 J2y1 = J1y1 J2x2 = I2x2 J2y2 = I2y2 K1x1 = math.round( sw ? math.avg(deg0_1_x, deg240_1_x) : deg0_1_x - ((deg0_1_x - deg240_3_x) * (math.abs(val6 * ang) / m))) // Lside 6 K1y1 = l_6.get_price(K1x1) // Lside 6 K1x2 = sw ? xMid330 : deg0_1_x K1y2 = sw ? yMid330 : 0 K2x1 = K1x1 K2y1 = K1y1 K2x2 = sw ? math.round(deg210_3_x - (deg210_3_x - deg210_1_x) * (val6 / m)) : math.round(deg0_1_x - (deg0_1_x - deg210_1_x ) * (math.abs(val6) / m)) // POINT 6 K2y2 = ln6.get_price(K2x2) // POINT 6 L1x1 = deg0_1_x // Rside 6 L1y1 = sw ? deg0_3_h : deg0_3_h * (math.abs(val6 * ang) / m) // Rside 6 L1x2 = K1x2 L1y2 = K1y2 L2x1 = L1x1 L2y1 = L1y1 L2x2 = K2x2 L2y2 = K2y2 // value labels (points) lb1.set_xy(A2x2, A2y2) lb2.set_xy(C2x2, C2y2) lb3.set_xy(E2x2, E2y2) lb4.set_xy(G2x2, G2y2) lb5.set_xy(I2x2, I2y2) lb6.set_xy(K2x2, K2y2) // fills lf1.get_line1 ().set_xy1(A1x1, A1y1), lf1.get_line1 ().set_xy2(A1x2, A1y2) lf1.get_line2 ().set_xy1(A2x1, A2y1), lf1.get_line2 ().set_xy2(A2x2, A2y2), lf1.set_color (c(val1, 'c')) lf2.get_line1 ().set_xy1(B1x1, B1y1), lf2.get_line1 ().set_xy2(B1x2, B1y2) lf2.get_line2 ().set_xy1(B2x1 ,B2y1), lf2.get_line2 ().set_xy2(B2x2, B2y2), lf2.set_color (c(val1, 'c')) lf3.get_line1 ().set_xy1(C1x1, C1y1), lf3.get_line1 ().set_xy2(C1x2, C1y2) lf3.get_line2 ().set_xy1(C2x1, C2y1), lf3.get_line2 ().set_xy2(C2x2, C2y2), lf3.set_color (c(val2, 'c')) lf4.get_line1 ().set_xy1(D1x1, D1y1), lf4.get_line1 ().set_xy2(D1x2, D1y2) lf4.get_line2 ().set_xy1(D2x1, D2y1), lf4.get_line2 ().set_xy2(D2x2, D2y2), lf4.set_color (c(val2, 'c')) lf5.get_line1 ().set_xy1(E1x1, E1y1), lf5.get_line1 ().set_xy2(E1x2, E1y2) lf5.get_line2 ().set_xy1(E2x1, E2y1), lf5.get_line2 ().set_xy2(E2x2, E2y2), lf5.set_color (c(val3, 'c')) lf6.get_line1 ().set_xy1(F1x1, F1y1), lf6.get_line1 ().set_xy2(F1x2, F1y2) lf6.get_line2 ().set_xy1(F2x1, F2y1), lf6.get_line2 ().set_xy2(F2x2, F2y2), lf6.set_color (c(val3, 'c')) lf7.get_line1 ().set_xy1(G1x1, G1y1), lf7.get_line1 ().set_xy2(G1x2, G1y2) lf7.get_line2 ().set_xy1(G2x1, G2y1), lf7.get_line2 ().set_xy2(G2x2, G2y2), lf7.set_color (c(val4, 'c')) lf8.get_line1 ().set_xy1(H1x1, H1y1), lf8.get_line1 ().set_xy2(H1x2, H1y2) lf8.get_line2 ().set_xy1(H2x1, H2y1), lf8.get_line2 ().set_xy2(H2x2, H2y2), lf8.set_color (c(val4, 'c')) lf9.get_line1 ().set_xy1(I1x1, I1y1), lf9.get_line1 ().set_xy2(I1x2, I1y2) lf9.get_line2 ().set_xy1(I2x1, I2y1), lf9.get_line2 ().set_xy2(I2x2, I2y2), lf9.set_color (c(val5, 'c')) lf10.get_line1().set_xy1(J1x1, J1y1), lf10.get_line1().set_xy2(J1x2, J1y2) lf10.get_line2().set_xy1(J2x1, J2y1), lf10.get_line2().set_xy2(J2x2, J2y2), lf10.set_color(c(val5, 'c')) lf11.get_line1().set_xy1(K1x1, K1y1), lf11.get_line1().set_xy2(K1x2, K1y2) lf11.get_line2().set_xy1(K2x1, K2y1), lf11.get_line2().set_xy2(K2x2, K2y2), lf11.set_color(c(val6, 'c')) lf12.get_line1().set_xy1(L1x1, L1y1), lf12.get_line1().set_xy2(L1x2, L1y2) lf12.get_line2().set_xy1(L2x1, L2y1), lf12.get_line2().set_xy2(L2x2, L2y2), lf12.set_color(c(val6, 'c')) // units pc = (deg60_1_x - deg0_1_x) / 2 un2x = deg60_1_x - (pc / 2) un3x = deg60_1_x - pc un4x = deg0_1_x + (pc / 2) un1.set_xy(deg60_1_x, l_2.get_price(deg60_1_x)), un1.set_text(sw ? str.tostring( m ) : str.tostring( m )) un2.set_xy(un2x , l_2.get_price(un2x )), un2.set_text(sw ? str.tostring( m / 2) : str.tostring( m/4*3)) un3.set_xy(un3x , l_2.get_price(un3x )), un3.set_text(sw ? '0' : str.tostring( m / 2)) un4.set_xy(un4x , l_2.get_price(un4x )), un4.set_text(sw ? str.tostring(-m / 2) : str.tostring( m / 4)) un5.set_xy(deg0_1_x , 0 ), un5.set_text(sw ? str.tostring(-m ) : '0' ) //-----------------------------------------------------------------------------} //Table //-----------------------------------------------------------------------------{ var tab = table.new(tPos, 4, 7 , frame_color = color(na), frame_width=1 , border_color = color(na), bgcolor = color(na), border_width = 1) table.cell(tab, 0, 0, text = 'N°' , bgcolor = color(na), text_color=cC) table.cell(tab, 1, 0, text = 'Prefix', bgcolor = color(na), text_color=cC) table.cell(tab, 2, 0, text = 'Ticker', bgcolor = color(na), text_color=cC) table.cell(tab, 3, 0, text = '%' , bgcolor = color(na), text_color=cC) tab(tab, '1', pre1, des1.replace(), naV1, 1) tab(tab, '2', pre2, des2.replace(), naV2, 2) tab(tab, '3', pre3, des3.replace(), naV3, 3) tab(tab, '4', pre4, des4.replace(), naV4, 4) tab(tab, '5', pre5, des5.replace(), naV5, 5) tab(tab, '6', pre6, des6.replace(), naV6, 6) //-----------------------------------------------------------------------------} //Plots //-----------------------------------------------------------------------------{ plot(hi1, 'Edge' , color=cP0, display=display.pane) plot(lo1, 'Edge' , color=cP0, display=display.pane) plot(hi1, 'circle 1', color=cP1, display=display.pane, style=plot.style_area) plot(lo1, 'circle 1', color=cP1, display=display.pane, style=plot.style_area) plot(hi2, 'circle 2', color=cP2, display=display.pane) plot(lo2, 'circle 2', color=cP2, display=display.pane) plot(hi3, 'circle 3', color=cP3, display=display.pane) plot(lo3, 'circle 3', color=cP3, display=display.pane) plot(hi4, 'circle 4', color=cP4, display=display.pane) plot(lo4, 'circle 4', color=cP4, display=display.pane) //-----------------------------------------------------------------------------}
Volume Profile Bar-Magnified Order Blocks [JacobMagleby]
https://www.tradingview.com/script/n5WMDywt-Volume-Profile-Bar-Magnified-Order-Blocks-JacobMagleby/
JacobMagleby
https://www.tradingview.com/u/JacobMagleby/
1,328
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/ // © JacobMagleby //@version=5 indicator(title = "Volume Profile Bar-Magnified Order Blocks [JacobMagleby]", shorttitle = "Volume Profile Bar-Magnified Order Blocks [JacobMagleby]", overlay = true, max_boxes_count = 500, max_lines_count = 500) // { <CONSTANTS> OB_BORDER_WIDTH = 2 // } <CONSTANTS> // { <INPUTS> tuning = input.int( title = "Tuning", defval = 7, group = "Main Settings") amountOfBoxes = input.int( title = "Amount Of Grids", defval = 10, group = "Main Settings") mitigationMethod = input.string( title = "Mitigation Method", defval = "Close Engulfs 100% Of Order Block", group = "Main Settings", inline = "mitigation", options = [ "Close Engulfs 100% Of Order Block", "Close Engulfs 75% Of Order Block", "Close Engulfs 50% Of Order Block", "Close Engulfs 25% Of Order Block", "Wick Engulfs 100% Of Order Block", "Wick Engulfs 75% Of Order Block", "Wick Engulfs 50% Of Order Block", "Wick Engulfs 25% Of Order Block"]) obHighVolumeColor = input.color( title = "", defval = color.new(color.yellow, 35), group = "Color Settings", inline = "colors") obLowVolumeColor = input.color( title = "", defval = color.new(color.orange, 35), group = "Color Settings", inline = "colors") obBorderColor = input.color( title = "", defval = color.new(color.gray, 85), group = "Color Settings", inline = "colors") obLinefillColor = input.color( title = "", defval = color.new(color.gray, 75), group = "Color Settings", inline = "colors") // } <INPUTS> // { <FUNCTIONS> checkObCondition(set)=> bear = false for i = tuning - 1 to 0 start = tuning - 1 if i == start if close[i] <= open[i] break else if close[i] > open[i] break if i == 0 bear := true bull = false for i = tuning - 1 to 0 start = tuning - 1 if i == start if close[i] >= open[i] break else if close[i] < open[i] break if i == 0 bull := true [bear, bull] // } <FUNCTIONS> // { <USER DEFINED TYPES> type orderBlock line topLine line botLine linefill bgFill array<box> boxArray = na array<float> boxVolume = na float topValue float botValue int leftTime int rightTime string direction float highestTop = na float highestBot = na method generateBorderLines(orderBlock self, topValue, botValue)=> newTopLine = line.new(x1 = self.leftTime, y1 = topValue, x2 = time, y2 = topValue, xloc = xloc.bar_time, extend = extend.none, color = obBorderColor, style = line.style_solid, width = OB_BORDER_WIDTH) newbotLine = line.new(x1 = self.leftTime, y1 = botValue, x2 = time, y2 = botValue, xloc = xloc.bar_time, extend = extend.none, color = obBorderColor, style = line.style_solid, width = OB_BORDER_WIDTH) newlinefill = linefill.new(newTopLine, newbotLine, obLinefillColor) self.topLine := newTopLine self.botLine := newbotLine self.bgFill := newlinefill method generateVolume(orderBlock self, topValue, botValue, vArray, hArray, lArray)=> newVolumeArray = self.boxVolume startingValue = topValue increment = (topValue - botValue) / amountOfBoxes for i = 0 to amountOfBoxes - 1 topOfGrid = startingValue - (increment * i) botOfGrid = startingValue - (increment * (i + 1)) if array.size(vArray) > 0 and array.size(hArray) > 0 and array.size(lArray) > 0 for j = 0 to array.size(vArray) - 1 candleVolume = array.get(vArray, j) candleHigh = array.get(hArray, j) candleLow = array.get(lArray, j) ltfDiff = candleHigh - candleLow if candleLow <= topOfGrid and candleHigh >= botOfGrid topRegister = math.min(candleHigh, topOfGrid) botRegister = math.max(candleLow, botOfGrid) registerDiff = topRegister - botRegister registerVolume = registerDiff / ltfDiff array.set(newVolumeArray, i, array.get(newVolumeArray, i) + nz(registerVolume * candleVolume)) array.sum(newVolumeArray) method generateBoxes(orderBlock self, topValue, botValue, leftValue, rightValue)=> newBoxesArray = array.new_box() highestVolume = array.max(self.boxVolume) lowestVolume = array.min(self.boxVolume) timeLength = self.rightTime - self.leftTime timeRatio = timeLength / highestVolume startingValue = topValue increment = (topValue - botValue) / amountOfBoxes for i = 0 to amountOfBoxes - 1 topOfGrid = startingValue - (increment * i) botOfGrid = startingValue - (increment * (i + 1)) color_ = color.from_gradient(array.get(self.boxVolume, i), lowestVolume, highestVolume, obLowVolumeColor, obHighVolumeColor) newbox = box.new(left = self.leftTime, top = topOfGrid, right = self.leftTime + math.round(array.get(self.boxVolume, i) * timeRatio), bottom = botOfGrid, border_color = color_, border_width = 2, xloc = xloc.bar_time, bgcolor = color_, extend = extend.none) array.push(newBoxesArray, newbox) self.boxArray := newBoxesArray method updateBoxes(orderBlock self, currentTime)=> self.rightTime := currentTime highestVolume = array.max(self.boxVolume) lowestVolume = array.min(self.boxVolume) timeLength = self.rightTime - self.leftTime timeRatio = timeLength / highestVolume for i = 0 to amountOfBoxes - 1 box.set_right(array.get(self.boxArray, i), self.leftTime + math.round(array.get(self.boxVolume, i) * timeRatio)) if array.get(self.boxVolume, i) == highestVolume self.highestTop := box.get_top(array.get(self.boxArray, i)) self.highestBot := box.get_bottom(array.get(self.boxArray, i)) line.set_x2(self.topLine, self.rightTime) line.set_x2(self.botLine, self.rightTime) method wipeBlock(orderBlock self)=> line.delete(self.topLine) line.delete(self.botLine) linefill.delete(self.bgFill) for i = array.size(self.boxArray) - 1 to 0 selectedBox = array.get(self.boxArray, i) box.delete(selectedBox) // } <USER DEFINED TYPES> // { <CALCULATIONS> bool bullRealtimeTouch = false bool bearRealtimeTouch = false bool bullishRejection = false bool bearishRejection = false bool newBull = false bool newBear = false rawTimeframe = timeframe.isdaily ? 1440 : timeframe.isweekly ? 1440 * 7 : timeframe.ismonthly ? 1440 * 30 : str.tonumber(timeframe.period) fixedTimeframe = math.round(rawTimeframe / 15) < 1 ? "30S" : str.tostring(math.round(rawTimeframe / 15)) [h, l, v] = request.security_lower_tf(syminfo.tickerid, fixedTimeframe, [high, low, volume]) [bear, bull] = checkObCondition(tuning) var array<orderBlock> orderBlockArray = array.new<orderBlock>(0) if not na(bar_index[tuning]) and barstate.isconfirmed topValue = high[tuning - 1] botValue = low[tuning - 1] leftValue = time[tuning - 1] rightValue = time if bull or bear newBull := bull ? true : newBull newBear := bear ? true : newBear neworderBlock = orderBlock.new(topValue = topValue, botValue = botValue, leftTime = leftValue, rightTime = rightValue, boxVolume = array.new_float(amountOfBoxes, 0), direction = bull ? "Bull" : "Bear") neworderBlock.generateBorderLines(neworderBlock.topValue, neworderBlock.botValue) vol = neworderBlock.generateVolume(neworderBlock.topValue, neworderBlock.botValue, v[tuning - 1], h[tuning - 1], l[tuning - 1]) neworderBlock.generateBoxes(neworderBlock.topValue, neworderBlock.botValue, neworderBlock.leftTime, neworderBlock.rightTime) if vol == 0 neworderBlock.wipeBlock() else array.push(orderBlockArray, neworderBlock) maxBlocks = math.floor(500 / amountOfBoxes) if array.size(orderBlockArray) > 0 for i = array.size(orderBlockArray) - 1 to 0 block = array.get(orderBlockArray, i) block.updateBoxes(time) if close <= block.highestTop and close >= block.highestBot if block.direction == "Bull" bullRealtimeTouch := true else bearRealtimeTouch := true if low <= block.highestBot and close >= block.highestBot and block.direction == "Bull" and barstate.isconfirmed bullishRejection := true if high >= block.highestTop and close <= block.highestTop and block.direction == "Bear" and barstate.isconfirmed bearishRejection := true blockDifference = block.topValue - block.botValue startingValue = block.direction == "Bull" ? block.topValue : block.botValue sourceToUse = str.contains(mitigationMethod, "Close") ? close : (block.direction == "Bull" ? low : high) incrementMultiplier = str.contains(mitigationMethod, "100%") ? math.abs(blockDifference * 1) : str.contains(mitigationMethod, "75%") ? math.abs(blockDifference * .75) : str.contains(mitigationMethod, "50%") ? math.abs(blockDifference * .50) : .25 incrementMultiplier *= block.direction == "Bull" ? -1 : 1 breakValue = startingValue + incrementMultiplier bullBreak = block.direction == "Bull" and sourceToUse < breakValue bearBreak = block.direction == "Bear" and sourceToUse > breakValue if (bullBreak or bearBreak or i < (array.size(orderBlockArray) - 1 - maxBlocks)) and barstate.isconfirmed block.wipeBlock() array.remove(orderBlockArray, i) // } <CALCULATIONS> // { <ALERTS> alertcondition(condition = bullRealtimeTouch, title = "Price Inside Bullish Max Volume Zone") alertcondition(condition = bearRealtimeTouch, title = "Price Inside Bearish Max Volume Zone") alertcondition(condition = bullishRejection, title = "Confirmed Rejection Off Bullish Max Volume Zone") alertcondition(condition = bearishRejection, title = "Confirmed Rejection Off Bearish Max Volume Zone") alertcondition(condition = newBull, title = "New Bullish Order Block") alertcondition(condition = newBear, title = "New Bearish Order Block") // } <ALERTS>
Show Extended Hours (Futures & Crypto)
https://www.tradingview.com/script/B7EzfHLP-Show-Extended-Hours-Futures-Crypto/
liquid-trader
https://www.tradingview.com/u/liquid-trader/
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/ // © liquid-trader // This indicator mimics TradingViews "Extended trading hours" background color settings. // It is most useful on symbols that do not conventionally have extended hours, but are available to trade during // those hours (ie. Futures and Crypto). // More here: https://www.tradingview.com/script/B7EzfHLP-Show-Extended-Hours-Futures-Crypto/ //@version=5 indicator("Show Extended Hours (Futures & Crypto)", "Ext. Hrs.", true) // Base Colors clr1 = color.new(color.orange, 92), clr2 = color.new(color.blue, 92), clr3 = color.new(color.gray, 90) // Group Labels g1 = "Market Segments", g2 = "Market Hours" // Premarket Settings pm = input.bool(true, "Premarket               ", inline="pm", group=g1, display=display.none) pmClr = input.color(clr1, "", inline="pm", group=g1, display=display.none) // After Hours Settings ah = input.bool(true, "After Hour               ", inline="ah", group=g1, display=display.none) ahClr = input.color(clr2, "", inline="ah", group=g1, display=display.none) // Near Open Settings no = input.bool(true, "Near Market Open ", inline="no", group=g1, display=display.none) noClr = input.color(clr3, "", inline="no", group=g1, display=display.none) noMin = input.int(60, "", 0, tooltip="The number of minutes before the market opens to change the charts background color, as a visual reminder it's about to open.", group=g1, inline="no", display=display.none) // Near Close Settings nc = input.bool(true, "Near Market Close ", inline="nc", group=g1, display=display.none) ncClr = input.color(clr3, "", inline="nc", group=g1, display=display.none) ncMin = input.int(60, "", 0, tooltip="The number of minutes before the market closes to change the charts background color, as a visual reminder it's about to close.", group=g1, inline="nc", display=display.none) // Midday Settings md = input.bool(false, "Midday Range        ", inline="md", group=g1, display=display.none) mdClr = input.color(clr3, "", inline="md", group=g1, display=display.none) mdMin = input.session("1100-1300", "", tooltip = "The time range considered \"midday\" in a 24 hour format, where 1100 is 11:00 AM, 1330 is 1:30 PM, etc.", group=g1, inline="md", display=display.none) // Market Hour Settings mktHrs = input.session("0930-1600", "Start / End Time", tooltip = "A 24 hour format, where 0930 is 9:30 AM, 1600 is 4:00 PM, etc.", group=g2, display=display.none) timezone = input("America/New_York", "Time Zone", "Any IANA time zone ID. Ex: America/New_York", group=g2, display=display.none) // Normalize times. startTime = str.substring(mktHrs, 0, 4), var endTime = str.substring(mktHrs, 5, 9), var st = str.tonumber(startTime), var et = str.tonumber(endTime) normalizeTime(t) => str = str.tostring(t) while str.length(str) < 4 str := "0" + str str setTimeNearOC(t) => r = switch t st => noMin et => ncMin h = math.floor(t / 100) m = t % 100, m := m - r if m < 0 while m < 0 h -= 1 m += 60 normalizeTime(h * 100 + m) nearStartTime = setTimeNearOC(st) nearEndTime = setTimeNearOC(et) // Define Market Hours pmHrs = "0000-" + startTime aftHrs = endTime + "-2400" nearMktOpen = nearStartTime + "-" + startTime nearMktClose = nearEndTime + "-" + endTime minutesInDay = "1440" // Evaluate if the current time is within the premarket or after hours. premarket = not na(time(minutesInDay, pmHrs, timezone)) and pm afterhours = not na(time(minutesInDay, aftHrs, timezone)) and ah nearOpen = not na(time(minutesInDay, nearMktOpen, timezone)) and no midday = not na(time(minutesInDay, mdMin, timezone)) and md nearClose = not na(time(minutesInDay, nearMktClose, timezone)) and nc // Change the charts background color. bgcolor(premarket ? pmClr : na, 0, false) bgcolor(afterhours ? ahClr : na, 0, false) bgcolor(nearOpen ? noClr : na, 0, false) bgcolor(midday ? mdClr : na, 0, false) bgcolor(nearClose ? ncClr : na, 0, false)
David Varadi Intermediate Oscillator
https://www.tradingview.com/script/NNwvuRlA-David-Varadi-Intermediate-Oscillator/
QuantiLuxe
https://www.tradingview.com/u/QuantiLuxe/
249
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/ // © EliCobra //@version=5 indicator("David Varadi Intermediate Oscillator", "{Ʌ} - DVI", false, timeframe = "", timeframe_gaps = true) mmult = input.float(0.8, "Magnitude Weight", group = "Composite Weight Ratio") smult = input.float(0.2, "Stretch Weight", group = "Composite Weight Ratio") nlen1 = input.int(5, "Magnitude Length 1", group = "Magnitude Lengths") nlen2 = input.int(100, "Magnitude Length 2", group = "Magnitude Lengths") nlen3 = input.int(5, "Magnitude Length 3", group = "Magnitude Lengths") mlen1 = input.int(10, "Stretch Length 1", group = "Stretch Lengths") mlen2 = input.int(100, "Stretch Length 1", group = "Stretch Lengths") mlen3 = input.int(2, "Stretch Length 1", group = "Stretch Lengths") colbar = input.string("None", "Bar Coloring", ["None", "Trend", "Extremeties", "Reversions"], group = "UI Options") revshow = input.bool(true, "Show Reversal Signals", group = "UI Options") k = 3 b = close > close[1] ? 1 : -1 r = close / ta.sma(close, 3) - 1 magnitude = ta.percentrank(ta.sma((nlen1 * ta.sma(r, nlen1) + nlen2 * ta.sma(r, nlen2) / 10) / 2, nlen3), 252) stretch = ta.percentrank(ta.sma((mlen1 * ta.sma(r, mlen1) + mlen2 * ta.sma(r, mlen2) / 10) / 2, mlen3), 252) dvi = mmult * magnitude + smult * stretch d = plot(dvi, "DVI", dvi > 50 ? color.from_gradient(dvi, 50, 70, #a5a5a5, #00b350) : color.from_gradient(dvi, 30, 50, #bb0010, #9e9e9e)) hline(50, "Mid Line", #ffffff80, hline.style_dotted) u = plot(80, "Upper Line", #ffffff80, display = display.pane) l = plot(20, "Lower Line", #ffffff80, display = display.pane) fill(d, u, 100, 80, #bb0010c0, #bb001000) fill(d, l, 20, 0, #00b35100, #00b351b2) plotshape(revshow ? dvi > 80 and dvi < dvi[1] and not (dvi[1] < dvi[2]) ? 110 : na : na, "OB", shape.triangledown, location.absolute, #bb0010, size = size.tiny) plotshape(revshow ? dvi < 20 and dvi > dvi[1] and not (dvi[1] > dvi[2]) ? -10 : na : na, "OS", shape.triangleup, location.absolute, #00b350, size = size.tiny) color col = switch colbar "None" => na "Trend" => dvi > 50 ? #00b350 : #bb0010 "Extremeties" => dvi > 80 ? #00b350 : dvi < 20 ? #bb0010 : #b3b3b3c2 "Reversions" => dvi > 80 and dvi < dvi[1] and not (dvi[1] < dvi[2]) ? #bb0010 : dvi < 20 and dvi > dvi[1] and not (dvi[1] > dvi[2]) ? #00b350 : #b3b3b3c2 barcolor(col)
Liquidity Engulfing & Displacement [MsF]
https://www.tradingview.com/script/rXN2YTsl/
Trader_Morry
https://www.tradingview.com/u/Trader_Morry/
191
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/ // © Trader_Morry // This is an interesting take on a common engulfing candle pattern with 2 additional filter critera to ensure there is a liquidity play // Idea came from AtaBankz based on trade setup 4H candles. Thanks mate! //@version=5 indicator("Liquidity Engulfing & Displacement [MsF]", overlay=true) ///////////////////////////////////////////////////////////////////////////////////////////////// // Liquidity Engulfing Candles - LEC // --------------- INPUTS --------------- var GRP1 = "LEC setting" show_H1 = input(true, title='Show H1 LEC', group=GRP1) show_H4 = input(false, title='Show H4 LEC', group=GRP1) show_CUR = input(false, title='Show Current LEC', group=GRP1) filter_liqudity = input.bool(true, "Apply Stop Hunt Wick Filter", tooltip="Require candle wick into prior candle retracement zone") filter_close = input.bool(true, "Apply Close Filter", tooltip="Require LL/HH on candle in order to print a valid engulfing signal") // --------------- function --------------- drawing_lec() => bull_engulf = false bear_engulf = false if barstate.isnew prior_open = open[1] prior_close = close[1] current_open = open current_close = close // identify "normal" engulfing candles bull_engulf := (current_open <= prior_close) and (current_open < prior_open) and (current_close > prior_open) bear_engulf := (current_open >= prior_close) and (current_open > prior_open) and (current_close < prior_open) // "stop hunt" logic if filter_liqudity bull_engulf := bull_engulf and low <= low[1] bear_engulf := bear_engulf and high >= high[1] // require LL/HH on the candle if filter_close bull_engulf := bull_engulf and close >= high[1] bear_engulf := bear_engulf and close <= low[1] [bull_engulf, bear_engulf] // --------------- Main MTF --------------- [bull_engulf_H1, bear_engulf_H1] = request.security(syminfo.tickerid, "60", drawing_lec()) [bull_engulf_H4, bear_engulf_H4] = request.security(syminfo.tickerid, "240", drawing_lec()) [bull_engulf_CUR, bear_engulf_CUR] = request.security(syminfo.tickerid, timeframe.period, drawing_lec()) // plots bullcol = color.aqua bearcol = color.red plotshape(bull_engulf_H1 and not bull_engulf_H1[1] and show_H1, style=shape.triangleup, location=location.belowbar, color=bullcol, size=size.small) plotshape(bear_engulf_H1 and not bear_engulf_H1[1] and show_H1, style=shape.triangledown , location=location.abovebar, color=bearcol, size=size.small) plotshape(bull_engulf_H4 and not bull_engulf_H4[1] and show_H4, style=shape.triangleup, location=location.belowbar, color=bullcol, size=size.small) plotshape(bear_engulf_H4 and not bear_engulf_H4[1] and show_H4, style=shape.triangledown , location=location.abovebar, color=bearcol, size=size.small) plotshape(bull_engulf_CUR and not bull_engulf_CUR[1] and show_CUR, style=shape.triangleup, location=location.belowbar, color=bullcol, size=size.small) plotshape(bear_engulf_CUR and not bear_engulf_CUR[1] and show_CUR, style=shape.triangledown , location=location.abovebar, color=bearcol, size=size.small) // alarts alertcondition(bull_engulf_H1,"H1 Bullish LEC detected","H1 Bullish LEC detected!!") alertcondition(bear_engulf_H1,"H1 Bearish LEC detected","H1 Bearish LEC detected!!") alertcondition(bull_engulf_H4,"H4 Bullish LEC detected","H4 Bullish LEC detected!!") alertcondition(bear_engulf_H4,"H4 Bearish LEC detected","H4 Bearish LEC detected!!") alertcondition(bull_engulf_CUR,"Bullish LEC detected","Bullish LEC detected!!") alertcondition(bear_engulf_CUR,"Bearish LEC detected","Bearish LEC detected!!") // ///////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////// // Displacement // --------------- INPUTS --------------- var GRP2 = "Displacement setting" require_fvg = input.bool(true, "Require FVG", group = GRP2) disp_type = input.string("Open to Close", "Displacement Type", options = ['Open to Close', 'High to Low'], group = GRP2) std_len = input.int(100, minval = 1, title = "Displacement Length", tooltip = "How far back the script will look to determine the candle range standard deviation", group = GRP2) std_x = input.int(2, minval = 0, title = "Displacement Strength", group = GRP2) disp_color = input.color(color.yellow, "Bar Color", group = GRP2) candle_range = disp_type == "Open to Close" ? math.abs(open - close) : high - low std = ta.stdev(candle_range, std_len) * std_x fvg = close[1] > open[1] ? high[2] < low[0] : low[2] > high[0] displacement = require_fvg ? candle_range[1] > std[1] and fvg : candle_range > std barcolor(displacement ? disp_color : na, offset = require_fvg ? -1 : na) // /////////////////////////////////////////////////////////////////////////////////////////////////
Donchian Volatility Indicator - Adaptive Channel Width
https://www.tradingview.com/script/UYVkIXD3-Donchian-Volatility-Indicator-Adaptive-Channel-Width/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
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/ // © LeafAlgo //@version=5 indicator("Donchian Volatility Indicator - Adaptive Channel Width", overlay=false) // Calculation Inputs length = input.int(50, "Lookback Period for Donchian Channel") atrPeriod = input.int(14, "ATR Period") atrMultiplier = input.float(2.0, "ATR Multiplier") lookbackPeriod = input.int(250, "Lookback Period for Extremes") signalPeriod = input.int(50, "Length of Signal Line") // Calculate ATR atr = ta.atr(length = atrPeriod) // Calculate Upper and Lower Channels upperChannel = ta.highest(high, length) + atr * atrMultiplier lowerChannel = ta.lowest(low, length) - atr * atrMultiplier // Calculate Channel Width channelWidth = upperChannel - lowerChannel // Signal Line signalLine = ta.sma(channelWidth, signalPeriod) // Plotting plot(channelWidth, color=color.maroon, linewidth=4, title="Channel Width") plot(signalLine, color=color.aqua, linewidth=4, title="Signal Line") // Bar Color barC = channelWidth > signalLine ? color.lime : color.fuchsia barcolor(barC) // Background Color bgcolor(barC, transp=80)
FalconRed VIX
https://www.tradingview.com/script/Tva4w8uW-FalconRed-VIX/
falcon_red
https://www.tradingview.com/u/falcon_red/
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/ // © falcon_red //@version=5 indicator("FalconRed VIX", overlay=true, linktoseries=true) timeframeInput = input.string("5", "Timeframe", ["1", "3", "5", "15", "6h", "D", "W", "M", "Y"]) price = request.security(syminfo.ticker, timeframe.period, close) indiaVix = request.security('INDIAVIX', timeframe.period, close) factor = (timeframeInput == "D") ? (indiaVix/math.sqrt(365)/100) : (timeframeInput == "6h") ? (indiaVix/math.sqrt(1461)/100) : (timeframeInput == "Y") ? (indiaVix/math.sqrt(1)/100) : (timeframeInput == "M") ? (indiaVix/math.sqrt(12)/100) : (timeframeInput == "W") ? (indiaVix/math.sqrt(52)/100) : (timeframeInput == "1") ? (indiaVix/math.sqrt(105120)/100) : (timeframeInput == "3") ? (indiaVix/math.sqrt(175200)/100) : (timeframeInput == "5") ? (indiaVix/math.sqrt(105120)/100) : (timeframeInput == "15") ? (indiaVix/math.sqrt(35040)/100) : (indiaVix/math.sqrt(365)/100) // factor = (indiaVix/math.sqrt(105120)/100) lower = price * (1 - factor) upper = price * (1 + factor) plot(lower, color = color.green, style = plot.style_line) // plot(price, color = color.black, style = plot.style_line) plot(upper, color = color.red, style = plot.style_line)
Range Projections [TFO]
https://www.tradingview.com/script/5mCuGUSR-Range-Projections-TFO/
tradeforopp
https://www.tradingview.com/u/tradeforopp/
1,277
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/ // © tradeforopp //@version=5 indicator("Range Projections [TFO]", "Range Projections [TFO]", true, max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500) // -------------------------------------------------- Inputs -------------------------------------------------- var g_SET = "Settings" session = input.session("1600-2000", "Session", inline = "X", tooltip = "The time window whose range will be utilized for projections", group = g_SET) range_type = input.string('Wick', "Range Type", options = ['Wick', 'Body'], tooltip = "Wick will consider the range from high to low, whereas Body will ignore the wicks (on the current chart timeframe)", group = g_SET) sd_limit = input.float(1.5, "Standard Deviation Filter", tooltip = "Ranges will be filtered out/ignored if their size exceeds this number of standard deviations (measured from a history of all prior range sizes)", group = g_SET) var g_SD = "Standard Deviations" use_sd_1 = input.bool(true, "SD 1", inline = "SD1", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD) sd_1 = input.float(1, "", 0, inline = "SD1", group = g_SD) use_sd_2 = input.bool(true, "SD 2", inline = "SD2", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD) sd_2 = input.float(2, "", 0, inline = "SD2", group = g_SD) use_sd_3 = input.bool(true, "SD 3", inline = "SD3", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD) sd_3 = input.float(3, "", 0, inline = "SD3", group = g_SD) use_sd_4 = input.bool(true, "SD 4", inline = "SD4", tooltip = "The difference between the range high and low will be multiplied by this factor, added to the range high for the upper projection, and subtracted from the range low for the lower projection", group = g_SD) sd_4 = input.float(4, "", 0, inline = "SD4", group = g_SD) var g_DRW = "Drawings" show_data = input.bool(true, "Data Table", tooltip = "Shows statistics on how often price exceeds X number of standard deviations from the range", group = g_DRW) vert_lines = input.bool(true, "Session Delineations", tooltip = "Draws vertical lines delineating the session beginning and ending times", group = g_DRW) show_labels = input.bool(true, "SD Labels", tooltip = "Shows the numerical value of each projection level", group = g_DRW) horiz_lines = input.bool(true, "SD Projection Lines", tooltip = "Extends the projections out in time", group = g_DRW) show_exceed = input.bool(true, "SD Projections Exceeded", tooltip = "Shows when price exceeds any of the projection levels", group = g_DRW) var g_STY = "Style" range_box_color = input.color(color.new(color.blue, 70), "Range Box Color", group = g_STY) range_line_color = input.color(color.black, "Range Delineation Color", group = g_STY) label_color = input.color(#ffffff00, "SD Label Color", group = g_STY) label_text = input.color(color.black, "SD Label Text", group = g_STY) proj_color = input.color(color.new(color.gray, 70), "SD Projection Box Color", group = g_STY) proj_style = input.string('Dotted', "SD Projection Line Style", options = ['Solid', 'Dotted', 'Dashed'], group = g_STY) line_color = input.color(color.black, "SD Projection Line Color", group = g_STY) exceed_color = input.color(color.blue, "SD Exceeded Color", group = g_STY) var g_TABLE = "Table" table_position = input.string('Top Right', "Table Position", options = ['Bottom Center', 'Bottom Left', 'Bottom Right', 'Middle Center', 'Middle Left', 'Middle Right', 'Top Center', 'Top Left', 'Top Right'], group = g_TABLE) table_size = input.string('Auto', "Text Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = g_TABLE) table_text = input.color(color.black, "Text", group = g_TABLE) table_bg = input.color(color.white, "Table Background", group = g_TABLE) table_frame = input.color(color.black, "Table Frame", group = g_TABLE) table_border = input.color(color.black, "Table Border", group = g_TABLE) table_border_width = input.int(1, "Table Border Width", group = g_TABLE) table_frame_width = input.int(2, "Table Frame Width", group = g_TABLE) // -------------------------------------------------- Inputs -------------------------------------------------- // -------------------------------------------------- Constants & Variables -------------------------------------------------- t = not na(time("", session, "America/New_York")) range_wick = range_type == 'Wick' transparent = #ffffff00 range_high = (range_wick ? high : math.max(open, close)) range_low = (range_wick ? low : math.min(open, close)) var range_size = array.new_float() var box range_box = na var box proj_p1 = na var box proj_m1 = na var box proj_p2 = na var box proj_m2 = na var box proj_p3 = na var box proj_m3 = na var box proj_p4 = na var box proj_m4 = na var int start = 0 var int sessions = 0 var bool valid_range = false var bool passed_p1 = false var bool passed_p2 = false var bool passed_p3 = false var bool passed_p4 = false var bool passed_m1 = false var bool passed_m2 = false var bool passed_m3 = false var bool passed_m4 = false var int count_p1 = 0 var int count_p2 = 0 var int count_p3 = 0 var int count_p4 = 0 var int count_m1 = 0 var int count_m2 = 0 var int count_m3 = 0 var int count_m4 = 0 var int count_a1 = 0 var int count_a2 = 0 var int count_a3 = 0 var int count_a4 = 0 var line line_p1 = na var line line_p2 = na var line line_p3 = na var line line_p4 = na var line line_m1 = na var line line_m2 = na var line line_m3 = na var line line_m4 = na // -------------------------------------------------- Constants & Variables -------------------------------------------------- // -------------------------------------------------- Functions -------------------------------------------------- manual_stdev() => mean = range_size.avg() accum = 0.0 size = range_size.size() if size > 0 for i = 0 to size - 1 accum += math.pow((range_size.get(i) - mean), 2) sd = math.sqrt(accum / size) get_line_style(i) => result = switch i 'Solid' => line.style_solid 'Dashed' => line.style_dashed 'Dotted' => line.style_dotted proj_style := get_line_style(proj_style) get_table_position(pos) => result = switch pos "Bottom Center" => position.bottom_center "Bottom Left" => position.bottom_left "Bottom Right" => position.bottom_right "Middle Center" => position.middle_center "Middle Left" => position.middle_left "Middle Right" => position.middle_right "Top Center" => position.top_center "Top Left" => position.top_left "Top Right" => position.top_right get_table_text_size(size) => result = switch size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge // -------------------------------------------------- Functions -------------------------------------------------- // -------------------------------------------------- Core Logic -------------------------------------------------- if t and not t[1] range_box := box.new(bar_index, range_high, bar_index, range_low, border_color = range_box_color, bgcolor = range_box_color) start := bar_index valid_range := false if vert_lines line.new(bar_index, high, bar_index, low, extend = extend.both, color = range_line_color) else if t range_box.set_right(bar_index) if range_high > range_box.get_top() range_box.set_top(range_high) if range_low < range_box.get_bottom() range_box.set_bottom(range_low) else if not t and t[1] top = range_box.get_top() bot = range_box.get_bottom() dif = top - bot range_size.push(dif) range_box := na line_p1 := na if vert_lines line.new(bar_index - 1, high, bar_index - 1, low, extend = extend.both, color = range_line_color) if dif <= manual_stdev() * sd_limit valid_range := true sessions += 1 if use_sd_1 proj_p1 := box.new(start, top + dif * sd_1, bar_index - 1, top, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, top + dif * sd_1, str.tostring(sd_1), textcolor = label_text, color = label_color, style = label.style_label_lower_left) if horiz_lines line_p1 := line.new(bar_index - 1, top + dif * sd_1, bar_index + 1, top + dif * sd_1, color = line_color, style = proj_style) if use_sd_2 proj_p2 := box.new(start, top + dif * sd_2, bar_index - 1, top + dif * sd_1, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, top + dif * sd_2, str.tostring(sd_2), textcolor = label_text, color = label_color, style = label.style_label_lower_left) if horiz_lines line_p2 := line.new(bar_index - 1, top + dif * sd_2, bar_index + 1, top + dif * sd_2, color = line_color, style = proj_style) if use_sd_3 proj_p3 := box.new(start, top + dif * sd_3, bar_index - 1, top + dif * sd_2, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, top + dif * sd_3, str.tostring(sd_3), textcolor = label_text, color = label_color, style = label.style_label_lower_left) if horiz_lines line_p3 := line.new(bar_index - 1, top + dif * sd_3, bar_index + 1, top + dif * sd_3, color = line_color, style = proj_style) if use_sd_4 proj_p4 := box.new(start, top + dif * sd_4, bar_index - 1, top + dif * sd_3, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, top + dif * sd_4, str.tostring(sd_4), textcolor = label_text, color = label_color, style = label.style_label_lower_left) if horiz_lines line_p4 := line.new(bar_index - 1, top + dif * sd_4, bar_index + 1, top + dif * sd_4, color = line_color, style = proj_style) if use_sd_1 proj_m1 := box.new(start, bot, bar_index - 1, bot - dif * sd_1, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, bot - dif * sd_1, "-" + str.tostring(sd_1), textcolor = label_text, color = label_color, style = label.style_label_upper_left) if horiz_lines line_m1 := line.new(bar_index - 1, bot - dif * sd_1, bar_index + 1, bot - dif * sd_1, color = line_color, style = proj_style) if use_sd_2 proj_m2 := box.new(start, bot - dif * sd_1, bar_index - 1, bot - dif * sd_2, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, bot - dif * sd_2, "-" + str.tostring(sd_2), textcolor = label_text, color = label_color, style = label.style_label_upper_left) if horiz_lines line_m2 := line.new(bar_index - 1, bot - dif * sd_2, bar_index + 1, bot - dif * sd_2, color = line_color, style = proj_style) if use_sd_3 proj_m3 := box.new(start, bot - dif * sd_2, bar_index - 1, bot - dif * sd_3, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, bot - dif * sd_3, "-" + str.tostring(sd_3), textcolor = label_text, color = label_color, style = label.style_label_upper_left) if horiz_lines line_m3 := line.new(bar_index - 1, bot - dif * sd_3, bar_index + 1, bot - dif * sd_3, color = line_color, style = proj_style) if use_sd_4 proj_m4 := box.new(start, bot - dif * sd_3, bar_index - 1, bot - dif * sd_4, border_color = proj_color, bgcolor = proj_color) if show_labels label.new(bar_index, bot - dif * sd_4, "-" + str.tostring(sd_4), textcolor = label_text, color = label_color, style = label.style_label_upper_left) if horiz_lines line_m4 := line.new(bar_index - 1, bot - dif * sd_4, bar_index + 1, bot - dif * sd_4, color = line_color, style = proj_style) else if not t if horiz_lines and not na(line_p1) line_p1.set_x2(bar_index + 1) line_p2.set_x2(bar_index + 1) line_p3.set_x2(bar_index + 1) line_p4.set_x2(bar_index + 1) line_m1.set_x2(bar_index + 1) line_m2.set_x2(bar_index + 1) line_m3.set_x2(bar_index + 1) line_m4.set_x2(bar_index + 1) if not t and valid_range if high > proj_p1.get_top() and not passed_p1 passed_p1 := true if show_exceed label.new(bar_index, proj_p1.get_top(), str.tostring(sd_1), style = label.style_label_down, color = exceed_color, textcolor = label_text) if high > proj_p2.get_top() and not passed_p2 passed_p2 := true if show_exceed label.new(bar_index, proj_p2.get_top(), str.tostring(sd_2), style = label.style_label_down, color = exceed_color, textcolor = label_text) if high > proj_p3.get_top() and not passed_p3 passed_p3 := true if show_exceed label.new(bar_index, proj_p3.get_top(), str.tostring(sd_3), style = label.style_label_down, color = exceed_color, textcolor = label_text) if high > proj_p4.get_top() and not passed_p4 passed_p4 := true if show_exceed label.new(bar_index, proj_p4.get_top(), str.tostring(sd_4), style = label.style_label_down, color = exceed_color, textcolor = label_text) if low < proj_m1.get_bottom() and not passed_m1 passed_m1 := true if show_exceed label.new(bar_index, proj_m1.get_bottom(), "-" + str.tostring(sd_1), style = label.style_label_up, color = exceed_color, textcolor = label_text) if low < proj_m2.get_bottom() and not passed_m2 passed_m2 := true if show_exceed label.new(bar_index, proj_m2.get_bottom(), "-" + str.tostring(sd_2), style = label.style_label_up, color = exceed_color, textcolor = label_text) if low < proj_m3.get_bottom() and not passed_m3 passed_m3 := true if show_exceed label.new(bar_index, proj_m3.get_bottom(), "-" + str.tostring(sd_3), style = label.style_label_up, color = exceed_color, textcolor = label_text) if low < proj_m4.get_bottom() and not passed_m4 passed_m4 := true if show_exceed label.new(bar_index, proj_m4.get_bottom(), "-" + str.tostring(sd_4), style = label.style_label_up, color = exceed_color, textcolor = label_text) else if t and not t[1] if passed_p1 or passed_m1 count_a1 += 1 if passed_p2 or passed_m2 count_a2 += 1 if passed_p3 or passed_m3 count_a3 += 1 if passed_p4 or passed_m4 count_a4 += 1 passed_p1 := false passed_p2 := false passed_p3 := false passed_p4 := false passed_m1 := false passed_m2 := false passed_m3 := false passed_m4 := false // -------------------------------------------------- Core Logic -------------------------------------------------- // -------------------------------------------------- Data Table -------------------------------------------------- if show_data var stats = table.new(get_table_position(table_position), 10, 10, bgcolor = table_bg, frame_color = table_frame, frame_width = table_frame_width, border_color = table_border, border_width = table_border_width) if barstate.islast ts = get_table_text_size(table_size) table.cell(stats, 0, 1, "Valid Sessions", text_size = ts) table.cell(stats, 1, 1, str.tostring(sessions), text_size = ts) table.cell(stats, 2, 1, "-", text_size = ts) if use_sd_1 table.cell(stats, 0, 2, "Exceeded " + str.tostring(sd_1) + " SD", text_size = ts) table.cell(stats, 1, 2, str.tostring(count_a1), text_size = ts) table.cell(stats, 2, 2, str.tostring(math.round(count_a1 / sessions * 1000) / 10) + "%", text_size = ts) if use_sd_2 table.cell(stats, 0, 3, "Exceeded " + str.tostring(sd_2) + " SD", text_size = ts) table.cell(stats, 1, 3, str.tostring(count_a2), text_size = ts) table.cell(stats, 2, 3, str.tostring(math.round(count_a2 / sessions * 1000) / 10) + "%", text_size = ts) if use_sd_3 table.cell(stats, 0, 4, "Exceeded " + str.tostring(sd_3) + " SD", text_size = ts) table.cell(stats, 1, 4, str.tostring(count_a3), text_size = ts) table.cell(stats, 2, 4, str.tostring(math.round(count_a3 / sessions * 1000) / 10) + "%", text_size = ts) if use_sd_4 table.cell(stats, 0, 5, "Exceeded " + str.tostring(sd_4) + " SD", text_size = ts) table.cell(stats, 1, 5, str.tostring(count_a4), text_size = ts) table.cell(stats, 2, 5, str.tostring(math.round(count_a4 / sessions * 1000) / 10) + "%", text_size = ts) // -------------------------------------------------- Data Table --------------------------------------------------
PriceCatch-Intraday Volume
https://www.tradingview.com/script/OOMr6lrG-PriceCatch-Intraday-Volume/
PriceCatch
https://www.tradingview.com/u/PriceCatch/
40
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/ // © PriceCatch // You must credit PriceCatch if you modify this code or use it in your scripts. //@version=5 indicator(title="PriceCatch-Intraday Volume", shorttitle="PC-IDVol", overlay=true) if not timeframe.isintraday runtime.error("Please change to intraday time-frame chart") var float _bullVol = na var int _bullCandles = na var float _bullTrades = na var float _bearVol = na var int _bearCandles = na var float _bearTrades = na var float _dojiVol = na var int _dojiCandles = na var float _dojiTrades = na _newDay = ta.change(time('D')) if _newDay _bearVol := 0 _bearCandles := 0 _bearTrades := 0 _bullVol := 0 _bullCandles := 0 _bullTrades := 0 _dojiVol := 0 _dojiCandles := 0 _dojiTrades := 0 if barstate.isconfirmed and open > close _bearVol += volume _bearCandles += 1 _bearTrades += volume / syminfo.pointvalue if barstate.isconfirmed and close > open _bullVol += volume _bullCandles += 1 _bullTrades += volume / syminfo.pointvalue if barstate.isconfirmed and open == close _dojiVol += volume _dojiCandles += 1 _dojiTrades += volume / syminfo.pointvalue // print results // Volume Info Panel Section tblPos = input.string(title='Position on Chart', defval='Bottom Center', options=['Top Left', 'Top Right', 'Bottom Left', 'Bottom Center', 'Bottom Right', 'Middle Left', 'Middle Right'], group="Information Panel") tblposition = tblPos == 'Top Left' ? position.top_left : tblPos == 'Top Right' ? position.top_right : tblPos == 'Bottom Left' ? position.bottom_left : tblPos == 'Bottom Center' ? position.bottom_center : tblPos == 'Bottom Right' ? position.bottom_right : tblPos == 'Middle Left' ? position.middle_left : position.middle_right tblBorderColor = input(title='Border Color', defval=#636363, group="Information Panel") title1_bgColor = input(title='Title Background', defval=#004074, group="Information Panel") title1_textColor = input(title='Title Text', defval=#7AC3ff, group="Information Panel") _downBgColor = input(title='Down Background Color', defval=#000000, group="Information Panel") _downTextColor = input(title='Down Text Color', defval=color.red, group="Information Panel") _upBgColor = input(title='Up Background Color', defval=#000000, group="Information Panel") _upTextColor = input(title='Up Text Color', defval=color.blue, group="Information Panel") _dojiBgColor = input(title='Doji Background Color', defval=#000000, group="Information Panel") _dojiTextColor = input(title='Doji Text Color', defval=color.rgb(185, 185, 185), group="Information Panel") var table resultsTable = na resultsTable := table.new(position=tblposition, columns=4, rows=4, bgcolor=#ffffff, border_width=0, frame_color=tblBorderColor, frame_width=2) table.cell( resultsTable, column=0, row=0, text= "", text_color=title1_textColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=title1_bgColor, text_size=size.normal) table.cell( resultsTable, column=1, row=0, text= "Volume", text_color=title1_textColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=title1_bgColor, text_size=size.normal) table.cell( resultsTable, column=2, row=0, text= "Candles", text_color=title1_textColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=title1_bgColor, text_size=size.normal) table.cell( resultsTable, column=3, row=0, text= "Trades", text_color=title1_textColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=title1_bgColor, text_size=size.normal) table.cell( resultsTable, column=0, row=1, text= "Down", text_color=_downTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_downBgColor, text_size=size.normal) table.cell( resultsTable, column=1, row=1, text= str.tostring(_bearVol), text_color=_downTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_downBgColor, text_size=size.normal) table.cell( resultsTable, column=2, row=1, text= str.tostring(_bearCandles), text_color=_downTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_downBgColor, text_size=size.normal) table.cell( resultsTable, column=3, row=1, text= str.tostring(_bearTrades), text_color=_downTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_downBgColor, text_size=size.normal) table.cell( resultsTable, column=0, row=2, text= "Up", text_color=_upTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_upBgColor, text_size=size.normal) table.cell( resultsTable, column=1, row=2, text= str.tostring(_bullVol), text_color=_upTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_upBgColor, text_size=size.normal) table.cell( resultsTable, column=2, row=2, text= str.tostring(_bullCandles), text_color=_upTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_upBgColor, text_size=size.normal) table.cell( resultsTable, column=3, row=2, text= str.tostring(_bullTrades), text_color=_upTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_upBgColor, text_size=size.normal) table.cell( resultsTable, column=0, row=3, text= "Doji", text_color=_dojiTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_dojiBgColor, text_size=size.normal) table.cell( resultsTable, column=1, row=3, text= str.tostring(_dojiVol), text_color=_dojiTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_dojiBgColor, text_size=size.normal) table.cell( resultsTable, column=2, row=3, text= str.tostring(_dojiCandles), text_color=_dojiTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_dojiBgColor, text_size=size.normal) table.cell( resultsTable, column=3, row=3, text= str.tostring(_dojiTrades), text_color=_dojiTextColor, text_halign=text.align_center, text_valign=text.align_center, bgcolor=_dojiBgColor, text_size=size.normal)
3 Fib EMAs To Scalp Them All
https://www.tradingview.com/script/0muaoeXU-3-Fib-EMAs-To-Scalp-Them-All/
JohannCoffee
https://www.tradingview.com/u/JohannCoffee/
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/ // © JohannCoffee //@version=5 indicator("3 Fib EMAs To Scalp Them All", shorttitle="Fib EMAs", overlay=true) // EMA inputs input_ema1 = input(21, title="Micro EMA", group = "Choose Your EMA") input_ema2 = input(55, title="Mid EMA", group = "Choose Your EMA") input_ema3 = input(233, title="Macro EMA", group = "Choose Your EMA") // Bollinger Bands length = input(200, title = "Bands length") src = input(hlc3, title="Source") mult = input.float(defval = 3.0, title = "Mult", minval=0.001, maxval=50) basis = ta.vwma(src, length) dev = mult * ta.stdev(src, length) upper= basis + (1*dev) lower= basis - (1*dev) ema1 = ta.ema(close, input_ema1) ema2 = ta.ema(close, input_ema2) ema3 = ta.ema(close, input_ema3) var color color_ema1 = na var color color_prev = na color_ema1 := ema1 < ema2 and ema2 < ema3 ? color.rgb(255, 0, 0) : ema1 > ema2 and ema2 > ema3 ? color.rgb(0, 255, 8) : color.new(#f7fff7, 0) redDiamondCondition = na(color_ema1[1]) ? na : color_ema1 == color.rgb(255, 0, 0) and color_prev != color.rgb(255, 0, 0) greenDiamondCondition = na(color_ema1[1]) ? na : color_ema1 == color.rgb(0, 255, 8) and color_prev != color.rgb(0, 255, 8) redCrossCondition = na(color_ema1[1]) ? na : color_prev == color.rgb(255, 0, 0) and color_ema1 != color.rgb(255, 0, 0) greenCrossCondition = na(color_ema1[1]) ? na : color_prev == color.rgb(0, 255, 8) and color_ema1 != color.rgb(0, 255, 8) color_prev := color_ema1 // Plotting EMAs line1 = plot(ema1, color=color_ema1 ,title="Micro EMA") line2 = plot(ema2, color=color.new(#4ecdc4,0), title="Mid EMA") line3 = plot(ema3, color=color.new(#1a535c,0), title="Macro EMA") fill(line1, line2, color=color.new(#4ecdc4,70)) fill(line2, line3, color=color.new(#1a535c,90)) // Plot RS Fib Bands plot(upper, color=color.rgb(14,100,84), linewidth=2, title="Upper Band") plot(lower, color=color.rgb(14,100,84), linewidth=2, title="Lower Band") // Plot signals plotshape(series=redDiamondCondition, location=location.abovebar, color=color.rgb(255, 0, 0), style=shape.diamond, offset = -1, size = size.small, title="Downtrend") plotshape(series=redCrossCondition, location=location.abovebar, color=color.rgb(255, 0, 0), style=shape.xcross, offset = -1, size = size.small, title="Downtrend end") plotshape(series=greenDiamondCondition, location=location.belowbar, color=color.rgb(0, 255, 8), style=shape.diamond, offset = -1, size = size.small, title="Uptrend") plotshape(series=greenCrossCondition, location=location.belowbar, color=color.rgb(0, 255, 8), style=shape.xcross, offset = -1, size = size.small, title="Uptrend end") // Alerts alertcondition(redDiamondCondition, title="Downtrend", message="Red Diamond: Time to short!") alertcondition(redCrossCondition, title="Downtrend Stopped", message="Red Cross: End of downtrend, exit short positions!") alertcondition(greenDiamondCondition, title="Uptrend", message="Green Diamond: Time to go long!") alertcondition(greenCrossCondition, title="Uptrend Stopped", message="Green Cross: End of uptrend, exit long positions!") //
Selective Moving Average: Demo
https://www.tradingview.com/script/XvnYrN12-Selective-Moving-Average-Demo/
wbburgin
https://www.tradingview.com/u/wbburgin/
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/ // © wbburgin //@version=5 indicator("Selective Moving Average: Demo",shorttitle = "Selective Moving Average [wbburgin]",overlay=true) selective_ma(bool condition, float source, simple int length, string ma_type) => selective_data = condition ? source : na sum_selective_data = 0.0 count = 0 for i = 0 to length - 1 if not na(selective_data[i]) sum_selective_data := sum_selective_data + selective_data[i] count := count + 1 selma = 0. if count > 0 if ma_type == "SMA" selma := sum_selective_data / count if ma_type == "EMA" selma := ta.ema(sum_selective_data / count, length) if ma_type == "RMA" selma := ta.rma(sum_selective_data / count, length) if ma_type == "WMA" selma := ta.wma(sum_selective_data / count, length) if ma_type == "VWMA" selma := ta.vwma(sum_selective_data / count, length) selma src = input.source(close,"Source") condition_str = input.string("Source Within 1 Standard Deviation","Condition",options=["Source Within 1 Standard Deviation","Source Within 2 Standard Deviations","Positive Volume","Negative Volume","RSI > 50","RSI < 50","Candlestick > Body"], tooltip="Condition that you want the moving average to take into account. Future updates will include external conditions.") length = input.int(200,"Length") ma_type = input.string("SMA","Average Type",options=["SMA","EMA","RMA","WMA","VWMA"]) condition_length = input.int(14,"Condition Length",tooltip = "If your condition is an indicator and has a length, add it here.") within_stdev(source,length,standevs)=> ma = ta.sma(source,length) dev = ta.stdev(source,length) condition = source > ma - (standevs * dev) and source < ma + (standevs * dev) ? true : false condition condition = switch condition_str == "Source Within 1 Standard Deviation" => within_stdev(src,length,1) condition_str == "Source Within 2 Standard Deviations"=> within_stdev(src,length,2) condition_str == "Positive Volume" => volume > volume[1] condition_str == "Negative Volume" => volume < volume[1] condition_str == "RSI > 50" => ta.rsi(src,condition_length) > 50 condition_str == "RSI < 50" => ta.rsi(src,condition_length) < 50 condition_str == "Candlestick > Body" => high - math.max(close,open) + math.min(close,open) - low > math.abs(close-open) selma = selective_ma(condition,src,length,ma_type) > 0 ? selective_ma(condition,src,length,ma_type) : na plot(selma,color=color.yellow,title="Selective Moving Average",style=plot.style_linebr)
improved volume
https://www.tradingview.com/script/MgDqdchK/
CyrptoTraderBoss
https://www.tradingview.com/u/CyrptoTraderBoss/
51
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/ // © KriptoTraderYusuf //@version=5 indicator('improved Volume', shorttitle='Vol', overlay=false, format = format.volume) ma = input(defval = true, title = "Length", inline = "ma") len = input(defval = 21, title = "", inline = "ma") src = input.string(defval = "SMA", title = "Average", options = ["SMA", "EMA"], inline = "ma") type = ma ? (src == "SMA" ? math.round(ta.sma(volume, len)) : math.round(ta.ema(volume, len))) : na clr = close > open ? color.green : color.red plot(math.round(volume), title='Volume', style=plot.style_columns, color = clr) plot(type, title= "Average", color=color.new(color.yellow, 50), style=plot.style_area) plot(type * 2 , title= "2x Ortalama", color=color.new(color.yellow, 0), style=plot.style_line, show_last = 1) plot(type * 3 , title= "3x Ortalama", color=color.new(color.yellow, 0), style=plot.style_line, show_last = 1) plot(type * 4 , title= "4x Ortalama", color=color.new(color.yellow, 0), style=plot.style_line, show_last = 1) kesx1 = ta.cross(volume, (type *1)) kesx2 = ta.cross(volume, (type *2)) kesx3 = ta.cross(volume, (type *3)) kesx4 = ta.cross(volume, (type *4)) alertcondition(kesx1, title='1x Hacim Sinyali', message='Hacim 1X Seviyesinde!') alertcondition(kesx2, title='2x Hacim Sinyali', message='Hacim 2X Seviyesinde!') alertcondition(kesx3, title='3x Hacim Sinyali', message='Hacim 3X Seviyesinde!') alertcondition(kesx4, title='4x Hacim Sinyali', message='Hacim 4X Seviyesinde!')
Gap Finder (Arpan)
https://www.tradingview.com/script/4jRL0LSN-Gap-Finder-Arpan/
truetechlevels
https://www.tradingview.com/u/truetechlevels/
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/ // © truetechlevels //@version=5 indicator("Gap Finder (Arpan)", overlay = true, max_boxes_count = 25) varBS = ta.barssince(dayofmonth != dayofmonth[1]) var varBlOpeningGaps = input.bool(false, "Opening Gaps On/Off") var varBoxLength = input.int(0, "Box Length") var varGapupBGColor = input.color(color.aqua, "Gap Up Background") var varGapupBorderColor = input.color(color.white, "Gap Up Border") var varGapDnBGColor = input.color(color.rgb(215, 31, 248), "Gap Down Background") var varGapDnBorderColor = input.color(color.white, "Gap Down Border") varBlGapUp = low > high[1] varBlGapDown = high < low[1] if varBlGapUp if varBlOpeningGaps==false and ( varBS > 1) BoxUp = box.new(bar_index-1,low,bar_index + varBoxLength,high[1], border_color = varGapupBorderColor, bgcolor = varGapupBGColor) else if varBlOpeningGaps BoxUp = box.new(bar_index-1,low,bar_index + varBoxLength,high[1], border_color = varGapupBorderColor, bgcolor = varGapupBGColor) if varBlGapDown if varBlOpeningGaps==false and ( varBS > 1) BoxDown = box.new(bar_index-1,high,bar_index + varBoxLength,low[1], border_color = varGapDnBorderColor, bgcolor = varGapDnBGColor) else if varBlOpeningGaps BoxDown = box.new(bar_index-1,high,bar_index + varBoxLength,low[1], border_color = varGapDnBorderColor, bgcolor = varGapDnBGColor)
Volatility-Based Mean Reversion Bands
https://www.tradingview.com/script/Iy7HR2sE-Volatility-Based-Mean-Reversion-Bands/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
127
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/ // © LeafAlgo //@version=5 indicator("Volatility-Based Mean Reversion Bands", overlay=true) // Calculation Inputs length = input.int(20, "Lookback Period", minval=1) multiplier = input.float(2.5, "Multiplier", minval=0.1, maxval=10.0) // Calculate Average True Range (ATR) atr = ta.atr(length) // Calculate Mean Reversion Bands mean = ta.sma(close, length) upperBand = mean + (atr * multiplier) lowerBand = mean - (atr * multiplier) // RSI Inputs useRSI = input.bool(true, "Use RSI as Confluence") rsiLength = input.int(20, "RSI Length", minval=1) // Calculate RSI rsi = useRSI ? ta.rsi(close, rsiLength) : na // Confluence Conditions confluenceRSI = useRSI ? (rsi > 70 or rsi < 30) : false confluenceCondition = confluenceRSI // Plotting plot(mean, color=color.blue, linewidth=2, title="Mean") plot(upperBand, color=color.lime, linewidth=2, title="Upper Band") plot(lowerBand, color=color.fuchsia, linewidth=2, title="Lower Band") // Bar Color barC = close > upperBand ? color.lime : close < lowerBand ? color.fuchsia : na barcolor(barC) // Background Color bgColor = barC == color.lime ? color.new(color.lime, 80) : barC == color.fuchsia ? color.new(color.fuchsia, 80) : na bgcolor(bgColor) // Entry Arrows plotshape(close > upperBand and confluenceCondition, title="Short Entry", location=location.abovebar, color=color.fuchsia, style=shape.triangleup, size=size.small) plotshape(close < lowerBand and confluenceCondition, title="Long Entry", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.small) // Alert Conditions alertcondition(close > upperBand and confluenceCondition, title="Short Entry", message="Short Entry Signal") alertcondition(close < lowerBand and confluenceCondition, title="Long Entry", message="Long Entry Signal")
EMA/SMA Cross with Levels
https://www.tradingview.com/script/XpkYKL0M-EMA-SMA-Cross-with-Levels/
jjustingreyy
https://www.tradingview.com/u/jjustingreyy/
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/ // © jjustingreyy //@version=5 indicator(title='EMA/SMA Cross', overlay=true) HTF = input.timeframe('', 'TimeFrame') short_src = input.source(close, 'Short Source', inline='short') short_len = input.int(120, 'Length', inline='short') long_src = input.source(close, 'Long Source', inline='long') long_len = input.int(200, 'Length', inline='long') last = input(5, 'Display last X lines') short = request.security(syminfo.tickerid, HTF, ta.ema(short_src, short_len)) long = request.security(syminfo.tickerid, HTF, ta.sma(long_src, long_len)) plot(short, color=color.rgb(85, 240, 131)) plot(long, color=color.rgb(240, 97, 97)) colordots = short >= long ? color.green : color.red plot(ta.cross(short, long) ? short : na, style=plot.style_circles, linewidth=4, color=colordots, transp=0) lineLevel = ta.cross(short, long) ? short : na var mylines = array.new_line(0) if ta.cross(short, long) array.push(mylines, line.new(x1=bar_index - 1, y1=long, x2=bar_index, y2=long, xloc=xloc.bar_index, style=line.style_dashed, extend=extend.right, color=color.white, width=1)) if array.size(mylines) > last line.delete(array.get(mylines, 0)) array.remove(mylines, 0)
Dynamic Trendlines Multi-Timeframe
https://www.tradingview.com/script/pFV6T1r2-Dynamic-Trendlines-Multi-Timeframe/
jjustingreyy
https://www.tradingview.com/u/jjustingreyy/
169
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/ // © jjustingreyy //@version=5 indicator(title='Dynamic Trendlines Multi-Timeframe', overlay=true, shorttitle="MTF Dyno Lines") // Input settings atrLength = input(14, title="ATR Length") thresholdMultiplier = input(1.5, title="Threshold Multiplier") HTF = input.timeframe('', 'TimeFrame') // Get data from the higher timeframe [h_high, h_low, h_close] = request.security(syminfo.tickerid, HTF, [high, low, close]) // Calculate True Range and Average True Range trueRange = math.max(math.max(h_high - h_low, math.abs(h_high - h_close[1])), math.abs(h_low - h_close[1])) atr = ta.sma(trueRange, atrLength) threshold = atr * thresholdMultiplier // Determine if it's a high volatility candle isHighVolatility = h_close > h_close[1] + threshold // Line settings last = input(5, 'Display last X lines') lineLevel = isHighVolatility ? (h_close[1] > h_close ? h_high : h_low) : na // Line management variables var line[] mylines = array.new_line(0) var bool[] mylinestyles = array.new_bool(0) // Store initial styles var int[] crossCount = array.new_int(0) // Store cross counts var float prevLineLevel = na var int prevBarIndex = na var bool prevState = na // Draw trendlines if isHighVolatility if not na(prevLineLevel) // Determine the initial color and style based on price action initialColor = close[1] > lineLevel ? color.rgb(108, 240, 126) : color.red initialStyle = close[1] > lineLevel ? line.style_solid : line.style_solid // Create the new line and add it to the array lineId = line.new(x1=prevBarIndex, y1=prevLineLevel, x2=bar_index[0], y2=lineLevel, xloc=xloc.bar_index, style=initialStyle, extend=array.size(mylines) == last - 1 ? extend.right : extend.none, color=initialColor, width=2) array.push(mylines, lineId) array.push(mylinestyles, initialStyle == line.style_solid) // Store the initial style as a boolean (true for solid) array.push(crossCount, 0) // Initialize cross count for the new line // Remove lines and associated data beyond the recent X amount of lines if array.size(mylines) > last line.delete(array.shift(mylines)) array.shift(mylinestyles) array.shift(crossCount) // Update previous line level and bar index prevLineLevel := lineLevel prevBarIndex := bar_index[0] // Check for price crossing the trendline var line closestLine = na if array.size(mylines) > 0 closestLine := array.get(mylines, array.size(mylines) - 1) crossOver = ta.crossover(close, line.get_price(closestLine, bar_index)) crossUnder = ta.crossunder(close, line.get_price(closestLine, bar_index)) // Declare isAboveLine variable bool isAboveLine = na // Update the color of the closest trendline based on price action if array.size(mylines) > 0 isAboveLine := close >= line.get_price(closestLine, bar_index) if na(prevState) prevState := isAboveLine if crossOver or crossUnder // Increment the cross count array.set(crossCount, array.size(crossCount) - 1, array.get(crossCount, array.size(crossCount) - 1) + 1) // Check if the price has crossed the trendline twice if array.get(crossCount, array.size(crossCount) - 1) >= 2 line.set_style(closestLine, line.style_dashed) // Set line style to dashed when the price crosses a red line else line.set_color(closestLine, isAboveLine ? color.rgb(108, 240, 126) : color.rgb(255, 82, 82)) prevState := isAboveLine // Extend only the current line to the right for i = 0 to array.size(mylines) - 1 line.set_extend(array.get(mylines, i), i == array.size(mylines) - 1 ? extend.right : extend.none) // Plot triangles for high volatility candles with color based on the trendline it starts shapeColor = color.rgb(255, 255, 255) plotshape(isHighVolatility and array.size(mylines) <= last, style=shape.triangleup, location=location.belowbar, color=shapeColor, size=size.tiny)
Bull & Bear Engulfing - 3 Strike and 180 Candles
https://www.tradingview.com/script/0hxHKYGA-Bull-Bear-Engulfing-3-Strike-and-180-Candles/
SenatorVonShaft
https://www.tradingview.com/u/SenatorVonShaft/
29
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/ // © SenatorVonShaft //@version=4 study("Bull & Bear Engulfing - 3 Strike and 180 Candles" , overlay = true) candlperc = input(title="Bar Fullness Percentage", minval=50.00, maxval=100, step=0.1, defval=80) * 0.01 AvgBarBack = input(title = "Average Bar Backwds Candles", minval=1, step=1, defval=20) avgcandlmult = input(title="Average Bar Height Multiptier", minval=0.1, maxval=20, step=0.1, defval=1.5) ortBar = sma(abs(close - open) , AvgBarBack) ortBarCond = abs(close - open) > avgcandlmult * ortBar BiggerBar = abs (close - open) > abs (close [1] - open [1]) BullBar = close > open and hl2 > open and ((close - open) / (high - low)) >= candlperc and BiggerBar and ortBarCond BearBar = close < open and hl2 < open and ((open - close) / (high - low)) >= candlperc and BiggerBar and ortBarCond Bull3 = BullBar and close[1] < open [1] and close[2] < open [2] and close[3] < open [3] and close > open [3] Bear3 = BearBar and close[1] > open [1] and close[2] > open [2] and close[3] > open [3] and close < open [3] Bull180 = BearBar[1] and close > open and abs(open - close) > abs(open[1] - close [1]) Bear180 = BullBar[1] and close < open and abs(open - close) > abs(open[1] - close [1]) plotshape(BullBar, style=shape.labelup , location= location.belowbar, color = color.green, transp = 10 ) // plotshape(BearBar, style=shape.labeldown, location=location.abovebar , color = color.red, transp = 10 ) plotshape(Bull3, style=shape.labelup , location=location.belowbar, color = color.green, transp = 10 , text = "3S" , textcolor = color.white ) plotshape(Bear3, style=shape.labeldown , location=location.abovebar , color = color.red, transp = 10 , text = "3S" , textcolor = color.white ) plotshape(Bull180, style=shape.labelup , location=location.belowbar, color = color.green, transp = 10 , text = "180" , textcolor = color.white ) plotshape(Bear180, style=shape.labeldown , location=location.abovebar , color = color.red, transp = 10 , text = "180" , textcolor = color.white ) plot (ortBar , color = color.white)
Support Resistance Classification [LuxAlgo]
https://www.tradingview.com/script/5FCWOMoR-Support-Resistance-Classification-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
1,830
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( title='Support Resistance Classification [LuxAlgo]' , shorttitle='LuxAlgo - Support Resistance Classification' , max_lines_count =500 , max_labels_count=500 , max_bars_back =3000 , overlay =true) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ set = 'SET (N° – Type – Length – Mult – HTF)' lkb = input.int ( 500 , 'Lookback' , minval=20, maxval=3000 ) fade = input.int ( 5 , 'fade' , tooltip='After x breaks\nthe line is invisible') opt = input.string ('line', 'value' , options= ['value', 'line'] ) colU = input.color (color.lime, '              ' , inline='c') colD = input.color (color.red , '' , inline='c') left = input.int ( 10, 'left' , minval=1, maxval=20 , group='Swings settings' ) right = input.int ( 1, 'right', minval=1, maxval=10 , group='Swings settings' ) showPP = input.bool (false, 'show' , group='Swings settings' ) chc1 = input.string ( 'SMA' , '1' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='1') len1 = input.int ( 50 , '' , group=set , inline='1') mlt1 = input.float ( 2 , '' , group=set , inline='1') res1 = input.timeframe( 'D' , '' , group=set , inline='1') chc2 = input.string ( 'SMA' , '2' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='2') len2 = input.int ( 100 , '' , group=set , inline='2') mlt2 = input.float ( 2 , '' , group=set , inline='2') res2 = input.timeframe( 'D' , '' , group=set , inline='2') chc3 = input.string ( 'SMA' , '3' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='3') len3 = input.int ( 20 , '' , group=set , inline='3') mlt3 = input.float ( 2 , '' , group=set , inline='3') res3 = input.timeframe( 'W', '' , group=set , inline='3') chc4 = input.string ('Previous High' , '4' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='4') len4 = input.int ( 20 , '' , group=set , inline='4') mlt4 = input.float ( 2 , '' , group=set , inline='4') res4 = input.timeframe( 'W' , '' , group=set , inline='4') chc5 = input.string ( 'Previous Low' , '5' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='5') len5 = input.int ( 20 , '' , group=set , inline='5') mlt5 = input.float ( 2 , '' , group=set , inline='5') res5 = input.timeframe( 'W' , '' , group=set , inline='5') chc6 = input.string ('Upper' , '6' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='6') len6 = input.int ( 20 , '' , group=set , inline='6') mlt6 = input.float ( 2 , '' , group=set , inline='6') res6 = input.timeframe( 'D' , '' , group=set , inline='6') chc7 = input.string ('Lower' , '7' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='7') len7 = input.int ( 20 , '' , group=set , inline='7') mlt7 = input.float ( 2 , '' , group=set , inline='7') res7 = input.timeframe( 'D' , '' , group=set , inline='7') chc8 = input.string ('Swings' , '8' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='8') len8 = input.int ( 20 , '' , group=set , inline='8') mlt8 = input.float ( 2 , '' , group=set , inline='8') res8 = input.timeframe( 'D' , '' , group=set , inline='8') chc9 = input.string ('Fibonacci' , '9' , options = ['NONE','SMA','Upper','Lower','Previous High','Previous Low','Swings','Fibonacci'] , group=set , inline='9') len9 = input.int ( 20 , '' , group=set , inline='9') mlt9 = input.float ( 2 , '' , group=set , inline='9') res9 = input.timeframe( 'W' , '' , group=set , inline='9') pick1 = input.bool (false , 'A' , group='show values', inline='1') choice1 = input.int ( 1 , '' , minval=1, maxval=9, group='show values', inline='1') pick2 = input.bool (false , 'B' , group='show values', inline='2') choice2 = input.int ( 3 , '' , minval=1, maxval=9, group='show values', inline='2') pick3 = input.bool (false , 'C' , group='show values', inline='3') choice3 = input.int ( 5 , '' , minval=1, maxval=9, group='show values', inline='3') pick4 = input.bool (false , 'D' , group='show values', inline='4') choice4 = input.int ( 7 , '' , minval=1, maxval=9, group='show values', inline='4') pick5 = input.bool (false , 'E' , group='show values', inline='5') choice5 = input.int ( 9 , '' , minval=1, maxval=9, group='show values', inline='5') showBreaks = false //-----------------------------------------------------------------------------} //User Defined Types //-----------------------------------------------------------------------------{ type piv int b float p type sw label lb line ln type data int e float value string chc string txt string tooltip int grade label lb line ln //-----------------------------------------------------------------------------} //Variables //-----------------------------------------------------------------------------{ n = bar_index isRecent = last_bar_index - n <= lkb max = array.from(0.) float [] aGrade = array.new<float>() var data[] aData = array.new<data >() var sw [] aSw = array.new< sw >() var piv [] pivH = array.new<piv>(1, piv.new(na, na)) var piv [] pivL = array.new<piv>(1, piv.new(na, na)) arrChoices = array.from(chc1, chc2, chc3, chc4, chc5, chc6, chc7, chc8, chc9) var box top = box.new(na, na, na, na, bgcolor=color.new(color.red , 90), border_color=color(na)) var box btm = box.new(na, na, na, na, bgcolor=color.new(color.lime, 90), border_color=color(na)) var line st = line(na) var float mnPiv = 10e6 var float mxPiv = 0 //-----------------------------------------------------------------------------} //General Calculations //-----------------------------------------------------------------------------{ fromR = opt == 'value' ph = ta.pivothigh(left, right) pl = ta.pivotlow (left, right) highest = ta.highest (lkb) lowest = ta.lowest (lkb) if isRecent hSz = pivH.size() lSz = pivL.size() // delete pivots which are too far if hSz > 0 for i = hSz -1 to 0 if pivH.get(i).b < last_bar_index - lkb pivH.remove(i) if lSz > 0 for i = lSz -1 to 0 if pivL.get(i).b < last_bar_index - lkb pivL.remove(i) // only keep non-broken pivots if ph if ph > mxPiv mxPiv := ph for i = pivH.size() -1 to 0 get = pivH.get(i) if ph >= get.p pivH.remove(i) pivH.unshift(piv.new(n -right, ph)) if pl if pl < mnPiv mnPiv := pl for i = pivL.size() -1 to 0 get = pivL.get(i) if pl <= get.p pivL.remove(i) pivL.unshift(piv.new(n -right, pl)) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ isPP(get) => pp = get == 'Fibonacci' choiceIsPP(i) => get = arrChoices.get(i), isPP(get) f(choice) => c = choice == 1 ? chc1 : choice == 2 ? chc2 : choice == 3 ? chc3 : choice == 4 ? chc4 : choice == 5 ? chc5 : choice == 6 ? chc6 : choice == 7 ? chc7 : choice == 8 ? chc8 : chc9 notPP = c != 'Fibonacci' setLine(e, sBs, chc, len, res) => // collect data from last 'lkb' bars (isRecent) var float val = na val := sBs hl = chc == 'Previous High' or chc == 'Previous Low' htf = timeframe.in_seconds(res) >= timeframe.in_seconds(timeframe.period) tfChange = timeframe.change (res) bsChange = ta.barssince (tfChange) bars = hl and fromR ? math.min(lkb, bsChange) : lkb // only push data in array when latest bar if barstate.islast and val <= highest and val >= lowest and htf firstPos = sBs > close ? 'r' : 's' // 's/r' support or resistance at current bar pos = 1 // 1/0 -> 1 = same position as firstPos , 0 = diff pos breaks = 0 switch firstPos 'r' => for i = 0 to bars // lkb v = hl ? val : fromR ? val[i] : val if pos == 1 and close[i] > v breaks += 1 pos := 0 if pos == 0 and close[i] < v pos := 1 's' => for i = 0 to bars // lkb v = hl ? val : fromR ? val[i] : val if pos == 1 and close[i] < v breaks += 1 pos := 0 if pos == 0 and close[i] > v pos := 1 isAbove = close > val grade = math.min(100, math.round((100 / fade) * breaks)) max.set(0, math.max(max.get(0), grade)) chart = res == '' s = chart ? 'chart' : res aData.unshift( data.new( e , val , chc , (chart ? '' : '(') + res + (chart ? '' : ')') + (showBreaks ? '\n' + str.tostring(breaks) : '') , str.format("N°{0} – HTF: {1} \n{2}", e, s, chc) + (hl ? '' : ', len ' + str.tostring(len)) , grade ) ) aGrade.unshift(grade) calc(e, chc, len, mlt, res) => // collect data var float bs = na var arrPP = array.from( 0., 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ) act = chc != 'NONE' htf = timeframe.in_seconds(res) >= timeframe.in_seconds(timeframe.period) if htf bs := switch chc 'SMA' => ta.sma(close, len) "Swings" => na "Previous High" => high "Previous Low" => low => [b, u, l] = ta.bb(close, len, mlt) switch chc 'Upper' => u 'Lower' => l => na sBs = htf ? request.security(syminfo.tickerid, res, act ? bs[1] : na, lookahead=barmerge.lookahead_on) : na if act and isRecent pp = isPP(chc) st = pp ? 'Fib.' : chc switch pp and htf => // collect data from last 'lkb' bars (isRecent) var arStr = array.from('P', 'R1', 'S1', 'R2', 'S2', 'R3', 'S3', 'R4', 'S4', 'R5', 'S5') tfChange = timeframe.change(res) bsChange = ta.barssince(tfChange) pivotPointsArray = ta.pivot_point_levels(chc, timeframe.change(res)) if tfChange for i = 0 to pivotPointsArray.size() -1 arrPP.set(i, pivotPointsArray.get(i)) // only push data in array when latest bar if barstate.islast for i = 0 to arrPP.size() -1 p = arrPP.get(i) if p <= highest and p >= lowest firstPos = p > close ? 'r' : 's' // 's/r' support or resistance at chart.left_visible_bar_time pos = 1 // 1/0 -> 1 = same position as firstPos , 0 = diff pos breaks = 0 bars = fromR ? math.min(lkb, bsChange) : lkb switch firstPos 'r' => for d = 0 to bars if pos == 1 and close[d] > p breaks += 1 pos := 0 if pos == 0 and close[d] < p pos := 1 's' => for d = 0 to bars if pos == 1 and close[d] < p breaks += 1 pos := 0 if pos == 0 and close[d] > p pos := 1 isAbove = close > p chart = res == '' s = chart ? 'chart' : res grade = math.min(100, math.round((100 / fade) * breaks)) max.set(0, math.max(max.get(0), grade)) aData.unshift( data.new( e , p , chc , (chart ? '' : '(') + res + (chart ? '' : ')') + (showBreaks ? '\n' + str.tostring(breaks) : '') , str.format("N°{0} – HTF: {1} \n{2} ({3})" , e, s, arStr.get(i), st) , grade ) ) aGrade.unshift(grade) chc != 'Swings' and htf => setLine(e, sBs, chc, len, res) chc == 'Swings' => // Swings if barstate.islast for i = 0 to pivH.size() -1 p = pivH.get(i) if p.p <= highest and p.p >= lowest pos = 1 breaks = 0 //only 'line', otherwise 0 breaks (if breaks, Swings would not be included) for d = 0 to lkb if pos == 1 and close[d] > p.p breaks += 1 pos := 0 if pos == 0 and close[d] < p.p pos := 1 grade = math.min(100, math.round((100 / fade) * breaks)) max.set(0, math.max(max.get(0) , grade)) aData.unshift( data.new( e , p.p , chc , '' + (showBreaks ? '\n' + str.tostring(breaks) : '') , 'N°' + str.tostring(e) + ' Swings' , grade ) ) aGrade.unshift(grade) for i = 0 to pivL.size() -1 p = pivL.get(i) if p.p <= highest and p.p >= lowest pos = 1 breaks = 0 //only 'line', otherwise 0 breaks (if breaks, Swings would not be included) for d = 0 to lkb if pos == 1 and close[d] < p.p breaks += 1 pos := 0 if pos == 0 and close[d] > p.p pos := 1 grade = math.min(100, math.round((100 / fade) * breaks)) max.set(0, math.max(max.get(0) , grade)) aData.unshift( data.new( e , p.p , chc , '' + (showBreaks ? '\n' + str.tostring(breaks) : '') , 'N°' + str.tostring(e) + ' Swings' , grade ) ) aGrade.unshift(grade) [sBs, arrPP] //-----------------------------------------------------------------------------} //Calculations //-----------------------------------------------------------------------------{ // first delete data and labels/lines while aData.size() > 0 pop = aData.pop() pop.lb.delete () pop.ln.delete () // then collect data e = 1 [sBs1, arrPP1] = calc(e, chc1 , len1 , mlt1 , res1 ), e +=1 [sBs2, arrPP2] = calc(e, chc2 , len2 , mlt2 , res2 ), e +=1 [sBs3, arrPP3] = calc(e, chc3 , len3 , mlt3 , res3 ), e +=1 [sBs4, arrPP4] = calc(e, chc4 , len4 , mlt4 , res4 ), e +=1 [sBs5, arrPP5] = calc(e, chc5 , len5 , mlt5 , res5 ), e +=1 [sBs6, arrPP6] = calc(e, chc6 , len6 , mlt6 , res6 ), e +=1 [sBs7, arrPP7] = calc(e, chc7 , len7 , mlt7 , res7 ), e +=1 [sBs8, arrPP8] = calc(e, chc8 , len8 , mlt8 , res8 ), e +=1 [sBs9, arrPP9] = calc(e, chc9 , len9 , mlt9 , res9 ), e +=1 arrVal = array.from( sBs1, sBs2, sBs3, sBs4, sBs5, sBs6, sBs7, sBs8, sBs9 ) // lastly, set labels/lines if barstate.islast st := line.new (n -lkb, highest, n -lkb , lowest), (st[1]).delete() top.set_lefttop (n -lkb, highest) top.set_rightbottom(n +8 , highest - ((highest - lowest) / 20)) btm.set_lefttop (n -lkb, lowest + ((highest - lowest) / 20)) btm.set_rightbottom(n +8 , lowest ) arr = aGrade.copy(), arr.sort(), aSz = arr.size(), dSz = aData.size() // sort + rank ~ grade if aSz > 1 lastValue = arr.get(aSz -1) for j = arr.size() -2 to 0 if arr.get(j) == lastValue arr.remove(j) lastValue := arr.get(j) if dSz > 0 for i = 0 to dSz -1 get = aData.get(i) gtt = get.txt val = get.value grd = get.grade col = close > val ? color.new( colU , grd) : close < val ? color.new( colD , grd) : color.new(color.blue, grd) get.txt := str.tostring(arr.indexof(get.grade) + 1) + ' ' + gtt get.lb := label.new(n +8 + (get.e * 5), val, text = get.txt, tooltip = get.tooltip, color=color(na) , textcolor= col) get.ln := line.new (n -lkb, val, n +8, val, color=col) // Make Swings visible if showPP while aSw.size() > 0 pop = aSw.pop() pop.lb.delete() pop.ln.delete() for i = 0 to pivH.size() -1 aSw.unshift( sw.new( label.new(pivH.get(i).b, pivH.get(i).p, style=label.style_label_right, size=size.tiny) , line.new (pivH.get(i).b, pivH.get(i).p, n +8, pivH.get(i).p) ) ) for i = 0 to pivL.size() -1 aSw.unshift( sw.new( label.new(pivL.get(i).b, pivL.get(i).p, style=label.style_label_right, size=size.tiny) , line.new (pivL.get(i).b, pivL.get(i).p, n +8, pivL.get(i).p) ) ) //-----------------------------------------------------------------------------} //Plot Functions //-----------------------------------------------------------------------------{ pickArrPP(i, f) => out = i == 1 ? arrPP1.get(f) : i == 2 ? arrPP2.get(f) : i == 3 ? arrPP3.get(f) : i == 4 ? arrPP4.get(f) : i == 5 ? arrPP5.get(f) : i == 6 ? arrPP6.get(f) : i == 7 ? arrPP7.get(f) : i == 8 ? arrPP8.get(f) : arrPP9.get(f) plots(pick, choice) => p1 = pick ? not choiceIsPP(choice -1) ? arrVal.get(choice -1) : pickArrPP(choice, 0 ) : na p2 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 1 ) : na p3 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 2 ) : na p4 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 3 ) : na p5 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 4 ) : na p6 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 5 ) : na p7 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 6 ) : na p8 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 7 ) : na p9 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 8 ) : na p10 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 9 ) : na p11 = pick ? not choiceIsPP(choice -1) ? na : pickArrPP(choice, 10) : na [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11] //-----------------------------------------------------------------------------} //Plots //-----------------------------------------------------------------------------{ [plotA1, plotA2, plotA3, plotA4, plotA5, plotA6, plotA7, plotA8, plotA9, plotA10, plotA11] = plots(pick1, choice1) [plotB1, plotB2, plotB3, plotB4, plotB5, plotB6, plotB7, plotB8, plotB9, plotB10, plotB11] = plots(pick2, choice2) [plotC1, plotC2, plotC3, plotC4, plotC5, plotC6, plotC7, plotC8, plotC9, plotC10, plotC11] = plots(pick3, choice3) [plotD1, plotD2, plotD3, plotD4, plotD5, plotD6, plotD7, plotD8, plotD9, plotD10, plotD11] = plots(pick4, choice4) [plotE1, plotE2, plotE3, plotE4, plotE5, plotE6, plotE7, plotE8, plotE9, plotE10, plotE11] = plots(pick5, choice5) plot(plotA1 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , display=display.pane) plot(plotA2 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA3 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA4 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA5 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA6 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA7 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA8 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA9 , 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA10, 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotA11, 'A', style= f(choice1) ? plot.style_line : plot.style_circles, color=color.blue , editable=false, display=display.pane) plot(plotB1 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, display=display.pane) plot(plotB2 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB3 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB4 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB5 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB6 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB7 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB8 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB9 , 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB10, 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotB11, 'B', style= f(choice2) ? plot.style_line : plot.style_circles, color=color.yellow, editable=false, display=display.pane) plot(plotC1 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, display=display.pane) plot(plotC2 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC3 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC4 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC5 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC6 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC7 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC8 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC9 , 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC10, 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotC11, 'C', style= f(choice3) ? plot.style_line : plot.style_circles, color=color.purple, editable=false, display=display.pane) plot(plotD1 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, display=display.pane) plot(plotD2 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD3 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD4 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD5 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD6 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD7 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD8 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD9 , 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD10, 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotD11, 'D', style= f(choice4) ? plot.style_line : plot.style_circles, color=color.orange, editable=false, display=display.pane) plot(plotE1 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , display=display.pane) plot(plotE2 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE3 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE4 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE5 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE6 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE7 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE8 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE9 , 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE10, 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) plot(plotE11, 'E', style= f(choice5) ? plot.style_line : plot.style_circles, color=color.white , editable=false, display=display.pane) //-----------------------------------------------------------------------------}
Relative Strength, not RSI
https://www.tradingview.com/script/gZdtBmIo-Relative-Strength-not-RSI/
jjustingreyy
https://www.tradingview.com/u/jjustingreyy/
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/ // © jjustingreyy //@version=5 indicator(title='Relative Strength, not RSI', shorttitle='not RSI') // Input parameters len = input(14, title='RSI Length') src = input(close, title='Source') HTF = input.timeframe('', 'TimeFrame') lenMFI = input(14, title='Length MFI') srcMFI = hlc3 smoothLen = input(5, title='Smooth Length') // Calculate RSI rsiSecurity(_symbol, _tf) => _up = ta.rma(math.max(ta.change(src), 0), len) _down = ta.rma(-math.min(ta.change(src), 0), len) _down == 0 ? 100 : _up == 0 ? 0 : 100 - 100 / (1 + _up / _down) rsi = request.security(syminfo.tickerid, HTF, rsiSecurity(syminfo.tickerid, HTF)) // Calculate MFI mfiSecurity(_symbol, _tf) => _upper = math.sum(volume * (ta.change(srcMFI) <= 0 ? 0 : srcMFI), lenMFI) _lower = math.sum(volume * (ta.change(srcMFI) >= 0 ? 0 : srcMFI), lenMFI) if _lower == 0 100 else if _upper == 0 0 else 100.0 - 100.0 / (1.0 + _upper / _lower) mfi = request.security(syminfo.tickerid, HTF, mfiSecurity(syminfo.tickerid, HTF)) // Calculate TRS using RSI and MFI TRS = (rsi + mfi) / 2 // Smoothen the TRS line using SMA smoothTRS = ta.sma(TRS, smoothLen) // Determine trend color trendColor = smoothTRS[1] < smoothTRS ? color.green : color.red // Plot smoothed TRS with trend color, linewidth, and circles for color changes TRS_plot = plot(smoothTRS, title='Smoothed TRS', color=trendColor, linewidth=2) // Draw the Zero Line using line.new line.new(x1=bar_index[1], y1=0, x2=bar_index, y2=0, width=1, color=color.gray, style=line.style_dotted) // Plot circles when trend changes trendSeries = smoothTRS[1] < smoothTRS ? 1 : 0 plotshape(ta.change(trendSeries) ? smoothTRS : na, title='Color Change Circle', location=location.absolute, style=shape.circle, size=size.tiny, color=trendColor, transp=0)
Adaptive Mean Reversion Indicator
https://www.tradingview.com/script/UWITlMWj-Adaptive-Mean-Reversion-Indicator/
LeafAlgo
https://www.tradingview.com/u/LeafAlgo/
120
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/ // © LeafAlgo //@version=5 indicator("Adaptive Mean Reversion Indicator", overlay=false) // Market Regime Detection volatilityThreshold = input.float(5.0, "Volatility Threshold") isTrending = ta.atr(14) > volatilityThreshold // Parameter Optimization lookbackPeriod = isTrending ? input.int(40, "Lookback Period (Trending)") : input.int(20, "Lookback Period (Ranging)") thresholdLevel = isTrending ? input.float(2.0, "Threshold Level (Trending)") : input.float(1.5, "Threshold Level (Ranging)") // Calculate Mean Reversion mean = ta.sma(close, lookbackPeriod) deviation = ta.stdev(close, lookbackPeriod) upperBand = mean + (deviation * thresholdLevel) lowerBand = mean - (deviation * thresholdLevel) // Real-Time Parameter Adjustment adaptiveMean = isTrending ? mean : ta.sma(close, 3) adaptiveUpperBand = isTrending ? upperBand : mean + (deviation * thresholdLevel * 0.75) adaptiveLowerBand = isTrending ? lowerBand : mean - (deviation * thresholdLevel * 0.75) // Plotting plot(adaptiveMean, color=color.aqua, linewidth=2, title="Adaptive Mean") plot(adaptiveUpperBand, color=color.lime, linewidth=2, title="Adaptive Upper Band") plot(adaptiveLowerBand, color=color.fuchsia, linewidth=2, title="Adaptive Lower Band") // Signal Generation isAboveUpperBand = close > adaptiveUpperBand isBelowLowerBand = close < adaptiveLowerBand signal = isAboveUpperBand ? -1 : isBelowLowerBand ? 1 : 0 // RSI Calculation rsiLength = input.int(14, "RSI Length") rsi = ta.rsi(close, rsiLength) // Confluence Condition confluenceCondition = rsi > 70 or rsi < 30 // Background Color bgcolor(signal == -1 and confluenceCondition ? color.new(color.lime, 80) : signal == 1 and confluenceCondition ? color.new(color.fuchsia, 80) : na) // Bar Color barcolor(signal == -1 and confluenceCondition ? color.lime : signal == 1 and confluenceCondition ? color.fuchsia : na) // Alert Conditions alertcondition(signal == 1 and confluenceCondition, title="Long Entry", message="Long Entry Signal") alertcondition(signal == -1 and confluenceCondition, title="Short Entry", message="Short Entry Signal")
bar view
https://www.tradingview.com/script/xI09XRmj-bar-view/
nishantsaxena
https://www.tradingview.com/u/nishantsaxena/
20
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/ // © nishantsaxena //@version=5 indicator("bar view",overlay = true,max_boxes_count = 500, max_labels_count = 500, max_bars_back = 4000) //Input options lookbackInput1 = input.int(15, minval = 0, maxval = 60, title = "bar grouping period", step = 5) boxBorderSize = input.int(2, title="Box border size", minval=0) upBoxColor = input.color(color.new(color.green, 85), title="Up box colour") upBorderColor = input.color(color.green, title="Up border colour") downBoxColor = input.color(color.new(color.red, 85), title="Down box colour") downBorderColor = input.color(color.red, title="Down border colour") joinBoxes = input.bool(false, title="Join boxes") // Create variables var dayHighPrice = 0.0 var dayLowPrice = 0.0 var prevDayClose = 0.0 var box dailyBox = na // See if a new calendar day started on the intra-day time frame newDayStart = (minute % lookbackInput1) == 0 and timeframe.isintraday // 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 newDayStart 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. if newDayStart dailyBox := box.new(left=bar_index, top=dayHighPrice, right=bar_index + 1, bottom=dayLowPrice, border_width=boxBorderSize) box.set_bgcolor(dailyBox, color.rgb(0,0,0,100)) box.set_border_color(dailyBox, color.rgb(0,0,0,100)) // If we don't want the boxes to join, the previous box shouldn't // end on the same bar as the new box starts. if not joinBoxes box.set_right(dailyBox[1], bar_index[1]) else box.set_top(dailyBox, dayHighPrice) box.set_rightbottom(dailyBox, right=bar_index + 1, bottom=dayLowPrice) // If the current bar closed higher than yesterday's close, make // the box green (and paint it red otherwise) if close > prevDayClose box.set_bgcolor(dailyBox, upBoxColor) box.set_border_color(dailyBox, upBorderColor) else box.set_bgcolor(dailyBox, downBoxColor) box.set_border_color(dailyBox, downBorderColor)
Key Levels (Open, Premarket, & Yesterday)
https://www.tradingview.com/script/UtD0cGM2-Key-Levels-Open-Premarket-Yesterday/
liquid-trader
https://www.tradingview.com/u/liquid-trader/
333
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/ // © liquid-trader // This indicator automatically identifies and draws high-probability support / resistance levels (key levels). // Initially, it only tracked yesterdays highs / lows, premarket highs / lows, as well as yesterdays end of day // moving averages. It has since expanded to capture other key levels traders commonly use. // More here: https://www.tradingview.com/script/UtD0cGM2-Key-Levels-Premarket-Yesterday/ //@version=5 indicator("Key Levels (Open, Premarket, & Yesterday)", "Key Levels", overlay=true, max_lines_count=500, max_labels_count=500) // ---------------------------------------------------- SETTINGS --------------------------------------------------- // // Base Colors none = color.new(color.black, 100), clr1 = color.gray, clr2 = color.orange, clr3 = color.blue, clr4 = color.fuchsia, clr5 = color.red, clr6 = color.aqua, clr7 = color.purple, clr8 = color.maroon, clr9 = color.lime // Group Labels g1 = "Recent High / Low Pairs", g2 = "Distant High / Low Pairs", g3 = "Single Values", g4 = "Moving Averages", g5 = "Custom Levels", g6 = "General Settings", g7 = "Price Proximity", g8 = "Market Hours" // Todays High / Low Settings tdHiLo = input.bool(true, "Today                ", "High & low line colors. Enabling \"Mkt Hrs Only\" (Market Hours Only) limits todays high / low to the highest high and lowest low within regular trading hours.\n\nDisabling \"Mkt Hrs Only\" will include Premarket and After Hours levels, if they exceed the levels during market hours.", inline="tdHL", group=g1, display=display.none) tdHiClr = input.color(color.new(clr2, 66), "", inline="tdHL", group=g1, display=display.none) tdLoClr = input.color(color.new(clr2, 66), "", inline="tdHL", group=g1, display=display.none) tdMktOnly = input.bool(true, "Mkt Hrs Only", inline="tdHL", group=g1, display=display.none) // Opening Range Settings orHiLo = input.bool(false, "Opening Range", "Line & Background colors, and the number of minutes that qualify as \"the open\" during the first market hour.", inline="orHL", group=g1, display=display.none) orClr = input.color(color.new(clr6, 50), "", inline="orHL", group=g1, display=display.none) orBoxClr = input.color(color.new(clr6, 95), "", inline="orHL", group=g1, display=display.none) orRange = input.int(15, "", 1, 60, inline="orHL", group=g1, display=display.none), var box orBox = na // Near Open High / Low Settings noHiLo = input.bool(false, "Near Open        ", "High & low line colors, and the number of minutes before the open that qualifies as \"near the open\". If your chart settings have extended hours turned off, these will not display.", inline="noHL", group=g1, display=display.none) noHiClr = input.color(clr5, "", inline="noHL", group=g1, display=display.none) noLoClr = input.color(clr5, "", inline="noHL", group=g1, display=display.none) noRange = input.int(60, "", 0, inline="noHL", group=g1, display=display.none) // Premarket High / Low Settings pmHiLo = input.bool(true, "Premarket         ", "High & low line colors. If your chart settings have extended hours turned off, these will not display.", inline="pmHL", group=g1, display=display.none) pmHiClr = input.color(color.new(clr2, 33), "", inline="pmHL", group=g1, display=display.none) pmLoClr = input.color(color.new(clr2, 33), "", inline="pmHL", group=g1, display=display.none) // Overnight High / Low Settings onHiLo = input.bool(false, "Overnight         ", "High & low line colors. If your chart settings have extended hours turned off, or you are not trading in a session that begins before midnight, these will not display.", inline="onHL", group=g1, display=display.none) onHiClr = input.color(clr8, "", inline="onHL", group=g1, display=display.none) onLoClr = input.color(clr8, "", inline="onHL", group=g1, display=display.none) // After-Hours High / Low Settings ahHiLo = input.bool(false, "After Hours       ", "High & low line colors. If your chart settings have extended hours turned off, these will not display.", inline="ahHL", group=g1, display=display.none) ahHiClr = input.color(clr7, "", inline="ahHL", group=g1, display=display.none) ahLoClr = input.color(clr7, "", inline="ahHL", group=g1, display=display.none) // Yesterday High / Low Settings ydHiLo = input.bool(true, "Yesterday         ", "High & low line colors. Enabling \"Mkt Hrs Only\" (Market Hours Only) limits yesterdays high / low to the highest high and lowest low within regular trading hours.\n\nDisabling \"Mkt Hrs Only\" will include Premarket and After Hours levels, if they exceed the levels during market hours.", inline="ydHL", group=g1, display=display.none) ydHiClr = input.color(clr2, "", inline="ydHL", group=g1, display=display.none) ydLoClr = input.color(clr2, "", inline="ydHL", group=g1, display=display.none) ydMktOnly = input.bool(true, "Mkt Hrs Only", inline="ydHL", group=g1, display=display.none) // This Weeks High / Low Settings twHiLo = input.bool(false, "This Week        ", "High & low line colors.", inline="twHL", group=g2, display=display.none) twHiClr = input.color(color.new(clr1, 50), "", inline="twHL", group=g2, display=display.none) twLoClr = input.color(color.new(clr1, 50), "", inline="twHL", group=g2, display=display.none) // Last Weeks High / Low Settings lwHiLo = input.bool(false, "Last Week        ", "High & low line colors.", inline="lwHL", group=g2, display=display.none) lwHiClr = input.color(color.new(clr1, 50), "", inline="lwHL", group=g2, display=display.none) lwLoClr = input.color(color.new(clr1, 50), "", inline="lwHL", group=g2, display=display.none) // This Months High / Low Settings tmHiLo = input.bool(false, "This Month       ", "High & low line colors.", inline="tmHL", group=g2, display=display.none) tmHiClr = input.color(color.new(clr1, 50), "", inline="tmHL", group=g2, display=display.none) tmLoClr = input.color(color.new(clr1, 50), "", inline="tmHL", group=g2, display=display.none) // Last Months High / Low Settings lmHiLo = input.bool(false, "Last Month       ", "High & low line colors.", inline="lmHL", group=g2, display=display.none) lmHiClr = input.color(color.new(clr1, 50), "", inline="lmHL", group=g2, display=display.none) lmLoClr = input.color(color.new(clr1, 50), "", inline="lmHL", group=g2, display=display.none) // This Quarters High / Low Settings tqHiLo = input.bool(false, "This Quarter     ", "High & low line colors.", inline="tqHL", group=g2, display=display.none) tqHiClr = input.color(color.new(clr1, 50), "", inline="tqHL", group=g2, display=display.none) tqLoClr = input.color(color.new(clr1, 50), "", inline="tqHL", group=g2, display=display.none) // Last Quarters High / Low Settings lqHiLo = input.bool(false, "Last Quarter     ", "High & low line colors.", inline="lqHL", group=g2, display=display.none) lqHiClr = input.color(color.new(clr1, 50), "", inline="lqHL", group=g2, display=display.none) lqLoClr = input.color(color.new(clr1, 50), "", inline="lqHL", group=g2, display=display.none) // This Years High / Low Settings tyHiLo = input.bool(false, "This Year          ", "High & low line colors.", inline="tyHL", group=g2, display=display.none) tyHiClr = input.color(color.new(clr1, 50), "", inline="tyHL", group=g2, display=display.none) tyLoClr = input.color(color.new(clr1, 50), "", inline="tyHL", group=g2, display=display.none) // Last Years High / Low Settings lyHiLo = input.bool(false, "Last Year          ", "High & low line colors.", inline="lyHL", group=g2, display=display.none) lyHiClr = input.color(color.new(clr1, 50), "", inline="lyHL", group=g2, display=display.none) lyLoClr = input.color(color.new(clr1, 50), "", inline="lyHL", group=g2, display=display.none) // Todays Opening Settings O = "open", H = "high", L = "low", C = "close", HL2 = "hl2", HLC3 = "hlc3", OHLC4 = "ohlc4", HLCC4 = "hlcc4" tdOpn = input.bool(false, "Todays Open        ", "Line color, and the value to use from todays first market bar.", inline="tdOpen", group=g3, display=display.none) tdOpnClr = input.color(color.new(clr1, 50), "", inline="tdOpen", group=g3, display=display.none) tdOpnSrc = input.string(O, "", [O, H, L, C, HL2, HLC3, OHLC4, HLCC4], inline="tdOpen", group=g3, display=display.none) // Yesterdays Close Settings ydCls = input.bool(false, "Yesterdays Close ", "Line color, and the value to use from yesterdays last market bar.", inline="ydClose", group=g3, display=display.none) ydClsClr = input.color(color.new(clr1, 50), "", inline="ydClose", group=g3, display=display.none) ydClsSrc = input.string(C, "", [O, H, L, C, HL2, HLC3, OHLC4, HLCC4], inline="ydClose", group=g3, display=display.none) // Yesterdays Opening Settings ydOpn = input.bool(false, "Yesterdays Open  ", "Line color, and the value to use from yesterdays first market bar.", inline="ydOpen", group=g3, display=display.none) ydOpnClr = input.color(color.new(clr1, 50), "", inline="ydOpen", group=g3, display=display.none) ydOpnSrc = input.string(O, "", [O, H, L, C, HL2, HLC3, OHLC4, HLCC4], inline="ydOpen", group=g3, display=display.none) // Todays VWAP Settings tdVWAP = input.bool(false, "Todays VWAP               ", "Line color of todays Volume Weighted Average Price.", inline="tdV", group=g4, display=display.none) tdVpClr = input.color(clr3, "", inline="tdV", group=g4, display=display.none) // Yesterday VWAP Settings ydVWAP = input.bool(false, "Yesterdays EOD VWAP", "Line color of yesterdays end of day Volume Weighted Average Price.", inline="ydV", group=g4, display=display.none) ydVpClr = input.color(color.new(clr3, 50), "", inline="ydV", group=g4, display=display.none) // Todays MA Settings tdMA = input.bool(false, "Todays MA                    ", "Line color of todays Moving Average. The MA parameters are below.", inline="tdM", group=g4, display=display.none) tdMaClr = input.color(clr4, "", inline="tdM", group=g4, display=display.none) // Yesterday MA Settings ydMA = input.bool(false, "Yesterdays EOD MA     ", "Line color of yesterdays end of day Moving Average. The MA parameters are below.", inline="ydM", group=g4, display=display.none) ydMaClr = input.color(color.new(clr4, 50), "", inline="ydM", group=g4, display=display.none) // Moving Average Settings maLen = input.int(135, "MA Params.", 1, tooltip="Length, source, and type of the Moving Average.", inline="ma", group=g4, display=display.none) maSrc = input.string(HLC3, "", [O, H, L, C, HL2, HLC3, OHLC4, HLCC4], inline="ma", group=g4, display=display.none) maTyp = input.string("EMA", "", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], inline="ma", group=g4, display=display.none) // Custom Level Settings cstm1 = input.bool(false, "", "Title, price, and color of a custom level.", inline="c1", group=g5, display=display.none) c1Lbl = input.string("Custom Level 1", "", inline="c1", group=g5, display=display.none) c1Num = input.price(12.34, "", inline="c1", group=g5, display=display.none) c1Clr = input.color(clr9, "", inline="c1", group=g5, display=display.none) cstm2 = input.bool(false, "", "Title, price, and color of a custom level.", inline="c2", group=g5, display=display.none) c2Lbl = input.string("Custom Level 2", "", inline="c2", group=g5, display=display.none) c2Num = input.price(56.78, "", inline="c2", group=g5, display=display.none) c2Clr = input.color(clr9, "", inline="c2", group=g5, display=display.none) // Label Settings showLabel = input.bool(true, "Show Labels","Label visibility, with options to abbreviate the text of the label and include the price of the level, as well as change the background & text colors", inline="labels", group=g6, display=display.none) inclPrice = input.bool(true, "Incl. Price", inline="labels", group=g6, display=display.none) abbreviate = input.bool(true, "Abrv.", inline="labels", group=g6, display=display.none) lblClr = input.color(none, "", inline="labels", group=g6, display=display.none) txtClr = input.color(clr1, "", inline="labels", group=g6, display=display.none) // Older Level Settings showOldLevels = input.bool(false, "Show older levels", "Visibility & color of older levels.\n\nOlder levels will not display if \"Toggle Visibility\" is also enabled.", inline="old", group=g6, display=display.none) oldColor = input.color(clr1, "", inline="old", group=g6, display=display.none) // Line Settings truncate = input.bool(false, "Max line length    ", "Truncates the lines so they do not stretch back to their origin.", inline="max line length", group=g6, display=display.none) truncLen = input.int(15, "", 0, inline="max line length", group=g6, display=display.none) width = input.int(2, "Line Width & Style       ", 1, 10, 1, inline="lines", group=g6, display=display.none) style = input.string("Solid", "", ["Solid", "Dashed", "Dotted"], inline="lines", group=g6, display=display.none), lineStyle = style == "Dotted" ? line.style_dotted : style == "Dashed" ? line.style_dashed : line.style_solid // Price Proximity Settings atrZone = input.bool(false, "ATR Zones", "This will show a 5 bar ATR zone around the level when price is proximal to a given line. Half the ATR is above the line, and half the ATR is below the line.", group=g7, display=display.none) showProx = input.bool(false, "Toggle Visibility", "This will hide levels by default, and only show a level when price is proximal to a given line.", inline="prox vis", group=g7, display=display.none) extend = input.bool(false, "Line Length Override", "This will extend the line back to its origin when price is proximal to a given line and \"Max Line Length\" is enabled.", inline="extend", group=g7, display=display.none) prxRng = input.float(0.025, "Range of Proximity ( % )", 0, tooltip="How close price needs to be for an enabled proximity setting to take effect. This is a percentage (not monetary) value.", group=g7, display=display.none) // Market Hours Settings mktHrs = input.session("0930-1600", "Start / End Time", tooltip = "A 24 hour format, where 0930 is 9:30 AM, 1600 is 4:00 PM, etc.", group=g8, display=display.none) zone = input("America/New_York", "Time Zone", "Any IANA time zone ID. Ex: America/New_York\n\nYou can also use \"syminfo.timezone\", which inherits the time zone of the exchange of the chart.", group=g8, display=display.none) timezone = zone == "syminfo.timezone" ? syminfo.timezone : zone // ----------------------------------------------------- CORE ------------------------------------------------------ // // Declare object to store bar values. type barVals float High = high float Low = low int Index = time bar = barVals.new() // Declare object to track key levels. type level bool InitState bool Show color Color string Name string ToolTip float Level float Price int Index int OldIndex line Line label Label box Range var keyLevels = array.new<level>() // Methods for interacting with keyLevels. method Get(int i) => keyLevels.get(i) method set_field(int i, bool Show = na, float Level = na, int Index = na, int OldIndex = na) => kl = Get(i) if not na(Show) kl.Show := Show if not na(Level) kl.Level := Level if not na(Index) kl.Index := Index if not na(OldIndex) kl.OldIndex := OldIndex // Declare object to track indices within keyLevels. type index int tdH = 0 int tdL = 1 int orH = 2 int orL = 3 int noH = 4 int noL = 5 int pmH = 6 int pmL = 7 int onH = 8 int onL = 9 int ahH = 10 int ahL = 11 int ydH = 12 int ydL = 13 int twH = 14 int twL = 15 int lwH = 16 int lwL = 17 int tmH = 18 int tmL = 19 int lmH = 20 int lmL = 21 int tqH = 22 int tqL = 23 int lqH = 24 int lqL = 25 int tyH = 26 int tyL = 27 int lyH = 28 int lyL = 29 int tdO = 30 int ydC = 31 int ydO = 32 int tdVWAP = 33 int ydVWAP = 34 int tdMA = 35 int ydMA = 36 int custom1 = 37 int custom2 = 38 var id = index.new() // Functions to identify every other, and every 4th, index. evenNum(i) => i % 2 == 0 thisWMY(i) => math.floor(i / 2) % 2 != 0 // Functions for initializing key level strings. acronym(fullStr) => wordList = str.split(fullStr, " "), firstCharacters = "" for word in wordList firstCharacters += str.match(word, "\\w") firstCharacters rangeStrings(i, abrvStr, fullStr) => ohlc = "", thisLast = "", possesive = "" switch i < id.tdO true => ohlc := evenNum(i) ? "High" : "Low" false => ohlc := evenNum(i) ? "Open" : "Close" if i >= id.twH and i <= id.lyL thisLast := thisWMY(i) ? "This " : "Last " if i <= id.tdL or (i >= id.ydH and i <= id.ydO) possesive := "s" name = switch abbreviate true => " " + acronym(thisLast) + abrvStr + acronym(ohlc) + " " false => " " + ohlc + " • " + thisLast + fullStr + " " tooltip = " " + thisLast + fullStr + possesive + " " + ohlc + " " [name, tooltip] customName(fullStr) => acronym = acronym(fullStr) " " + (abbreviate ? acronym : fullStr) + " " // Initialize keyLevels array. var Levels_Not_Initialized = true if Levels_Not_Initialized // Create temporary arrays to help initialize the keyLevels object array. fullStr = array.from("Today", "Opening Range", "Near Open", "Premarket", "Overnight", "After Hours", "Yesterday", "Week", "Month", "Quarter", "Year") abrvStr = array.from("TD", "OR", "NO", "PM", "ON", "AH", "YD", "W", "M", "Q", "Y") colors = array.from(tdHiClr, tdLoClr, orClr, orClr, noHiClr, noLoClr, pmHiClr, pmLoClr, onHiClr, onLoClr, ahHiClr, ahLoClr, ydHiClr, ydLoClr, twHiClr, twLoClr, lwHiClr, lwLoClr, tmHiClr, tmLoClr, lmHiClr, lmLoClr, tqHiClr, tqLoClr, lqHiClr, lqLoClr, tyHiClr, tyLoClr, lyHiClr, lyLoClr, tdOpnClr, ydClsClr, ydOpnClr, tdVpClr, ydVpClr, tdMaClr, ydMaClr, c1Clr, c2Clr) lvlVis = array.from(tdHiLo, tdHiLo, orHiLo, orHiLo, noHiLo, noHiLo, pmHiLo, pmHiLo, onHiLo, onHiLo, ahHiLo, ahHiLo, ydHiLo, ydHiLo, twHiLo, twHiLo, lwHiLo, lwHiLo, tmHiLo, tmHiLo, lmHiLo, lmHiLo, tqHiLo, tqHiLo, lqHiLo, lqHiLo, tyHiLo, tyHiLo, lyHiLo, lyHiLo, tdOpn, ydCls, ydOpn, tdVWAP, ydVWAP, tdMA, ydMA, cstm1, cstm2) // Set visibility. for v in lvlVis keyLevels.push(level.new(v,v)) // Set strings. for [i, kl] in keyLevels if kl.Show kl.Color := colors.get(i) // Highs & Lows of Today & Yesterday if i <= id.ydL j = math.floor(i/2) [name, tooltip] = rangeStrings(i, abrvStr.get(j), fullStr.get(j)) kl.Name := name kl.ToolTip := tooltip // Highs & Lows of This & Last Week, Month, & Year else if i > id.ydL and i <= id.lyL j = math.floor(i/4 + 3.5) [name, tooltip] = rangeStrings(i, abrvStr.get(j), fullStr.get(j)) kl.Name := name kl.ToolTip := tooltip // Open & Close of Today & Yesterday else if i > id.lyL and i < id.tdVWAP j = (i == id.tdO ? id.tdH : id.ydH)/2 [name, tooltip] = rangeStrings(i, abrvStr.get(j), fullStr.get(j)) kl.Name := name kl.ToolTip := tooltip // VWAP, MA, and Custom Levels else j = i - id.tdVWAP if j <= 3 full = evenNum(j) ? fullStr.get(id.tdH/2) : fullStr.get(id.ydH/2) abrv = evenNum(j) ? abrvStr.get(id.tdH/2) : abrvStr.get(id.ydH/2) day = abbreviate ? abrv : full nStr = j < 2 ? "VWAP" : (abbreviate ? str.tostring(maTyp) : str.tostring(maTyp) + " " + str.tostring(maLen)) tStr = j < 2 ? "s VWAP " : "s " + str.tostring(maLen) + " " + str.tostring(maTyp) + " " prefix = "", suffix = "", delim = "" if abbreviate prefix := " " + day + " ", suffix := " ", delim := "" else prefix := " ", suffix := day + " ", delim := " • " kl.Name := prefix + nStr + delim + suffix kl.ToolTip := full + tStr else cStr = j == 2 ? c1Lbl : c2Lbl cLvl = j == 2 ? c1Num : c2Num kl.Name := customName(cStr) kl.ToolTip := cStr + " " kl.Level := cLvl Levels_Not_Initialized := false // --------------------------------------------------- TIME LOGIC -------------------------------------------------- // // Function to convert bar_time into a bar_index. numOfBars(n) => timeframe.multiplier * ( timeframe.isseconds ? 1000 : timeframe.isminutes ? 60000 : timeframe.isdaily ? 86400000 : timeframe.isweekly ? 604800000 : timeframe.ismonthly ? 2629800000 : 1) * n // Functions to normalize market times ranges. normalizeTime(t) => str = str.tostring(t) while str.length(str) < 4 str := "0" + str str setTimeNearOpen(t) => r = noRange hr = math.floor(t / 100) m = t % 100, m := m - r if m < 0 while m < 0 hr -= 1 m += 60 normalizeTime(hr * 100 + m) // Convert trader specified market time variables to strings. marketHours = mktHrs mktStartTime = str.substring(mktHrs, 0, 4) mktEndTime = str.substring(mktHrs, 5, 9) preMktHours = "0000-" + mktStartTime nearMktOpen = setTimeNearOpen(str.tonumber(mktStartTime)) + "-" + mktStartTime openingMins = mktStartTime + "-" + normalizeTime(str.tonumber(mktStartTime) + orRange) minutesInDay = "1440" mktCloseToMidnight = mktEndTime + "-2400" // Define session segments. premarket = not na(time(minutesInDay, preMktHours, timezone)) nearOpen = not na(time(minutesInDay, nearMktOpen, timezone)) marketOpen = not na(time(minutesInDay, openingMins, timezone)) market = not na(time(minutesInDay, marketHours, timezone)) newSession = session.isfirstbar, var newSessionBeforeMidnight = false newSessionBeforeMidnight := newSession ? hour(time, timezone) * 60 + minute(time, timezone) < 1440 : market ? false : newSessionBeforeMidnight afterHours = not na(time(minutesInDay, mktCloseToMidnight, timezone)) and not newSessionBeforeMidnight overnight = not na(time(minutesInDay, mktCloseToMidnight, timezone)) and newSessionBeforeMidnight firstPremarketBar = premarket and (not premarket[1] or newSession) firstNearOpenBar = nearOpen and (not nearOpen[1] or newSession) firstMarketBar = market and (not market[1] or newSession) lastMarketBar = market[1] and (not market or newSession) firstAfterHoursBar = afterHours and market[1] firstOvernightBar = overnight and newSession var beforeMarketOpen = false, beforeMarketOpen := newSession and not market ? true : market ? false : beforeMarketOpen var firstMarketBarIndex = time, var lastMarketBarIndex = time // Define annual segments. newWeek = timeframe.change("W") newMonth = timeframe.change("M") newQuarter = timeframe.change("3M") newYear = timeframe.change("12M") // Increment the session count. Used to disregard incomplete data from the first session on the chart. var session = -1, session += newSession and session < 1 ? 1 : 0 // ----------------------------------------------- RECENT LEVEL LOGIC ---------------------------------------------- // // Functions to update recent levels. src(src) => switch src O => open H => high L => low C => close HL2 => hl2 HLC3 => hlc3 OHLC4 => ohlc4 HLCC4 => hlcc4 saveOldIndices(a, b) => for i = a to b i.set_field(OldIndex = Get(i).Index) set(i, lvl) => i.set_field(Level = lvl, Index = bar.Index) setHiLo(a, b) => set(a, bar.High) set(b, bar.Low) setHiLoLevels(firstBar, ifTrue, a, b) => if firstBar saveOldIndices(a, b) setHiLo(a, b) if bar.High > Get(a).Level and ifTrue set(a, bar.High) if bar.Low < Get(b).Level and ifTrue set(b, bar.Low) // Save certain bar indices that are necessary for showing old levels correctly, but may be overwritten. if newSession saveOldIndices(id.tdH, id.onL) saveOldIndices(id.tdVWAP, id.custom2) saveOldIndices(id.tdO, id.tdO) // Track opening range levels. if market and orHiLo setHiLoLevels(firstMarketBar, marketOpen, id.orH, id.orL) // Track near open levels. if nearOpen and noHiLo setHiLoLevels(firstNearOpenBar, true, id.noH, id.noL) // Track premarket levels. if premarket and pmHiLo and ((not noHiLo) or (noHiLo and not nearOpen)) setHiLoLevels(firstPremarketBar, not firstPremarketBar, id.pmH, id.pmL) // Track overnight levels. if overnight and onHiLo setHiLoLevels(firstOvernightBar, true, id.onH, id.onL) // Track after-hours levels. if afterHours and ahHiLo setHiLoLevels(firstAfterHoursBar, true, id.ahH, id.ahL) // Track daily levels. if not newSession // Todays Levels if (not tdMktOnly or (tdMktOnly and market)) and tdHiLo firstBar = tdMktOnly ? firstMarketBar : firstPremarketBar setHiLoLevels(firstBar, true, id.tdH, id.tdL) // Yesterdays Levels if (not ydMktOnly or (ydMktOnly and market)) and ydHiLo setHiLoLevels(false, true, id.ydH, id.ydL) // Track the daily open. if firstMarketBar and tdOpn set(id.tdO, src(tdOpnSrc)) // Track the daily close. if lastMarketBar and ydCls set(id.ydC, src(ydClsSrc)) // Track todays VWAP if tdVWAP id.tdVWAP.set_field(Level = ta.vwap) // Track todays MA movAvg = switch maTyp "SMA" => ta.sma(src(maSrc), maLen) "EMA" => ta.ema(src(maSrc), maLen) "SMMA (RMA)" => ta.rma(src(maSrc), maLen) "WMA" => ta.wma(src(maSrc), maLen) "VWMA" => ta.vwma(src(maSrc), maLen) if tdMA id.tdMA.set_field(Level = movAvg, Index = bar.Index - numOfBars(maLen - 1)) // Track yesterdays EOD VWAP and MA. if newSession if ydVWAP set(id.ydVWAP, ta.vwap[1]) if ydMA set(id.ydMA, movAvg) // Set first market bar index. if firstMarketBar and not newSession firstMarketBarIndex := bar.Index else if firstMarketBar[1] and newSession[1] firstMarketBarIndex := bar.Index[1] // Set last market bar index. if market[1] and (afterHours or newSession) lastMarketBarIndex := bar.Index[1] // ---------------------------------------------- DISTANT LEVEL LOGIC ---------------------------------------------- // // Functions to update distant levels. reqSec(tf) => request.security(ticker.modify(syminfo.tickerid, session.extended), tf, [high, high[1], low, low[1]], lookahead=barmerge.lookahead_on) getDistVal(i) => wmy = math.floor(i/4 - id.twH/4) [thisHi, lastHi, thisLo, lastLo] = switch wmy 0 => reqSec("W") 1 => reqSec("M") 2 => reqSec("3M") 3 => reqSec("12M") evenNum(i) ? thisWMY(i) ? thisHi : lastHi : thisWMY(i) ? thisLo: lastLo newWMY(i) => switch thisWMY(i) true => (newWeek and (i == id.twH or i == id.twL)) or (newMonth and (i == id.tmH or i == id.tmL)) or (newQuarter and (i == id.tqH or i == id.tqL)) or (newYear and (i == id.tyH or i == id.tyL)) false => (newWeek and (i == id.lwH or i == id.lwL)) or (newMonth and (i == id.lmH or i == id.lmL)) or (newQuarter and (i == id.lqH or i == id.lqL)) or (newYear and (i == id.lyH or i == id.lyL)) distLevelTouch(i, v) => session.ismarket and (evenNum(i) ? bar.High >= v : bar.Low <= v) // Track distant levels (this / last week, month, year). for i = id.twH to id.lyL kl = Get(i) // Set value if empty, or if symbol has extended hours and it's the first market bar. if na(kl.Level) or (session.ispremarket[1] and session.ismarket) kl.Level := getDistVal(i) // If THIS week / month / year … if thisWMY(i) if newWMY(i) or distLevelTouch(i, kl.Level) kl.OldIndex := kl.Index kl.Level := getDistVal(i) kl.Index := bar.Index // If a new month starts in the middle of a weekly bar… if (i >= id.tmH and i <= id.tqL) and timeframe.isweekly and dayofmonth > 3 and not distLevelTouch(i, kl.Level) kl.Index := bar.Index[1] // If LAST week / month / year … else if kl.Show if newWMY(i) kl.Level := session.ispremarket ? Get(i - 2).Level : getDistVal(i) kl.Index := Get(i - 2).OldIndex // -------------------------------------------- OBJECT UPDATE FUNCTIONS -------------------------------------------- // labelString(kl, t) => number = str.tostring(math.round_to_mintick(kl.Level)) + " " switch t "text" => kl.Name + (inclPrice ? "• " + number : "" ) "tooltip" => kl.ToolTip + "@ " + number method newLine(level kl, int x1) => kl.Line := line.new(x1, kl.Level, bar.Index + numOfBars(1), kl.Level, xloc.bar_time, extend.none, kl.Color, lineStyle, width) kl.Price := kl.Level method newLabel(level kl) => kl.Label := showLabel ? label.new(bar.Index + numOfBars(10), kl.Level, labelString(kl, "text"), xloc.bar_time, yloc.price, lblClr, label.style_label_left, txtClr, size.normal, text.align_center, labelString(kl, "tooltip")) : na showFirstBarLevels(a, b) => for i = a to b kl = Get(i) kl.newLine(kl.Index) kl.newLabel() updateX(i, kl) => if i != id.orH and i != id.orL kl.Line.set_x1(kl.Index) kl.Line.set_x2(bar.Index + numOfBars(1)) kl.Label.set_x(bar.Index) updateY(kl) => kl.Price := kl.Level kl.Line.set_y1(kl.Level) kl.Line.set_y2(kl.Level) kl.Label.set_y(kl.Level) updateLabelString(kl) => kl.Label.set_text(labelString(kl, "text")) kl.Label.set_tooltip(labelString(kl, "tooltip")) updateLevel(i, kl) => updateX(i, kl) updateY(kl) updateLabelString(kl) updateOpeningRange() => orBox.set_right(bar.Index + numOfBars(10)) if firstMarketBar orBox.set_left(bar.Index) orBox.set_border_width(0) orBox.set_border_color(none) orBox.set_bgcolor(orBoxClr) if marketOpen orBox.set_top(Get(id.orH).Level) orBox.set_bottom(Get(id.orL).Level) if truncate orBox.set_left(bar.Index - numOfBars(truncLen)) manageHiLo(firstBar, timeOfDay, a, b) => // Turn on level visibility. if firstBar showFirstBarLevels(a, b) // Update levels. if timeOfDay A = Get(a) B = Get(b) if bar.High == A.Level updateLevel(a, A) if bar.Low == B.Level updateLevel(b, B) manageDistHiLo(a) => if evenNum(a) A = Get(a) if A.Show b = a + 1 B = Get(b) updateLevel(a, A) updateLevel(b, B) manageMA(a) => if not evenNum(a) A = Get(a) if A.Show updateY(A) updateLabelString(A) if a == id.tdMA A.Line.set_x1(A.Index) hideLevel(a, b) => for i = a to b i.set_field(Show = false) // ----------------------------------------------- NEW SESSION LOGIC ----------------------------------------------- // // On the first bar of a new session with complete data… if newSession and session > 0 // Reset level visibility to their intial states. for kl in keyLevels kl.Show := kl.InitState // Disable levels that are not meaningful or measurable… if timeframe.isdwm // Disable intrabar levels. hideLevel(id.tdO, id.ydMA) hideLevel(id.tdH, timeframe.isweekly ? id.lwL : timeframe.ismonthly ? timeframe.multiplier < 3 ? id.lmL : id.lqL : id.ydL) else if market and market[1] // Disable all levels that are not part of market hours. hideLevel(id.noH, id.ahL) else if not afterHours[1] // Disable after hours levels. hideLevel(id.ahH, id.ahL) if market // Disable near open, premarket, and overnight levels. hideLevel(id.noH, id.onL) else if premarket // Disable overnight Levels. hideLevel(id.onH, id.onL) // If the trader wants levels from the previous session to remain visible… if showOldLevels and not showProx // Reformat opening range box. orBox.set_bgcolor(color.new(oldColor, 95)) orBox.set_left(firstMarketBarIndex) orBox.set_right(lastMarketBarIndex) // Only reformat lines and labels of recent levels. for [i, kl] in keyLevels if (i < id.twH or i > id.lyL) and timeframe.isintraday openingRange = i == id.orH or i == id.orL // Lines kl.Line.set_x1(openingRange ? firstMarketBarIndex : kl.OldIndex) kl.Line.set_x2(openingRange ? lastMarketBarIndex : bar.Index[1]) kl.Line.set_color(oldColor) kl.Line.set_style(line.style_dotted) kl.Line.set_width(1) kl.Line.set_extend(extend.none) // Labels kl.Label.set_x(openingRange ? lastMarketBarIndex : bar.Index[1]) kl.Label.set_color(none) kl.Label.set_textcolor(oldColor) kl.Label.set_style(label.style_label_lower_right) else kl.Line.delete() kl.Label.delete() else // Otherwise, delete the old stuff. orBox.delete() for kl in keyLevels kl.Line.delete() kl.Label.delete() // Create new opening range box for current sesison. orBox := box.new(na, na, na, na, xloc = xloc.bar_time) // Create new levels for the current session. for [i, kl] in keyLevels if kl.Show x1 = i < id.tdVWAP ? kl.Index : bar.Index kl.newLine(x1) kl.newLabel() if i < id.ahH or i == id.tdO kl.Line.delete() kl.Label.delete() // Reset bar indices… for [i, kl] in keyLevels // If key level will extend into the next session… if (i >= id.ahH and i <= id.ydL) or (i >= id.tdO and i <= id.ydO) kl.OldIndex := kl.Index // If key level is recent… else if i < id.twH or i > id.lyL kl.Index := bar.Index // ----------------------------------------------- BAR BY BAR LOGIC ------------------------------------------------ // // Update todays levels. if tdHiLo firstBar = tdMktOnly ? firstMarketBar : firstPremarketBar timeOfDay = tdMktOnly ? market : premarket or market or afterHours manageHiLo(firstBar, timeOfDay, id.tdH, id.tdL) // Update todays opening value and range. if tdOpn manageHiLo(firstMarketBar, false, id.tdO, id.tdO) if orHiLo manageHiLo(firstMarketBar, marketOpen, id.orH, id.orL) updateOpeningRange() // Update near open, premarket, and overnight levels. if beforeMarketOpen if noHiLo manageHiLo(firstNearOpenBar, nearOpen, id.noH, id.noL) if pmHiLo manageHiLo(firstPremarketBar, premarket and not (nearOpen and noHiLo), id.pmH, id.pmL) if onHiLo manageHiLo(firstOvernightBar, overnight, id.onH, id.onL) // Update todays VWAP and MA. for i = id.tdVWAP to id.tdMA manageMA(i) // Update weekly, monthly, and yearly levels. for i = id.twH to id.lyL manageDistHiLo(i) // Allow custom level to extend left if chart is not intraday. if timeframe.isdwm for i = id.custom1 to id.custom2 kl = Get(i) if kl.Show kl.Line.set_x1(na) // Hide after hours levels if they overlap yesterdays levels. if newSession and ahHiLo and ydHiLo and not ydMktOnly for i = 0 to 1 aftHrs = Get(id.ahH + i) daily = Get(id.ydH + i) if aftHrs.Level == daily.Level aftHrs.Line.delete(), aftHrs.Label.delete() // Adjust lines and labels. for kl in keyLevels kl.Label.set_x(bar.Index + numOfBars(10)) kl.Line.set_x2(bar.Index + numOfBars(10)) if truncate kl.Line.set_x1(bar.Index - numOfBars(truncLen)) // Reset daily levels. resetDailyLevels = newSession or firstPremarketBar if resetDailyLevels or (firstMarketBar and tdMktOnly) setHiLo(id.tdH, id.tdL) if resetDailyLevels or (firstMarketBar and ydMktOnly) setHiLo(id.ydH, id.ydL) if firstMarketBar set(id.ydO, src(ydOpnSrc)) // ----------------------------------------- PRICE & LEVEL PROXIMITY LOGIC ----------------------------------------- // // Proximity functions. getLevelRange(kl) => lvlRng = kl.Price * (prxRng / 100) lvlRngHi = kl.Price + lvlRng lvlRngLo = kl.Price - lvlRng [kl.Price, lvlRng, lvlRngHi, lvlRngLo] priceWithinLevelProximity(lvlRngHi, lvlRngLo) => (bar.High < lvlRngHi and bar.High > lvlRngLo) or (bar.Low < lvlRngHi and bar.Low > lvlRngLo) or (bar.High > lvlRngHi and bar.Low < lvlRngLo) or (bar.High[1] < lvlRngHi and bar.High[1] > lvlRngLo) or (bar.Low[1] < lvlRngHi and bar.Low[1] > lvlRngLo) or (bar.High[1] > lvlRngHi and bar.Low[1] < lvlRngLo) proximal(kl) => [lvl, lvlRng, lvlRngHi, lvlRngLo] = getLevelRange(kl) proximal = priceWithinLevelProximity(lvlRngHi, lvlRngLo) // If proximity settings are enabled… if (truncate and extend) or showProx or atrZone // Set proximity ATR value. prxAtr = ta.atr(5) / 2 // Check if bars are proximal to key levels. for [i, kl] in keyLevels if kl.Show if proximal(kl) if truncate and extend // Override truncated line length. x1 = i == id.orH or i == id.orL ? firstMarketBarIndex : i == id.ydH or i == id.ydL ? kl.OldIndex : kl.Index kl.Line.set_x1(x1) if showProx // Show level and label. kl.Line.set_color(kl.Color) labelColor = i < id.onH and overnight ? none : lblClr textColor = i < id.onH and overnight ? none : txtClr if showLabel kl.Label.delete() kl.newLabel() if atrZone // Show average true range zone around level. [lvl, lvlRng, lvlRngHi, lvlRngLo] = getLevelRange(kl) boxBgClr = i < id.onH and overnight ? none : color.new(kl.Color, 90) boxBorderClr = i < id.onH and overnight ? none : color.new(kl.Color, 80) kl.Range.delete() kl.Range := box.new(kl.Line.get_x1(), lvl + prxAtr, kl.Line.get_x2(), lvl - prxAtr, boxBorderClr, 1, bgcolor = boxBgClr, xloc = xloc.bar_time) else if truncate and extend // Re-truncate lines. kl.Line.set_x1(bar.Index - numOfBars(truncLen)) if showProx // Hide level and label. orBox.delete() kl.Line.set_color(none) if showLabel kl.Label.delete() if atrZone // Hide ATR zone. kl.Range.delete() kl.Range := box.new(na, na, na, na, xloc = xloc.bar_time)
Turtle Soup Indicator
https://www.tradingview.com/script/28gN99Tw-Turtle-Soup-Indicator/
kulturdesken
https://www.tradingview.com/u/kulturdesken/
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/ // © kulturdesken //@version=5 indicator("Turtle Soup", overlay=true) period = 20 high_value = ta.highest(high, period) low_value = ta.lowest(low, period) high_candle = high == high_value low_candle = low == low_value prev_high_value = ta.highest(high[1], period) prev2_high_value = ta.highest(high[2], period) prev3_high_value = ta.highest(high[3], period) prev4_high_value = ta.highest(high[4], period) prev_low_value = ta.lowest(low[1], period) prev2_low_value = ta.lowest(low[2], period) prev3_low_value = ta.lowest(low[3], period) prev4_low_value = ta.lowest(low[4], period) no_prev_high_candle = not (high[1] == prev_high_value or high[2] == prev2_high_value or high[3] == prev3_high_value or high[4] == prev4_high_value) no_prev_low_candle = not (low[1] == prev_low_value or low[2] == prev2_low_value or low[3] == prev3_low_value or low[4] == prev4_low_value) plotshape(high_candle and no_prev_high_candle and no_prev_low_candle, title="Turtle Soup", location=location.abovebar, color=color.green, style=shape.cross, size=size.tiny) plotshape(low_candle and no_prev_high_candle and no_prev_low_candle, title="Turtle Soup", location=location.belowbar, color=color.red, style=shape.cross, size=size.tiny)
Congestionautilus
https://www.tradingview.com/script/WKcCPH92/
Rumost
https://www.tradingview.com/u/Rumost/
17
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/ // © Rumost ...dedicato ai simpatici amici del gruppo di supporto ;-) //@version=5 indicator("Congestionautilus", overlay = true, max_boxes_count = 500) ZoneColor = input(defval = color.new(#ffde4b, 90), title = "Area") BorderColor = input(defval = color.new(#795c1e, 35), title = "Border") ExtendColor = input(defval = color.new(#795c1e, 35), title = "Extension") Extend = input(defval = true, title = "Extend the last congestion") var CHigh = array.new_float(0) var CLow = array.new_float(0) var ALine = line.new(1,0,1,0,color=na) var BLine = line.new(1,0,1,0,color=na) var E1Line = line.new(1,0,1,0,color=na) var E2Line = line.new(1,0,1,0,color=na) var xBox = box.new(1,0,1,0,bgcolor = na, border_color = na) var count = 3 congestionCondtion() => if ( array.size(CHigh) == 0 ) close[1] >= low[2] and close[1] <= high[2] and open[1] >= low[2] and open[1] <= high[2] else close[1] >= array.get(CLow, 0) and close[1] <= array.get(CHigh, 0) and open[1] >= array.get(CLow, 0) and open[1] <= array.get(CHigh, 0) reset() => array.clear(CHigh) array.clear(CLow) box.delete(xBox) line.delete(ALine) line.delete(BLine) counter() => counter=array.size(CHigh) if ( congestionCondtion() ) array.push(CHigh, high[2]) array.push(CLow, low[2]) else if( counter() < count ) reset() if( counter() >= count and congestionCondtion() == false ) float maxCZ = array.get(CHigh, 0) float minCZ = array.get(CLow, 0) box.new(bar_index - counter()-2, maxCZ, bar_index-2, minCZ, bgcolor = ZoneColor, border_color = BorderColor) reset() else if( counter() >= count and congestionCondtion() == true ) float maxCZ = array.get(CHigh, 0) float minCZ = array.get(CLow, 0) line.delete(ALine) line.delete(BLine) box.delete(xBox) xBox:=box.new(bar_index - counter()-1, maxCZ, bar_index+1, minCZ, bgcolor = ZoneColor, border_color = na) ALine:=line.new(bar_index - counter()-1, maxCZ, bar_index+1, maxCZ, color=BorderColor, style=line.style_solid, width=1, xloc=xloc.bar_index) BLine:=line.new(bar_index - counter()-1, minCZ, bar_index+1, minCZ, color=BorderColor, style=line.style_solid, width=1, xloc=xloc.bar_index) if (Extend) line.delete(E1Line) line.delete(E2Line) E1Line:=line.new(bar_index, maxCZ, bar_index+1, maxCZ, color=ExtendColor, style=line.style_dashed, width=1, xloc=xloc.bar_index,extend=extend.right) E2Line:=line.new(bar_index, minCZ, bar_index+1, minCZ, color=ExtendColor, style=line.style_dashed, width=1, xloc=xloc.bar_index,extend=extend.right)
Liquidity Channel with B/S
https://www.tradingview.com/script/WPs9eAc7/
Genesis-Trader
https://www.tradingview.com/u/Genesis-Trader/
44
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/ // © atnx //@version=5 indicator("Liquidity Channel with B/S", overlay = true, shorttitle = "Liq Chan B/S") // 1. Indicator - Liquidity Level source = close length = 14 mult = 1.0 lowestLow = ta.lowest(low, length) highestHigh = ta.highest(high, length) rng = highestHigh - lowestLow averagerng = ta.sma(rng, length) middleLine = lowestLow + rng / 2 upperLine = middleLine + mult * averagerng lowerLine = middleLine - mult * averagerng liquidityLevel = (upperLine + lowerLine) / 2 liquidityLevelDist = (upperLine - lowerLine) / 2 sellSide = liquidityLevel + (liquidityLevelDist / 2) buySide = liquidityLevel - (liquidityLevelDist / 2) liquidityBuyCondition = close < buySide liquiditySellCondition = close > sellSide plot(sellSide,'UpperLiquidity', color=color.rgb(250, 0, 0)) plot(buySide,'LowerLiquidity', color=#006cc4) // 2. Indicator - D-BoT Alpha Reversals ROCLength = 20 RSILength = 14 osg = 50 obg = 50 Extremities = 0.5 xPrice = close nRes = ta.rsi(ta.roc(xPrice, ROCLength), RSILength) maxrsi = 21 minrsi = 7 // Signal triggering var FiredSignal = false var CooledSignal = false N = maxrsi - minrsi + 1 z = nz(xPrice - xPrice[1]) var X = array.new_float(N, 0) var Y = array.new_float(N, 0) t = 0 o = 0 s = 0 avg = 0. for i = minrsi to maxrsi alpha = 1 / i X_rma = alpha * z + (1 - alpha) * array.get(X, t) Y_rma = alpha * math.abs(z) + (1 - alpha) * array.get(Y, t) rsi = 50 * X_rma / Y_rma + 50 avg := avg + rsi o := rsi > osg ? o + 1 : o s := rsi < obg ? s + 1 : s array.set(X, t, X_rma) array.set(Y, t, Y_rma) t := t + 1 v_rs = avg / N overboughtCondition = nRes > osg and v_rs > osg and math.abs(nRes - v_rs) <= Extremities oversoldCondition = nRes < obg and v_rs < obg and math.abs(nRes - v_rs) <= Extremities if (overboughtCondition and not FiredSignal) if (close < open) // red bar FiredSignal := true if (oversoldCondition and not CooledSignal) if (close > open) // green bar CooledSignal := true if (not overboughtCondition) FiredSignal := false if (not oversoldCondition) CooledSignal := false // Combined conditions buyCondition = liquidityBuyCondition and CooledSignal sellCondition = liquiditySellCondition and FiredSignal // Plot signals plotshape(buyCondition, title = "Buy", style = shape.labelup, location = location.belowbar, color = color.new(color.green, 0), text='Buy', textcolor=color.white, size = size.tiny) plotshape(sellCondition, title = "Sell", style = shape.labeldown, location = location.abovebar, color = color.new(color.red, 0), text='Sell', textcolor=color.white, size = size.tiny) barcolor(color=color.gray,title='BarColorPref:') // Alerts alertcondition(buyCondition, title='Buy', message='Buy!') alertcondition(sellCondition, title='Sell', message='Sell!')
Valuation Metrics Table (P/S, P/E, etc.)
https://www.tradingview.com/script/AR1mxfOy-Valuation-Metrics-Table-P-S-P-E-etc/
jvorndran311
https://www.tradingview.com/u/jvorndran311/
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/ // © jvorndran311 //@version=5 indicator("Valuation Metrics Table", overlay = true) yearsLookbackPS = input.int(defval = 5, title = "Amount of years to calculate median") i_PS = input.bool(defval = true, title = 'Price to sales') i_PSM = input.bool(defval = true, title = 'Price to sales median') i_PSD = input.bool(defval = true, title = 'Price to sales discount to median') i_PE = input.bool(defval = true, title = 'Price to earnings') i_PEM = input.bool(defval = true, title = 'Price to earnings median') i_PED = input.bool(defval = true, title = 'Price to earnings discount to median') i_FCF = input.bool(defval = true, title = 'Free cash flow per share') i_DE = input.bool(defval = true, title = 'Debt to Equity') i_PR = input.bool(defval = false, title = 'Payout Ratio') i_EV = input.bool(defval = true, title = 'EV/EBITDA') var table myTable = table.new(position = position.bottom_right, columns = 10, rows = 10) table.set_border_color(myTable, color.white) table.set_border_width(myTable, 2) table.set_frame_color(myTable, color.white) table.set_frame_width(myTable, 2) float rev = request.financial(symbol = syminfo.tickerid, financial_id = "TOTAL_REVENUE", period = 'TTM') float totalSharesOut = request.financial(symbol = syminfo.tickerid, financial_id = "TOTAL_SHARES_OUTSTANDING", period = "FY") float mktCap = close * totalSharesOut float priceSalesRatio = ((close * totalSharesOut) / rev) //252 trading days a year float medianPriceSales = ta.median(priceSalesRatio, 252 * yearsLookbackPS) float meanPriceSales = math.sum(priceSalesRatio, 252 * yearsLookbackPS) / (252 * yearsLookbackPS) float std = ta.stdev(priceSalesRatio, 252 * yearsLookbackPS) float discountMedian = (priceSalesRatio / medianPriceSales) float discountMean = (priceSalesRatio / meanPriceSales) // plot(priceSalesRatio, color = color.white, style = plot.style_line, linewidth = 2) // plot(medianPriceSales, color = color.aqua, linewidth = 2) // plot(std + meanPriceSales, color = color.orange, linewidth = 2) // plot(meanPriceSales - std, color = color.orange, linewidth = 2) if i_PSD table.cell(myTable, 0, 2, text = "P/S Discount To 5yr Median", text_color = color.white) table.cell(myTable, 1, 2, str.tostring(discountMedian < 1 ? 100 - (discountMedian * 100) : (discountMedian * 100), format = '#.###') + '%', text_color = color.white) if i_PS table.cell(myTable, 0, 0, text = "P/S", text_color = color.white ) table.cell(myTable, 1, 0, str.tostring(priceSalesRatio, format = '#.###'), text_color = color.white) if i_PSM table.cell(myTable, 0, 1, text = "P/S Median (Default 5 yrs)", text_color = color.white) table.cell(myTable, 1, 1, str.tostring(medianPriceSales, format = '#.###'), text_color = color.white) //P/E float PE = close / request.financial(syminfo.tickerid, financial_id = 'EARNINGS_PER_SHARE_DILUTED', period = 'TTM') float medianPE = ta.median(PE, 252 * yearsLookbackPS) float discountPE = PE / medianPE discountPE := discountPE < 1 ? 100 - (discountPE * 100) : (discountPE * 100) if i_PE table.cell(myTable, 0, 3, text = "P/E", text_color = color.white) table.cell(myTable, 1, 3, text = str.tostring(PE, '#.###'), text_color = color.white) table.set_bgcolor(myTable, bgcolor = color.black) if i_PEM table.cell(myTable, 0, 4, text = "P/E Median (Default 5 yrs)", text_color = color.white) table.cell(myTable, 1, 4, text = str.tostring(medianPE, '#.###'), text_color = color.white) if i_PED table.cell(myTable, 0, 5, text = "P/E Discount To 5yr Median", text_color = color.white) table.cell(myTable, 1, 5, text = str.tostring(discountPE, '#.###') + '%', text_color = color.white) //P/E //FCF float FCFperShare = request.financial(syminfo.tickerid, 'FREE_CASH_FLOW', period = 'FQ') / totalSharesOut if i_FCF table.cell(myTable, 0, 6, text = "FCF/Share", text_color = color.white) table.cell(myTable, 1, 6, text = str.tostring(FCFperShare, '#.###'), text_color = color.white) //FCF // D/E float DE = request.financial(syminfo.tickerid, 'DEBT_TO_EQUITY', period = 'FY') if i_DE table.cell(myTable, 0, 7, text = "Debt/Equity", text_color = color.white) table.cell(myTable, 1, 7, text = str.tostring(DE, '#.###'), text_color = color.white) // D/E // PEG // EPS1YR = request.financial(syminfo.tickerid, 'EARNINGS_PER_SHARE_DILUTED', period = 'TTM')[252] // EPS = request.financial(syminfo.tickerid, 'EARNINGS_PER_SHARE_DILUTED', period = 'TTM') // PEG = (close / EPS) / (((EPS / EPS1YR)) * 100) // plot(PEG) // PEG //Estimates // float EPSest = request.financial(syminfo.tickerid, "EARNINGS_ESTIMATE", "FQ") // float revEst = request.financial(syminfo.tickerid, "SALES_ESTIMATES", "FQ") // plot(EPSest) // float projEpsGrowth = (EPSest / request.financial(syminfo.tickerid, financial_id = 'EARNINGS_PER_SHARE_BASIC', period = 'FQ')) * 100 // table.cell(myTable, 0, 8, "Projected EPS Growth", text_color = color.white) // table.cell(myTable, 1, 8,str.tostring(projEpsGrowth - 100, '#.###') + '%', text_color = color.white) //Estimates //Div Payout Ratio float payoutRatio = request.financial(syminfo.tickerid, "DIVIDEND_PAYOUT_RATIO", period = "FQ") if i_PR table.cell(myTable, 0, 8, text = "Payout Ratio", text_color = color.white) table.cell(myTable, 1, 8, str.tostring(payoutRatio, '#.###') + '%', text_color = color.white) //Div Payout Ratio // EV/EBITA float EV = request.financial(syminfo.tickerid, "ENTERPRISE_VALUE_EBITDA", period = "FQ") if i_EV table.cell(myTable, 0, 9, "EV/EBITDA", text_color = color.white) table.cell(myTable, 1, 9, str.tostring(EV, '#.###'), text_color = color.white) //EV/EBITA
AIAE Indicator
https://www.tradingview.com/script/oU7Cw6Le-AIAE-Indicator/
rodopacapital
https://www.tradingview.com/u/rodopacapital/
30
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/ // © rodopacapital //@version=5 indicator("AIAE Indicator", overlay=false) TMVS = request.security("WILL5000PRFC*1000000000", 'W', close) TMVB = request.security("FRED:GFDEBTN", 'W', close) C = request.security("FRED:M2SL", 'W', close) // Calculating Aggregate (or Average) Investor Allocation to Equities indicator in percents AIAE = TMVS/(TMVS+TMVB+C) // Calculating Bonds indicator in percents BOND = TMVB/(TMVS+TMVB+C) // Calculating other money indicator in percents other = C/(TMVS+TMVB+C) // Calculating real stocks holdings in percents stocks = TMVS/(TMVS+TMVB+C-(other*C))*100 bonds = TMVB/(TMVS+TMVB+C)*100 // Plot the global liquidity value as a candlestick chart plot(stocks, "Stocks holdings as percent from total market", color = color.blue, trackprice=true) plot(bonds, "Bonds holdings as percent from total market", color = color.red, display = display.none) plot(other*100, "Other cash holdings as percent from total market", color = color.green, display = display.none)
Vwma Oscillator [MMD]
https://www.tradingview.com/script/cDbmStQP/
muratm82
https://www.tradingview.com/u/muratm82/
71
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/ // © muratm82 //@version=5 indicator("Vwma Oscillator [MMD]",overlay=false) a1=ta.ema(close*volume,4)/ta.ema(volume,4) a2=a1-ta.vwma(close,8) a3=2*ta.vwma(a2,8)-ta.vwma(a2,16) plot(a3,color=((a3>a3[3]*0.8 and a3<a3[3]*1.2) or (a3<a3[3]*0.8 and a3>a3[3]*1.2))?color.silver:(a3>0?color.green:color.red), linewidth =3,style=plot.style_circles) p1=plot(a3[3]*0.8,transp=100) p2=plot(a3[3]*1.2,transp=100) fill(p1,p2,color=a3[2]*0.8>a3[2]*1.2?color.red:color.green,transp=25) plot(0,color=color.gray,linewidth =2) a1s=ta.sar(0.003,0.004,0.2) a2s=ta.ema(close,200) a3s=ta.vwma(close,50) a4s=math.sqrt(a1s*a2s) a5s=math.sqrt(a3s*a4s) plot(close-a5s,style=plot.style_columns,color=close-a5s>0?color.lime:color.maroon,transp=75)
Moving Average Trend Sniper [ChartPrime]
https://www.tradingview.com/script/iwEyBE2d-Moving-Average-Trend-Sniper-ChartPrime/
ChartPrime
https://www.tradingview.com/u/ChartPrime/
933
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/ // © ChartPrime //@version=5 indicator("Moving Average Trend Sniper [ChartPrime]", "MATS [ChartPrime]", true) // Custom cosh function cosh(float x) => (math.exp(x) + math.exp(-x)) / 2 // Custom acosh function acosh(float x) => x < 1 ? na : math.log(x + math.sqrt(x * x - 1)) // Custom sinh function sinh(float x) => (math.exp(x) - math.exp(-x)) / 2 // Custom asinh function asinh(float x) => math.log(x + math.sqrt(x * x + 1)) // Custom inverse tangent function atan(float x) => math.pi / 2 - math.atan(1 / x) // Chebyshev Type I Moving Average chebyshevI(float src, int len, float ripple) => a = 0. b = 0. g = 0. chebyshev = 0. a := cosh(1 / len * acosh(1 / (1 - ripple))) b := sinh(1 / len * asinh(1 / ripple)) g := (a - b) / (a + b) chebyshev := (1 - g) * src + g * nz(chebyshev[1]) chebyshev bool_to_float(bool source) => source ? 1 : 0 ema(source)=> var float ema = 0.0 var int count = 0 count := nz(count[1]) + 1 ema := (1.0 - 2.0 / (count + 1.0)) * nz(ema[1]) + 2.0 / (count + 1.0) * source ema atan2(y, x) => var float angle = 0.0 if x > 0 angle := math.atan(y / x) else if x < 0 and y >= 0 angle := math.atan(y / x) + math.pi else if x < 0 and y < 0 angle := math.atan(y / x) - math.pi else if x == 0 and y > 0 angle := math.pi / 2 else if x == 0 and y < 0 angle := -math.pi / 2 angle degrees(float source) => source * 180 / math.pi tra()=> atr = ema(ta.tr) slope = (close - close[10]) / (atr * 10) angle_rad = atan2(slope, 1) degrees = degrees(angle_rad) source = ta.sma((degrees > 0 ? high : low), 2) mats(source, length) => smooth = 0. higher_high = math.max(math.sign(ta.change(ta.highest(length))), 0) lower_low = math.max(math.sign(ta.change(ta.lowest(length)) * -1), 0) time_constant = math.pow(ta.sma(bool_to_float(higher_high or lower_low), length), 2) smooth := nz(smooth[1] + time_constant * (source - smooth[1]), source) wilders_period = length * 4 - 1 atr = math.abs(nz(smooth[1]) - smooth) ma_atr = ta.ema(atr, wilders_period) delta_fast_atr = ta.ema(ma_atr, wilders_period) * length * 0.4 result = 0.0 if smooth > nz(result[1]) if smooth - delta_fast_atr < result[1] result := result[1] else result := smooth - delta_fast_atr else if smooth + delta_fast_atr > result[1] result := result[1] else result := smooth + delta_fast_atr // Return result length = input.int(30, "Length", 2) up_color = input.color(color.blue, "", inline = "color") down_color = input.color(color.orange, "", inline = "color") enable_glow = input.bool(true, "Enable Glow", inline = "color") mats = mats(tra(), length) atr = ta.atr(length) colour = ta.sma(close, 2) > mats ? up_color : down_color atr_10 = ema(ta.tr) / 2 alpha = color.new(color.black, 100) max = mats + atr_10 min = mats - atr_10 center = plot(mats, "Moving Average Trend Sniper", colour, editable = true) plot(mats, "Moving Average Trend Sniper", color.new(colour, 70), 2, editable = true) plot(mats, "Moving Average Trend Sniper", color.new(colour, 80), 3, editable = true) plot(mats, "Moving Average Trend Sniper", color.new(colour, 90), 4, editable = true) top = plot(enable_glow ? max : na, "Moving Average Trend Sniper", alpha) bottom = plot(enable_glow ? min : na, "Moving Average Trend Sniper", alpha) fill(top, center, top_value = max, bottom_value = mats, bottom_color = color.new(colour, 75), top_color = alpha, editable = true) fill(center, bottom, top_value = mats, bottom_value = min, bottom_color = alpha, top_color = color.new(colour, 75), editable = true)
7 Closes above/below 5 SMA
https://www.tradingview.com/script/EfQbv9xs-7-Closes-above-below-5-SMA/
kulturdesken
https://www.tradingview.com/u/kulturdesken/
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/ // © kulturdesken // This script looks for 7 consecutive closes above/below the 5-period SMA. The indicator is inspired by trading legend Linda Raschke's ideas. // It can be used in at least two ways. I use it at a learning tool to test models. These are the two models I am testing, inspired by Raschke: // 1) Persistency of trend / Extended run setup. Around 10-12 times per year we get a persistency of trend in instruments in general. // After 7 consecutive closes above/below the 5-period you can re-enter as it moves up/down again. Then try to hold as long as possible. Way longer than you can percieve or think of. Up to 24-28 periods is what we are looking for. // 2) Normal usage is to use it as a possible oscillating signal, after which we can look for a reverse setup in price action. // Read Linda Raschkes work to learn more about these ideas. // I added settings so you can change preferences for changing shape, where to display the shape and in what color //@version=5 indicator("Closes vs 5", overlay=true) // Calculate the 5-period SMA smaPeriod = 5 smaValue = ta.sma(close, smaPeriod) // Initialize variables var int consecutiveClosesAbove = 0 var int consecutiveClosesBelow = 0 // Check if the close is above the SMA isAboveSMA = close > smaValue // Count consecutive closes above and below the SMA consecutiveClosesAbove := isAboveSMA ? nz(consecutiveClosesAbove[1]) + 1 : 0 consecutiveClosesBelow := isAboveSMA ? 0 : nz(consecutiveClosesBelow[1]) + 1 // Check if we have reached 7 consecutive closes above the SMA sevenConsecutiveClosesAbove = consecutiveClosesAbove >= 7 and consecutiveClosesBelow < 7 // Check if we have reached 7 consecutive closes below the SMA sevenConsecutiveClosesBelow = consecutiveClosesBelow >= 7 and consecutiveClosesAbove < 7 // Plot green dot when 7 consecutive closes above the SMA occur plotshape(sevenConsecutiveClosesAbove, color=color.green, style=shape.circle, title="7 consecutive closes above SMA", location=location.belowbar) // Plot red dot when 7 consecutive closes below the SMA occur plotshape(sevenConsecutiveClosesBelow, color=color.red, style=shape.circle, title="7 consecutive closes below SMA", location=location.abovebar)
ICT Seek & Destroy Profile [TFO]
https://www.tradingview.com/script/O2WBggA3-ICT-Seek-Destroy-Profile-TFO/
tradeforopp
https://www.tradingview.com/u/tradeforopp/
1,500
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/ // © tradeforopp //@version=5 indicator("ICT Seek & Destroy Profile [TFO]", "S&D Profile [TFO]", true, max_boxes_count = 500, max_labels_count = 500) // -------------------------------------------------- Inputs -------------------------------------------------- var g_KZS = "Killzones" as_am = input.session(title="Asia", defval="2000-0300", inline = "ASKZ", group = g_KZS) askz_color = input.color(color.new(color.blue, 80), "", inline = "ASKZ", group = g_KZS) lo_am = input.session(title="London", defval="0300-0830", inline = "LOKZ", group = g_KZS) ldkz_color = input.color(color.new(color.yellow, 80), "", inline = "LOKZ", group = g_KZS) ny_am = input.session(title="New York", defval="0830-1600", inline = "NYKZ", group = g_KZS) nykz_color = input.color(color.new(color.green, 80), "", inline = "NYKZ", group = g_KZS) var g_CRT = "Success Criteria" crt_inside_day = input.bool(true, "NY Stays Within London Range", tooltip = "The New York range is contained within the London range", group = g_CRT) crt_outside_day = input.bool(true, "NY Exceeds London High & Low", tooltip = "The New York range exceeds both the high and low of the London range", group = g_CRT) crt_close_in_lo = input.bool(true, "NY Closes Within London Range", tooltip = "The New York range closes within the London range", group = g_CRT) crt_sd_limit = input.bool(true, "NY Range Too Small", tooltip = "The New York range will be compared to the standard deviation of its historical ranges, multiplied by this factor", inline = "SD", group = g_CRT) sd_limit = input.float(1.0, "", inline = "SD", group = g_CRT) var g_SND = "Labels" show_snd_pre = input.bool(true, "Potential S&D Day", inline = "PRE", tooltip = "If London took both sides of the Asian range, this label will be generated", group = g_SND) snd_pre_color = input.color(title="", defval = #f23645, inline = "PRE", group = g_SND) show_snd_day = input.bool(true, "Successful S&D Day", inline = "POST", tooltip = "If New York met any of the selected success criteria, this label will populate", group = g_SND) snd_day_color = input.color(title="", defval = #089981, inline = "POST", group = g_SND) var g_WRN = "Warning" show_wrn_table = input.bool(true, "Show Warning", tooltip = "Display the custom warning message when it is a potential S&D day (for the duration of the NY session)", group = g_WRN) wrn_msg = input.string("Potential S&D Day", "Warning Message", group = g_WRN) wrn_text = input.color(color.white, "Text Color", group = g_WRN) wrn_bg = input.color(#f23645, "Table Background", group = g_WRN) var g_STY = "Statistics" show_stat_table = input.bool(true, "Show Statistics Table", group = g_STY) table_position = input.string('Top Right', "Table Position", options = ['Bottom Center', 'Bottom Left', 'Bottom Right', 'Middle Center', 'Middle Left', 'Middle Right', 'Top Center', 'Top Left', 'Top Right'], group = g_STY) table_size = input.string('Auto', "Text Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group = g_STY) table_text = input.color(color.black, "Text", group = g_STY) table_bg = input.color(color.white, "Table Background", group = g_STY) table_frame = input.color(color.black, "Table Frame", group = g_STY) table_border = input.color(color.black, "Table Border", group = g_STY) table_border_width = input.int(1, "Table Border Width", group = g_STY) table_frame_width = input.int(2, "Table Frame Width", group = g_STY) // -------------------------------------------------- Inputs -------------------------------------------------- // -------------------------------------------------- Constants & Variables -------------------------------------------------- nykz = not na(time(timeframe.period, ny_am, "America/New_York")) lokz = not na(time(timeframe.period, lo_am, "America/New_York")) askz = not na(time(timeframe.period, as_am, "America/New_York")) var int sessions = 0 var int last_snd_pre = 0 var int last_snd_day = 0 var int total_snd_wrn = 0 var int total_snd_day = 0 var box nykz_box = na var box lokz_box = na var box askz_box = na var int last_new_ny = na var float last_ny_high = na var float last_ny_low = na var float last_ny_close = na var int last_new_lo = na var float last_lo_high = na var float last_lo_low = na var float last_lo_close = na var int last_new_as = na var float last_as_high = na var float last_as_low = na var float last_as_close = na var ny_range = array.new_float() // -------------------------------------------------- Constants & Variables -------------------------------------------------- // -------------------------------------------------- Functions -------------------------------------------------- manual_stdev() => mean = ny_range.avg() accum = 0.0 size = ny_range.size() if size > 0 for i = 0 to size - 1 accum += math.pow((ny_range.get(i) - mean), 2) sd = math.sqrt(accum / size) get_table_position(pos) => result = switch pos "Bottom Center" => position.bottom_center "Bottom Left" => position.bottom_left "Bottom Right" => position.bottom_right "Middle Center" => position.middle_center "Middle Left" => position.middle_left "Middle Right" => position.middle_right "Top Center" => position.top_center "Top Left" => position.top_left "Top Right" => position.top_right get_text_size(size) => result = switch size 'Auto' => size.auto 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal 'Large' => size.large 'Huge' => size.huge // -------------------------------------------------- Functions -------------------------------------------------- // -------------------------------------------------- Core Logic -------------------------------------------------- if nykz if not nykz[1] nykz_box := box.new(bar_index, high, bar_index, low, text = "New York", text_color = nykz_color, bgcolor = nykz_color, border_color = nykz_color) sessions += 1 else top = box.get_top(nykz_box) bot = box.get_bottom(nykz_box) if high > top top := high if low < bot bot := low box.set_rightbottom(nykz_box, bar_index, bot) box.set_top(nykz_box, top) if lokz if not lokz[1] lokz_box := box.new(bar_index, high, bar_index, low, text = "London", text_color = ldkz_color, bgcolor = ldkz_color, border_color = ldkz_color) else top = box.get_top(lokz_box) bot = box.get_bottom(lokz_box) if high > top top := high if low < bot bot := low box.set_rightbottom(lokz_box, bar_index, bot) box.set_top(lokz_box, top) if askz if not askz[1] askz_box := box.new(bar_index, high, bar_index, low, text = "Asia", text_color = askz_color, bgcolor = askz_color, border_color = askz_color) else top = box.get_top(askz_box) bot = box.get_bottom(askz_box) if high > top top := high if low < bot bot := low box.set_rightbottom(askz_box, bar_index, bot) box.set_top(askz_box, top) if not nykz and nykz[1] last_ny_high := box.get_top(nykz_box[1]) last_ny_low := box.get_bottom(nykz_box[1]) last_ny_close := close[1] last_new_ny := bar_index ny_range.push(last_ny_high - last_ny_low) if not lokz and lokz[1] last_lo_high := box.get_top(lokz_box[1]) last_lo_low := box.get_bottom(lokz_box[1]) last_lo_close := close[1] last_new_lo := bar_index if not askz and askz[1] last_as_high := box.get_top(askz_box[1]) last_as_low := box.get_bottom(askz_box[1]) last_as_close := close[1] last_new_as := bar_index snd_day_wrn = false if last_new_lo > last_new_as and last_lo_high > last_as_high and last_lo_low < last_as_low and last_snd_pre < last_new_lo snd_day_wrn := true last_snd_pre := bar_index total_snd_wrn += 1 snd_day_valid = false if last_new_ny > last_new_lo and last_snd_pre > last_new_as and last_snd_day < last_new_ny outside_day = crt_outside_day ? last_ny_high >= last_lo_high and last_ny_low <= last_lo_low : false inside_day = crt_inside_day ? last_ny_high < last_lo_high and last_ny_low > last_lo_low : false close_inside_lo = crt_close_in_lo ? last_ny_close < last_lo_high and last_ny_close > last_lo_low : false stdev = crt_sd_limit ? last_ny_high - last_ny_low <= manual_stdev() * sd_limit : false if outside_day or inside_day or close_inside_lo or stdev snd_day_valid := true last_snd_day := bar_index total_snd_day += 1 if show_snd_pre and snd_day_wrn label.new(bar_index, last_lo_high, "Potential S&D Day", color = snd_pre_color, textcolor = wrn_text) if show_snd_day and snd_day_valid label.new(bar_index, last_ny_high, "Valid S&D Day", color = snd_day_color, textcolor = wrn_text) // -------------------------------------------------- Core Logic -------------------------------------------------- // -------------------------------------------------- Table -------------------------------------------------- var stats = table.new(get_table_position(table_position), 10, 10, bgcolor = table_bg, frame_color = table_frame, border_color = table_border, frame_width = table_frame_width, border_width = table_border_width) table_text_size = get_text_size(table_size) if barstate.islast if show_stat_table table.cell(stats, 0, 1, "Seek & Destroy Profile", text_color = table_text, text_size = table_text_size) table.cell(stats, 0, 2, "Total Sessions", text_color = table_text, text_size = table_text_size) table.cell(stats, 1, 2, str.tostring(sessions), text_color = table_text, text_size = table_text_size) table.cell(stats, 0, 3, "Warnings Given", text_color = table_text, text_size = table_text_size) table.cell(stats, 1, 3, str.tostring(total_snd_wrn), text_color = table_text, text_size = table_text_size) table.cell(stats, 0, 4, "Warning Success", text_color = table_text, text_size = table_text_size) table.cell(stats, 1, 4, str.tostring(total_snd_day), text_color = table_text, text_size = table_text_size) table.cell(stats, 0, 5, "Warning Success Rate", text_color = table_text, text_size = table_text_size) table.cell(stats, 1, 5, str.tostring(math.round(total_snd_day / total_snd_wrn * 100)) + "%", text_color = table_text, text_size = table_text_size) if show_wrn_table if last_snd_pre > last_new_ny table.cell(stats, 0, 1, wrn_msg, text_color = wrn_text, bgcolor = wrn_bg, text_size = table_text_size) // -------------------------------------------------- Table --------------------------------------------------
Hann Window Amplitude Filter
https://www.tradingview.com/script/GtnadVvI-Hann-Window-Amplitude-Filter/
mks17
https://www.tradingview.com/u/mks17/
13
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/ // © mks17 //@version=5 indicator('Hann Window Amplitude Filter', overlay=false) //Inputs length = input(14, "Number of frequencies to Filter") var shifts = input.int(0, "Bar moves of the Hann window") minBase = input.float(0.1, "Filter Minimum Base", step = .1) //Calcs int ArrayLen = 2 * length - 1 var Array = array.new_float(ArrayLen, 0), pi = math.pi h = 0.0, c = 0.0, var leftside = 0, var rightside = 0, var coef = 0.0 if bar_index <= ArrayLen c := nz(c[1], 0) == ArrayLen - 1 ? 0 : nz(c[1], 0) + 1 h := (1 - math.cos(2 * pi * (c - 1) / ArrayLen)) / 2 + minBase array.insert(Array, 0, h) else if bar_index <= ArrayLen + 1 if shifts > 0 for i = 0 to shifts - 1 by 1 array.shift(Array) array.push(Array, minBase) shifts := shifts - 1 else if shifts < 0 for i = 0 to math.abs(shifts) - 1 by 1 array.unshift(Array,minBase) shifts := shifts + 1 if ArrayLen % 2 == 0 leftside := length / 2 rightside := ArrayLen - length / 2 else leftside := math.floor(length / 2) rightside := ArrayLen - math.floor(length / 2) for i = leftside to rightside coef := coef + array.get(Array, i) for i = leftside to rightside array.set(Array, i, array.get(Array,i) / coef) //Plots plot(h) plot(coef, color=color.purple) plot(array.get(Array, length), title='HW', color=color.new(#FA8258, 0)) plot(bar_index % ArrayLen, title='Bar Index % Array Len', color=color.new(#FA8258, 0), display=display.data_window) plot(c, title='Counter', color=color.new(#FA8258, 0), display=display.data_window) plot(array.get(Array, length - 1), title='MaxCoeff +', color=color.new(#FA8258, 0), display=display.data_window) plot(array.get(Array, length), title='MaxCoeff -', color=color.new(#FA8258, 0), display=display.data_window) plot(array.get(Array, leftside), title='MinCoeff +', color=color.new(#FA8258, 0), display=display.data_window) plot(array.get(Array, rightside), title='MinCoeff -', color=color.new(#FA8258, 0), display=display.data_window) hline(0) hline(1)
Simple Dollar Cost Average
https://www.tradingview.com/script/wE93nMBC-Simple-Dollar-Cost-Average/
RomainHaenni
https://www.tradingview.com/u/RomainHaenni/
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/ // © RomainHaenni //@version=5 indicator("Dollar Cost Average", "DCA") float startingAmount = input.float(0.0, "Starting Investment") float investmentAmount = input.float(500.0, "Repeating Investment") int frequency = input.int(7, "Repeats every (in days)", inline="frequency") float feeRatio = input.float(0.02, "Broker Fee") int startDate = input.time(timestamp("Jan 01 2023"), "Starting Date") int endDate = input.time(timestamp("Jan 01 2033"), "Ending Date") float cellWidth = input.float(0.0, "Cell Width", group="advanced") float cellHeight = input.float(10.0, "Cell Height", group="advanced") var float assets = 0.0 var float feeAmount = 0.0 var float entryPrice = 0.0 var float invested = 0.0 var float netProfit = 0.0 var float totalFee = 0.0 var float grossProfit = 0.0 var float grossLoss = 0.0 var int totalTrades = 0 var float portfolioValue = 0.0 var table info = table.new(position.bottom_left, 1, 7, #212121, #313131, 1, #313131, 1) table.cell(info, 0, 0, "$0.00 invested", cellWidth, cellHeight, color.lime, text.align_left) table.cell(info, 0, 1, "$0.00 (0.0%) PnL", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 2, "$0.00 (0.0%) fee", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 3, "$0.00 total", cellWidth, cellHeight, color.yellow, text.align_left) table.cell(info, 0, 4, "0.00 shares", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 5, "$0.00 / share", cellWidth, cellHeight, #BDBDBD, text.align_left) table.cell(info, 0, 6, "0 trades", cellWidth, cellHeight, #BDBDBD, text.align_left) bool investmentWindow = time >= startDate and time < endDate if investmentWindow if startingAmount > 0.0 and invested == 0.0 totalTrades := totalTrades + 1 feeAmount := startingAmount * feeRatio invested := startingAmount newAssets = (startingAmount - feeAmount) / close assets := newAssets entryPrice := close totalFee := feeAmount if math.floor((time - startDate) / 1000 / 60 / 60 / 24) % frequency == 0 and (timeframe.isdwm or (timeframe.isintraday and hour(time) == 12 and minute(time) == 0)) totalTrades := totalTrades + 1 feeAmount := investmentAmount * feeRatio invested := invested + investmentAmount newAssets = (investmentAmount - feeAmount) / close entryPrice := (entryPrice * assets + (investmentAmount - feeAmount)) / (assets + newAssets) assets := assets + newAssets totalFee := totalFee + feeAmount netProfit := close * assets - entryPrice * assets portfolioValue := entryPrice * assets + netProfit table.cell_set_text(info, 0, 0, str.tostring(math.round(invested, 2)) + " invested") table.cell_set_text(info, 0, 1, str.tostring(math.round(netProfit, 2)) + " (" + str.tostring(math.round(netProfit * 100 / invested, 2)) + "%) PnL") table.cell_set_text(info, 0, 2, "-" + str.tostring(math.round(totalFee, 2)) + " (-" + str.tostring(math.round(totalFee * 100 / invested, 3)) + "%) fees") table.cell_set_text(info, 0, 3, str.tostring(math.round(portfolioValue, 2)) + " total") table.cell_set_text(info, 0, 4, str.tostring(math.round(assets, 8)) + " shares") table.cell_set_text(info, 0, 5, str.tostring(math.round_to_mintick(entryPrice)) + " / share") table.cell_set_text(info, 0, 6, str.tostring(totalTrades) + " trades") plot(investmentWindow ? portfolioValue : na, "Portfolio Value", color.yellow) plot(investmentWindow ? invested : na, "Invested Amount", color.lime, 2)
90 Minute Cycles + MTF
https://www.tradingview.com/script/Xm0okM5F-90-Minute-Cycles-MTF/
HandlesHandled
https://www.tradingview.com/u/HandlesHandled/
420
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/ // © HandlesHandled //@version=5 indicator("90min Cycles" , overlay = true , max_bars_back = 500 , max_lines_count = 500 , max_boxes_count = 500 , max_labels_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ ///Session A show_sesa = input(true, '', inline='sesa', group='Session A') sesa_txt = input('Asian A', '', inline='sesa', group='Session A') sesa_ses = input.session('1800-1930', '', inline='sesa', group='Session A') sesa_css = input.color(#2962ff, '', inline='sesa', group='Session A') sesa_range = input(true, 'Range', inline='sesa_overlays', group='Session A') ///Session B show_sesb = input(true, '', inline='sesb', group='Session B') sesb_txt = input('Asian M', '', inline='sesb', group='Session B') sesb_ses = input.session('1930-2100', '', inline='sesb', group='Session B') sesb_css = input.color(#f23645, '', inline='sesb', group='Session B') sesb_range = input(true, 'Range', inline='sesb_overlays', group='Session B') ///Session C show_sesc = input(true, '', inline='sesc', group='Session C') sesc_txt = input('Asian D', '', inline='sesc', group='Session C') sesc_ses = input.session('2100-2230', '', inline='sesc', group='Session C') sesc_css = input.color(#4caf50, '', inline='sesc', group='Session C') sesc_range = input(true, 'Range', inline='sesc_overlays', group='Session C') ///Session D show_sesd = input(true, '', inline='sesd', group='Session D') sesd_txt = input('Asian R', '', inline='sesd', group='Session D') sesd_ses = input.session('2230-0000', '', inline='sesd', group='Session D') sesd_css = input.color(#b2b5be, '', inline='sesd', group='Session D') sesd_range = input(true, 'Range', inline='sesd_overlays', group='Session D') ///Session E show_sese = input(true, '', inline='sese', group='Session E') sese_txt = input('London A', '', inline='sese', group='Session E') sese_ses = input.session('0000-0130', '', inline='sese', group='Session E') sese_css = input.color(#2962ff, '', inline='sese', group='Session E') sese_range = input(true, 'Range', inline='sese_overlays', group='Session E') ///Session F show_sesf = input(true, '', inline='sesf', group='Session F') sesf_txt = input('London M', '', inline='sesf', group='Session F') sesf_ses = input.session('0130-0300', '', inline='sesf', group='Session F') sesf_css = input.color(#f23645, '', inline='sesf', group='Session F') sesf_range = input(true, 'Range', inline='sesf_overlays', group='Session F') ///Session G show_sesg = input(true, '', inline='sesg', group='Session G') sesg_txt = input('London D', '', inline='sesg', group='Session G') sesg_ses = input.session('0300-0430', '', inline='sesg', group='Session G') sesg_css = input.color(#4caf50, '', inline='sesg', group='Session G') sesg_range = input(true, 'Range', inline='sesg_overlays', group='Session G') ///Session H show_sesh = input(true, '', inline='sesh', group='Session H') sesh_txt = input('London R', '', inline='sesh', group='Session H') sesh_ses = input.session('0430-0600', '', inline='sesh', group='Session H') sesh_css = input.color(#b2b5be, '', inline='sesh', group='Session H') sesh_range = input(true, 'Range', inline='sesh_overlays', group='Session H') ///Session I show_sesi = input(true, '', inline='sesi', group='Session I') sesi_txt = input('NY A', '', inline='sesi', group='Session I') sesi_ses = input.session('0600-0730', '', inline='sesi', group='Session I') sesi_css = input.color(#2962ff, '', inline='sesi', group='Session I') sesi_range = input(true, 'Range', inline='sesi_overlays', group='Session I') ///Session J show_sesj = input(true, '', inline='sesj', group='Session J') sesj_txt = input('NY M', '', inline='sesj', group='Session J') sesj_ses = input.session('0730-0900', '', inline='sesj', group='Session J') sesj_css = input.color(#f23645, '', inline='sesj', group='Session J') sesj_range = input(true, 'Range', inline='sesj_overlays', group='Session J') ///Session K show_sesk = input(true, '', inline='sesk', group='Session K') sesk_txt = input('NY D', '', inline='sesk', group='Session K') sesk_ses = input.session('0900-1030', '', inline='sesk', group='Session K') sesk_css = input.color(#4caf50, '', inline='sesk', group='Session K') sesk_range = input(true, 'Range', inline='sesk_overlays', group='Session K') ///Session L show_sesl = input(true, '', inline='sesl', group='Session L') sesl_txt = input('NY R', '', inline='sesl', group='Session L') sesl_ses = input.session('1030-1200', '', inline='sesl', group='Session L') sesl_css = input.color(#b2b5be, '', inline='sesl', group='Session L') sesl_range = input(true, 'Range', inline='sesl_overlays', group='Session L') ///Session M show_sesm = input(true, '', inline='sesm', group='Session M') sesm_txt = input('PM A', '', inline='sesm', group='Session M') sesm_ses = input.session('1200-1330', '', inline='sesm', group='Session M') sesm_css = input.color(#2962ff, '', inline='sesm', group='Session M') sesm_range = input(true, 'Range', inline='sesm_overlays', group='Session M') ///Session N show_sesn = input(true, '', inline='sesn', group='Session N') sesn_txt = input('PM M', '', inline='sesn', group='Session N') sesn_ses = input.session('1330-1500', '', inline='sesn', group='Session N') sesn_css = input.color(#f23645, '', inline='sesn', group='Session N') sesn_range = input(true, 'Range', inline='sesn_overlays', group='Session N') ///Session O show_seso = input(true, '', inline='seso', group='Session O') seso_txt = input('PM D', '', inline='seso', group='Session O') seso_ses = input.session('1500-1630', '', inline='seso', group='Session O') seso_css = input.color(#4caf50, '', inline='seso', group='Session O') seso_range = input(true, 'Range', inline='seso_overlays', group='Session O') ///Session P show_sesp = input(true, '', inline='sesp', group='Session P') sesp_txt = input('PM R', '', inline='sesp', group='Session P') sesp_ses = input.session('1630-1800', '', inline='sesp', group='Session P') sesp_css = input.color(#b2b5be, '', inline='sesp', group='Session P') sesp_range = input(true, 'Range', inline='sesp_overlays', group='Session P') ///Session Q show_sesq = input(true, '', inline='sesq', group='Session Q') sesq_txt = input('Daily A', '', inline='sesq', group='Session Q') sesq_ses = input.session('1800-0000', '', inline='sesq', group='Session Q') sesq_css = input.color(#b2b5be, '', inline='sesq', group='Session Q') sesq_range = input(true, 'Range', inline='sesq_overlays', group='Session Q') ///Session R show_sesr = input(true, '', inline='sesr', group='Session R') sesr_txt = input('Daily M', '', inline='sesr', group='Session R') sesr_ses = input.session('0000-0600', '', inline='sesr', group='Session R') sesr_css = input.color(#b2b5be, '', inline='sesr', group='Session R') sesr_range = input(true, 'Range', inline='sesr_overlays', group='Session R') ///Session S show_sess = input(true, '', inline='sess', group='Session S') sess_txt = input('Daily D', '', inline='sess', group='Session S') sess_ses = input.session('0600-1200', '', inline='sess', group='Session S') sess_css = input.color(#b2b5be, '', inline='sess', group='Session S') sess_range = input(true, 'Range', inline='sess_overlays', group='Session S') ///Session T show_sest = input(true, '', inline='sest', group='Session T') sest_txt = input('Daily R', '', inline='sest', group='Session T') sest_ses = input.session('1200-1800', '', inline='sest', group='Session T') sest_css = input.color(#b2b5be, '', inline='sest', group='Session T') sest_range = input(true, 'Range', inline='sest_overlays', group='Session T') //Timezones tz_incr = input.int(-4, 'UTC (+/-)' , group = 'Timezone') use_exchange = input(false, 'Use Exchange Timezone' , group = 'Timezone') //Ranges Options bg_transp = input.float(90, 'Range Area Transparency' , group = 'Ranges Settings') show_outline = input(true, 'Range Outline' , group = 'Ranges Settings') show_txt = input(true, 'Range Label' , group = 'Ranges Settings') //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ n = bar_index //Set session range get_range(session, session_name, session_css)=> var t = 0 var max = high var min = low var box bx = na var label lbl = na if session > session[1] t := time max := high min := low bx := box.new(n, max, n, min , bgcolor = color.new(session_css, bg_transp) , border_color = show_outline ? session_css : na , border_style = line.style_dotted) if show_txt lbl := label.new(t, max, session_name , xloc = xloc.bar_time , textcolor = session_css , style = label.style_label_down , color = color.new(color.white, 100) , size = size.tiny) if session and session == session[1] max := math.max(high, max) min := math.min(low, min) box.set_top(bx, max) box.set_rightbottom(bx, n, min) if show_txt label.set_xy(lbl, int(math.avg(t, time)), max) //-----------------------------------------------------------------------------} //Sessions //-----------------------------------------------------------------------------{ tf = timeframe.period var tz = use_exchange ? syminfo.timezone : str.format('UTC{0}{1}', tz_incr >= 0 ? '+' : '-', math.abs(tz_incr)) is_sesa = math.sign(nz(time(tf, sesa_ses, tz))) is_sesb = math.sign(nz(time(tf, sesb_ses, tz))) is_sesc = math.sign(nz(time(tf, sesc_ses, tz))) is_sesd = math.sign(nz(time(tf, sesd_ses, tz))) is_sese = math.sign(nz(time(tf, sese_ses, tz))) is_sesf = math.sign(nz(time(tf, sesf_ses, tz))) is_sesg = math.sign(nz(time(tf, sesg_ses, tz))) is_sesh = math.sign(nz(time(tf, sesh_ses, tz))) is_sesi = math.sign(nz(time(tf, sesi_ses, tz))) is_sesj = math.sign(nz(time(tf, sesj_ses, tz))) is_sesk = math.sign(nz(time(tf, sesk_ses, tz))) is_sesl = math.sign(nz(time(tf, sesl_ses, tz))) is_sesm = math.sign(nz(time(tf, sesm_ses, tz))) is_sesn = math.sign(nz(time(tf, sesn_ses, tz))) is_seso = math.sign(nz(time(tf, seso_ses, tz))) is_sesp = math.sign(nz(time(tf, sesp_ses, tz))) is_sesq = math.sign(nz(time(tf, sesq_ses, tz))) is_sesr = math.sign(nz(time(tf, sesr_ses, tz))) is_sess = math.sign(nz(time(tf, sess_ses, tz))) is_sest = math.sign(nz(time(tf, sest_ses, tz))) //-----------------------------------------------------------------------------} //Overlays //-----------------------------------------------------------------------------{ //Ranges if show_sesa and sesa_range get_range(is_sesa, sesa_txt, sesa_css) if show_sesb and sesb_range get_range(is_sesb, sesb_txt, sesb_css) if show_sesc and sesc_range get_range(is_sesc, sesc_txt, sesc_css) if show_sesd and sesd_range get_range(is_sesd, sesd_txt, sesd_css) if show_sese and sese_range get_range(is_sese, sese_txt, sese_css) if show_sesf and sesf_range get_range(is_sesf, sesf_txt, sesf_css) if show_sesg and sesg_range get_range(is_sesg, sesg_txt, sesg_css) if show_sesh and sesh_range get_range(is_sesh, sesh_txt, sesh_css) if show_sesi and sesi_range get_range(is_sesi, sesi_txt, sesi_css) if show_sesj and sesj_range get_range(is_sesj, sesj_txt, sesj_css) if show_sesk and sesk_range get_range(is_sesk, sesk_txt, sesk_css) if show_sesl and sesl_range get_range(is_sesl, sesl_txt, sesl_css) if show_sesm and sesm_range get_range(is_sesm, sesm_txt, sesm_css) if show_sesn and sesn_range get_range(is_sesn, sesn_txt, sesn_css) if show_seso and seso_range get_range(is_seso, seso_txt, seso_css) if show_sesp and sesp_range get_range(is_sesp, sesp_txt, sesp_css) if show_sesq and sesq_range get_range(is_sesq, sesq_txt, sesq_css) if show_sesr and sesr_range get_range(is_sesr, sesr_txt, sesr_css) if show_sess and sess_range get_range(is_sess, sess_txt, sess_css) if show_sest and sest_range get_range(is_sest, sest_txt, sest_css)
90cycle @joshuuu
https://www.tradingview.com/script/9SLWvcoc-90cycle-joshuuu/
joshuuu
https://www.tradingview.com/u/joshuuu/
398
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/ // © joshuuu //@version=5 indicator("90cycle @joshuuu", overlay = true) asia = input.bool(true, "asia") lokz = input.bool(true, "lokz") nyam = input.bool(true, "nyam") nypm = input.bool(true, "nypm") version = input.string("CLS", options = ["Daye", "CLS"]) var line open_line = na open_line_color = color.new(color.orange,69) line_color = color.new(color.gray,69) if version == "Daye" if asia if hour(time, timezone = "America/New_York") == 18 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 19 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 21 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 22 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if asia or lokz if hour(time, timezone = "America/New_York") == 00 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if lokz if hour(time, timezone = "America/New_York") == 1 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) open_line := line.new(bar_index, open, bar_index+1,open, color = open_line_color) else if hour(time, timezone = "America/New_York") == 3 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 4 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else line.set_x2(open_line, bar_index) if lokz or nyam if hour(time, timezone = "America/New_York") == 6 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if nyam if hour(time, timezone = "America/New_York") == 7 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) open_line := line.new(bar_index, open, bar_index+1,open, color = open_line_color) else if hour(time, timezone = "America/New_York") == 9 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 10 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else line.set_x2(open_line, bar_index) if nyam or nypm if hour(time, timezone = "America/New_York") == 12 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if nypm if hour(time, timezone = "America/New_York") == 13 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) open_line := line.new(bar_index, open, bar_index+1,open, color = open_line_color) else if hour(time, timezone = "America/New_York") == 15 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 16 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 18 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else line.set_x2(open_line, bar_index) else if version == "CLS" if lokz if hour(time, timezone = "America/New_York") == 2 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 4 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 5 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if lokz or nyam if hour(time, timezone = "America/New_York") == 7 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) if nyam if hour(time, timezone = "America/New_York") == 8 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 10 and minute(time, timezone = "America/New_York") == 00 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) else if hour(time, timezone = "America/New_York") == 11 and minute(time, timezone = "America/New_York") == 30 line.new(bar_index, high, bar_index, low, extend = extend.both, color = line_color) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 18 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q1", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 19 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q2", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 21 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q3", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 22 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q4", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 00 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q1", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 01 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q2", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 03 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q3", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 04 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q4", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 06 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q1", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 07 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q2", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 09 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q3", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 10 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q4", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 12 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q1", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 13 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q2", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 15 and minute(time[1], timezone = "America/New_York") == 00, location = location.bottom, color = color.gray, text = "q3", char = "", size = size.tiny) plotchar(version == "Daye" and timeframe.in_seconds() < timeframe.in_seconds("60") and hour(time, timezone = "America/New_York") == 16 and minute(time[1], timezone = "America/New_York") == 30, location = location.bottom, color = color.gray, text = "q4", char = "", size = size.tiny)
Swing Volume Profiles [LuxAlgo]
https://www.tradingview.com/script/Ai8Heos2-Swing-Volume-Profiles-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
3,178
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("Swing Volume Profiles [LuxAlgo]", "LuxAlgo - Swing Volume Profiles", true, max_bars_back = 5000, max_boxes_count = 500, max_labels_count = 500, max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ mode = input.string('Present', title = 'Mode', options =['Present', 'Historical'], inline = 'MOD') back = input.int (300, '    # Bars', minval = 100, maxval = 5000, step = 10, inline = 'MOD') grpVP = 'Swing Volume Profiles' ppTT = 'The Swing High Low indicator is used to determine and anticipate potential changes in market price and reversals\n' + '\'Swing Volume Profiles [LuxAlgo]\' aims at highliting the trading activity at specified price levels between two Swing Levels' ppLen = input.int(47, "Swing Detection Length", minval = 1, group = grpVP, tooltip = ppTT) vpTT = 'Common Interest Profile (Total Volume) - displays total trading activity over a specified time period at specific price levels' vpShw = input.bool(true, 'Swing Volume Profiles', inline = 'BB3', group = grpVP, tooltip = vpTT) vpTVC = input.color(color.new(#fbc02d, 65), '', inline = 'BB3', group = grpVP) vpVVC = input.color(color.new(#434651, 65), '', inline = 'BB3', group = grpVP) vpB = input.bool(false, 'Profile Range Background Fill', inline ='BG', group = grpVP) vpBC = input.color(color.new(#2962ff, 95), '', inline ='BG', group = grpVP) grpPC = 'Point of Control (POC)' pcTT = 'Point of Control (POC) - The price level for the time period with the highest traded volume' pcShw = input.bool(true, 'Point of Control (PoC)', inline = 'PoC', group = grpPC, tooltip = pcTT) pcC = input.color(color.new(#ff0000, 0), '', inline = 'PoC', group = grpPC) dpTT = 'Developing Point of Control, displays how POC is changing during the active market session' dpcS = input.bool(true, 'Developing PoC    ', inline = 'dPoC', group = grpPC, tooltip = dpTT) dpcC = input.color(color.new(#ff0000, 0), '', inline = 'dPoC', group = grpPC) pcE = input.string('None', 'Extend PoC', options=['Until Last Bar', 'Until Bar Cross', 'Until Bar Touch', 'None'], group = grpPC) grpVA = 'Value Area (VA)' vaTT = 'Value Area (VA) – The range of price levels in which a specified percentage of all volume was traded during the time period' isVA = input.float(68, "Value Area Volume %", minval = 0, maxval = 100, group = grpVA, tooltip = vaTT) / 100 vhTT = 'Value Area High (VAH) - The highest price level within the value area' vhShw = input.bool(true, 'Value Area High (VAH)', inline = 'VAH', group = grpVA, tooltip = vhTT) vaHC = input.color(color.new(#2962ff, 0), '', inline = 'VAH', group = grpVA) vlTT = 'Value Area Low (VAL) - The lowest price level within the value area' vlShw = input.bool(true, 'Value Area Low (VAL) ', inline = 'VAL', group = grpVA, tooltip = vlTT) vaLC = input.color(color.new(#2962ff, 0), '', inline = 'VAL', group = grpVA) vaB = input.bool(false, 'Value Area (VA) Background Fill', inline = 'vBG', group = grpVA) vaBC = input.color(color.new(#2962ff, 89), '', inline = 'vBG', group = grpVA) grpLQ = 'Liquidity Levels / Voids' liqUF = input(true, 'Unfilled Liquidity, Thresh', inline = 'UFL', group = grpLQ) liqT = input(21, '', inline = 'UFL', group = grpLQ) / 100 liqC = input.color(color.new(#00bcd4, 90), '', inline = 'UFL', group = grpLQ) grpLB = 'Profile Stats' ppLev = input.string('Swing High/Low', 'Position', options = ['Swing High/Low', 'Profile High/Low', 'Value Area High/Low'], inline='ppLS' , group = grpLB) ppLS = input.string('Small', "Size", options=['Tiny', 'Small', 'Normal'], inline='ppLS', group = grpLB) ppS = switch ppLS 'Tiny' => size.tiny 'Small' => size.small 'Normal' => size.normal ppP = input(false, "Price", inline = 'Levels', group = grpLB) ppC = input(false, "Price Change", inline = 'Levels', group = grpLB) ppV = input(false, "Cumulative Volume", inline = 'Levels', group = grpLB) grpOT = 'Volume Profile Others' vpLev = input.int(27, 'Number of Rows' , minval = 10, maxval = 100 , step = 1, group = grpOT) vpPlc = input.string('Left', 'Placment', options = ['Right', 'Left'], group = grpOT) vpWth = input.int(50, 'Profile Width %', minval = 0, maxval = 100, group = grpOT) / 100 //-----------------------------------------------------------------------------} //User Defined Types //-----------------------------------------------------------------------------{ // @type bar properties with their values // // @field h (float) high price of the bar // @field l (float) low price of the bar // @field v (float) volume of the bar // @field i (int) index of the bar type bar float h = high float l = low float v = volume int i = bar_index // @type store pivot high/low and index data // // @field x (int) last pivot bar index // @field x1 (int) previous pivot bar index // @field h (float) last pivot high // @field l (float) last pivot low // @field s (string) last pivot as 'L' or 'H' type pivotPoint int x int x1 float h float l string s // @type maintain liquidity data // // @field b (array<bool>) array maintains price levels where liquidity exists // @field bx (array<box>) array maintains visual object of price levels where liquidity exists type liquidity bool [] b box [] bx // @type maintain volume profile data // // @field vs (array<float>) array maintains tolal traded volume // @field vp (array<box>) array maintains visual object of each price level type volumeProfile float [] vs box [] vp //-----------------------------------------------------------------------------} //Variables //-----------------------------------------------------------------------------{ var aPOC = array.new_box() var dPOC = array.new_line() var dPCa = array.new_line() var laP = 0, var lbP = 0, var dpcL = 0, var float ersten = na bar b = bar.new() var pivotPoint pp = pivotPoint.new() var liquidity[] aLIQ = array.new<liquidity> (1, liquidity.new(array.new <bool> (vpLev, false), array.new <box> (na))) var liquidity[] dLIQ = array.new<liquidity> (1, liquidity.new(array.new <bool> (na) , array.new <box> (na))) volumeProfile aVP = volumeProfile.new(array.new <float> (vpLev + 1, 0.), array.new <box> (na)) volumeProfile aVPa = volumeProfile.new(array.new <float> (vpLev + 1, 0.), array.new <box> (na)) var volumeProfile dVP = volumeProfile.new(array.new <float> (na) , array.new <box> (na)) //-----------------------------------------------------------------------------} //Functions/methods //-----------------------------------------------------------------------------{ // @function calcuates highest, lowest price value and cumulative volume of the given range // // @param _l (int) length of the range // @param _c (bool) check // @param _o (int) offset // // @returns (float, float, float) highest, lowest and cumulative volume f_calcHL(_l, _c, _o) => if _c l = low [_o] h = high[_o] v = 0. for x = 0 to _l - 1 l := math.min(low [_o + x], l) h := math.max(high[_o + x], h) v += volume[_o + x] l := math.min(low [_o + _l], l) h := math.max(high[_o + _l], h) [h, l, v] // @function check bar breaches // // @param _a (array<box>) array containg the boxes to be checked // @param _e (strings) extend statment : 'Until Last Bar', 'Until Bar Cross', 'Until Bar Touch' and 'None' // // @returns none, updated visual objects (boxes) f_checkBreaches(_a, _e) => int qBX = array.size(_a) for no = 0 to (qBX > 0 ? qBX - 1 : na) if no < array.size(_a) cBX = array.get(_a, no) mBX = math.avg(box.get_bottom(cBX), box.get_top(cBX)) ced = math.sign(close[1] - mBX) != math.sign(close - mBX) ted = math.sign(close[1] - mBX) != math.sign(low - mBX) or math.sign(close[1] - mBX) != math.sign(high - mBX) if ced and _e == 'Until Bar Cross' array.remove(_a, no) int(na) else if ted and _e == 'Until Bar Touch' array.remove(_a, no) int(na) else box.set_right(cBX, bar_index) int(na) // @function creates new line object, updates existing line objects // // @param details in Pine Script™ language reference manual // // @returns id of the line f_drawLineX(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) => var id = line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) line.set_xy1(id, _x1, _y1) line.set_xy2(id, _x2, _y2) line.set_color(id, _color) id // @function creates new label object, updates existing label objects // // @param details in Pine Script™ language reference manual // // @returns none f_drawLabelX(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) => var id = label.new(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) label.set_xy(id, _x, _y) label.set_text(id, _text) label.set_tooltip(id, _tooltip) //-----------------------------------------------------------------------------} //Calculations //-----------------------------------------------------------------------------{ per = mode == 'Present' ? last_bar_index - b.i <= back : true nzV = nz(b.v) pp_h = ta.pivothigh(ppLen, ppLen) pp_l = ta.pivotlow (ppLen, ppLen) if not na(pp_h) pp.h := pp_h pp.s := 'H' if not na(pp_l) pp.l := pp_l pp.s := 'L' go = not na(pp_h) or not na(pp_l) if go pp.x1 := pp.x pp.x := b.i vpLen = pp.x - pp.x1 [pHst, pLst, tV] = f_calcHL(vpLen, go, ppLen) pStp = (pHst - pLst) / vpLev [pHta, pLta, _] = f_calcHL(ppLen, go, 0) pSpa = (pHta - pLta) / vpLev if go and nzV and pStp > 0 and b.i > vpLen and vpLen > 0 and per if dPCa.size() > 0 for i = 0 to dPCa.size() - 1 dPCa.shift().delete() for bIt = 1 to vpLen l = 0 bI = bIt + ppLen for pLev = pLst to pHst by pStp if b.h[bI] >= pLev and b.l[bI] < pLev + pStp aVP.vs.set(l, aVP.vs.get(l) + nzV[bI] * ((b.h[bI] - b.l[bI]) == 0 ? 1 : pStp / (b.h[bI] - b.l[bI]))) l += 1 pcL = aVP.vs.indexof(aVP.vs.max()) ttV = aVP.vs.sum() * isVA va = aVP.vs.get(pcL) laP := pcL lbP := pcL while va < ttV if lbP == 0 and laP == vpLev - 1 break vaP = 0. if laP < vpLev - 1 vaP := aVP.vs.get(laP + 1) vbP = 0. if lbP > 0 vbP := aVP.vs.get(lbP - 1) if vbP == 0 and vaP == 0 break if vaP >= vbP va += vaP laP += 1 else va += vbP lbP -= 1 aLIQ.unshift(liquidity.new(array.new <bool> (vpLev, false), array.new <box> (na))) cLIQ = aLIQ.get(0) for l = vpLev - 1 to 0 if vpShw sbI = vpPlc == 'Right' ? b.i - int(aVP.vs.get(l) / aVP.vs.max() * vpLen * vpWth) : b.i - vpLen ebI = vpPlc == 'Right' ? b.i : sbI + int( aVP.vs.get(l) / aVP.vs.max() * vpLen * vpWth) aVP.vp.push(box.new(sbI - ppLen, pLst + (l + 0.1) * pStp, ebI - ppLen, pLst + (l + 0.9) * pStp, l >= lbP and l <= laP ? vpTVC : vpVVC, bgcolor = l >= lbP and l <= laP ? vpTVC : vpVVC)) if liqUF if aVP.vs.get(l) / aVP.vs.max() < liqT cLIQ.b.set(l, true) cLIQ.bx.unshift(box.new(b.i[ppLen], pLst + (l + 0.00) * pStp, b.i[ppLen], pLst + (l + 1.00) * pStp, border_color = color(na), bgcolor = liqC )) else cLIQ.bx.unshift(box.new(na, na, na, na)) cLIQ.b.set(l, false) for bIt = 0 to vpLen bI = bIt + ppLen int qBX = cLIQ.bx.size() for no = 0 to (qBX > 0 ? qBX - 1 : na) if no < cLIQ.bx.size() if cLIQ.b.get(no) cBX = cLIQ.bx.get(no) mBX = math.avg(cBX.get_bottom(), cBX.get_top()) if math.sign(close[bI + 1] - mBX) != math.sign(low[bI] - mBX) or math.sign(close[bI + 1] - mBX) != math.sign(high[bI] - mBX) or math.sign(close[bI + 1] - mBX) != math.sign(close[bI] - mBX) cBX.set_left(b.i[bI]) cLIQ.b.set(no, false) for bI = ppLen to 0 int qBX = cLIQ.bx.size() for no = (qBX > 0 ? qBX - 1 : na) to 0 if no < cLIQ.bx.size() cBX = cLIQ.bx.get(no) mBX = math.avg(box.get_bottom(cBX), box.get_top(cBX)) if math.sign(close[bI + 1] - mBX) != math.sign(low[bI] - mBX) or math.sign(close[bI + 1] - mBX) != math.sign(high[bI] - mBX) cBX.delete() cLIQ.bx.remove(no) else cBX.set_right(b.i[bI]) if dpcS l = 0 for pLev = pLta to pHta by pSpa if b.h[bI] >= pLev and b.l[bI] < pLev + pSpa aVPa.vs.set(l, aVPa.vs.get(l) + nzV[bI] * ((b.h[bI] - b.l[bI]) == 0 ? 1 : pSpa / (b.h[bI] - b.l[bI]))) l += 1 if bI == ppLen ersten := math.avg(b.h[ppLen], b.l[ppLen])//pLta + (aVPa.vs.indexof(aVPa.vs.max()) + .50) * pSpa else dPCa.push(line.new(b.i[bI] - 1, ersten, b.i[bI], pLta + (aVPa.vs.indexof(aVPa.vs.max()) + .50) * pSpa, color = dpcC, width = 2)) ersten := pLta + (aVPa.vs.indexof(aVPa.vs.max()) + .50) * pSpa if vpB aVP.vp.push(box.new(b.i[ppLen] - vpLen, pHst, b.i[ppLen], pLst, vpBC, border_style = line.style_dotted, bgcolor = vpBC)) if pcShw aPOC.push(box.new(b.i[ppLen] - vpLen, pLst + (pcL + .40) * pStp, b.i[ppLen], pLst + (pcL + .60) * pStp, pcC, bgcolor = pcC )) vah = line.new(b.i[ppLen] - vpLen, pLst + (laP + 1.00) * pStp, b.i[ppLen], pLst + (laP + 1.00) * pStp, xloc.bar_index, extend.none, vhShw ? vaHC : #00000000, line.style_solid, 2) val = line.new(b.i[ppLen] - vpLen, pLst + (lbP + 0.00) * pStp, b.i[ppLen], pLst + (lbP + 0.00) * pStp, xloc.bar_index, extend.none, vlShw ? vaLC : #00000000, line.style_solid, 2) if vaB linefill.new(vah, val, vaBC) statTip = '\n -Traded Volume : ' + str.tostring(tV, format.volume) + ' (' + str.tostring(vpLen - 1) + ' bars)' + '\n *Average Volume/Bar : ' + str.tostring(tV / (vpLen - 1), format.volume) + '\n\nProfile High : ' + str.tostring(pHst, format.mintick) + ' ↑ %' + str.tostring((pHst - pLst) / pLst * 100, '#.##') + '\nProfile Low : ' + str.tostring(pLst, format.mintick) + ' ↓ %' + str.tostring((pHst - pLst) / pHst * 100, '#.##') + '\n -Point Of Control : ' + str.tostring(pLst + (pcL + .50) * pStp, format.mintick) + '\n\nValue Area High : ' + str.tostring(pLst + (laP + 1.00) * pStp, format.mintick) + '\nValue Area Low : ' + str.tostring(pLst + (lbP + 0.00) * pStp, format.mintick) + '\n -Value Area Width : %' + str.tostring(((pLst + (laP + 1.00) * pStp) - (pLst + (lbP + 0.00) * pStp)) / (pHst - pLst) * 100, '#.##') + '\n\nNumber of Bars (Profile) : ' + str.tostring(vpLen) if ppLev != 'Swing High/Low' uPl = ppLev == 'Value Area High/Low' ? pLst + (laP + 1.00) * pStp : pHst lPl = ppLev == 'Value Area High/Low' ? pLst + (lbP + 0.00) * pStp : pLst uTx = (ppP ? str.tostring(uPl, format.mintick) : '') + (not na(pp_h) ? (ppC ? (ppP ? ' ↑ %' : '↑ %') + str.tostring((pp.h - pp.l) * 100 / pp.l, '#.##') : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tV, format.volume) : '') : '') lTx = (ppP ? str.tostring(lPl, format.mintick) : '') + (not na(pp_l) ? (ppC ? (ppP ? ' ↓ %' : '↓ %') + str.tostring((pp.h - pp.l) * 100 / pp.h, '#.##') : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tV, format.volume) : '') : '') label.new(b.i[ppLen] - vpLen / 2, uPl, uTx, xloc.bar_index, yloc.price, #00000000, label.style_label_down, chart.fg_color, ppS, text.align_center, ' Profile High : ' + str.tostring(pHst, format.mintick) + '\n %' + str.tostring((pHst - pLst) / pLst * 100, '#.##') + ' higher than the Profile Low' + statTip) label.new(b.i[ppLen] - vpLen / 2, lPl, lTx, xloc.bar_index, yloc.price, #00000000, label.style_label_up , chart.fg_color, ppS, text.align_center, ' Profile Low : ' + str.tostring(pLst, format.mintick) + '\n %' + str.tostring((pHst - pLst) / pHst * 100, '#.##') + ' lower than the Profile High' + statTip) else if not na(pp_h) label.new(b.i[ppLen], pp.h, (ppP ? str.tostring(pp.h, format.mintick) : '') + (ppC ? (ppP ? ' ↑ %' : '↑ %') + str.tostring((pp.h - pp.l) * 100 / pp.l, '#.##') : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tV, format.volume) : ''), xloc.bar_index, yloc.price, (not ppP and not ppC and not ppV ? chart.fg_color : #00000000), label.style_label_down, chart.fg_color, (not ppP and not ppC and not ppV ? size.tiny : ppS), text.align_center, 'Swing High : ' + str.tostring(pp.h, format.mintick) + '\n -Price Change : %' + str.tostring((pp.h - pp.l) * 100 / pp.l, '#.##') + statTip) if not na(pp_l) label.new(b.i[ppLen], pp.l ,(ppP ? str.tostring(pp.l, format.mintick) : '') + (ppC ? (ppP ? ' ↓ %' : '↓ %') + str.tostring((pp.h - pp.l) * 100 / pp.h, '#.##') : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tV, format.volume) : ''), xloc.bar_index, yloc.price, (not ppP and not ppC and not ppV ? chart.fg_color : #00000000), label.style_label_up , chart.fg_color, (not ppP and not ppC and not ppV ? size.tiny : ppS), text.align_center, 'Swing Low : ' + str.tostring(pp.l, format.mintick) + '\n -Price Change : %' + str.tostring((pp.h - pp.l) * 100 / pp.h, '#.##') + statTip) if pcShw and pcE != 'None' f_checkBreaches(aPOC, pcE) for i = 0 to aLIQ.size() - 1 x = aLIQ.get(i) int qBX = x.bx.size() for no = (qBX > 0 ? qBX - 1 : na) to 0 if no < x.bx.size() cBX = x.bx.get(no) mBX = math.avg(box.get_bottom(cBX), box.get_top(cBX)) if math.sign(close[1] - mBX) != math.sign(low - mBX) or math.sign(close[1] - mBX) != math.sign(high - mBX) cBX.delete() x.bx.remove(no) else cBX.set_right(b.i) vpLen := barstate.islast ? last_bar_index - pp.x + ppLen : 1 pHst := ta.highest(b.h, vpLen > 0 ? vpLen + 1 : 1) pLst := ta.lowest (b.l, vpLen > 0 ? vpLen + 1 : 1) pStp := (pHst - pLst) / vpLev [_, _, tVd] = f_calcHL(vpLen, true, 0) if barstate.islast and nzV and vpLen > 0 and pStp > 0 if dVP.vp.size() > 0 for i = 0 to dVP.vp.size() - 1 dVP.vp.shift().delete() if dPOC.size() > 0 for i = 0 to dPOC.size() - 1 dPOC.shift().delete() tLIQ = dLIQ.shift() if tLIQ.bx.size() > 0 for i = 0 to tLIQ.bx.size() - 1 tLIQ.bx.shift().delete() tLIQ.b.shift() for bI = vpLen to 1 //1 to vpLen l = 0 for pLev = pLst to pHst by pStp if b.h[bI] >= pLev and b.l[bI] < pLev + pStp aVP.vs.set(l, aVP.vs.get(l) + nzV[bI] * ((b.h[bI] - b.l[bI]) == 0 ? 1 : pStp / (b.h[bI] - b.l[bI]))) l += 1 if dpcS if bI == last_bar_index - pp.x if dPCa.size() > 0 dPOC.push(line.new(b.i[bI], dPCa.get(dPCa.size() - 1).get_y2(), b.i[bI] + 1, pLst + (aVP.vs.indexof(aVP.vs.max()) + .50) * pStp, color = dpcC, width = 2)) else if bI < last_bar_index - pp.x if dPOC.size() > 0 dPOC.push(line.new(b.i[bI], dPOC.get(dPOC.size() - 1).get_y2(), b.i[bI] + 1, pLst + (aVP.vs.indexof(aVP.vs.max()) + .50) * pStp, color = dpcC, width = 2)) dpcL := aVP.vs.indexof(aVP.vs.max()) ttV = aVP.vs.sum() * isVA va = aVP.vs.get(dpcL) laP := dpcL lbP := dpcL while va < ttV if lbP == 0 and laP == vpLev - 1 break vaP = 0. if laP < vpLev - 1 vaP := aVP.vs.get(laP + 1) vbP = 0. if lbP > 0 vbP := aVP.vs.get(lbP - 1) if vbP == 0 and vaP == 0 break if vaP >= vbP va += vaP laP += 1 else va += vbP lbP -= 1 dLIQ.unshift(liquidity.new(array.new <bool> (na), array.new <box> (na))) cLIQ = dLIQ.get(0) for l = 0 to vpLev - 1 if vpShw sbI = vpPlc == 'Right' ? b.i - int(aVP.vs.get(l) / aVP.vs.max() * vpLen * vpWth) : b.i - vpLen ebI = vpPlc == 'Right' ? b.i : sbI + int( aVP.vs.get(l) / aVP.vs.max() * vpLen * vpWth) dVP.vp.push(box.new(sbI, pLst + (l + 0.1) * pStp, ebI, pLst + (l + 0.9) * pStp, l >= lbP and l <= laP ? vpTVC : vpVVC, bgcolor = l >= lbP and l <= laP ? vpTVC : vpVVC)) if liqUF if aVP.vs.get(l) / aVP.vs.max() < liqT cLIQ.b.unshift(true) cLIQ.bx.unshift(box.new(b.i, pLst + (l + 0.00) * pStp, b.i, pLst + (l + 1.00) * pStp, border_color = color(na), bgcolor = liqC)) else cLIQ.bx.unshift(box.new(na, na, na, na)) cLIQ.b.unshift(false) for bI = 0 to vpLen int qBX = cLIQ.bx.size() for no = 0 to (qBX > 0 ? qBX - 1 : na) if no < cLIQ.bx.size() if cLIQ.b.get(no) cBX = cLIQ.bx.get(no) mBX = math.avg(cBX.get_bottom(), cBX.get_top()) if math.sign(close[bI + 1] - mBX) != math.sign(low[bI] - mBX) or math.sign(close[bI + 1] - mBX) != math.sign(high[bI] - mBX) or math.sign(close[bI + 1] - mBX) != math.sign(close[bI] - mBX) cBX.set_left(b.i[bI]) cLIQ.b.set(no, false) if vpB dVP.vp.push(box.new(b.i - vpLen, pHst, b.i, pLst, vpBC, bgcolor = vpBC)) if pcShw and not dpcS dVP.vp.push(box.new(b.i - vpLen, pLst + (dpcL + .40) * pStp, b.i, pLst + (dpcL + .60) * pStp, pcC, bgcolor = pcC)) vah = f_drawLineX(b.i - vpLen, pLst + (laP + 1.00) * pStp, b.i, pLst + (laP + 1.00) * pStp, xloc.bar_index, extend.none, vhShw ? vaHC : #00000000, line.style_solid, 2) val = f_drawLineX(b.i - vpLen, pLst + (lbP + 0.00) * pStp, b.i, pLst + (lbP + 0.00) * pStp, xloc.bar_index, extend.none, vlShw ? vaLC : #00000000, line.style_solid, 2) if vaB linefill.new(vah, val, vaBC) if ppLev != 'Swing High/Low' statTip = '\n -Traded Volume : ' + str.tostring(tVd, format.volume) + ' (' + str.tostring(vpLen - 1) + ' bars)' + '\n *Average Volume/Bar : ' + str.tostring(tVd / (vpLen - 1), format.volume) + '\n\nProfile High : ' + str.tostring(pHst, format.mintick) + ' ↑ %' + str.tostring((pHst - pLst) / pLst * 100, '#.##') + '\nProfile Low : ' + str.tostring(pLst, format.mintick) + ' ↓ %' + str.tostring((pHst - pLst) / pHst * 100, '#.##') + '\n -Point Of Control : ' + str.tostring(pLst + (dpcL + 0.50) * pStp, format.mintick) + '\n\nValue Area High : ' + str.tostring(pLst + (laP + 1.00) * pStp, format.mintick) + '\nValue Area Low : ' + str.tostring(pLst + (lbP + 0.00) * pStp, format.mintick) + '\n -Value Area Width : %' + str.tostring(((pLst + (laP + 1.00) * pStp) - (pLst + (lbP + 0.00) * pStp)) / (pHst - pLst) * 100, '#.##') + '\n\nNumber of Bars (Profile) : ' + str.tostring(vpLen) + (ppC ? '\n\n*price change caculated based on last swing high/low and last price' : '') uPl = ppLev == 'Value Area High/Low' ? pLst + (laP + 1.00) * pStp : pHst lPl = ppLev == 'Value Area High/Low' ? pLst + (lbP + 0.00) * pStp : pLst uTx = (ppP ? str.tostring(uPl, format.mintick) : '') + (pp.s == 'L' ? (ppC ? (ppP ? ' ↑ %' : '↑ %') + str.tostring((close - pp.l) * 100 / pp.l, '#.##') + '*' : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tVd, format.volume) : '') : '') lTx = (ppP ? str.tostring(lPl, format.mintick) : '') + (pp.s == 'H' ? (ppC ? (ppP ? ' ↓ %' : '↓ %') + str.tostring((pp.h - close) * 100 / pp.h, '#.##') + '*' : '') + (ppV ? (ppP or ppC ? '\n' : '') + str.tostring(tVd, format.volume) : '') : '') f_drawLabelX(b.i - vpLen / 2, uPl, uTx, xloc.bar_index, yloc.price, #00000000, label.style_label_down, chart.fg_color, ppS, text.align_center, 'Profile High : ' + str.tostring(pHst, format.mintick) + '\n %' + str.tostring((pHst - pLst) / pLst * 100, '#.##') + ' higher than the Profile Low' + statTip) f_drawLabelX(b.i - vpLen / 2, lPl, lTx, xloc.bar_index, yloc.price, #00000000, label.style_label_up , chart.fg_color, ppS, text.align_center, 'Profile Low : ' + str.tostring(pLst, format.mintick) + '\n %' + str.tostring((pHst - pLst) / pHst * 100, '#.##') + ' lower than the Profile High' + statTip) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ priceTxt = str.tostring(close, format.mintick) tickerTxt = syminfo.ticker if ta.cross(close, pLst + (dpcL + 0.50) * pStp) and pcShw alert(tickerTxt + ' : Swings Volume Profile : Price touches/crosses Point Of Control Line, price ' + priceTxt) if ta.cross(close, pLst + (laP + 1.00) * pStp) and vhShw alert(tickerTxt + ' : Swings Volume Profile : Price touches/crosses Value Area High Line, price ' + priceTxt) if ta.cross(close, pLst + (lbP + 0.00) * pStp) and vlShw alert(tickerTxt + ' : Swings Volume Profile : Price touches/crosses Value Area Low Line, price ' + priceTxt) //-----------------------------------------------------------------------------}
Weekly Range Support & Resistance Levels [QuantVue]
https://www.tradingview.com/script/5aTZzreA-Weekly-Range-Support-Resistance-Levels-QuantVue/
QuantVue
https://www.tradingview.com/u/QuantVue/
257
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/ // © QuantVue //@version=5 indicator("Weekly Range Support & Resistance Levels", overlay = true, max_labels_count = 500, max_lines_count = 500) //-----------------------------------------------// //runtime errors //-----------------------------------------------// if timeframe.ismonthly runtime.error('Please switch to lower timeframe') else if (timeframe.in_seconds() / 60 < timeframe.in_seconds('3') / 60) and (syminfo.type == 'stock' or syminfo.type == 'fund' or syminfo.type == 'index') runtime.error('Please switch to 3 minute chart or higher') else if timeframe.in_seconds() / 60 < timeframe.in_seconds('30') / 60 and (syminfo.type == 'crypto' or syminfo.type == 'forex') runtime.error('Please switch to 30 minute time frame or higher') else if timeframe.in_seconds() / 60 < timeframe.in_seconds('15') / 60 and syminfo.type == 'cfd' runtime.error('Please switch to 15 minute time frame or higher') //-----------------------------------------------// //inputs //-----------------------------------------------// showTable = input.bool(true, 'Show Stats on Weekly Chart', inline = '1') yPos = input.string("Top", " ", options = ["Top", "Middle", "Bottom"], inline = '1') xPos = input.string("Right", " ", options = ["Right","Center", "Left"], inline = '1') statsBG = input.color(color.gray, 'Stats Table BG Color', inline = '2') statsText = input.color(color.white, 'Stats Table Text Color', inline = '2') averagingPerdiod = input.int(30, 'Averaging Period', minval = 5, step = 1) multiplier = input.float(1.0, 'StDev Multiplier', minval = .25, maxval = 4, step = .25) sLineColor = input.color(color.green, 'Support Color', inline = '3') rLineColor = input.color(color.red, 'Resistance Color', inline = '3') showFill = input.bool(true, 'Fill', inline = '3') showPrice = input.bool(true, 'Show Support / Resistance Prices', inline = '4') labelTextColor = input.color(color.rgb(255, 255, 255), ' ', inline = '4') showWO = input.bool(true, 'Show Weekly Open Line', inline = '5') wOColor = input.color(color.orange, ' ', inline = '5') r1Style = input.string('Solid', 'R1 Line Style', ['Solid', 'Dashed', 'Dotted'], inline = '6') r2Style = input.string('Solid', 'R2 Line Style', ['Solid', 'Dashed', 'Dotted'], inline = '6') s1Style = input.string('Solid', 'S1 Line Style', ['Solid', 'Dashed', 'Dotted'], inline = '7') s2Style = input.string('Solid', 'S2 Line Style', ['Solid', 'Dashed', 'Dotted'], inline = '7') showPrevious = input.bool(false, 'Show Previous Levls') //-----------------------------------------------// //methods //-----------------------------------------------// method switcher(string this) => switch this 'Solid' => line.style_solid 'Dashed' => line.style_dashed 'Dotted' => line.style_dotted //-----------------------------------------------// //variables //-----------------------------------------------// var table stats = table.new(str.lower(yPos) + '_' + str.lower(xPos), 5, 4, border_color = color.new(color.white,100), border_width = 2, frame_color = color.new(color.white,100), frame_width = 2) var float[] upAvgArray = array.new<float>() var float[] downAvgArray = array.new<float>() var line r1Line = na, var line r2Line = na, var line s1Line = na, var line s2Line = na, var line WO = na var label r1Label = na, var label r2Label = na, var label s1Label = na, var label s2Label = na var box rFill = na, var box sFill = na var weekCount = 0, var closeAboveR1 = 0, var closeAboveR2 = 0, var closeBelowS1 = 0, var closeBelowS2 = 0 var touchR1 = 0, var touchR2 = 0, var touchS1 = 0, var touchS2 = 0 var R1 = 0.0, var R2 = 0.0, var S1 = 0.0, var S2 = 0.0 [weekOpen, weekHigh, weekLow, weekClose] = request.security(syminfo.tickerid, 'W',[open,high,low,close], lookahead = barmerge.lookahead_on) avgPeriod = timeframe.period == 'W' ? 30 : timeframe.period == 'D' ? averagingPerdiod * 5 : timeframe.isminutes ? (58500 / str.tonumber(timeframe.period)) : averagingPerdiod newWeek = ta.change(time('W')) idxCount = ta.barssince(newWeek) //-----------------------------------------------// //calculations //-----------------------------------------------// up = newWeek ? 100 * ((weekHigh - weekOpen) / weekClose) : na down = newWeek ? 100 * math.abs(((weekOpen - weekLow) / weekClose)) : na upStdev = ta.stdev(up, averagingPerdiod) * multiplier upSD = newWeek ? upStdev[1] : na downStdev = ta.stdev(down, averagingPerdiod) * multiplier downSd = newWeek ? downStdev[1] : na if newWeek if upAvgArray.size() > averagingPerdiod upAvgArray.pop() upAvgArray.unshift(up) else upAvgArray.unshift(up) upAvg = upAvgArray.size() > 0 ? upAvgArray.avg() : na if newWeek if downAvgArray.size() > averagingPerdiod downAvgArray.pop() downAvgArray.unshift(down) else downAvgArray.unshift(down) downAvg = downAvgArray.size() > 0 ? downAvgArray.avg() : na R1 := newWeek ? weekOpen + (upAvg / 100) * weekOpen : R1[1] R2 := newWeek ? weekOpen + ((upAvg + upSD) / 100) * weekOpen : R2[1] S1 := newWeek ? weekOpen - (downAvg / 100) * weekOpen : S1[1] S2 := newWeek ? weekOpen - ((downAvg + downSd) / 100) * weekOpen : S2[1] //-----------------------------------------------// //weekly stats //-----------------------------------------------// weekCount := newWeek ? weekCount + 1 : weekCount if weekClose > R1 closeAboveR1 += 1 if weekClose > R2 closeAboveR2 += 1 if weekClose < S1 closeBelowS1 += 1 if weekClose < S2 closeBelowS2 += 1 if weekHigh >= R1 touchR1 += 1 if weekHigh >= R2 touchR2 += 1 if weekLow <= S1 touchS1 += 1 if weekLow <= S2 touchS2 += 1 closeInsideAvg = weekCount - closeAboveR1 - closeBelowS1 closeInsideAvgPlus = weekCount - closeAboveR2 - closeBelowS2 //-----------------------------------------------// //weekly stats table //-----------------------------------------------// if barstate.islast and showTable and timeframe.isweekly and yPos == 'Top' stats.cell(0,0, ' ') stats.cell(0, 1, 'Touch R1: ' + str.tostring(touchR1) + ' / ' + str.tostring((touchR1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(1, 1, 'Close > R1: ' + str.tostring(closeAboveR1) + ' / ' + str.tostring((closeAboveR1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(2, 1, 'Touch R2: ' + str.tostring(touchR2) + ' / ' + str.tostring((touchR2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(3, 1, 'Close > R2: ' + str.tostring(closeAboveR2) + ' / ' + str.tostring((closeAboveR2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(0, 2, 'Touch S1: ' + str.tostring(touchS1) + ' / ' + str.tostring((touchS1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(1, 2, 'Close < S1: ' + str.tostring(closeBelowS1) + ' / ' + str.tostring((closeBelowS1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(2, 2, 'Touch S2: ' + str.tostring(touchS2) + ' / ' + str.tostring((touchS2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(3, 2, 'Close < S2: ' + str.tostring(closeBelowS2) + ' / ' + str.tostring((closeBelowS2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(4, 3, 'Weeks Analyzed: ' + str.tostring(weekCount), text_color = statsText, bgcolor = statsBG) stats.cell(4, 1, 'Total Closes Inside R1/S1: ' + str.tostring(closeInsideAvg) + ' / ' + str.tostring((closeInsideAvg/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(4, 2, 'Total Closes Inside R2/S2: ' + str.tostring(closeInsideAvgPlus) + ' / ' + str.tostring((closeInsideAvgPlus/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) else if barstate.islast and showTable and timeframe.isweekly stats.cell(0, 0, 'Touch R1: ' + str.tostring(touchR1) + ' / ' + str.tostring((touchR1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(1, 0, 'Close > R1: ' + str.tostring(closeAboveR1) + ' / ' + str.tostring((closeAboveR1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(2, 0, 'Touch R2: ' + str.tostring(touchR2) + ' / ' + str.tostring((touchR2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(3, 0, 'Close > R2: ' + str.tostring(closeAboveR2) + ' / ' + str.tostring((closeAboveR2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(0, 1, 'Touch S1: ' + str.tostring(touchS1) + ' / ' + str.tostring((touchS1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(1, 1, 'Close < S1: ' + str.tostring(closeBelowS1) + ' / ' + str.tostring((closeBelowS1/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(2, 1, 'Touch S2: ' + str.tostring(touchS2) + ' / ' + str.tostring((touchS2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(3, 1, 'Close < S2: ' + str.tostring(closeBelowS2) + ' / ' + str.tostring((closeBelowS2/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(0, 2, 'Weeks Analyzed: ' + str.tostring(weekCount), text_color = statsText, bgcolor = statsBG) stats.cell(1, 2, 'Total Closes Inside R1/S1: ' + str.tostring(closeInsideAvg) + ' / ' + str.tostring((closeInsideAvg/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) stats.cell(2, 2, 'Total Closes Inside R2/S2: ' + str.tostring(closeInsideAvgPlus) + ' / ' + str.tostring((closeInsideAvgPlus/weekCount), '#.#%'), text_color = statsText, bgcolor = statsBG) //-----------------------------------------------// //support and resistance levels //-----------------------------------------------// if newWeek and (syminfo.type == 'stock' or syminfo.type == 'fund' or syminfo.type == 'index') (r1Line[1]).delete(), (r2Line[1]).delete(), (s1Line[1]).delete(), (s2Line[1]).delete() (r1Label[1]).delete(), (r2Label[1]).delete(), (s1Label[1]).delete(), (s2Label[1]).delete() (WO[1]).delete() if showWO WO := line.new(bar_index, weekOpen, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, weekOpen, color = wOColor, width = 3) r1Line := line.new(bar_index, R1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, R1, color = rLineColor, width = 2, style = r1Style.switcher()) r2Line := line.new(bar_index, R2, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, R2, color = rLineColor, width = 2, style = r2Style.switcher()) s1Line := line.new(bar_index, S1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, S1, color = sLineColor, width = 2, style = s1Style.switcher()) s2Line := line.new(bar_index, S2, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, S2, color = sLineColor, width = 2, style = s2Style.switcher()) if showPrice r1Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, R1, 'R1 $' + str.tostring(R1, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) r2Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, R2, 'R2 $' + str.tostring(R2, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) s1Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, S1, 'S1 $' + str.tostring(S1, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) s2Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, S2, 'S2 $' + str.tostring(S2, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) if showFill (sFill[1]).delete(), (rFill[1]).delete() sFill := box.new(bar_index, S1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, S2, border_width = 0, bgcolor = color.new(sLineColor,80)) rFill := box.new(bar_index, R1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 4 : timeframe.isminutes ? bar_index + int((390 / (str.tonumber(timeframe.period)) * 5)) : bar_index + 4, R2, border_width = 0, bgcolor = color.new(rLineColor,80)) else if newWeek and (syminfo.type == 'crypto' or syminfo.type == 'forex' or syminfo.type == 'cfd') (r1Line[1]).delete(), (r2Line[1]).delete(), (s1Line[1]).delete(), (s2Line[1]).delete() (r1Label[1]).delete(), (r2Label[1]).delete(), (s1Label[1]).delete(), (s2Label[1]).delete() (WO[1]).delete() if showWO WO := line.new(bar_index, weekOpen, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, weekOpen, color = wOColor, width = 3) r1Line := line.new(bar_index, R1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, R1, color = rLineColor, width = 2, style = r1Style.switcher()) r2Line := line.new(bar_index, R2, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60/ (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, R2, color = rLineColor, width = 2, style = r2Style.switcher()) s1Line := line.new(bar_index, S1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, S1, color = sLineColor, width = 2, style = s1Style.switcher()) s2Line := line.new(bar_index, S2, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, S2, color = sLineColor, width = 2, style = s2Style.switcher()) if showPrice r1Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, R1, 'R1 $' + str.tostring(R1, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) r2Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, R2, 'R2 $' + str.tostring(R2, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) s1Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, S1, 'S1 $' + str.tostring(S1, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) s2Label := label.new(timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, S2, 'S2 $' + str.tostring(S2, format.mintick), style = label.style_label_left, color = color.new(color.white,100), textcolor = labelTextColor) if showFill (sFill[1]).delete(), (rFill[1]).delete() sFill := box.new(bar_index, S1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, S2, border_width = 0, bgcolor = color.new(sLineColor,80)) rFill := box.new(bar_index, R1, timeframe.isweekly ? bar_index + 2 : timeframe.isdaily ? bar_index + 6 : timeframe.isminutes ? bar_index + int((24 * 60 / (str.tonumber(timeframe.period)) * 7)) : bar_index + 6, R2, border_width = 0, bgcolor = color.new(rLineColor,80)) if showPrevious and showFill sFill.set_left(bar_index), rFill.set_left(bar_index) //-----------------------------------------------// //show historical levels //-----------------------------------------------// fillColor = color.new(color.white,100) r1Plot = plot(showPrevious ? R1 : na, color = color.red) r2Plot = plot(showPrevious ? R2 : na, color = color.maroon) s1Plot = plot(showPrevious ? S1 : na, color = color.green) s2Plot = plot(showPrevious ? S2 : na, color = color.lime) woPlot = plot(showPrevious ? weekOpen : na, color = wOColor, style = plot.style_linebr) fill(r1Plot, r2Plot, color = showFill ? color.new(rLineColor, 80) : fillColor) fill(s1Plot, s2Plot, color = showFill ? color.new(sLineColor, 80) : fillColor) //-----------------------------------------------// //alert conditions //-----------------------------------------------// crossR1 = ta.crossover(close,R1) crossR2 = ta.crossover(close,R2) crossS1 = ta.crossunder(close,S1) crossS2 = ta.crossunder(close,S2) alertcondition(crossR1, 'Cross Above R1', 'Price crossing above R1') alertcondition(crossR2, 'Cross Above R2', 'Price crossing above R2') alertcondition(crossS1, 'Cross Below S1', 'Price crossing below S1') alertcondition(crossS2, 'Cross Below S2', 'Price crossing below S2')
Interactive Motive Wave Checklist
https://www.tradingview.com/script/ypAxpurY-Interactive-Motive-Wave-Checklist/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
1,327
study
5
CC-BY-NC-SA-4.0
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // © Trendoscope Pty Ltd // ░▒ // ▒▒▒ ▒▒ // ▒▒▒▒▒ ▒▒ // ▒▒▒▒▒▒▒░ ▒ ▒▒ // ▒▒▒▒▒▒ ▒ ▒▒ // ▓▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒ // ▒▒▒▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ // ▒ ▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▒▒▒▒▒▒▒ // ▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ // ▒▒▒▒▒ ▒▒▒▒▒▒▒ // ▒▒▒▒▒▒▒▒▒ // ▒▒▒▒▒ ▒▒▒▒▒ // ░▒▒▒▒ ▒▒▒▒▓ ████████╗██████╗ ███████╗███╗ ██╗██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗ // ▓▒▒▒▒ ▒▒▒▒ ╚══██╔══╝██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔═══██╗██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝ // ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ██║ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║██║ ██║███████╗██║ ██║ ██║██████╔╝█████╗ // ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██║██║ ██║╚════██║██║ ██║ ██║██╔═══╝ ██╔══╝ // ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██║ ██║███████╗██║ ╚████║██████╔╝╚██████╔╝███████║╚██████╗╚██████╔╝██║ ███████╗ // ▒▒ ▒ //@version=5 indicator("Interactive Motive Wave Checklist", overlay = true) import HeWhoMustNotBeNamed/DrawingTypes/2 as dr import HeWhoMustNotBeNamed/DrawingMethods/2 import HeWhoMustNotBeNamed/FibRatios/1 as fibs import HeWhoMustNotBeNamed/utils/1 as ut import HeWhoMustNotBeNamed/iLogger/1 as l var logger = l.Logger.new(minimumLevel = 'DEBUG', showOnlyLast = true) logger.init() p0price = input.price(0,'0',group='XABC', inline= 'Start', confirm=true) p0time = input.time(0,'',group='XABC', inline= 'Start', confirm=true) p1price = input.price(0,'1',group='XABC', inline= '(1)', confirm=true) p1time = input.time(0,'',group='XABC', inline= '(1)', confirm=true) p2price = input.price(0,'2',group='XABC', inline= '(2)', confirm=true) p2time = input.time(0,'',group='XABC', inline= '(2)', confirm=true) p3price = input.price(0,'3',group='XABC', inline= '(3)', confirm=true) p3time = input.time(0,'',group='XABC', inline= '(3)', confirm=true) p4price = input.price(0,'4',group='XABC', inline= '(4)', confirm=true) p4time = input.time(0,'',group='XABC', inline= '(4)', confirm=true) p5price = input.price(0,'5',group='XABC', inline= '(5)', confirm=true) p5time = input.time(0,'',group='XABC', inline= '(5)', confirm=true) var notDrawn = true if(barstate.islast and notDrawn) notDrawn := false pivotsInOrder = p0time < p1time and p1time < p2time and p2time< p3time and p3time < p4time and p4time < p5time w1 = p1price - p0price w2 = p2price - p1price w3 = p3price - p2price w4 = p4price - p3price w5 = p5price - p4price direction = math.sign(p5price - p0price) directionInOrder = math.sign(w1) == math.sign(w3) and math.sign(w3) == math.sign(w5) and math.sign(w2) == math.sign(w4) and math.sign(w1) != math.sign(w2) w1Length = math.abs(w1) w2Length = math.abs(w2) w3Length = math.abs(w3) w4Length = math.abs(w4) w5Length = math.abs(w5) w3isNotShortest = w3Length > w1Length or w3Length > w5Length w2Ratio = fibs.retracementRatio(p0price, p1price, p2price) w3Ratio = fibs.retracementRatio(p1price, p2price, p3price) w4Ratio = fibs.retracementRatio(p2price, p3price, p4price) w5Ratio = fibs.retracementRatio(p3price, p4price, p5price) mRatio = fibs.retracementRatio(p0price, p3price, p4price) w2DoesNotRetraceBeyondW1 = w2Ratio < 1 w3MovesBeyondW1 = w3Ratio > 1 motiveRatiosIntact = w2DoesNotRetraceBeyondW1 and w3MovesBeyondW1 and w4Ratio < 1 and w5Ratio > 0.9 and mRatio < 1 isMotiveWave = pivotsInOrder and directionInOrder and w3isNotShortest and motiveRatiosIntact w4NotBeyondEndofW1 = direction*p1price < direction*p4price numberofExtendedWaves = (1/w2Ratio > 2? 1 : 0) + (w3Ratio > 2? 1 : 0) + (w5Ratio > 2? 1 : 0) notAllExtended = numberofExtendedWaves < 3 isImpulse = w4NotBeyondEndofW1 and isMotiveWave and notAllExtended wave4NotBeyondWave3 = w4Ratio < 1 wave1OverlapsWave4 = direction*p1price > direction*p4price isExpandingWaves = w1Length < w3Length and w3Length < w5Length and w2Length < w4Length isContractingWaves = w1Length > w3Length and w3Length > w5Length and w2Length > w4Length isExpandingOrContracting = isExpandingWaves or isContractingWaves isExpandingDiagonal = isMotiveWave and wave1OverlapsWave4 and isExpandingWaves and wave4NotBeyondWave3 isContractingDiagonal = isMotiveWave and wave1OverlapsWave4 and isContractingWaves and wave4NotBeyondWave3 dr.Point start = dr.Point.new(p0price, 0, p0time) dr.Point p1 = dr.Point.new(p1price, 0, p1time) dr.Point p2 = dr.Point.new(p2price, 0, p2time) dr.Point p3 = dr.Point.new(p3price, 0, p3time) dr.Point p4 = dr.Point.new(p4price, 0, p4time) dr.Point p5 = dr.Point.new(p5price, 0, p5time) var tbl = table.new(position.top_right, 2, 10) tbl.cell(0, 0, 'Motive Wave Checklist', text_color = color.white, bgcolor = color.new(color.gray, 60), text_halign = text.align_left) tbl.cell(0, 1, 'Pivots In Order '+(pivotsInOrder?'✅':'❌'), text_color = color.white, bgcolor = color.new(pivotsInOrder? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(0, 2, 'Directions In Order '+(directionInOrder?'✅':'❌'), text_color = color.white, bgcolor = color.new(directionInOrder? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(0, 3, 'Wave 2 never moves beyond the start of wave 1 '+(w2DoesNotRetraceBeyondW1?'✅':'❌'), text_color = color.white, bgcolor = color.new(w2DoesNotRetraceBeyondW1? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(0, 4, 'Wave 3 always moves beyond the end of wave 1 '+(w3MovesBeyondW1?'✅':'❌'), text_color = color.white, bgcolor = color.new(w3MovesBeyondW1? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(0, 5, 'Wave 3 is never the shortest wave '+(w3isNotShortest?'✅':'❌'), text_color = color.white, bgcolor = color.new(w3isNotShortest? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(1, 0, 'Impulse Wave Checklist', text_color = color.white, bgcolor = color.new(color.gray, 60), text_halign = text.align_left) tbl.cell(1, 1, 'Wave 4 never moves beyond the end of wave 1 '+(w4NotBeyondEndofW1?'✅':'❌'), text_color = color.white, bgcolor = color.new(w4NotBeyondEndofW1? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(1, 2, 'Never are waves 1, 3 and 5 all extended. '+(notAllExtended?'✅':'❌'), text_color = color.white, bgcolor = color.new(notAllExtended? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(1, 3, 'Diagonal Wave Checklist', text_color = color.white, bgcolor = color.new(color.gray, 60), text_halign = text.align_left) tbl.cell(1, 4, 'Wave 4 never moves beyond the start of wave 3 '+(wave4NotBeyondWave3?'✅':'❌'), text_color = color.white, bgcolor = color.new(wave4NotBeyondWave3? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(1, 5, 'Wave 4 always ends within the price territory of wave 1 '+(wave1OverlapsWave4?'✅':'❌'), text_color = color.white, bgcolor = color.new(wave1OverlapsWave4? color.green: color.red, 60), text_halign = text.align_left) tbl.cell(1, 6, 'Waves are progressively expanding or contracting '+(isExpandingOrContracting?'✅':'❌'), text_color = color.white, bgcolor = color.new(isExpandingOrContracting? color.green: color.red, 60), text_halign = text.align_left) waveDescription = isImpulse? 'Impulse Wave' : isContractingDiagonal? 'Contracting Diagonal Wave' : isExpandingDiagonal? 'Expanding Diagonal Wave' : 'None' txtColor = isImpulse or isContractingDiagonal or isExpandingDiagonal? (direction > 0? color.green : color.red) : color.silver var waveLabel = table.new(position.middle_center, 1, 1) waveLabel.cell(0, 0, waveDescription, text_color = color.new(txtColor, 70), text_size = size.huge) dr.LineProperties properties = dr.LineProperties.new(xloc.bar_time, color = color.yellow, style = line.style_dotted, width = 0) dr.LineProperties mainLineProperty = dr.LineProperties.new(xloc.bar_time, color = color.yellow, style = line.style_solid, width = 2) start.createLine(p5, mainLineProperty).draw() start.createLine(p1, properties).draw() p1.createLine(p2, properties).draw() p2.createLine(p3, properties).draw() p3.createLine(p4, properties).draw() p4.createLine(p5, properties).draw() dr.LabelProperties lblPRoperties = dr.LabelProperties.new(xloc.bar_time, yloc.price, txtColor, label.style_text_outline, color.yellow, size.large) start.createLabel('(0)', properties = lblPRoperties).draw() p1.createLabel('(1)', properties = lblPRoperties).draw() p2.createLabel('(2)', properties = lblPRoperties).draw() p3.createLabel('(3)', properties = lblPRoperties).draw() p4.createLabel('(4)', properties = lblPRoperties).draw() p5.createLabel('(5)', properties = lblPRoperties).draw()
Rolling Risk-Adjusted Performance Ratios
https://www.tradingview.com/script/J1aP07iJ-Rolling-Risk-Adjusted-Performance-Ratios/
QuantiLuxe
https://www.tradingview.com/u/QuantiLuxe/
516
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/ // © EliCobra //@version=5 indicator("Rolling Risk-Adjusted Performance Ratios", "[Ʌ] - RAPR", false, timeframe = "", timeframe_gaps = true) type ratios float srt = na float srp = na float omg = na method calc(float src, simple int len) => array<float> a_prtr = array.new<float>() array<float> a_nrtr = array.new<float>() array<float> a_rtr = array.new<float>() float rtr = src / src[1] - 1 for i = 0 to len - 1 if rtr[i] < 0. a_nrtr.push(rtr[i]) else a_prtr.push(rtr[i]) a_rtr .push(rtr[i]) ratios rapr = ratios.new( math.round(a_rtr .avg() / a_nrtr.stdev() * math.sqrt(len), 2), math.round(a_rtr .avg() / a_rtr .stdev() * math.sqrt(len), 2), math.round(a_prtr.sum() / a_nrtr.sum () * (-1 ), 2)) rapr var string gc = "Calculation", var string gp = "Display" src = input.source(close, "Source" , group = gc) len = input.int (30 , "Period" , group = gc) blsrp = input.bool (true , "Sharpe" , group = gp) blstn = input.bool (true , "Sortino" , group = gp) blomg = input.bool (true , "Omega" , group = gp) blmid = input.bool (true , "Zero Line", group = gp) ratios rapr = src.calc(len) hline(blmid ? 0 : na, "Zero Line" , chart.fg_color, hline.style_solid) plot (blsrp ? rapr.srp : na, "Sharpe Ratio" , #529cca ) plot (blstn ? rapr.srt : na, "Sortino Ratio", #bb6cbb ) plot (blomg ? rapr.omg : na, "Omega Ratio" , #4fa34f )
ADW - Volatility Map
https://www.tradingview.com/script/tREldEYH-ADW-Volatility-Map/
Tradespot
https://www.tradingview.com/u/Tradespot/
15
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/ // © Andrew Wilkinson //@version=5 indicator(title='ADW - Volatility Map', overlay=true, precision=0) awaitBarConfirmation = false cciLength = 20 atrLength = 14 //----- COLORS lowTranspColor = color.new(color.green, 85) highTranspColor = color.new(color.red, 85) extremelyLowTranspColor = color.new(color.green, 70) extremelyHighTranspColor = color.new(color.red, 70) //----- HELPERS commodityChannelIndex(src, length) => ma = ta.sma(src, length) (src - ma) / (0.015 * ta.dev(src, length)) cciInterpretations(cciValue) => isLow = cciValue < 0 isHigh = cciValue > 0 isExtremelyLow = cciValue <= -100 isExtremelyHigh = cciValue >= 100 [isLow, isHigh, isExtremelyLow, isExtremelyHigh] //----- VALUES atrValue = ta.atr(atrLength) atrCci = commodityChannelIndex(atrValue, cciLength) trCci = commodityChannelIndex(ta.tr, cciLength) [atrIsLow, atrIsHigh, atrIsExtremelyLow, atrIsExtremelyHigh] = cciInterpretations(atrCci) [trIsLow, trIsHigh, trIsExtremelyLow, trIsExtremelyHigh] = cciInterpretations(trCci) //----- RENDER readyToRender = awaitBarConfirmation ? barstate.isconfirmed : true shouldHighlightAtr = readyToRender and (atrIsLow or atrIsHigh) shouldHighlightTr = readyToRender and (trIsLow or trIsHigh) atrHighlightColor = atrIsExtremelyLow ? extremelyLowTranspColor : atrIsExtremelyHigh ? extremelyHighTranspColor : atrIsLow ? lowTranspColor : atrIsHigh ? highTranspColor : na trHighlightColor = trIsExtremelyLow ? extremelyLowTranspColor : trIsExtremelyHigh ? extremelyHighTranspColor : na bgColor = shouldHighlightAtr ? atrHighlightColor : na bgcolor(bgColor) plot(shouldHighlightTr ? trCci : na, color=trHighlightColor, linewidth=2, title="TR CCI Line")
TV Draft1
https://www.tradingview.com/script/QodMUl8i-TV-Draft1/
NAVINAGICHA
https://www.tradingview.com/u/NAVINAGICHA/
6
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/ // © N //@version=5 indicator("TV Draft1",overlay=true) //overlay=true, timeframe="", timeframe_gaps=true BRange = input.int(20, minval=0, title="Bull Bear Range (eg. NF-25% BNF-17%)") ema = input(33, title = "MA Length") //show_table5 = input(true, "Show Table?") EMA_HTF = input.int(33, title="EMA HTF", minval=1, maxval=100) res = input.timeframe(defval='240', title="Timeframe") // symin1 = input.symbol(title="Symbol", defval='NIFTY', confirm=true) // symin2 = input.symbol(title="Symbol", defval='BANKNIFTY', confirm=true) // symin3 = input.symbol(title="Symbol", defval='HDFCBANK', confirm=true) // symin4 = input.symbol(title="Symbol", defval='ICICIBANK', confirm=true) // symin5 = input.symbol(title="Symbol", defval='RELIANCE', confirm=true) // symin6 = input.symbol(title="Symbol", defval='INFY', confirm=true) // symin7 = input.symbol(title="Symbol", defval='SBIN', confirm=true) // symin8 = input.symbol(title="Symbol", defval='AXISBANK', confirm=true) // symin9 = input.symbol(title="Symbol", defval='LT', confirm=true) // atrPeriod = input(23, "ATR Length") // factor = input.float(2.7, "Factor", step = 0.01) lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50) len = input.int(14, minval=1, title="DI Length") // use_tp = input(false, "Take Profit?") // tp_trigger = input.float(0.8, "Take profit %", minval=0, step=0.5) * 0.01 // ttp_trigger = input.float(0.2, "Trailing Take Profit %", minval=0, step=0.5) * 0.01 // [supertrend, direction] = ta.supertrend(factor, atrPeriod) //upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_circles) //downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_circles) // plotshape(ta.crossover(close,supertrend) ,text="U",style=shape.labelup,color=color.green,textcolor=color.black,location=location.belowbar) // plotshape(ta.crossunder(close, supertrend),text="D",style=shape.labeldown,color=color.red,textcolor=color.black) up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) trur = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(plusDM, len) / trur) minus = fixnan(100 * ta.rma(minusDM, len) / trur) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig) adxlevel = input.int(title="ADX Level", defval=25) //adxlevel2 = input.int(title="ADX Level 2", defval=20) // RSI Parameters // ==================================================================================== RSI_length = input(14, title='RSI Lenght') //RSI2_length = input(14, title='RSI Lenght') //RSI_overSold = input(20, title='RSI Oversold Limit') //RSI_overBought = input(80, title='RSI Overbought Limit') RSI_High_Trigger= input.int(55, minval=1, title="RSI High Trigger") RSI_Low_Trigger= input.int(45, minval=1, title="RSI Low Trigger") //RSI_50= input.int(55, minval=1, title="RSI Low Trigger") //RSI_40= input.int(50, minval=1, title="RSI Low Trigger") //RSI2 = ta.rsi(close, RSI2_length) RSI = ta.rsi(close, RSI_length) //adxplus = ((ta.crossover((plus),minus))) //and plus>adxlevel //adxminus = ((ta.crossover(minus,plus)) //and RSI2 < RSI_40) and plus>adxlevel //adxplus = (plus>adxlevel) //study("EMA/SMA Band", overlay = true) //ema = input(33, title = "MA Length") //on = input.bool(title = "Plot EMA's", defval = false) //on_sma = input.bool(title = "Use SMA?", defval = false) //ema_color = input.bool(title = "Plot Color", defval = false) // ema_1 = on_sma?ta.ema(high,ema):ta.ema(high,ema) // ema_2 = on_sma?ta.ema(close,ema):ta.ema(close,ema) // ema_3 = on_sma?ta.ema(low,ema):ta.ema(low,ema) //color_ = close>ema_2?color.green:color.red //ema33_1 = ta.ema(high, ema ) //ema33_2 = ta.ema(close, ema ) //ema33_3 = ta.ema(low, ema ) ema_1 = ta.ema(high,ema) ema_2 = ta.ema(close,ema) ema_3 = ta.ema(low,ema) //p1 = plot(ema_1, transp = on? 0:100, linewidth = 2, title = "High", color = ema_color?color_:color.new(color.orange, 80)) //plot(ema_2, transp = on? 0:100, linewidth = 2, title = "Close",color =ema_color? color_:color.rgb(244, 232, 130)) //p2 = plot(ema_3, transp = on?0: 100, linewidth = 2, title = "Low",color =ema_color? color_:color.new(color.orange, 80)) //fill(p1,p2, color = color.rgb(244, 235, 141), transp = 90, color = ema_color?color_:color.rgb(244, 235, 141)) //fill(p1,p2, color.new(color.blue, 70), title = "EMA 33 BAND") //p1 = plot(ema_1, transp = on? 0:100, linewidth = 2, title = "EMA High", color = ema_color?color_:color.new(color.orange, 80)) //plot(ema_2, transp = on? 0:100, linewidth = 2, title = "Close",color =ema_color? color_:color.rgb(244, 232, 130)) //p2 = plot(ema_3, transp = on?0: 100, linewidth = 2, title = "EMA Low",color =ema_color? color_:color.new(color.orange, 80)) //fill(p1,p2, color = color.rgb(244, 235, 141), transp = 90, color = ema_color?color_:color.rgb(244, 235, 141)) p1 = plot(ema_1, linewidth = 2, title = "EMA High", color = color.new(color.orange, 80)) //plot(ema_2, transp = on? 0:100, linewidth = 2, title = "Close",color =ema_color? color_:color.rgb(244, 232, 130)) p2 = plot(ema_3, linewidth = 2, title = "EMA Low",color =color.new(color.orange, 80)) //fill(p1,p2, color = color.rgb(244, 235, 141), transp = 90, color = ema_color?color_:color.rgb(244, 235, 141)) fill(p1,p2, color.new(color.blue, 70), title = "EMA 33 BAND") emahcr = (ta.crossover(close,ema_1)) emalcr = (ta.crossunder(close,ema_3)) RBbuy = (plus>adxlevel) and(RSI>RSI_High_Trigger) and emahcr RSsell = (minus>adxlevel) and(RSI<RSI_Low_Trigger) and emalcr // RBbuy = emahcr and (plus>adxlevel2) and(RSI>RSI_High_Trigger) // RSsell = emalcr and (minus>adxlevel2) and(RSI<RSI_Low_Trigger) plotshape((RBbuy),text="RB",textcolor=color.black, style=shape.labelup,color=color.green,location=location.belowbar,style=shape.triangleup,size=size.auto) plotshape((RSsell),text="RS",textcolor=color.black,style=shape.labeldown,color=color.red,location=location.abovebar,style=shape.triangledown,size=size.auto) // buy=ta.crossover(close,supertrend) // sell=ta.crossunder(close,supertrend) // since_buy = ta.barssince(buy) // since_sell = ta.barssince(sell) // buy_trend = since_sell > since_buy // sell_trend = since_sell < since_buy // change_trend = (buy_trend and sell_trend[1]) or (sell_trend and buy_trend[1]) // entry_price = ta.valuewhen(buy or sell, close, 0) // var tp_price_trigger = -1.0 // var is_tp_trigger_hit = false // var tp_trail = 0.0 // tp_close_long = false // tp_close_short = false // if use_tp // if change_trend // tp_price_trigger := entry_price * (1.0 + (buy_trend ? 1.0 : sell_trend ? -1.0 : na) * tp_trigger) // is_tp_trigger_hit := false // if buy_trend // is_tp_trigger_hit := (high >= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1]) // tp_trail := math.max(high, change_trend ? tp_price_trigger : tp_trail[1]) // tp_close_long := (is_tp_trigger_hit and (high <= tp_trail * (1.0 - ttp_trigger))) or (not change_trend and tp_close_long[1]) // else if sell_trend // is_tp_trigger_hit := (low <= tp_price_trigger) or (not change_trend and is_tp_trigger_hit[1]) // tp_trail := math.min(low, change_trend ? tp_price_trigger : tp_trail[1]) // tp_close_short := (is_tp_trigger_hit and (low >= tp_trail * (1.0 + ttp_trigger))) or (not change_trend and tp_close_short[1]) //plot(use_tp and tp_price_trigger != -1.0 ? tp_price_trigger : na,title='Take Profit Price Trigger', color=color.blue,style=plot.style_circles, linewidth=2) //Created by Robert Nance on 072315 //study(title="Moving Average Colored EMA/SMA", shorttitle="Colored EMA /SMA", overlay=true) //emaplot = input (true, title="Show EMA on chart") //len3 = input.int(33, minval=1, title="ema Length") //src = low //out = ta.ema(src, len3) //up3 = out > out[1] //down3 = out < out[1] //mycolor = up3 ? color.green : down3 ? color.red : color.blue //plot(out and emaplot ? out :na, title="EMA", color=mycolor, linewidth=3) //smaplot = input (false, title="Show EMA on chart") //len2 = input(33, title="sma Length") //src2 = high //out2 = ta.ema(src2, len2) //up2 = out2 > out2[1] //down2 = out2 < out2[1] //mycolor2 = up2 ? color.green : down2 ? color.red : color.blue //plot(out2 and smaplot ? out2 :na , title="SMA", color=mycolor2, linewidth=1) // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // Developed by Marco Jarquin as part of Arkansas 22 Project for Binary Options // CBRA for binary options (Configurable Bollinger Bands, RSI and Aroon) //@version=5 // ==================================================================================== //strategy('A22.CBRA.Strat', overlay=true, initial_capital=10000, currency='USD', calc_on_every_tick=true, default_qty_type=strategy.cash, default_qty_value=4000, commission_type=strategy.commission.cash_per_order, commission_value=0) // Aroonish Parameters // ==================================================================================== // Aroonish_length = input.int(4, minval=1, title='Aroonish Lenght') // Aroonish_ConfVal = input.int(50, minval=0, maxval=100, step=25, title='Aroonish Confirmation Value') // Aroonish_upper = 100 * (-ta.highestbars(high, Aroonish_length + 1) + Aroonish_length) / Aroonish_length // Aroonish_lower = 100 * (-ta.lowestbars(low, Aroonish_length + 1) + Aroonish_length) / Aroonish_length // // Aroonish confirmations // // ==================================================================================== // Aroonish_ConfLong = Aroonish_lower >= Aroonish_ConfVal and Aroonish_upper < Aroonish_lower // Aroonish_ConfShrt = Aroonish_upper >= Aroonish_ConfVal and Aroonish_upper > Aroonish_lower // //plotshape(ta.crossover(Aroonish_lower, Aroonish_upper), color=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar, size=size.auto, title='Ar-OB') // //plotshape(ta.crossover(Aroonish_upper, Aroonish_lower), color=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar, size=size.auto, title='Ar-OS') // ArOB = (ta.crossover(Aroonish_lower, Aroonish_upper)) // ArOS = (ta.crossover(Aroonish_upper, Aroonish_lower)) // plotshape(ta.crossover(RSI, RSI_overSold), color=color.new(color.orange, 0), style=shape.square, location=location.belowbar, size=size.auto, title='RSI-B') // plotshape(ta.crossunder(RSI, RSI_overBought), color=color.new(color.orange, 0), style=shape.square, location=location.abovebar, size=size.auto, title='RSI-S') // RSI_overSold2 = ta.crossover(RSI, RSI_overSold) // RSI_overBought2 = ta.crossunder(RSI, RSI_overBought) // // Bollinger Parameters // // ==================================================================================== // BB_length = input.int(20, minval=1, title='Bollinger Lenght') // BB_mult = input.float(2.5, minval=0.1, maxval=50, step=0.1, title='Bollinger Std Dev') // // BB_bars = input(3, minval=1, maxval=5, title="Check bars after crossing") // BB_basis = ta.sma(close, BB_length) // BB_dev = BB_mult * ta.stdev(close, BB_length) // BB_upper = BB_basis + BB_dev // BB_lower = BB_basis - BB_dev // //p1 = plot(BB_upper, color=color.new(color.blue, 0)) // //p2 = plot(BB_lower, color=color.new(color.blue, 0)) // // Bars to have the operation open // // ==================================================================================== // nBars = input.int(3, minval=1, maxval=30, title='Bars to keep the operation open') // // Strategy condition short or long // // ==================================================================================== // //ConditionShrt = (ta.crossunder(close, BB_upper) or ta.crossunder(close[1], BB_upper[1])) and Aroonish_ConfShrt and (ta.crossunder(RSI, RSI_overBought) or ta.crossunder(RSI[1], RSI_overBought[1])) // //ConditionLong = (ta.crossover(close, BB_lower) or ta.crossover(close[1], BB_lower[1])) and Aroonish_ConfLong and (ta.crossover(RSI, RSI_overSold) or ta.crossover(RSI[1], RSI_overSold[1])) // plotshape(ta.crossover(close, BB_lower), color=color.new(color.blue, 0), style=shape.circle, location=location.belowbar, size=size.auto, title='BB-B') // plotshape(ta.crossunder(close, BB_upper), color=color.new(color.blue, 0), style=shape.circle, location=location.abovebar, size=size.auto, title='BB-S') // // Make input options that configure backtest date range // // ==================================================================================== // //iSDate = input.time(title='Start Date', defval=timestamp('14 Sep 2022 06:00 +0100'), tooltip='Start date and time of backtest') // //iFDate = input.time(title='End Date', defval=timestamp('16 Sep 2022 16:00 +0100'), tooltip='End date and time of backtest') // // Look if the close time of the current bar falls inside the date range // // ==================================================================================== // //inDateRange = (time >= iSDate and time < iFDate) // // Evaluates conditions to enter short or long // // ==================================================================================== // //if inDateRange and ConditionLong // // strategy.entry('A22.L', strategy.long) // //if inDateRange and ConditionLong[nBars] // // strategy.close('A22.L', comment='A22.L Exit') // //if inDateRange and ConditionShrt // // strategy.entry('A22.S', strategy.short) // //if inDateRange and ConditionShrt[nBars] // // strategy.close('A22.S', comment='A22.S Exit') // //if not inDateRange // // strategy.close_all() // //This is for 15 mins logic.. // //up15on = input(true, title="15 Minute Opening Range High") // //down15on = input(true, title="15 Minute Opening Range Low") // //up30on = input(true, title="30 Minute Opening Range High") // //down30on = input(true, title="30 Minute Opening Range Low") // //is_newbar(res) => ta.change(time(res)) != 0 // //adopt(r, s) => request.security(syminfo.tickerid, r, s) // //high_range = ta.valuewhen(is_newbar('D'),high,0) // //low_range = ta.valuewhen(is_newbar('D'),low,0) // //high_rangeL = ta.valuewhen(is_newbar('D'),high,0) // //low_rangeL = ta.valuewhen(is_newbar('D'),low,0) // //up1 = plot(up15on ? adopt('15', high_range):na, color = #0E7A34, style= plot.style_line, linewidth=2, title="15 mins High") // //down1 = plot(down15on ? adopt('15', low_range): na, color = #DC143C, style= plot.style_line, linewidth=2, title="15 mins Low") // //up30 = plot(up30on ? adopt('30', high_range):na, color = #0E7A34, style= plot.style_line, linewidth=2, title="30 mins High") // //down30 = plot(down30on ? adopt('30', low_range): na, color = #DC143C, style= plot.style_line, linewidth=2, title="30 mins Low") // //trans15 = up15on ? 75 : 100 // //trans30 = up30on ? 75 : 100 // //fill(up1, down1, color = #ffffff, transp=trans15) // //fill(up1, down1, color = #ffffff, transp=trans30) // //symin1 = input.symbol(title="Symbol", defval='NIFTY', confirm=true) // t0= timeframe.period // sym1c = request.security(symin1, t0, close) // sym1h = request.security(symin1, t0, high) // sym1l = request.security(symin1, t0, low) // RSI_sym = input(14, title='RSI Lenght') // RSIs1 = ta.rsi(sym1c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // //up1 = ta.change(sym1h) // //down1 = -ta.change(sym1l) // //plusDM1 = na(up1) ? na : (up1 > down1 and up1 > 0 ? up1 : 0) // //minusDM1 = na(down1) ? na : (down1 > up1 and down1 > 0 ? down1 : 0) // //trur1 = ta.rma(ta.tr, len) // //plus1 = fixnan(100 * ta.rma(plusDM1, len) / trur1) // //minus1 = fixnan(100 * ta.rma(minusDM1, len) / trur1) // //sum1 = plus1 + minus1 // //adx1 = 100 * ta.rma(math.abs(plus1 - minus1) / (sum1 == 0 ? 1 : sum1), lensig) // //adxlevel = input.int(title="ADX Level", defval=25) // len1 = input(14) // TrueRange1 = math.max(math.max(sym1h-sym1l, math.abs(sym1h-nz(sym1c[1]))), math.abs(sym1l-nz(sym1c[1]))) // DirectionalMovementPlus1 = sym1h-nz(sym1h[1]) > nz(sym1l[1])-sym1l ? math.max(sym1h-nz(sym1h[1]), 0): 0 // DirectionalMovementMinus1 = nz(sym1l[1])-sym1l > sym1h-nz(sym1h[1]) ? math.max(nz(sym1l[1])-sym1l, 0): 0 // SmoothedTrueRange1 = 0.0 // SmoothedTrueRange1 := nz(SmoothedTrueRange1[1]) - (nz(SmoothedTrueRange1[1])/len1) + TrueRange1 // SmoothedDirectionalMovementPlus1 = 0.0 // SmoothedDirectionalMovementPlus1 := nz(SmoothedDirectionalMovementPlus1[1]) - (nz(SmoothedDirectionalMovementPlus1[1])/len1) + DirectionalMovementPlus1 // SmoothedDirectionalMovementMinus1 = 0.0 // SmoothedDirectionalMovementMinus1 := nz(SmoothedDirectionalMovementMinus1[1]) - (nz(SmoothedDirectionalMovementMinus1[1])/len1) + DirectionalMovementMinus1 // DIPlus1 = SmoothedDirectionalMovementPlus1 / SmoothedTrueRange1 * 100 // DIMinus1 = SmoothedDirectionalMovementMinus1 / SmoothedTrueRange1 * 100 // DX1 = math.abs(DIPlus1-DIMinus1) / (DIPlus1+DIMinus1)*100 // ADX1 = ta.sma(DX1, len1) // //symin2 = input.symbol(title="Symbol", defval='BANKNIFTY', confirm=true) // sym2c = request.security(symin2, t0, close) // sym2h = request.security(symin2, t0, high) // sym2l = request.security(symin2, t0, low) // RSIs2 = ta.rsi(sym2c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len2 = len1 // TrueRange2 = math.max(math.max(sym2h-sym2l, math.abs(sym2h-nz(sym2c[1]))), math.abs(sym2l-nz(sym2c[1]))) // DirectionalMovementPlus2 = sym2h-nz(sym2h[1]) > nz(sym2l[1])-sym2l ? math.max(sym2h-nz(sym2h[1]), 0): 0 // DirectionalMovementMinus2 = nz(sym2l[1])-sym2l > sym2h-nz(sym2h[1]) ? math.max(nz(sym2l[1])-sym2l, 0): 0 // SmoothedTrueRange2 = 0.0 // SmoothedTrueRange2 := nz(SmoothedTrueRange2[1]) - (nz(SmoothedTrueRange2[1])/len2) + TrueRange2 // SmoothedDirectionalMovementPlus2 = 0.0 // SmoothedDirectionalMovementPlus2 := nz(SmoothedDirectionalMovementPlus2[1]) - (nz(SmoothedDirectionalMovementPlus2[1])/len2) + DirectionalMovementPlus2 // SmoothedDirectionalMovementMinus2 = 0.0 // SmoothedDirectionalMovementMinus2 := nz(SmoothedDirectionalMovementMinus2[1]) - (nz(SmoothedDirectionalMovementMinus2[1])/len2) + DirectionalMovementMinus2 // DIPlus2 = SmoothedDirectionalMovementPlus2 / SmoothedTrueRange2 * 100 // DIMinus2 = SmoothedDirectionalMovementMinus2 / SmoothedTrueRange2 * 100 // DX2 = math.abs(DIPlus2-DIMinus2) / (DIPlus2+DIMinus2)*100 // ADX2 = ta.sma(DX2, len2) // //symin3 = input.symbol(title="Symbol", defval='HDFCBANK', confirm=true) // sym3c = request.security(symin3, t0, close) // sym3h = request.security(symin3, t0, high) // sym3l = request.security(symin3, t0, low) // RSIs3 = ta.rsi(sym3c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len3 = len1 // TrueRange3 = math.max(math.max(sym3h-sym3l, math.abs(sym3h-nz(sym3c[1]))), math.abs(sym3l-nz(sym3c[1]))) // DirectionalMovementPlus3 = sym3h-nz(sym3h[1]) > nz(sym3l[1])-sym3l ? math.max(sym3h-nz(sym3h[1]), 0): 0 // DirectionalMovementMinus3 = nz(sym3l[1])-sym3l > sym3h-nz(sym3h[1]) ? math.max(nz(sym3l[1])-sym3l, 0): 0 // SmoothedTrueRange3 = 0.0 // SmoothedTrueRange3 := nz(SmoothedTrueRange3[1]) - (nz(SmoothedTrueRange3[1])/len3) + TrueRange3 // SmoothedDirectionalMovementPlus3 = 0.0 // SmoothedDirectionalMovementPlus3 := nz(SmoothedDirectionalMovementPlus3[1]) - (nz(SmoothedDirectionalMovementPlus3[1])/len3) + DirectionalMovementPlus3 // SmoothedDirectionalMovementMinus3 = 0.0 // SmoothedDirectionalMovementMinus3 := nz(SmoothedDirectionalMovementMinus3[1]) - (nz(SmoothedDirectionalMovementMinus3[1])/len3) + DirectionalMovementMinus3 // DIPlus3 = SmoothedDirectionalMovementPlus3 / SmoothedTrueRange3 * 100 // DIMinus3 = SmoothedDirectionalMovementMinus3 / SmoothedTrueRange3 * 100 // DX3 = math.abs(DIPlus3-DIMinus3) / (DIPlus3+DIMinus3)*100 // ADX3 = ta.sma(DX3, len3) // //symin4 = input.symbol(title="Symbol", defval='ICICIBANK', confirm=true) // sym4c = request.security(symin4, t0, close) // sym4h = request.security(symin4, t0, high) // sym4l = request.security(symin4, t0, low) // RSIs4 = ta.rsi(sym4c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len4 = len1 // TrueRange4 = math.max(math.max(sym4h-sym4l, math.abs(sym4h-nz(sym4c[1]))), math.abs(sym4l-nz(sym4c[1]))) // DirectionalMovementPlus4 = sym4h-nz(sym4h[1]) > nz(sym4l[1])-sym4l ? math.max(sym4h-nz(sym4h[1]), 0): 0 // DirectionalMovementMinus4 = nz(sym4l[1])-sym4l > sym4h-nz(sym4h[1]) ? math.max(nz(sym4l[1])-sym4l, 0): 0 // SmoothedTrueRange4 = 0.0 // SmoothedTrueRange4 := nz(SmoothedTrueRange4[1]) - (nz(SmoothedTrueRange4[1])/len4) + TrueRange4 // SmoothedDirectionalMovementPlus4 = 0.0 // SmoothedDirectionalMovementPlus4 := nz(SmoothedDirectionalMovementPlus4[1]) - (nz(SmoothedDirectionalMovementPlus4[1])/len4) + DirectionalMovementPlus4 // SmoothedDirectionalMovementMinus4 = 0.0 // SmoothedDirectionalMovementMinus4 := nz(SmoothedDirectionalMovementMinus4[1]) - (nz(SmoothedDirectionalMovementMinus4[1])/len4) + DirectionalMovementMinus4 // DIPlus4 = SmoothedDirectionalMovementPlus4 / SmoothedTrueRange4 * 100 // DIMinus4 = SmoothedDirectionalMovementMinus4 / SmoothedTrueRange4 * 100 // DX4 = math.abs(DIPlus4-DIMinus4) / (DIPlus4+DIMinus4)*100 // ADX4 = ta.sma(DX4, len4) // //symin5 = input.symbol(title="Symbol", defval='RELIANCE', confirm=true) // sym5c = request.security(symin5, t0, close) // sym5h = request.security(symin5, t0, high) // sym5l = request.security(symin5, t0, low) // RSIs5 = ta.rsi(sym5c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len5 = len1 // TrueRange5 = math.max(math.max(sym5h-sym5l, math.abs(sym5h-nz(sym5c[1]))), math.abs(sym5l-nz(sym5c[1]))) // DirectionalMovementPlus5 = sym5h-nz(sym5h[1]) > nz(sym5l[1])-sym5l ? math.max(sym5h-nz(sym5h[1]), 0): 0 // DirectionalMovementMinus5 = nz(sym5l[1])-sym5l > sym5h-nz(sym5h[1]) ? math.max(nz(sym5l[1])-sym5l, 0): 0 // SmoothedTrueRange5 = 0.0 // SmoothedTrueRange5 := nz(SmoothedTrueRange5[1]) - (nz(SmoothedTrueRange5[1])/len5) + TrueRange5 // SmoothedDirectionalMovementPlus5 = 0.0 // SmoothedDirectionalMovementPlus5 := nz(SmoothedDirectionalMovementPlus5[1]) - (nz(SmoothedDirectionalMovementPlus5[1])/len5) + DirectionalMovementPlus5 // SmoothedDirectionalMovementMinus5 = 0.0 // SmoothedDirectionalMovementMinus5 := nz(SmoothedDirectionalMovementMinus5[1]) - (nz(SmoothedDirectionalMovementMinus5[1])/len5) + DirectionalMovementMinus5 // DIPlus5 = SmoothedDirectionalMovementPlus5 / SmoothedTrueRange5 * 100 // DIMinus5 = SmoothedDirectionalMovementMinus5 / SmoothedTrueRange5 * 100 // DX5 = math.abs(DIPlus5-DIMinus5) / (DIPlus5+DIMinus5)*100 // ADX5 = ta.sma(DX5, len5) // //symin6 = input.symbol(title="Symbol", defval='INFY', confirm=true) // sym6c = request.security(symin6, t0, close) // sym6h = request.security(symin6, t0, high) // sym6l = request.security(symin6, t0, low) // RSIs6 = ta.rsi(sym6c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len6 = len1 // TrueRange6 = math.max(math.max(sym6h-sym6l, math.abs(sym6h-nz(sym6c[1]))), math.abs(sym6l-nz(sym6c[1]))) // DirectionalMovementPlus6 = sym6h-nz(sym6h[1]) > nz(sym6l[1])-sym6l ? math.max(sym6h-nz(sym6h[1]), 0): 0 // DirectionalMovementMinus6 = nz(sym6l[1])-sym6l > sym6h-nz(sym6h[1]) ? math.max(nz(sym6l[1])-sym6l, 0): 0 // SmoothedTrueRange6 = 0.0 // SmoothedTrueRange6 := nz(SmoothedTrueRange6[1]) - (nz(SmoothedTrueRange6[1])/len6) + TrueRange6 // SmoothedDirectionalMovementPlus6 = 0.0 // SmoothedDirectionalMovementPlus6 := nz(SmoothedDirectionalMovementPlus6[1]) - (nz(SmoothedDirectionalMovementPlus6[1])/len6) + DirectionalMovementPlus6 // SmoothedDirectionalMovementMinus6 = 0.0 // SmoothedDirectionalMovementMinus6 := nz(SmoothedDirectionalMovementMinus6[1]) - (nz(SmoothedDirectionalMovementMinus6[1])/len6) + DirectionalMovementMinus6 // DIPlus6 = SmoothedDirectionalMovementPlus6 / SmoothedTrueRange6 * 100 // DIMinus6 = SmoothedDirectionalMovementMinus6 / SmoothedTrueRange6 * 100 // DX6 = math.abs(DIPlus6-DIMinus6) / (DIPlus6+DIMinus6)*100 // ADX6 = ta.sma(DX6, len6) // //symin7 = input.symbol(title="Symbol", defval='SBIN', confirm=true) // sym7c = request.security(symin7, t0, close) // sym7h = request.security(symin7, t0, high) // sym7l = request.security(symin7, t0, low) // RSIs7 = ta.rsi(sym7c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len7 = len1 // TrueRange7 = math.max(math.max(sym7h-sym7l, math.abs(sym7h-nz(sym7c[1]))), math.abs(sym7l-nz(sym7c[1]))) // DirectionalMovementPlus7 = sym7h-nz(sym7h[1]) > nz(sym7l[1])-sym7l ? math.max(sym7h-nz(sym7h[1]), 0): 0 // DirectionalMovementMinus7 = nz(sym7l[1])-sym7l > sym7h-nz(sym7h[1]) ? math.max(nz(sym7l[1])-sym7l, 0): 0 // SmoothedTrueRange7 = 0.0 // SmoothedTrueRange7 := nz(SmoothedTrueRange7[1]) - (nz(SmoothedTrueRange7[1])/len7) + TrueRange7 // SmoothedDirectionalMovementPlus7 = 0.0 // SmoothedDirectionalMovementPlus7 := nz(SmoothedDirectionalMovementPlus7[1]) - (nz(SmoothedDirectionalMovementPlus7[1])/len7) + DirectionalMovementPlus7 // SmoothedDirectionalMovementMinus7 = 0.0 // SmoothedDirectionalMovementMinus7 := nz(SmoothedDirectionalMovementMinus7[1]) - (nz(SmoothedDirectionalMovementMinus7[1])/len7) + DirectionalMovementMinus7 // DIPlus7 = SmoothedDirectionalMovementPlus7 / SmoothedTrueRange7 * 100 // DIMinus7 = SmoothedDirectionalMovementMinus7 / SmoothedTrueRange7 * 100 // DX7 = math.abs(DIPlus7-DIMinus7) / (DIPlus7+DIMinus7)*100 // ADX7 = ta.sma(DX7, len7) // //symin8 = input.symbol(title="Symbol", defval='AXISBANK', confirm=true) // sym8c = request.security(symin8, t0, close) // sym8h = request.security(symin8, t0, high) // sym8l = request.security(symin8, t0, low) // RSIs8 = ta.rsi(sym8c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len8 = len1 // TrueRange8 = math.max(math.max(sym8h-sym8l, math.abs(sym8h-nz(sym8c[1]))), math.abs(sym8l-nz(sym8c[1]))) // DirectionalMovementPlus8 = sym8h-nz(sym8h[1]) > nz(sym8l[1])-sym8l ? math.max(sym8h-nz(sym8h[1]), 0): 0 // DirectionalMovementMinus8 = nz(sym8l[1])-sym8l > sym8h-nz(sym8h[1]) ? math.max(nz(sym8l[1])-sym8l, 0): 0 // SmoothedTrueRange8 = 0.0 // SmoothedTrueRange8 := nz(SmoothedTrueRange8[1]) - (nz(SmoothedTrueRange8[1])/len8) + TrueRange8 // SmoothedDirectionalMovementPlus8 = 0.0 // SmoothedDirectionalMovementPlus8 := nz(SmoothedDirectionalMovementPlus8[1]) - (nz(SmoothedDirectionalMovementPlus8[1])/len8) + DirectionalMovementPlus8 // SmoothedDirectionalMovementMinus8 = 0.0 // SmoothedDirectionalMovementMinus8 := nz(SmoothedDirectionalMovementMinus8[1]) - (nz(SmoothedDirectionalMovementMinus8[1])/len8) + DirectionalMovementMinus8 // DIPlus8 = SmoothedDirectionalMovementPlus8 / SmoothedTrueRange8 * 100 // DIMinus8 = SmoothedDirectionalMovementMinus8 / SmoothedTrueRange8 * 100 // DX8 = math.abs(DIPlus8-DIMinus8) / (DIPlus8+DIMinus8)*100 // ADX8 = ta.sma(DX8, len8) // //symin9 = input.symbol(title="Symbol", defval='LT', confirm=true) // sym9c = request.security(symin9, t0, close) // sym9h = request.security(symin9, t0, high) // sym9l = request.security(symin9, t0, low) // RSIs9 = ta.rsi(sym9c, RSI_sym) // //ovr22 = request.security(sym1, t0, close) // //nifclose = request.security('NIFTY', '3', close) // len9 = len1 // TrueRange9 = math.max(math.max(sym9h-sym9l, math.abs(sym9h-nz(sym9c[1]))), math.abs(sym9l-nz(sym9c[1]))) // DirectionalMovementPlus9 = sym9h-nz(sym9h[1]) > nz(sym9l[1])-sym9l ? math.max(sym9h-nz(sym9h[1]), 0): 0 // DirectionalMovementMinus9 = nz(sym9l[1])-sym9l > sym9h-nz(sym9h[1]) ? math.max(nz(sym9l[1])-sym9l, 0): 0 // SmoothedTrueRange9 = 0.0 // SmoothedTrueRange9 := nz(SmoothedTrueRange9[1]) - (nz(SmoothedTrueRange9[1])/len9) + TrueRange9 // SmoothedDirectionalMovementPlus9 = 0.0 // SmoothedDirectionalMovementPlus9 := nz(SmoothedDirectionalMovementPlus9[1]) - (nz(SmoothedDirectionalMovementPlus9[1])/len9) + DirectionalMovementPlus9 // SmoothedDirectionalMovementMinus9 = 0.0 // SmoothedDirectionalMovementMinus9 := nz(SmoothedDirectionalMovementMinus9[1]) - (nz(SmoothedDirectionalMovementMinus9[1])/len9) + DirectionalMovementMinus9 // DIPlus9 = SmoothedDirectionalMovementPlus9 / SmoothedTrueRange9 * 100 // DIMinus9 = SmoothedDirectionalMovementMinus9 / SmoothedTrueRange9 * 100 // DX9 = math.abs(DIPlus9-DIMinus9) / (DIPlus9+DIMinus9)*100 // ADX9 = ta.sma(DX9, len9) // // symin10 = input.symbol(title="Symbol", defval='TCS', confirm=true) // // sym10c = request.security(symin10, t0, close) // // sym10h = request.security(symin10, t0, high) // // sym10l = request.security(symin10, t0, low) // // RSIs10 = ta.rsi(sym10c, RSI_sym) // // //ovr22 = request.security(sym1, t0, close) // // //nifclose = request.security('NIFTY', '3', close) // // len10 = len1 // // TrueRange10 = math.max(math.max(sym10h-sym10l, math.abs(sym10h-nz(sym10c[1]))), math.abs(sym10l-nz(sym10c[1]))) // // DirectionalMovementPlus10 = sym10h-nz(sym10h[1]) > nz(sym10l[1])-sym10l ? math.max(sym10h-nz(sym10h[1]), 0): 0 // // DirectionalMovementMinus10 = nz(sym10l[1])-sym10l > sym10h-nz(sym10h[1]) ? math.max(nz(sym10l[1])-sym10l, 0): 0 // // SmoothedTrueRange10 = 0.0 // // SmoothedTrueRange10 := nz(SmoothedTrueRange10[1]) - (nz(SmoothedTrueRange10[1])/len10) + TrueRange10 // // SmoothedDirectionalMovementPlus10 = 0.0 // // SmoothedDirectionalMovementPlus10 := nz(SmoothedDirectionalMovementPlus10[1]) - (nz(SmoothedDirectionalMovementPlus10[1])/len10) + DirectionalMovementPlus10 // // SmoothedDirectionalMovementMinus10 = 0.0 // // SmoothedDirectionalMovementMinus10 := nz(SmoothedDirectionalMovementMinus10[1]) - (nz(SmoothedDirectionalMovementMinus10[1])/len10) + DirectionalMovementMinus10 // // DIPlus10 = SmoothedDirectionalMovementPlus10 / SmoothedTrueRange10 * 100 // // DIMinus10 = SmoothedDirectionalMovementMinus10 / SmoothedTrueRange10 * 100 // // DX10 = math.abs(DIPlus10-DIMinus10) / (DIPlus10+DIMinus10)*100 // // ADX10 = ta.sma(DX10, len10) // // symin11 = input.symbol(title="Symbol", defval='BAJFINANCE', confirm=true) // // sym11c = request.security(symin11, t0, close) // // sym11h = request.security(symin11, t0, high) // // sym11l = request.security(symin11, t0, low) // // RSIs11 = ta.rsi(sym11c, RSI_sym) // // //ovr22 = request.security(sym1, t0, close) // // //nifclose = request.security('NIFTY', '3', close) // // len11 = input(14) // // TrueRange11 = math.max(math.max(sym11h-sym11l, math.abs(sym11h-nz(sym11c[1]))), math.abs(sym11l-nz(sym11c[1]))) // // DirectionalMovementPlus11 = sym11h-nz(sym11h[1]) > nz(sym11l[1])-sym11l ? math.max(sym11h-nz(sym11h[1]), 0): 0 // // DirectionalMovementMinus11 = nz(sym11l[1])-sym11l > sym11h-nz(sym11h[1]) ? math.max(nz(sym11l[1])-sym11l, 0): 0 // // SmoothedTrueRange11 = 0.0 // // SmoothedTrueRange11 := nz(SmoothedTrueRange11[1]) - (nz(SmoothedTrueRange11[1])/len11) + TrueRange11 // // SmoothedDirectionalMovementPlus11 = 0.0 // // SmoothedDirectionalMovementPlus11 := nz(SmoothedDirectionalMovementPlus11[1]) - (nz(SmoothedDirectionalMovementPlus11[1])/len11) + DirectionalMovementPlus11 // // SmoothedDirectionalMovementMinus11 = 0.0 // // SmoothedDirectionalMovementMinus11 := nz(SmoothedDirectionalMovementMinus11[1]) - (nz(SmoothedDirectionalMovementMinus11[1])/len11) + DirectionalMovementMinus11 // // DIPlus11 = SmoothedDirectionalMovementPlus11 / SmoothedTrueRange11 * 110 // // DIMinus11 = SmoothedDirectionalMovementMinus11 / SmoothedTrueRange11 * 110 // // DX11 = math.abs(DIPlus11-DIMinus11) / (DIPlus11+DIMinus11)*110 // //ADX11 = ta.sma(DX11, len11) // // symin12 = input.symbol(title="Symbol", defval='MARUTI', confirm=true) // // sym12c = request.security(symin12, t0, close) // // sym12h = request.security(symin12, t0, high) // // sym12l = request.security(symin12, t0, low) // // RSIs12 = ta.rsi(sym12c, RSI_sym) // // //ovr22 = request.security(sym1, t0, close) // // //nifclose = request.security('NIFTY', '3', close) // // len12 = input(14) // // TrueRange12 = math.max(math.max(sym12h-sym12l, math.abs(sym12h-nz(sym12c[1]))), math.abs(sym12l-nz(sym12c[1]))) // // DirectionalMovementPlus12 = sym12h-nz(sym12h[1]) > nz(sym12l[1])-sym12l ? math.max(sym12h-nz(sym12h[1]), 0): 0 // // DirectionalMovementMinus12 = nz(sym12l[1])-sym12l > sym12h-nz(sym12h[1]) ? math.max(nz(sym12l[1])-sym12l, 0): 0 // // SmoothedTrueRange12 = 0.0 // // SmoothedTrueRange12 := nz(SmoothedTrueRange12[1]) - (nz(SmoothedTrueRange12[1])/len12) + TrueRange12 // // SmoothedDirectionalMovementPlus12 = 0.0 // // SmoothedDirectionalMovementPlus12 := nz(SmoothedDirectionalMovementPlus12[1]) - (nz(SmoothedDirectionalMovementPlus12[1])/len12) + DirectionalMovementPlus12 // // SmoothedDirectionalMovementMinus12 = 0.0 // // SmoothedDirectionalMovementMinus12 := nz(SmoothedDirectionalMovementMinus12[1]) - (nz(SmoothedDirectionalMovementMinus12[1])/len12) + DirectionalMovementMinus12 // // DIPlus12 = SmoothedDirectionalMovementPlus12 / SmoothedTrueRange12 * 120 // // DIMinus12 = SmoothedDirectionalMovementMinus12 / SmoothedTrueRange12 * 120 // // DX12 = math.abs(DIPlus12-DIMinus12) / (DIPlus12+DIMinus12)*120 // // ADX12 = ta.sma(DX12, len12) // // symin13 = input.symbol(title="Symbol", defval='DRREDDY', confirm=true) // // sym13c = request.security(symin13, t0, close) // // sym13h = request.security(symin13, t0, high) // // sym13l = request.security(symin13, t0, low) // // RSIs13 = ta.rsi(sym13c, RSI_sym) // // //ovr22 = request.security(sym1, t0, close) // // //nifclose = request.security('NIFTY', '3', close) // // len13 = input(14) // // TrueRange13 = math.max(math.max(sym13h-sym13l, math.abs(sym13h-nz(sym13c[1]))), math.abs(sym13l-nz(sym13c[1]))) // // DirectionalMovementPlus13 = sym13h-nz(sym13h[1]) > nz(sym13l[1])-sym13l ? math.max(sym13h-nz(sym13h[1]), 0): 0 // // DirectionalMovementMinus13 = nz(sym13l[1])-sym13l > sym13h-nz(sym13h[1]) ? math.max(nz(sym13l[1])-sym13l, 0): 0 // // SmoothedTrueRange13 = 0.0 // // SmoothedTrueRange13 := nz(SmoothedTrueRange13[1]) - (nz(SmoothedTrueRange13[1])/len13) + TrueRange13 // // SmoothedDirectionalMovementPlus13 = 0.0 // // SmoothedDirectionalMovementPlus13 := nz(SmoothedDirectionalMovementPlus13[1]) - (nz(SmoothedDirectionalMovementPlus13[1])/len13) + DirectionalMovementPlus13 // // SmoothedDirectionalMovementMinus13 = 0.0 // // SmoothedDirectionalMovementMinus13 := nz(SmoothedDirectionalMovementMinus13[1]) - (nz(SmoothedDirectionalMovementMinus13[1])/len13) + DirectionalMovementMinus13 // // DIPlus13 = SmoothedDirectionalMovementPlus13 / SmoothedTrueRange13 * 130 // // DIMinus13 = SmoothedDirectionalMovementMinus13 / SmoothedTrueRange13 * 130 // // DX13 = math.abs(DIPlus13-DIMinus13) / (DIPlus13+DIMinus13)*130 // // ADX13 = ta.sma(DX13, len13) // //show_table5 = input(true, "Show Table?") // tableposition=input.string("top_right",title="Table position", options=["top_left", "top_center", "top_right", "middle_left", "middle_center", "middle_right", "bottom_left", "bottom_center", "bottom_right"]) // tabpos= tableposition== "top_left"? position.top_left:tableposition== "top_center"?position.top_center : tableposition== "top_right"? position.top_right : tableposition== "middle_left"? position.middle_left : tableposition== "middle_center"? position.middle_center : tableposition== "middle_right"? position.middle_right : tableposition== "bottom_left"? position.bottom_left : tableposition== "bottom_center"? position.bottom_center: tableposition== "bottom_right"? position.bottom_right: position.top_right // //t0= timeframe.period // var table indicatorTable = table.new(tabpos, columns = 50, rows = 50, frame_color=color.black, frame_width=0,border_color=color.black, border_width=0) // if barstate.islast and show_table5 // // symbols // table.cell(indicatorTable, 0, 0, text="Screener", text_halign=text.align_center, bgcolor=color.black, text_color=color.white, text_size=size.small) // table.merge_cells(indicatorTable, 0, 0, 4, 0) // // table.cell(indicatorTable, 0, 10, text="Fast EMA", text_halign=text.align_center, bgcolor= color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 11, text="Slow EMA", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 10, str.tostring(math.round(out4,2)), text_halign=text.align_center, bgcolor=out4>out5? color.green:color.red, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 11, str.tostring(math.round(out5,2)), text_halign=text.align_center, bgcolor=out4>out5? color.green:color.red, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 5, text="Volume", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 6, text="5-Day Avg. Volume", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 5, str.tostring(math.round(vol,2)), text_halign=text.align_center, bgcolor= vol>vol_sma?color.blue:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 6, str.tostring(math.round(vol_sma,2)), text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 3, text="RSI", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 4, text="ADX", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 3, str.tostring(math.round(rsi,2)), text_halign=text.align_center, bgcolor= rsi>RSI_High_Trigger? color.green: rsi<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 4, str.tostring(math.round(sig,2)), text_halign=text.align_center, bgcolor=sig>ADX_Threshold1?color.blue:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 7, text="Close", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 8, text="5-Candle High", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 9, text="5-Candle Low", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 7, str.tostring(math.round(close,2)), text_halign=text.align_center, bgcolor= close>HH ?color.green:close<LL ? color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 8, str.tostring(math.round(HH,2)), text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 9, str.tostring(math.round(LL,2)), text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 1, text="ADX Positive", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 1, str.tostring(math.round(plus,2)), text_halign=text.align_center, bgcolor=plus>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 2, 1, (plus>adxlevel"Buy"), text_halign=text.align_center, bgcolor=plus>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 2, text="ADX Negative", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 2, str.tostring(math.round(minus,2)), text_halign=text.align_center, bgcolor=minus>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 3, text="RSI", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 3, str.tostring(math.round(RSI2,2)), text_halign=text.align_center, bgcolor= RSI2>RSI_High_Trigger? color.green: RSI2<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 6, text="RSI (4)", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 6, str.tostring(math.round(RSI,2)), text_halign=text.align_center, bgcolor= RSI<RSI_overBought? color.green: RSI>RSI_overSold?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 5, text="ST", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 5, str.tostring(math.round(supertrend,2)), text_halign=text.align_center, bgcolor= supertrend<close? color.green: supertrend>close?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 4, text="EMA", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 4, str.tostring(math.round(out,2)), text_halign=text.align_center, bgcolor= out<close? color.green: out>close?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 7, text="RSI OB/OS", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 7, str.tostring(math.round(RSI,2)), text_halign=text.align_center, bgcolor= RSI_overSold2? color.green: RSI_overBought2?color.red:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 0, 8, text="Aroonish OB/OS", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 8, str.tostring(math.round(Aroonish_ConfVal,2)), text_halign=text.align_center, bgcolor= ArOS? color.green: ArOB?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 1, text="Instruments", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 1, text="RSI", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 1, text="DMI +ve", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 1, text="DMI -ve", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 1, text="ADX", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 2, text=syminfo.ticker , text_halign=text.align_center, bgcolor=((RSI2>RSI_High_Trigger) and (plus>adxlevel))? color.green: ((RSI2<RSI_Low_Trigger) and (minus>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 2, str.tostring(math.round(RSI2,2)), text_halign=text.align_center, bgcolor= RSI2>RSI_High_Trigger? color.green: RSI2<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 2, str.tostring(math.round(plus,2)), text_halign=text.align_center, bgcolor=plus>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 2, str.tostring(math.round(minus,2)), text_halign=text.align_center, bgcolor=minus>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 2, str.tostring(math.round(adx,2)), text_halign=text.align_center, bgcolor=adx>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 3, text=symin1, text_halign=text.align_center, bgcolor=((RSIs1>RSI_High_Trigger) and (DIPlus1>adxlevel))? color.green: ((RSIs1<RSI_Low_Trigger) and (DIMinus1>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 3, str.tostring(math.round(RSIs1,2)), text_halign=text.align_center, bgcolor= RSIs1>RSI_High_Trigger? color.green: RSIs1<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 3, str.tostring(math.round(DIPlus1,2)), text_halign=text.align_center, bgcolor=DIPlus1>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 3, str.tostring(math.round(DIMinus1,2)), text_halign=text.align_center, bgcolor=DIMinus1>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 3, str.tostring(math.round(ADX1,2)), text_halign=text.align_center, bgcolor=ADX1>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 4, text=symin2, text_halign=text.align_center, bgcolor=((RSIs2>RSI_High_Trigger) and (DIPlus2>adxlevel))? color.green: ((RSIs2<RSI_Low_Trigger) and (DIMinus2>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 4, str.tostring(math.round(RSIs2,2)), text_halign=text.align_center, bgcolor= RSIs2>RSI_High_Trigger? color.green: RSIs2<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 4, str.tostring(math.round(DIPlus2,2)), text_halign=text.align_center, bgcolor=DIPlus2>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 4, str.tostring(math.round(DIMinus2,2)), text_halign=text.align_center, bgcolor=DIMinus2>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 4, str.tostring(math.round(ADX2,2)), text_halign=text.align_center, bgcolor=ADX2>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 5, text=symin3, text_halign=text.align_center, bgcolor=((RSIs3>RSI_High_Trigger) and (DIPlus3>adxlevel))? color.green: ((RSIs3<RSI_Low_Trigger) and (DIMinus3>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 5, str.tostring(math.round(RSIs3,2)), text_halign=text.align_center, bgcolor= RSIs3>RSI_High_Trigger? color.green: RSIs3<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 5, str.tostring(math.round(DIPlus3,2)), text_halign=text.align_center, bgcolor=DIPlus3>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 5, str.tostring(math.round(DIMinus3,2)), text_halign=text.align_center, bgcolor=DIMinus3>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 5, str.tostring(math.round(ADX3,2)), text_halign=text.align_center, bgcolor=ADX3>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 6, text=symin4, text_halign=text.align_center, bgcolor=((RSIs4>RSI_High_Trigger) and (DIPlus4>adxlevel))? color.green: ((RSIs4<RSI_Low_Trigger) and (DIMinus4>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 6, str.tostring(math.round(RSIs4,2)), text_halign=text.align_center, bgcolor= RSIs4>RSI_High_Trigger? color.green: RSIs4<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 6, str.tostring(math.round(DIPlus4,2)), text_halign=text.align_center, bgcolor=DIPlus4>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 6, str.tostring(math.round(DIMinus4,2)), text_halign=text.align_center, bgcolor=DIMinus4>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 6, str.tostring(math.round(ADX4,2)), text_halign=text.align_center, bgcolor=ADX4>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 7, text=symin7, text_halign=text.align_center, bgcolor=((RSIs7>RSI_High_Trigger) and (DIPlus7>adxlevel))? color.green: ((RSIs7<RSI_Low_Trigger) and (DIMinus7>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 7, str.tostring(math.round(RSIs7,2)), text_halign=text.align_center, bgcolor= RSIs7>RSI_High_Trigger? color.green: RSIs7<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 7, str.tostring(math.round(DIPlus7,2)), text_halign=text.align_center, bgcolor=DIPlus7>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 7, str.tostring(math.round(DIMinus7,2)), text_halign=text.align_center, bgcolor=DIMinus7>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 7, str.tostring(math.round(ADX7,2)), text_halign=text.align_center, bgcolor=ADX7>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 8, text=symin8, text_halign=text.align_center, bgcolor=((RSIs8>RSI_High_Trigger) and (DIPlus8>adxlevel))? color.green: ((RSIs8<RSI_Low_Trigger) and (DIMinus8>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 8, str.tostring(math.round(RSIs8,2)), text_halign=text.align_center, bgcolor= RSIs8>RSI_High_Trigger? color.green: RSIs8<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 8, str.tostring(math.round(DIPlus8,2)), text_halign=text.align_center, bgcolor=DIPlus8>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 8, str.tostring(math.round(DIMinus8,2)), text_halign=text.align_center, bgcolor=DIMinus8>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 8, str.tostring(math.round(ADX8,2)), text_halign=text.align_center, bgcolor=ADX8>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 9, text=symin5, text_halign=text.align_center, bgcolor=((RSIs5>RSI_High_Trigger) and (DIPlus5>adxlevel))? color.green: ((RSIs5<RSI_Low_Trigger) and (DIMinus5>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 9, str.tostring(math.round(RSIs5,2)), text_halign=text.align_center, bgcolor= RSIs5>RSI_High_Trigger? color.green: RSIs5<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 9, str.tostring(math.round(DIPlus5,2)), text_halign=text.align_center, bgcolor=DIPlus5>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 9, str.tostring(math.round(DIMinus5,2)), text_halign=text.align_center, bgcolor=DIMinus5>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 9, str.tostring(math.round(ADX5,2)), text_halign=text.align_center, bgcolor=ADX5>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 10, text=symin6, text_halign=text.align_center, bgcolor=((RSIs6>RSI_High_Trigger) and (DIPlus6>adxlevel))? color.green: ((RSIs6<RSI_Low_Trigger) and (DIMinus6>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 10, str.tostring(math.round(RSIs6,2)), text_halign=text.align_center, bgcolor= RSIs6>RSI_High_Trigger? color.green: RSIs6<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 10, str.tostring(math.round(DIPlus6,2)), text_halign=text.align_center, bgcolor=DIPlus6>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 10, str.tostring(math.round(DIMinus6,2)), text_halign=text.align_center, bgcolor=DIMinus6>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 10, str.tostring(math.round(ADX6,2)), text_halign=text.align_center, bgcolor=ADX6>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 0, 11, text=symin9, text_halign=text.align_center, bgcolor=((RSIs9>RSI_High_Trigger) and (DIPlus9>adxlevel))? color.green: ((RSIs9<RSI_Low_Trigger) and (DIMinus9>adxlevel))?color.red: color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 1, 11, str.tostring(math.round(RSIs9,2)), text_halign=text.align_center, bgcolor= RSIs9>RSI_High_Trigger? color.green: RSIs9<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 2, 11, str.tostring(math.round(DIPlus9,2)), text_halign=text.align_center, bgcolor=DIPlus9>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 3, 11, str.tostring(math.round(DIMinus9,2)), text_halign=text.align_center, bgcolor=DIMinus9>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // table.cell(indicatorTable, 4, 11, str.tostring(math.round(ADX9,2)), text_halign=text.align_center, bgcolor=ADX9>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 12, text="TCS", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 12, str.tostring(math.round(RSIs10,2)), text_halign=text.align_center, bgcolor= RSIs10>RSI_High_Trigger? color.green: RSIs10<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 2, 12, str.tostring(math.round(DIPlus10,2)), text_halign=text.align_center, bgcolor=DIPlus10>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 3, 12, str.tostring(math.round(DIMinus10,2)), text_halign=text.align_center, bgcolor=DIMinus10>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 4, 12, str.tostring(math.round(ADX10,2)), text_halign=text.align_center, bgcolor=ADX10>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 13, text="BAJFINANCE", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 13, str.tostring(math.round(RSIs11,2)), text_halign=text.align_center, bgcolor= RSIs11>RSI_High_Trigger? color.green: RSIs11<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 2, 13, str.tostring(math.round(DIPlus11,2)), text_halign=text.align_center, bgcolor=DIPlus11>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 3, 13, str.tostring(math.round(DIMinus11,2)), text_halign=text.align_center, bgcolor=DIMinus11>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 4, 13, str.tostring(math.round(ADX11,2)), text_halign=text.align_center, bgcolor=ADX11>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // // table.cell(indicatorTable, 0, 14, text="MARUTI", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 14, str.tostring(math.round(RSIs12,2)), text_halign=text.align_center, bgcolor= RSIs12>RSI_High_Trigger? color.green: RSIs12<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 2, 14, str.tostring(math.round(DIPlus12,2)), text_halign=text.align_center, bgcolor=DIPlus12>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 3, 14, str.tostring(math.round(DIMinus12,2)), text_halign=text.align_center, bgcolor=DIMinus12>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 4, 14, str.tostring(math.round(ADX12,2)), text_halign=text.align_center, bgcolor=ADX12>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 0, 15, text="DRREDDY", text_halign=text.align_center, bgcolor=color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 1, 15, str.tostring(math.round(RSIs13,2)), text_halign=text.align_center, bgcolor= RSIs13>RSI_High_Trigger? color.green: RSIs13<RSI_Low_Trigger?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 2, 15, str.tostring(math.round(DIPlus13,2)), text_halign=text.align_center, bgcolor=DIPlus13>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 3, 15, str.tostring(math.round(DIMinus13,2)), text_halign=text.align_center, bgcolor=DIMinus13>adxlevel?color.red:color.gray, text_color=color.white, text_size=size.small) // // table.cell(indicatorTable, 4, 15, str.tostring(math.round(ADX13,2)), text_halign=text.align_center, bgcolor=ADX13>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) // //table.cell(indicatorTable, 1, 1, str.tostring(math.round(plus,2)), text_halign=text.align_center, bgcolor=plus>adxlevel?color.green:color.gray, text_color=color.white, text_size=size.small) //study(title="DHL Cross over", shorttitle="PDHL Cross Over", overlay=true) D_High = request.security(syminfo.tickerid, 'D', high[1],lookahead=barmerge.lookahead_on) D_Low = request.security(syminfo.tickerid, 'D', low[1],lookahead=barmerge.lookahead_on) D_Close = request.security(syminfo.tickerid, 'D', close[1],lookahead=barmerge.lookahead_on) D_Open = request.security(syminfo.tickerid, 'D', open[1],lookahead=barmerge.lookahead_on) //len8 = input(14) cdo = request.security(syminfo.tickerid, 'D', open, lookahead=barmerge.lookahead_on) //pdc = request.security(syminfo.tickerid, 'D', close[1],lookahead=barmerge.lookahead_on ) //BRange = input.int(20, minval=0, title="Bull Bear Range eg NF25 BNF17") Range = ((cdo*BRange/10000)) //Range = ((D_High-D_Low)/BRange) + ((D_Open-D_Close)/BRange) //plot(isintraday ? D_High : na, title="Daily High",style=line, color=blue,linewidth=1) //plot(isintraday ? D_Low : na, title="Daily Low",style=line, color=blue,linewidth=1) // Written by Robert N. 030615 // Still looking for way to remove from previous days //study("Open/Close Daily Line", overlay=true) //odl = input(true, title="Open Daily Line") //dopen = request.security(syminfo.tickerid, 'D', open[0]) //dcolor = close < dopen ? color.red : color.green //plot(odl and dopen ? dopen :na , title="Daily_Open",style=plot.style_circles, color=dcolor, linewidth=3) //cdl = input(true, title="Previous Closing Daily Line") // dclose = request.security(syminfo.tickerid, 'D', close[1]) //dcolor2 = close < dclose ? red : green //plot(cdl and dclose ? dclose :na , title="Daily_Close",style=circles, color=dcolor2, linewidth=3) // daily_open(x) => // trigger = na(time("D")) or ta.change(time("D")) // ta.valuewhen(trigger, open, x) //plot(daily_open(0), "Daily Open", color.blue, 2, plot.style_circles) //key = if D_Open > D_Close // key = if cdo < D_Close // ((((((D_High*2)+D_Low+D_Close)/2)-D_High)+((((D_High*2)+D_Low+D_Close)/2)-D_Low))/2) // else // ((((((D_Low*2)+D_Low+D_Close)/2)-D_High)+((((D_Low*2)+D_Low+D_Close)/2)-D_Low))/2) //key = (cdo+pdc)/2 key = ((D_High-D_Low)/2) + ((D_Open+D_Close)/2) //POC = (dopen+dclose)/2 //poc = input(true, title="POC Line") //dcolor3 = close < POC ? color.red : color.green //plot(poc and POC ? POC :na , title="POC",style=circles, color=dcolor3, linewidth=3) //plot(POC, title="POC",style=plot.style_linebr, color=color.orange,linewidth=3) pocplot = plot(title='POC', style=plot.style_linebr,series=timeframe.isintraday ? key : na, linewidth=3, color= color.orange)//series=timeframe.isintraday ? key : na var label test =na test :=label.new (x=bar_index, y=key, text="POC/Key level",style = label.style_label_left) //test :=label.new (x=bar_index, y=key, text="Key level "+ str.tostring(key, format.mintick),style = label.style_label_left) label.delete(test[1]) //@version=5 //indicator("My script") //hline_price_1 = POC //hline(hline_price_1) //label hline_label_1 = label.new(bar_index, POC, text = "POC",textalign = text.align_left, style=label.style_none, textcolor=color.black) //label.delete(hline_label_1[1]) //plotshape(POC, style=shape.labelup, text="POC") //plot(daily_open(0), title="POC",style=plot.style_line, color=color.black,linewidth=2) //plot(dclose, title="POC",style=plot.style_line, color=color.black,linewidth=2) //x = position_labels == "Left" ? array.get(arr_time, i) : array.get(arr_time, i + 1) //label_style = position_labels == "Left" ? label.style_label_right : label.style_label_left //x = "left" //var label openLabel = label.new(x=bar_index, y=POC, text="POC/Key level", style = label.style_label_left, color=color.black, xloc=xloc.bar_index, yloc=yloc.price, size=size.small, textcolor = color.orange) //label.set_xy(openLabel, bar_index+2, POC) //label.set_style(id=openLabel, style=label.style_label_lower_left) //label.set_style(openLabel,label.style_label_left) //x = position_labels == "Left" ? array.get(arr_time, i) : array.get(arr_time, i + 1) // array.push(labels, label.new(x = x, y=y, text=display_text, textcolor=txt_color, style=label_style, color=#00000000, xloc=xloc.bar_time)) Bull = cdo+Range Bear = cdo-Range plot(Bull, title="Bull",style=plot.style_linebr, color=color.green,linewidth=3) plot(Bear, title="Bear",style=plot.style_linebr, color=color.red,linewidth=3) //plot(daily_open(0), title="Bear",style=plot.style_circles, color=color.black,linewidth=2) //plot(isintraday ? Range : na, title="R",style=line, color=orange,linewidth=2) //label_yh = label.new(Bull, text="PDHigh", style= label.style_none) //plot(open, title="Bull",style=plot.style_line, color=color.green,linewidth=2) var label BullLabel = label.new(x=bar_index, y=Bull, text="Bull Breakout", style = label.style_label_left ,color=color.black, xloc=xloc.bar_index, yloc=yloc.price, size=size.small, textcolor = color.green) label.set_xy(BullLabel, bar_index +2, Bull) var label BearLabel = label.new(x=bar_index, y=Bear, text="Bear Breakout", style = label.style_label_left, color=color.black, xloc=xloc.bar_index, yloc=yloc.price, size=size.small, textcolor = color.red) label.set_xy(BearLabel, bar_index +2, Bear) // //@version=5 // //indicator("Pivot Points Standard + Alerts V2", "Pivots + Alerts V2", overlay=true, max_lines_count=500, max_labels_count=500) // AUTO = "Auto" // DAILY = "Daily" // WEEKLY = "Weekly" // MONTHLY = "Monthly" // QUARTERLY = "Quarterly" // YEARLY = "Yearly" // BIYEARLY = "Biyearly" // TRIYEARLY = "Triyearly" // QUINQUENNIALLY = "Quinquennially" // DECENNIALLY = "Decennially" // TRADITIONAL = "Traditional" // FIBONACCI = "Fibonacci" // WOODIE = "Woodie" // CLASSIC = "Classic" // DEMARK = "DM" // CAMARILLA = "Camarilla" // ALERT_EVERYTIME = "Everytime" // ALERT_ONCE_PER_BAR = "Once Per Bar" // ALERT_ONCE_PER_BAR_CLOSE = "Once Per Bar Close" // kind = input.string(title="Type", defval="Traditional", options=[TRADITIONAL, FIBONACCI, WOODIE, CLASSIC, DEMARK, CAMARILLA]) // pivot_time_frame = input.string(title="Pivots Timeframe", defval=AUTO, options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY, QUINQUENNIALLY, DECENNIALLY]) // look_back = input.int(title="Number of Pivots Back", defval=15, minval=1, maxval=5000) // is_daily_based = input.bool(title="Use Daily-based Values", defval=true, tooltip="When this option is unchecked, Pivot Points will use intraday data while calculating on intraday charts. If Extended Hours are displayed on the chart, they will be taken into account during the pivot level calculation. If intraday OHLC values are different from daily-based values (normal for stocks), the pivot levels will also differ.") // show_labels = input.bool(title="Show Labels", defval=true, group="labels") // show_prices = input.bool(title="Show Prices", defval=false, group="labels") // position_labels = input.string("Left", "Labels Position", options=["Left", "Right"], group="labels") // line_width = input.int(title="Line Width", defval=1, minval=1, maxval=100, group="levels") // // alert_p = input.bool( false, "Alert on reaching P", group = "Alerts Options" ) // // alert_r5 = input.bool( false, "Alert on reaching R5", group = "Alerts Options" ) // // alert_r4 = input.bool( false, "Alert on reaching R4", group = "Alerts Options" ) // // alert_r3 = input.bool( false, "Alert on reaching R3", group = "Alerts Options" ) // // alert_r2 = input.bool( false, "Alert on reaching R2", group = "Alerts Options" ) // // alert_r1 = input.bool( false, "Alert on reaching R1", group = "Alerts Options" ) // // alert_s5 = input.bool( false, "Alert on reaching S5", group = "Alerts Options" ) // // alert_s4 = input.bool( false, "Alert on reaching S4", group = "Alerts Options" ) // // alert_s3 = input.bool( false, "Alert on reaching S3", group = "Alerts Options" ) // // alert_s2 = input.bool( false, "Alert on reaching S2", group = "Alerts Options" ) // // alert_s1 = input.bool( false, "Alert on reaching S1", group = "Alerts Options" ) // // alert_prev_low = input.bool( false, "Alert on Previous Day Low", group = "Alerts Options" ) // // alert_prev_high = input.bool( false, "Alert on Previous Day High", group = "Alerts Options" ) // // alert_freq = input.string(title="Alert Frequency", defval=ALERT_ONCE_PER_BAR, options=[ALERT_EVERYTIME, ALERT_ONCE_PER_BAR, ALERT_ONCE_PER_BAR_CLOSE], group = "Alerts Options") // // real_alert_frequency = alert_freq == ALERT_ONCE_PER_BAR ? alert.freq_once_per_bar : alert_freq == ALERT_ONCE_PER_BAR_CLOSE ? alert.freq_once_per_bar_close : alert.freq_all // var daily_high = high // var daily_low = low // var prev_day_high = 0.0 // var prev_day_low = 0.0 // var DEF_COLOR = #131313 // var DEF_COLOR1 = #00e804 // var DEF_COLOR2 = #fb0000 // var arr_time = array.new_int() // var p = array.new_float() // p_color = input.color(DEF_COLOR, "P‏ ‏ ‏", inline="P", group="levels") // p_show = input.bool(true, "", inline="P", group="levels") // var r1 = array.new_float() // var s1 = array.new_float() // s1_color = input.color(DEF_COLOR1, "S1", inline="S1/R1" , group="levels") // s1_show = input.bool(true, "", inline="S1/R1", group="levels") // r1_color = input.color(DEF_COLOR2, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R1", inline="S1/R1", group="levels") // r1_show = input.bool(true, "", inline="S1/R1", group="levels") // var r2 = array.new_float() // var s2 = array.new_float() // s2_color = input.color(DEF_COLOR1, "S2", inline="S2/R2", group="levels") // s2_show = input.bool(true, "", inline="S2/R2", group="levels") // r2_color = input.color(DEF_COLOR2, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R2", inline="S2/R2", group="levels") // r2_show = input.bool(true, "", inline="S2/R2", group="levels") // var r3 = array.new_float() // var s3 = array.new_float() // s3_color = input.color(DEF_COLOR1, "S3", inline="S3/R3", group="levels") // s3_show = input.bool(true, "", inline="S3/R3", group="levels") // r3_color = input.color(DEF_COLOR2, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R3", inline="S3/R3", group="levels") // r3_show = input.bool(true, "", inline="S3/R3", group="levels") // var r4 = array.new_float() // var s4 = array.new_float() // s4_color = input.color(DEF_COLOR1, "S4", inline="S4/R4", group="levels") // s4_show = input.bool(true, "", inline="S4/R4", group="levels") // r4_color = input.color(DEF_COLOR2, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R4", inline="S4/R4", group="levels") // r4_show = input.bool(true, "", inline="S4/R4", group="levels") // var r5 = array.new_float() // var s5 = array.new_float() // s5_color = input.color(DEF_COLOR1, "S5", inline="S5/R5", group="levels") // s5_show = input.bool(true, "", inline="S5/R5", group="levels") // r5_color = input.color(DEF_COLOR2, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R5", inline="S5/R5", group="levels") // r5_show = input.bool(true, "", inline="S5/R5", group="levels") // pivotX_open = float(na) // pivotX_open := nz(pivotX_open[1], open) // pivotX_high = float(na) // pivotX_high := nz(pivotX_high[1], high) // pivotX_low = float(na) // pivotX_low := nz(pivotX_low[1], low) // pivotX_prev_open = float(na) // pivotX_prev_open := nz(pivotX_prev_open[1]) // pivotX_prev_high = float(na) // pivotX_prev_high := nz(pivotX_prev_high[1]) // pivotX_prev_low = float(na) // pivotX_prev_low := nz(pivotX_prev_low[1]) // pivotX_prev_close = float(na) // pivotX_prev_close := nz(pivotX_prev_close[1]) // get_pivot_resolution() => // resolution = "M" // if pivot_time_frame == AUTO // if timeframe.isintraday // resolution := timeframe.multiplier <= 15 ? "D" : "W" // else if timeframe.isweekly or timeframe.ismonthly // resolution := "12M" // else if pivot_time_frame == DAILY // resolution := "D" // else if pivot_time_frame == WEEKLY // resolution := "W" // else if pivot_time_frame == MONTHLY // resolution := "M" // else if pivot_time_frame == QUARTERLY // resolution := "3M" // else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or pivot_time_frame == DECENNIALLY // resolution := "12M" // resolution // var lines = array.new_line() // var labels = array.new_label() // draw_line(i, pivot, col) => // if array.size(arr_time) > 1 // array.push(lines, line.new(array.get(arr_time, i), array.get(pivot, i), array.get(arr_time, i + 1), array.get(pivot, i), color=col, xloc=xloc.bar_time, width=line_width)) // draw_label(i, y, txt, txt_color) => // if (show_labels or show_prices) and not na(y) // display_text = (show_labels ? txt : "") + (show_prices ? str.format(" ({0})", math.round_to_mintick(y)) : "") // label_style = position_labels == "Left" ? label.style_label_right : label.style_label_left // x = position_labels == "Left" ? array.get(arr_time, i) : array.get(arr_time, i + 1) // array.push(labels, label.new(x = x, y=y, text=display_text, textcolor=txt_color, style=label_style, color=#00000000, xloc=xloc.bar_time)) // traditional() => // pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 // array.push(p, pivotX_Median) // array.push(r1, pivotX_Median * 2 - pivotX_prev_low) // array.push(s1, pivotX_Median * 2 - pivotX_prev_high) // array.push(r2, pivotX_Median + 1 * (pivotX_prev_high - pivotX_prev_low)) // array.push(s2, pivotX_Median - 1 * (pivotX_prev_high - pivotX_prev_low)) // array.push(r3, pivotX_Median * 2 + (pivotX_prev_high - 2 * pivotX_prev_low)) // array.push(s3, pivotX_Median * 2 - (2 * pivotX_prev_high - pivotX_prev_low)) // array.push(r4, pivotX_Median * 3 + (pivotX_prev_high - 3 * pivotX_prev_low)) // array.push(s4, pivotX_Median * 3 - (3 * pivotX_prev_high - pivotX_prev_low)) // array.push(r5, pivotX_Median * 4 + (pivotX_prev_high - 4 * pivotX_prev_low)) // array.push(s5, pivotX_Median * 4 - (4 * pivotX_prev_high - pivotX_prev_low)) // fibonacci() => // pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 // pivot_range = pivotX_prev_high - pivotX_prev_low // array.push(p, pivotX_Median) // array.push(r1, pivotX_Median + 0.382 * pivot_range) // array.push(s1, pivotX_Median - 0.382 * pivot_range) // array.push(r2, pivotX_Median + 0.618 * pivot_range) // array.push(s2, pivotX_Median - 0.618 * pivot_range) // array.push(r3, pivotX_Median + 1 * pivot_range) // array.push(s3, pivotX_Median - 1 * pivot_range) // woodie() => // pivotX_Woodie_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_open * 2)/4 // pivot_range = pivotX_prev_high - pivotX_prev_low // array.push(p, pivotX_Woodie_Median) // array.push(r1, pivotX_Woodie_Median * 2 - pivotX_prev_low) // array.push(s1, pivotX_Woodie_Median * 2 - pivotX_prev_high) // array.push(r2, pivotX_Woodie_Median + 1 * pivot_range) // array.push(s2, pivotX_Woodie_Median - 1 * pivot_range) // pivot_point_r3 = pivotX_prev_high + 2 * (pivotX_Woodie_Median - pivotX_prev_low) // pivot_point_s3 = pivotX_prev_low - 2 * (pivotX_prev_high - pivotX_Woodie_Median) // array.push(r3, pivot_point_r3) // array.push(s3, pivot_point_s3) // array.push(r4, pivot_point_r3 + pivot_range) // array.push(s4, pivot_point_s3 - pivot_range) // classic() => // pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close)/3 // pivot_range = pivotX_prev_high - pivotX_prev_low // array.push(p, pivotX_Median) // array.push(r1, pivotX_Median * 2 - pivotX_prev_low) // array.push(s1, pivotX_Median * 2 - pivotX_prev_high) // array.push(r2, pivotX_Median + 1 * pivot_range) // array.push(s2, pivotX_Median - 1 * pivot_range) // array.push(r3, pivotX_Median + 2 * pivot_range) // array.push(s3, pivotX_Median - 2 * pivot_range) // array.push(r4, pivotX_Median + 3 * pivot_range) // array.push(s4, pivotX_Median - 3 * pivot_range) // demark() => // pivotX_Demark_X = pivotX_prev_high + pivotX_prev_low * 2 + pivotX_prev_close // if pivotX_prev_close == pivotX_prev_open // pivotX_Demark_X := pivotX_prev_high + pivotX_prev_low + pivotX_prev_close * 2 // if pivotX_prev_close > pivotX_prev_open // pivotX_Demark_X := pivotX_prev_high * 2 + pivotX_prev_low + pivotX_prev_close // array.push(p, pivotX_Demark_X / 4) // array.push(r1, pivotX_Demark_X / 2 - pivotX_prev_low) // array.push(s1, pivotX_Demark_X / 2 - pivotX_prev_high) // camarilla() => // pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 // pivot_range = pivotX_prev_high - pivotX_prev_low // array.push(p, pivotX_Median) // array.push(r1, pivotX_prev_close + pivot_range * 1.1 / 12.0) // array.push(s1, pivotX_prev_close - pivot_range * 1.1 / 12.0) // array.push(r2, pivotX_prev_close + pivot_range * 1.1 / 6.0) // array.push(s2, pivotX_prev_close - pivot_range * 1.1 / 6.0) // array.push(r3, pivotX_prev_close + pivot_range * 1.1 / 4.0) // array.push(s3, pivotX_prev_close - pivot_range * 1.1 / 4.0) // array.push(r4, pivotX_prev_close + pivot_range * 1.1 / 2.0) // array.push(s4, pivotX_prev_close - pivot_range * 1.1 / 2.0) // r5_val = pivotX_prev_high / pivotX_prev_low * pivotX_prev_close // array.push(r5, r5_val) // array.push(s5, 2 * pivotX_prev_close - r5_val) // calc_pivot() => // if kind == TRADITIONAL // traditional() // else if kind == FIBONACCI // fibonacci() // else if kind == WOODIE // woodie() // else if kind == CLASSIC // classic() // else if kind == DEMARK // demark() // else if kind == CAMARILLA // camarilla() // resolution = get_pivot_resolution() // SIMPLE_DIVISOR = -1 // custom_years_divisor = switch pivot_time_frame // BIYEARLY => 2 // TRIYEARLY => 3 // QUINQUENNIALLY => 5 // DECENNIALLY => 10 // => SIMPLE_DIVISOR // calc_high(prev, curr) => // if na(prev) or na(curr) // nz(prev, nz(curr, na)) // else // math.max(prev, curr) // calc_low(prev, curr) => // if not na(prev) and not na(curr) // math.min(prev, curr) // else // nz(prev, nz(curr, na)) // calc_OHLC_for_pivot(custom_years_divisor) => // if custom_years_divisor == SIMPLE_DIVISOR // [open, high, low, close, open[1], high[1], low[1], close[1], time[1], time_close] // else // var prev_sec_open = float(na) // var prev_sec_high = float(na) // var prev_sec_low = float(na) // var prev_sec_close = float(na) // var prev_sec_time = int(na) // var curr_sec_open = float(na) // var curr_sec_high = float(na) // var curr_sec_low = float(na) // var curr_sec_close = float(na) // if year(time_close) % custom_years_divisor == 0 // curr_sec_open := open // curr_sec_high := high // curr_sec_low := low // curr_sec_close := close // prev_sec_high := high[1] // prev_sec_low := low[1] // prev_sec_close := close[1] // prev_sec_time := time[1] // for i = 2 to custom_years_divisor // prev_sec_open := nz(open[i], prev_sec_open) // prev_sec_high := calc_high(prev_sec_high, high[i]) // prev_sec_low := calc_low(prev_sec_low, low[i]) // prev_sec_time := nz(time[i], prev_sec_time) // [curr_sec_open, curr_sec_high, curr_sec_low, curr_sec_close, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time, time_close] // // store previous day low and high at next market day start // if timeframe.change( "1D") // prev_day_high := daily_high // prev_day_low := daily_low // daily_high := high // daily_low := low // // update daily high and low // if high > daily_high // daily_high := high // if low < daily_low // daily_low := low // plot( prev_day_high, "Prev Day High", color.aqua ) // plot( prev_day_low, "Prev Day Low", color.maroon ) // [sec_open, sec_high, sec_low, sec_close, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time, sec_time] = request.security(syminfo.tickerid, resolution, calc_OHLC_for_pivot(custom_years_divisor), lookahead = barmerge.lookahead_on) // sec_open_gaps_on = request.security(syminfo.tickerid, resolution, open, gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on) // is_change_years = custom_years_divisor > 0 and ta.change(time(resolution)) and year(time_close) % custom_years_divisor == 0 // var is_change = false // var uses_current_bar = timeframe.isintraday and kind == WOODIE // var change_time = int(na) // is_time_change = (ta.change(time(resolution)) and custom_years_divisor == SIMPLE_DIVISOR) or is_change_years // if is_time_change // change_time := time // var start_time = time // var was_last_premarket = false // var start_calculate_in_premarket = false // is_last_premarket = barstate.islast and session.ispremarket and time_close > sec_time and not was_last_premarket // if is_last_premarket // was_last_premarket := true // start_calculate_in_premarket := true // if session.ismarket // was_last_premarket := false // without_time_change = barstate.islast and array.size(arr_time) == 0 // is_can_calc_pivot = (not uses_current_bar and is_time_change and session.ismarket) or (ta.change(sec_open) and not start_calculate_in_premarket) or is_last_premarket or (uses_current_bar and not na(sec_open_gaps_on)) or without_time_change // enough_bars_for_calculate = prev_sec_time >= start_time or is_daily_based // if is_can_calc_pivot and enough_bars_for_calculate // if array.size(arr_time) == 0 and is_daily_based // pivotX_prev_open := prev_sec_open[1] // pivotX_prev_high := prev_sec_high[1] // pivotX_prev_low := prev_sec_low[1] // pivotX_prev_close := prev_sec_close[1] // pivotX_open := sec_open[1] // pivotX_high := sec_high[1] // pivotX_low := sec_low[1] // array.push(arr_time, start_time) // calc_pivot() // if is_daily_based // if is_last_premarket // pivotX_prev_open := sec_open // pivotX_prev_high := sec_high // pivotX_prev_low := sec_low // pivotX_prev_close := sec_close // pivotX_open := open // pivotX_high := high // pivotX_low := low // else // pivotX_prev_open := prev_sec_open // pivotX_prev_high := prev_sec_high // pivotX_prev_low := prev_sec_low // pivotX_prev_close := prev_sec_close // pivotX_open := sec_open // pivotX_high := sec_high // pivotX_low := sec_low // else // pivotX_prev_high := pivotX_high // pivotX_prev_low := pivotX_low // pivotX_prev_open := pivotX_open // pivotX_prev_close := close[1] // pivotX_open := open // pivotX_high := high // pivotX_low := low // if barstate.islast and not is_change and array.size(arr_time) > 0 and not without_time_change // array.set(arr_time, array.size(arr_time) - 1, change_time) // else if without_time_change // array.push(arr_time, start_time) // else // array.push(arr_time, nz(change_time, time)) // calc_pivot() // if array.size(arr_time) > look_back // if array.size(arr_time) > 0 // array.shift(arr_time) // if array.size(p) > 0 and p_show // array.shift(p) // if array.size(r1) > 0 and r1_show // array.shift(r1) // if array.size(s1) > 0 and s1_show // array.shift(s1) // if array.size(r2) > 0 and r2_show // array.shift(r2) // if array.size(s2) > 0 and s2_show // array.shift(s2) // if array.size(r3) > 0 and r3_show // array.shift(r3) // if array.size(s3) > 0 and s3_show // array.shift(s3) // if array.size(r4) > 0 and r4_show // array.shift(r4) // if array.size(s4) > 0 and s4_show // array.shift(s4) // if array.size(r5) > 0 and r5_show // array.shift(r5) // if array.size(s5) > 0 and s5_show // array.shift(s5) // is_change := true // else if not is_daily_based // pivotX_high := math.max(pivotX_high, high) // pivotX_low := math.min(pivotX_low, low) // if barstate.islast and not is_daily_based and array.size(arr_time) == 0 // runtime.error("Not enough intraday data to calculate Pivot Points. Lower the Pivots Timeframe or turn on the 'Use Daily-based Values' option in the indicator settings.") // // if array.size(arr_time) > 0 // // //label.new(bar_index, high, text = "close " + str.tostring(close) + ",p " + str.tostring( array.get( p, array.size(p) - 1 ) ) + ",s2 " + str.tostring( array.get( s2, array.size(s2) - 1 ) ) + ",s1x " + str.tostring(ta.cross( array.get(s1, array.size(s1) - 1 ), close )), color = color.white, textcolor = color.black ) // // if array.size(p) > 0 // // if ta.cross( array.get(p, array.size(p) - 1 ), close ) and alert_p // // alert("Price crossed over P level.", real_alert_frequency) // // if array.size(s1) > 0 // // if ta.cross( array.get(s1, array.size(s1) - 1 ), close ) and alert_s1 // // alert("Price crossed over S1 level.", real_alert_frequency) // // if array.size(s2) > 0 // // if ta.cross( array.get(s2, array.size(s2) - 1 ), close ) and alert_s2 // // alert("Price crossed over S2 level.", real_alert_frequency) // // if array.size(s3) > 0 // // if ta.cross( array.get(s3, array.size(s3) - 1 ), close ) and alert_s3 // // alert("Price crossed over S3 level.", real_alert_frequency) // // if array.size(s4) > 0 // // if ta.cross( array.get(s4, array.size(s4) - 1 ), close ) and alert_s4 // // alert("Price crossed over S4 level.", real_alert_frequency) // // if array.size(s5) > 0 // // if ta.cross( array.get(s5, array.size(s5) - 1 ), close ) and alert_s5 // // alert("Price crossed over S5 level.", real_alert_frequency) // // if array.size(r1) > 0 // // if ta.cross( array.get(r1, array.size(r1) - 1 ), close ) and alert_r1 // // alert("Price crossed over R1 level.", real_alert_frequency) // // if array.size(r2) > 0 // // if ta.cross( array.get(r2, array.size(r2) - 1 ), close ) and alert_r2 // // alert("Price crossed over R2 level.", real_alert_frequency) // // if array.size(r3) > 0 // // if ta.cross( array.get(r3, array.size(r3) - 1 ), close ) and alert_r3 // // alert("Price crossed over R3 level.", real_alert_frequency) // // if array.size(r4) > 0 // // if ta.cross( array.get(r4, array.size(r4) - 1 ), close ) and alert_r4 // // alert("Price crossed over R4 level.", real_alert_frequency) // // if array.size(r5) > 0 // // if ta.cross( array.get(r5, array.size(r5) - 1 ), close ) and alert_r5 // // alert("Price crossed over R5 level.", real_alert_frequency) // // // previous day high/low // // if ta.cross( prev_day_low, close ) and alert_prev_low // // alert("Price crossed over Previous Day Low.", real_alert_frequency) // // if ta.cross( prev_day_high, close ) and alert_prev_high // // alert("Price crossed over Previous Day High.", real_alert_frequency) // if barstate.islast and array.size(arr_time) > 0 and is_change // is_change := false // if custom_years_divisor > 0 // last_pivot_time = array.get(arr_time, array.size(arr_time) - 1) // pivot_timeframe = str.tostring(12 * custom_years_divisor) + "M" // estimate_pivot_time = last_pivot_time + timeframe.in_seconds(pivot_timeframe) * 1000 // array.push(arr_time, estimate_pivot_time) // else // array.push(arr_time, time_close(resolution)) // for i = 0 to array.size(lines) - 1 // if array.size(lines) > 0 // line.delete(array.shift(lines)) // if array.size(labels) > 0 // label.delete(array.shift(labels)) // for i = 0 to array.size(arr_time) - 2 // if array.size(p) > 0 and p_show // draw_line(i, p, p_color) // draw_label(i, array.get(p, i), "P", p_color) // if array.size(r1) > 0 and r1_show // draw_line(i, r1, r1_color) // draw_label(i, array.get(r1, i), "R1", r1_color) // if array.size(s1) > 0 and s1_show // draw_line(i, s1, s1_color) // draw_label(i, array.get(s1, i), "S1", s1_color) // if array.size(r2) > 0 and r2_show // draw_line(i, r2, r2_color) // draw_label(i, array.get(r2, i), "R2", r2_color) // if array.size(s2) > 0 and s2_show // draw_line(i, s2, s2_color) // draw_label(i, array.get(s2, i), "S2", s2_color) // if array.size(r3) > 0 and r3_show // draw_line(i, r3, r3_color) // draw_label(i, array.get(r3, i), "R3", r3_color) // if array.size(s3) > 0 and s3_show // draw_line(i, s3, s3_color) // draw_label(i, array.get(s3, i), "S3", s3_color) // if array.size(r4) > 0 and r4_show // draw_line(i, r4, r4_color) // draw_label(i, array.get(r4, i), "R4", r4_color) // if array.size(s4) > 0 and s4_show // draw_line(i, s4, s4_color) // draw_label(i, array.get(s4, i), "S4", s4_color) // if array.size(r5) > 0 and r5_show // draw_line(i, r5, r5_color) // draw_label(i, array.get(r5, i), "R5", r5_color) // if array.size(s5) > 0 and s5_show // draw_line(i, s5, s5_color) // draw_label(i, array.get(s5, i), "S5", s5_color) // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © VishvaP //@version=5 //indicator("34 EMA Bands", overlay = true) //Constants //EMA_HTF = input.int(33, title="EMA HTF", minval=1, maxval=100) h_EMA = ta.ema(high, EMA_HTF) l_EMA = ta.ema(low, EMA_HTF) EMA = ta.ema(close, EMA_HTF) //Multi Timeframe //res = input.timeframe(defval='240', title="Timeframe") h_EMAres = request.security(syminfo.tickerid, res, h_EMA) l_EMAres = request.security(syminfo.tickerid, res, l_EMA) EMAres = request.security(syminfo.tickerid, res, EMA) // //Lower reversion zone bands // b_High = ((h_EMAres - EMAres) * math.phi) * math.pi + EMAres // b_Low = (-(EMAres - l_EMAres) * math.phi) * math.pi + EMAres // //Lower reversion zone bands smoothed // b_High_S = ta.wma(b_High, 8) // b_Low_S = ta.wma(b_Low, 8) // //Higher reversion zone bands // phi_High = ((h_EMAres - EMAres) * math.phi) * (math.phi + 4) + EMAres // phi_Low = (-(EMAres - l_EMAres) * math.phi) * (math.phi + 4) + EMAres // //Higher reversion zone bands smoothed // phi_High_S = ta.wma(phi_High, 8) // phi_Low_S = ta.wma(phi_Low, 8) // // //====================================================================================================// // //Median zone bands [plot] highP1 = plot(h_EMAres, color = color.blue, title = "Top median zone", display=display.none) lowP1 = plot(l_EMAres, color = color.blue, title = "Bottom median zone", display=display.none) // //Lower reversion zone bands [plot] // highP3 = plot(b_High_S, color = color.yellow, title = "Lower sell zone", display=display.none) // lowP3 = plot(b_Low_S, color = color.teal, title = "Higher buy zone", display=display.none) // //Higher reversion zone bands [plot] // phiPlotHigh = plot(phi_High_S, color = color.red, title = "Top sell zone") // phiPlotLow = plot(phi_Low_S, color = color.green, title = "Bottom buy zone") // //Sell zone region [fill] // fill(phiPlotHigh, highP3, color.new(color.red, 95), title = "Sell zone") // //Buy zone region [fill] // fill(lowP3, phiPlotLow, color.new(color.green, 95), title = "Buy zone") //Median zone region [fill] fill(highP1, lowP1, color.new(color.black, 85), title = "Median zone") // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © liquid-trader // This script plots, and auto-updates, 3 separate VWAPs: a traditional VWAP, a VWAP anchored to a trends high, // and another anchored to a trends low. Because VWAP is a prominent market maker tool for executing large trades, // day traders can use it to better anticipate trends, mean reversion, and breakouts. // More here: https://www.tradingview.com/script/72stxVxI-Anchored-VWAP-Auto-High-Low/ //@version=5 //indicator("Anchored VWAP (Auto High & Low)", "AVWAP (Auto Hi / Lo)", overlay=true, max_bars_back=0) max_bars_back(time, 1440) // Base Colors none = color.new(color.black, 100), clr1 = color.aqua // Groups g1 = "Anchored VWAP", g2 = "Normal VWAP" // // High Anchor // shoHiA = input.bool(false, "High Anchor           ", "VWAP anchored and weighted to trend highs.", inline="hi", group=g1, display=display.none) // hiAnClr = input.color(clr1, "", inline="hi", group=g1, display=display.none) // hiWidth = input.int(2, "", 1, inline="hi", group=g1, display=display.none) // // Low Anchor // shoLoA = input.bool(false, "Low Anchor            ", "VWAP anchored and weighted to trend lows.", inline="lo", group=g1, display=display.none) // loAnClr = input.color(clr1, "", inline="lo", group=g1, display=display.none) // loWidth = input.int(2, "", 1, inline="lo", group=g1, display=display.none) // // Average of Anchors // shoMid = input.bool(false, "Avg. of Anchors     ", "The mean (average) between the high and low anchored VWAP's", inline="mid", group=g1, display=display.none) // midClr = input.color(color.new(clr1, 50), "", inline="mid", group=g1, display=display.none) // mWidth = input.int(2, "", 1, inline="mid", group=g1, display=display.none) // // Quarter levels // shoQrt = input.bool(false, "Quarter Values       ", "The median (middle) value between the mean (average) and high / low anchors.", inline="quarter", group=g1, display=display.none) // qrtClr = input.color(color.new(clr1, 80), "", inline="quarter", group=g1, display=display.none) // qWidth = input.int(1,"", 1, inline="quarter", group=g1, display=display.none) // // High eighth levels with fill // shoHiFil = input.bool(false, "High Interim Bands", inline="hiFill", group=g1, display=display.none) // hiEthClr = input.color(color.new(clr1, 93), "", inline="hiFill", group=g1, display=display.none) // hiFilClr = input.color(color.new(clr1, 97), "", inline="hiFill", group=g1, display=display.none) // // Low eighth levels with fill // shoLoFil = input.bool(false, "Low Interim Bands ", inline="loFill", group=g1, display=display.none) // loEthClr = input.color(color.new(clr1, 93), "", inline="loFill", group=g1, display=display.none) // loFilClr = input.color(color.new(clr1, 97), "", inline="loFill", group=g1, display=display.none) // Smooth Average of Anchors //shoMA = input.bool(false, "Smooth Average    ", inline="smooth", group=g1, display=display.none) //maSrc = input.string("SMMA (RMA)", "", ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA", "Linear Regression"], inline="smooth", group=g1, display=display.none) //maLen = input.int(3, "", 1, inline="smooth", group=g1, display=display.none) // Anchor Reset Settings sessionLimited = input.bool(false, "Limit anchor session continuation to ", "Defines when a given anchor should be reset if its VWAP has not been broken, measured in sessions.", inline="reset", group=g1, display=display.none) anchorMax = input.int(1, "", 1, inline="reset", group=g1, display=display.none) mktHrsOnly = input.bool(false, "Limit anchor resets to only regular trading hours and new sessions.", "Prevents a given VWAP from resetting afhours, overnight, or during the premarket.", group=g1, display=display.none) // 1 Day VWAP O = "open", H = "high", L = "low", C = "close", HL2 = "hl2", HLC3 = "hlc3", OHLC4 = "ohlc4", HLCC4 = "hlcc4" shoVWAP = input.bool(true, "VWAP", "The Volume Weighted Average Price is reset at the beginning of each session.", inline="vwap1", group=g2, display=display.none) vwap1Clr = input.color(color.blue, "", inline="vwap1", group=g2, display=display.none) vWidth1 = input.int(2, "", 1, inline="vwap1", group=g2, display=display.none) source1 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap1", group=g2, display=display.none) // 2 Day VWAP shoDay2 = input.bool(true, "Day 2 ", "Continuation of VWAP into a second day.", inline="vwap2", group=g2, display=display.none) vwap2Clr = input.color(color.new(color.teal, 25), "", inline="vwap2", group=g2, display=display.none) vWidth2 = input.int(2, "", 1, inline="vwap2", group=g2, display=display.none) source2 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap2", group=g2, display=display.none) // 3 Day VWAP shoDay3 = input.bool(true, "Day 3 ", "Continuation of VWAP into a third day.", inline="vwap3", group=g2, display=display.none) vwap3Clr = input.color(color.new(color.red, 50), "", inline="vwap3", group=g2, display=display.none) vWidth3 = input.int(2, "", 1, inline="vwap3", group=g2, display=display.none) source3 = input.string(HLC3, "", [O,H,L,C,HL2, HLC3, OHLC4, HLCC4], inline="vwap3", group=g2, display=display.none) // Market Hours Settings mktHrs = input.session("0930-1600", "Start / End Time", tooltip = "A 24 hour format, where 0930 is 9:30 AM, 1600 is 4:00 PM, etc.", group="Market Hours", inline="mkt", display=display.none) zone = input("America/New_York", "Time Zone          ", "Any IANA time zone ID. Ex: America/New_York\n\nYou can also use \"syminfo.timezone\", which inherits the time zone of the exchange of the chart.", group="Market Hours", inline="zone", display=display.none) timezone = zone == "syminfo.timezone" ? syminfo.timezone : zone minutesInDay = "1440", marketHours = time(minutesInDay, mktHrs, timezone) // Put colors into an array. //colors = array.from(hiAnClr, loAnClr, midClr, qrtClr, hiEthClr, loEthClr, hiFilClr, loFilClr) // Define new sessions. newSession = timeframe.isdwm ? false : session.isfirstbar // Set core variables. o = open, h = high, l = low, c = close, index = bar_index // Define candle patterns and parts. candleBody = math.abs( c - o ) rising = c > o falling = o > c upWick = rising ? h - c : h - o dnWick = falling ? c - l : o - l doji = (upWick >= candleBody or dnWick >= candleBody) and (h != o and h != c and l != o and l != c) higher = o > o[1] and c > c[1] lower = o < o[1] and c < c[1] risingHigher = rising and higher fallingLower = falling and lower // Anchor variables. var hi = h, var lo = l, var anchoredHi = h, var anchoredLo = l, var hrH = h, var hrL = l, var lrH = h, var lrL = l var resetHiAnchor = false, var resetLoAnchor = false, var bullish = false, var bearish = false var hiSessionCount = 0, var loSessionCount = 0 // Logic for what qualifies as "breaking" the previous anchors. breakingHigher = rising and (c > hi or (c[1] > anchoredHi and c > h[1] and o > anchoredHi and not doji)) breakingLower = falling and (c < lo or (c[1] < anchoredLo and c < l[1] and o < anchoredLo and not doji)) // Logic for when to reset anchors. if newSession and sessionLimited hiSessionCount += 1, loSessionCount += 1 if hiSessionCount == anchorMax hiSessionCount := 0 hi := h, hrH := h, hrL := l resetHiAnchor := true bullish := true if loSessionCount == anchorMax loSessionCount := 0 lo := l, lrH := h, lrL := l resetLoAnchor := true bearish := true else if breakingHigher and (not mktHrsOnly or (marketHours and marketHours)) hiSessionCount := 0 hi := h, hrH := h, hrL := l resetHiAnchor := true bullish := true else if breakingLower and (not mktHrsOnly or (marketHours and marketHours)) loSessionCount := 0 lo := l, lrH := h, lrL := l resetLoAnchor := true bearish := true else resetHiAnchor := false resetLoAnchor := false // Set the Anchored VWAP, and their average. anchoredHi := ta.vwap(h, resetHiAnchor) anchoredLo := ta.vwap(l, resetLoAnchor) anchoredMean = math.avg(anchoredHi, anchoredLo) // // Smooth the average according to the traders settings. // if shoMA // anchoredMean := switch maSrc // "SMA" => ta.sma(anchoredMean, maLen) // "EMA" => ta.ema(anchoredMean, maLen) // "SMMA (RMA)" => ta.rma(anchoredMean, maLen) // "WMA" => ta.wma(anchoredMean, maLen) // "VWMA" => ta.vwma(anchoredMean, maLen) // "Linear Regression" => ta.linreg(anchoredMean, maLen, 0) // // Set the anchored quarter values. // avg75 = math.avg(anchoredHi, anchoredMean), avg87 = math.avg(anchoredHi, avg75), avg62 = math.avg(anchoredMean, avg75) // avg25 = math.avg(anchoredLo, anchoredMean), avg12 = math.avg(anchoredLo, avg25), avg42 = math.avg(anchoredMean, avg25) // Function to get a price. price(a) => switch a O => open H => high L => low C => close HL2 => hl2 HLC3 => hlc3 OHLC4 => ohlc4 HLCC4 => hlcc4 // Function to get yesterdays total volume. ydVol() => request.security(syminfo.tickerid, "1D", volume) // Initialize variables for the VWAP handoff. var vwap1D = 0., var handoff = array.new_float(4, 0) // Handoff VWAP values from the previous day. if newSession handoff.unshift(ydVol()), handoff.pop() handoff.unshift(vwap1D), handoff.pop() // Calc VWAP continuation beyond the first day. for i = 0 to handoff.size() / 2 - 1 j = i * 2 vwap = handoff.get(j) src = switch i 0 => source2 1 => source3 vol = volume cvol = handoff.get(j + 1) newV = cvol + vol newP = (vwap * cvol + price(src) * vol) / newV handoff.set(j, newP) handoff.set(j + 1, newV) // Set VWAP value. vwap1D := ta.vwap(price(source1), timeframe.change("1D")) // Set VWAP colors. v1Clr = newSession ? none : vwap1Clr v2Clr = newSession ? none : vwap2Clr v3Clr = newSession ? none : vwap3Clr // Plot VWAPs plot(vwap1D, "1 Day VWAP", v1Clr, vWidth1, plot.style_linebr, false, na, na, na, false, na, shoVWAP ? display.pane : display.none) plot(handoff.get(0), "2 Day VWAP", v2Clr, vWidth2, plot.style_linebr, false, na, na, na, false, na, shoDay2 ? display.pane : display.none) plot(handoff.get(2), "3 Day VWAP", v3Clr, vWidth3, plot.style_linebr, false, na, na, na, false, na, shoDay3 ? display.pane : display.none) // Function defining abnormal candle move continuation. // moveCont(d) => // switch d // "up" => anchoredHi >= anchoredHi[1] or hlcc4 > avg87 // "dn" => anchoredLo <= anchoredLo[1] or hlcc4 < avg12 // // Function defining candle consolidation, relative to the previous anchor. // consolidating(d, resetHi, resetLo) => doji or (o <= resetHi and c <= resetHi and o >= resetLo and c >= resetLo) // // Set the plot and fill colors. // var clr = array.new_color(colors.size()) // for i = 0 to colors.size() - 1 // _c_ = colors.get(i) // _ifTrue_ = switch i // 0 => bullish and (resetHiAnchor or moveCont("up") or consolidating("up", hrH, hrL)) // 1 => bearish and (resetLoAnchor or moveCont("dn") or consolidating("dn", lrH, lrL)) // => false // clr.set(i, newSession ? none : _ifTrue_ ? color.new(_c_, 75) : _c_) // // Toggle the colors reset to be false, if it has been reset back to the user specified color. // bullish := clr.get(0) == hiAnClr ? false : bullish // bearish := clr.get(1) == loAnClr ? false : bearish // // Functions to determine if a plot or fill should display, based on the traders settings. // displayPlot(ifTrue) => ifTrue ? display.pane : display.none // displayFill(ifTrue) => ifTrue ? display.all : display.none // Plot the top, bottom, and average anchor values. // top = plot(anchoredHi, "High Anchor", clr.get(0), hiWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoHiA)) // bot = plot(anchoredLo, "Low Anchor", clr.get(1), loWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoLoA)) // mid = plot(anchoredMean, "Average of Anchors", clr.get(2), mWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoMid)) // Plot 1/4 values (half way between average and anchor). // t25 = plot(avg75, "Top 25% Line", clr.get(3), qWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoQrt)) // b25 = plot(avg25, "Bottom 25% Line", clr.get(3), qWidth, plot.style_linebr, false, na, na, na, false, na, displayPlot(shoQrt)) // Plot 1/8 lines. // showHideTopLine = displayPlot(shoHiFil) // showHideBotLine = displayPlot(shoLoFil) // t12 = plot(avg87, "Top 12.5% Line",clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) // t252 = plot(avg75, "Top 25% Line", clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) // t42 = plot(avg62, "Top 42.5% Line",clr.get(4), 1, plot.style_linebr, false, na, na, na, false, na, showHideTopLine) // b42 = plot(avg42, "Bottom 42.5% Line",clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) // b252 = plot(avg25, "Bottom 25% Line", clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) // b12 = plot(avg12, "Bottom 12.5% Line",clr.get(5), 1, plot.style_linebr, false, na, na, na, false, na, showHideBotLine) // Plot 1/8 fills. // showHideTopFill = displayFill(shoHiFil) // showHideBotFill = displayFill(shoLoFil) // fill(top, t12, clr.get(6), "Top 12.5% Fill", false, display = showHideTopFill) // fill(top, t25, clr.get(6), "Top 25% Fill", false, display = showHideTopFill) // fill(top, t42, clr.get(6), "Top 42.5% Fill", false, display = showHideTopFill) // fill(bot, b42, clr.get(7), "Bottom 42.5% Fill", false, display = showHideBotFill) // fill(bot, b25, clr.get(7), "Bottom 25% Fill", false, display = showHideBotFill) // fill(bot, b12, clr.get(7), "Bottom 12.5% Fill", false, display = showHideBotFill) // SFP Inquisitor // 1.0 // // coded by Bogdan Vaida // Code for Swing High, Swing Low and Swing Failure Pattern. // Note that the number you set in your Swing History variable // will also be the minimum delay you see until the apples appear. // This is because we're checking the forward "history" too. // The SFP will only check for these conditions: // - high above Swing History high and close below it // - low below Swing History high and close above it // In some cases you may see an apple before the SFP that "doesn't fit" // with the SFP conditions. That's because that apple was drawn later and // the SFP actually appeared because of the previous apple. // 20 candles later. // Legend: // 🍏 - swing high // 🍎 - swing low // 🍌 - swing failure pattern // 🍎🍌 - hungry scenario: swing low but also a SFP compared to the last swing // 🍰 - cake is for stronger SFPs / SFPs in a row (but with a the secret sauce) // IDEAS: // - show potential swing highs/lows (where current bar is < Swing History) // - different types of bananas (or kiwi on 1' and a mango on a HTF SFP) (credits: @imal_max) // Tested on 5' BTCUSDT and 4h ETHUSD //@version=5 //indicator(title='🍏🍎🍌 Swing Failure Pattern Inquisitor', shorttitle='SFP-I', overlay=true) // 🔥 Uncomment the lines below for the strategy and revert for the study // strategy(title="🍏🍎🍌 Swing Failure Pattern Inquisitor", shorttitle="SFP-I", overlay=true, pyramiding=1, // process_orders_on_close=true, calc_on_every_tick=true, // initial_capital=1000, currency = currency.USD, default_qty_value=10, // default_qty_type=strategy.percent_of_equity, // commission_type=strategy.commission.percent, commission_value=0.1, slippage=2) // swingHistory = input.int(10, title='Swing history:', minval=1) // plotSwings = input(true, title='Plot swings') // plotFirstSFPOnly = input(false, title='Plot only first SFP candle') // plotStrongerSFPs = input.int(10, title='Plot stronger SFPs:', minval=0) // tradingDirection = input.string(title='Trading Direction: ', group='Strategy', defval='L', options=['L&S', 'L', 'S']) // stopLoss = input.float(1.0, title='Stop Loss %', group='Strategy') / 100 // takeProfit = input.float(3.0, title='Take Profit %', group='Strategy') / 100 // plotTP = input.bool(true, title='Take Profit?', group='Strategy', inline='plot1') // plotSL = input.bool(true, title='Stop-Loss?', group='Strategy', inline='plot1') // plotBgColor = input.bool(true, title='Plot Background Color?', group='Strategy') // startDate = input.int(title='Start Date', defval=1, minval=1, maxval=31, group='Backtesting range') // startMonth = input.int(title='Start Month', defval=5, minval=1, maxval=12, group='Backtesting range') // startYear = input.int(title='Start Year', defval=2021, minval=1800, maxval=2100, group='Backtesting range') // endDate = input.int(title='End Date', defval=1, minval=1, maxval=31, group='Backtesting range') // endMonth = input.int(title='End Month', defval=1, minval=1, maxval=12, group='Backtesting range') // endYear = input.int(title='End Year', defval=2040, minval=1800, maxval=2100, group='Backtesting range') // // Date range filtering // inDateRange = time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0) and time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 23, 59) // // Swing Lows and Swing Highs code // isSwingHigh = false // isSwingLow = false // swingHigh = high[swingHistory] // swingLow = low[swingHistory] // range_1 = swingHistory * 2 // for i = 0 to range_1 by 1 // isSwingHigh := true // if i < swingHistory // if high[i] > swingHigh // isSwingHigh := false // break // if i > swingHistory // if high[i] >= swingHigh // isSwingHigh := false // break // for i = 0 to range_1 by 1 // isSwingLow := true // if i < swingHistory // if low[i] < swingLow // isSwingLow := false // break // if i > swingHistory // if low[i] <= swingLow // isSwingLow := false // break // // Swing Failure Pattern // isSwingHighFailure = false // isSwingLowFailure = false // var lastSwingHigh = float(na) // var lastSwingLow = float(na) // lastSwingHigh := isSwingHigh ? swingHigh : lastSwingHigh // lastSwingLow := isSwingLow ? swingLow : lastSwingLow // strengthOfHighSFP = 0 // if lastSwingHigh < high and lastSwingHigh > close and ta.barssince(lastSwingHigh) <= swingHistory // isSwingHighFailure := true // if plotFirstSFPOnly // lastSwingHigh := na // else // for i = 0 to plotStrongerSFPs by 1 // if isSwingHighFailure[i] // strengthOfHighSFP += 1 // it will be at least 1 // else // if high[i] > high // strengthOfHighSFP -= 1 // strengthOfLowSFP = 0 // if lastSwingLow > low and lastSwingLow < close and ta.barssince(lastSwingLow) <= swingHistory // isSwingLowFailure := true // if plotFirstSFPOnly // lastSwingLow := na // else // for i = 0 to plotStrongerSFPs by 1 // if isSwingHighFailure[i] // strengthOfLowSFP += 1 // it will be at least 1 // else // if low[i] < low // strengthOfLowSFP -= 1 // // Debugging // plotchar(isSwingHighFailure, 'Swing High Failure', '', location.top) // plotchar(isSwingLowFailure, 'Swing Low Failure', '', location.top) // plotchar(lastSwingHigh, 'Last Swing High', '', location.top) // plotchar(lastSwingLow, 'Last Swing Low', '', location.top) // // Alerting // alertcondition(condition=isSwingHighFailure, title='SFP: Swing High Failure', message='Swing High Failure') // alertcondition(condition=isSwingLowFailure, title='SFP: Swing Low Failure', message='Swing Low Failure') // alertcondition(condition=isSwingHighFailure or isSwingLowFailure, title='SFP: Any Swing Failure Pattern', message='Any Swing Failure Pattern') // // Plotting // // plotchar(series=plotSwings ? isSwingHigh : na, char='🔴', location=location.abovebar, size=size.tiny, offset=-swingHistory) // // plotchar(series=plotSwings ? isSwingLow : na, char='🟢', location=location.belowbar, size=size.tiny, offset=-swingHistory) // plotshape(series=plotSwings ? isSwingHigh : na, style= shape.circle, color= color.red, location=location.abovebar, size=size.tiny, offset=-swingHistory) // plotshape(series=plotSwings ? isSwingLow : na, style= shape.circle, color= color.green, location=location.belowbar, size=size.tiny, offset=-swingHistory) // //plot(swingHigh, style= plot.style_circles,linewidth = 5, offset=-swingHistory) // // plotchar(series=isSwingHighFailure and strengthOfHighSFP <= 1, char='🍌', location=location.abovebar, size=size.tiny) // // plotchar(series=isSwingHighFailure and strengthOfHighSFP >= 3, char='🍰', location=location.abovebar, size=size.tiny) // // plotchar(series=isSwingLowFailure and strengthOfLowSFP <= 1, char='🍌', location=location.belowbar, size=size.tiny) // // plotchar(series=isSwingLowFailure and strengthOfLowSFP >= 3, char='🍰', location=location.belowbar, size=size.tiny) // // 🔥 Uncomment the lines below for the strategy and revert for the study // // TP = strategy.position_size > 0 ? strategy.position_avg_price * (1 + takeProfit) : // // strategy.position_size < 0 ? strategy.position_avg_price * (1 - takeProfit) : na // // SL = strategy.position_size > 0 ? strategy.position_avg_price * (1 - stopLoss) : // // strategy.position_size < 0 ? strategy.position_avg_price * (1 + stopLoss) : na // // plot(series = (plotTP and strategy.position_size != 0) ? TP : na, style=plot.style_linebr, color=color.green, title="TP") // // plot(series = (plotSL and strategy.position_size != 0) ? SL : na, style=plot.style_linebr, color=color.red, title="SL") // // bgcolor(plotBgColor ? strategy.position_size > 0 ? color.new(color.green, 75) : strategy.position_size < 0 ? color.new(color.red,75) : color(na) : color(na)) // // strategy.risk.allow_entry_in(tradingDirection == "L&S" ? strategy.direction.all : // // tradingDirection == "L" ? strategy.direction.long : // // tradingDirection == "S" ? strategy.direction.short : na) // // strategy.entry("SFP", strategy.long, comment="Long", when=isSwingLowFailure) // // strategy.entry("SFP", strategy.short, comment="Short", when=isSwingHighFailure) // // strategy.exit(id="TP-SL", from_entry="SFP", limit=TP, stop=SL) // // if (not inDateRange) // // strategy.close_all()
RSI Primed [ChartPrime]
https://www.tradingview.com/script/TnJMMEJI-RSI-Primed-ChartPrime/
ChartPrime
https://www.tradingview.com/u/ChartPrime/
1,127
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/ // © ChartPrime //@version=5 indicator("RSI Primed [ChartPrime]") import lastguru/DominantCycle/2 as d double_exponential_moving_average(source)=> var float ema1 = 0.0 var float ema2 = 0.0 var int count = 0 if close == close count := nz(count[1]) + 1 ema1 := (1.0 - 2.0 / (count + 1.0)) * nz(ema1[1]) + 2.0 / (count + 1.0) * source ema2 :=(1.0 - 2.0 / (count + 1.0)) * nz(ema2[1]) + 2.0 / (count + 1.0) * ema1 2 * ema1 - ema2 patterns(Open, High, Low, Close, OHLC4, ma)=> c_down_trend = OHLC4 < ma c_up_trend = OHLC4 > ma rsi_low = High < 40 rsi_high = Low > 60 c_body_hi = math.max(Close, Open) c_body_lo = math.min(Close, Open) c_body = c_body_hi - c_body_lo c_body_avg = double_exponential_moving_average(c_body) c_body_middle = c_body / 2 + c_body_lo c_small_body = c_body < c_body_avg c_long_body = c_body > c_body_avg c_white_body = Open < Close c_black_body = Open > Close c_engulfing_bearish = c_up_trend and c_black_body and c_long_body and c_white_body[1] and c_small_body[1] and Close <= Open[1] and Open >= Close[1] and ( Close < Open[1] or Open > Close[1] ) and rsi_high c_engulfing_bullish = c_down_trend and c_white_body and c_long_body and c_black_body[1] and c_small_body[1] and Close >= Open[1] and Open <= Close[1] and ( Close > Open[1] or Open < Close[1] ) and rsi_low c_morning_star_bullish = false if c_long_body[2] and c_small_body[1] and c_long_body if c_down_trend and c_black_body[2] and c_body_hi[1] < c_body_lo[2] and c_white_body and c_body_hi >= c_body_middle[2] and c_body_hi < c_body_hi[2] and c_body_hi[1] < c_body_lo c_morning_star_bullish := true c_evening_star_bearish = false if c_long_body[2] and c_small_body[1] and c_long_body if c_up_trend and c_white_body[2] and c_body_lo[1] > c_body_hi[2] and c_black_body and c_body_lo <= c_body_middle[2] and c_body_lo > c_body_lo[2] and c_body_lo[1] > c_body_hi c_evening_star_bearish := true [c_engulfing_bearish, c_engulfing_bullish, c_morning_star_bullish, c_evening_star_bearish] grad_100(src)=> color out = switch int(src) 0 => color.new(#1500FF , 20) 1 => color.new(#1709F6 , 20) 2 => color.new(#1912ED , 20) 3 => color.new(#1B1AE5 , 20) 4 => color.new(#1D23DC , 20) 5 => color.new(#1F2CD3 , 20) 6 => color.new(#2135CA , 20) 7 => color.new(#233EC1 , 20) 8 => color.new(#2446B9 , 20) 9 => color.new(#264FB0 , 20) 10 => color.new(#2858A7 , 20) 11 => color.new(#2A619E , 20) 12 => color.new(#2C6A95 , 20) 13 => color.new(#2E728D , 20) 14 => color.new(#307B84 , 20) 15 => color.new(#32847B , 20) 16 => color.new(#348D72 , 20) 17 => color.new(#36956A , 20) 18 => color.new(#389E61 , 20) 19 => color.new(#3AA758 , 20) 20 => color.new(#3CB04F , 20) 21 => color.new(#3EB946 , 20) 22 => color.new(#3FC13E , 20) 23 => color.new(#41CA35 , 20) 24 => color.new(#43D32C , 20) 25 => color.new(#45DC23 , 20) 26 => color.new(#47E51A , 20) 27 => color.new(#49ED12 , 20) 28 => color.new(#4BF609 , 20) 29 => color.new(#4DFF00 , 20) 30 => color.new(#53FF00 , 20) 31 => color.new(#59FF00 , 20) 32 => color.new(#5FFE00 , 20) 33 => color.new(#65FE00 , 20) 34 => color.new(#6BFE00 , 20) 35 => color.new(#71FE00 , 20) 36 => color.new(#77FD00 , 20) 37 => color.new(#7DFD00 , 20) 38 => color.new(#82FD00 , 20) 39 => color.new(#88FD00 , 20) 40 => color.new(#8EFC00 , 20) 41 => color.new(#94FC00 , 20) 42 => color.new(#9AFC00 , 20) 43 => color.new(#A0FB00 , 20) 44 => color.new(#A6FB00 , 20) 45 => color.new(#ACFB00 , 20) 46 => color.new(#B2FB00 , 20) 47 => color.new(#B8FA00 , 20) 48 => color.new(#BEFA00 , 20) 49 => color.new(#C4FA00 , 20) 50 => color.new(#CAF900 , 20) 51 => color.new(#D0F900 , 20) 52 => color.new(#D5F900 , 20) 53 => color.new(#DBF900 , 20) 54 => color.new(#E1F800 , 20) 55 => color.new(#E7F800 , 20) 56 => color.new(#EDF800 , 20) 57 => color.new(#F3F800 , 20) 58 => color.new(#F9F700 , 20) 59 => color.new(#FFF700 , 20) 60 => color.new(#FFEE00 , 20) 61 => color.new(#FFE600 , 20) 62 => color.new(#FFDE00 , 20) 63 => color.new(#FFD500 , 20) 64 => color.new(#FFCD00 , 20) 65 => color.new(#FFC500 , 20) 66 => color.new(#FFBD00 , 20) 67 => color.new(#FFB500 , 20) 68 => color.new(#FFAC00 , 20) 69 => color.new(#FFA400 , 20) 70 => color.new(#FF9C00 , 20) 71 => color.new(#FF9400 , 20) 72 => color.new(#FF8C00 , 20) 73 => color.new(#FF8300 , 20) 74 => color.new(#FF7B00 , 20) 75 => color.new(#FF7300 , 20) 76 => color.new(#FF6B00 , 20) 77 => color.new(#FF6200 , 20) 78 => color.new(#FF5A00 , 20) 79 => color.new(#FF5200 , 20) 80 => color.new(#FF4A00 , 20) 81 => color.new(#FF4200 , 20) 82 => color.new(#FF3900 , 20) 83 => color.new(#FF3100 , 20) 84 => color.new(#FF2900 , 20) 85 => color.new(#FF2100 , 20) 86 => color.new(#FF1900 , 20) 87 => color.new(#FF1000 , 20) 88 => color.new(#FF0800 , 20) 89 => color.new(#FF0000 , 20) 90 => color.new(#F60000 , 20) 91 => color.new(#DF0505 , 20) 92 => color.new(#C90909 , 20) 93 => color.new(#B20E0E , 20) 94 => color.new(#9B1313 , 20) 95 => color.new(#851717 , 20) 96 => color.new(#6E1C1C , 20) 97 => color.new(#572121 , 20) 98 => color.new(#412525 , 20) 99 => color.new(#2A2A2A , 20) 100 => color.new(#220027 , 20) out grad(values)=> switch values 39 => #6ef057 38 => #77ec56 37 => #7fe854 36 => #86e553 35 => #8ce151 34 => #92dd50 33 => #98d94f 32 => #9ed54d 31 => #a3d14c 30 => #a7ce4b 29 => #acca49 28 => #b0c648 27 => #b4c247 26 => #b8be46 25 => #bcb944 24 => #bfb543 23 => #c3b142 22 => #c6ad41 21 => #c9a93f 20 => #cca43e 19 => #cfa03d 18 => #d29c3c 17 => #d4973b 16 => #d79239 15 => #d98e38 14 => #dc8937 13 => #de8436 12 => #e07f35 11 => #e37934 10 => #e57433 9 => #e76e32 8 => #e96931 7 => #ea6230 6 => #ec5c2f 5 => #ee552e 4 => #f04d2d 3 => #f1452c 2 => #f33b2c 1 => #f5302b 0 => #f6212a ema(source)=> var float ema = 0.0 var int count = 0 count := nz(count[1]) + 1 ema := (1.0 - 2.0 / (count + 1.0)) * nz(ema[1]) + 2.0 / (count + 1.0) * source ema atan2(y, x) => var float angle = 0.0 if x > 0 angle := math.atan(y / x) else if x < 0 and y >= 0 angle := math.atan(y / x) + math.pi else if x < 0 and y < 0 angle := math.atan(y / x) - math.pi else if x == 0 and y > 0 angle := math.pi / 2 else if x == 0 and y < 0 angle := -math.pi / 2 angle // Custom cosh function cosh(float x) => (math.exp(x) + math.exp(-x)) / 2 // Custom acosh function acosh(float x) => x < 1 ? na : math.log(x + math.sqrt(x * x - 1)) // Custom sinh function sinh(float x) => (math.exp(x) - math.exp(-x)) / 2 // Custom asinh function asinh(float x) => math.log(x + math.sqrt(x * x + 1)) // Custom inverse tangent function atan(float x) => math.pi / 2 - math.atan(1 / x) // Chebyshev Type I Moving Average chebyshevI(float src, float len, float ripple) => a = 0. b = 0. g = 0. chebyshev = 0. a := cosh(1 / len * acosh(1 / (1 - ripple))) b := sinh(1 / len * asinh(1 / ripple)) g := (a - b) / (a + b) chebyshev := (1 - g) * src + g * nz(chebyshev[1]) chebyshev degrees(float source) => source * 180 / math.pi trend_angle(source, length, smoothing_length, smoothing_ripple) => atr = ema(ta.highest(source, length) - ta.lowest(source, length)) slope = (source - source[length]) / (atr/(length) * length) angle_rad = atan2(slope, 1) degrees = chebyshevI(degrees(angle_rad), smoothing_length, smoothing_ripple) normalized = int((90 + degrees)/180 * 39) ha_close(float Open = open, float High = high, float Low = low, float Close = close, bool enable = true) => ha_close = (Open + High + Low + Close) / 4 out = enable == true ? ha_close : Close ha_open(float Open = open, float High = high, float Low = low, float Close = close, bool enable = true) => ha_open = float(na) ha_close = ha_close(Open, High, Low, Close) ha_open := na(ha_open[1]) ? (Open + Close) / 2 : (nz(ha_open[1]) + nz(ha_close[1])) / 2 out = enable == true ? ha_open : Open ha_high(float Open = open, float High = high, float Low = low, float Close = close, bool enable = true) => ha_close = ha_close(Open, High, Low, Close) ha_open = ha_open(Open, High, Low, Close) ha_high = math.max(High, math.max(ha_open, ha_close)) out = enable == true ? ha_high : High ha_low(float Open = open, float High = high, float Low = low, float Close = close, bool enable = true) => ha_close = ha_close(Open, High, Low, Close) ha_open = ha_open(Open, High, Low, Close) ha_low = math.min(Low, math.min(ha_open, ha_close)) out = enable == true ? ha_low : Low rsi(source = close, length = 14, smoothing = 3)=> close_filtered = chebyshevI(source, smoothing, 0.5) up = math.max(ta.change(close_filtered), 0) down = -math.min(ta.change(close_filtered), 0) up_filtered = chebyshevI(up, length, 0.5) down_filtered = chebyshevI(down, length, 0.5) rsi = down_filtered == 0 ? 100 : 100 - (100 / (1 + up_filtered / down_filtered)) ema(float source = close, float length = 9)=> alpha = 2 / (length + 1) var float smoothed = na smoothed := alpha * source + (1 - alpha) * nz(smoothed[1]) length(source, harmonic)=> cycle = math.round(d.mamaPeriod(source, 1, 2048)) var cycles = array.new<float>(1) var count_cycles = array.new<int>(1) if not array.includes(cycles, cycle) array.push(cycles, cycle) array.push(count_cycles, 1) else index = array.indexof(cycles, cycle) array.set(count_cycles, index, array.get(count_cycles, index) + 1) max_index = array.indexof(count_cycles, array.max(count_cycles)) max_cycle = array.get(cycles, max_index) * harmonic style = input.string("Candle With Patterns", "Style", ["Candle", "Candle With Patterns", "Heikin Ashi", "Line"], inline = "Style") color_candles = input.bool(false, "Colorize", "Color the candles bassed on the RSI value.", "Style") ashi = style == "Heikin Ashi" not_line = style != "Line" length = input.float(24, "Length", 3, 500, 0.5) smoothing = input.float(3, "Smoothing", 1, 500, 0.25) enable_ma = input.bool(true, "Auto MA", inline = "MA") harmonic = input.int(1, "", 1, inline = "MA") colour_enable = input.bool(false, "Color Candles Overlay", "Enable this to color the chart's candles.") rsi_open = rsi(open, length, smoothing) rsi_high = rsi(high, length, smoothing) rsi_low = rsi(low, length, smoothing) rsi_close = rsi(close, length, smoothing) ha_close = ha_close(rsi_open, rsi_high, rsi_low, rsi_close, ashi) ha_open = ha_open(rsi_open, rsi_high, rsi_low, rsi_close, ashi) ha_high = ha_high(rsi_open, rsi_high, rsi_low, rsi_close, ashi) ha_low = ha_low(rsi_open, rsi_high, rsi_low, rsi_close, ashi) OHLC4 = math.avg(ha_close, ha_open, ha_high, ha_low) grad_100 = grad_100(ha_close) ma_length = length(OHLC4, harmonic) aema = chebyshevI(OHLC4, ma_length, 0.05) aema_colour = grad(trend_angle(aema, 4, 2, 0.5)) bullish_color = #26a69a bearish_color = #ef5350 alpha = color.new(color.black, 100) colour = color_candles ? grad_100 : ha_close > ha_open ? bullish_color : bearish_color [engulfing_bearish, engulfing_bullish, morning_star_bullish, evening_star_bearish] = patterns(ha_open, ha_high, ha_low, ha_close, OHLC4, aema) if engulfing_bullish and style == "Candle With Patterns" label.new(bar_index, -20, "EG", color = alpha, textcolor = bullish_color) line.new(bar_index, 100, bar_index, 0, color = color.new(color.gray, 50), style = line.style_dashed) if morning_star_bullish and style == "Candle With Patterns" label.new(bar_index, -20, "ES", color = alpha, textcolor = bullish_color) line.new(bar_index, 100, bar_index, 0, color = color.new(color.gray, 50), style = line.style_dashed) if engulfing_bearish and style == "Candle With Patterns" label.new(bar_index, 120, "EG", color = alpha, textcolor = bearish_color, style = label.style_label_up) line.new(bar_index, 100, bar_index, 0, color = color.new(color.gray, 50), style = line.style_dashed) if evening_star_bearish and style == "Candle With Patterns" label.new(bar_index, 120, "ES", color = alpha, textcolor = bearish_color, style = label.style_label_up) line.new(bar_index, 100, bar_index, 0, color = color.new(color.gray, 50), style = line.style_dashed) plotcandle(not_line ? ha_open : na, not_line ? ha_high : na, not_line ? ha_low : na, not_line ? ha_close : na, "RSI HA Candles", colour, colour, bordercolor = colour) plot(not not_line ? OHLC4 : na, "RSI Line", color_candles ? grad_100 : #7352FF, 2) plot(enable_ma ? aema : na, "MA", aema_colour, 2) barcolor(colour_enable ? grad_100 : na) top = hline(70) hline(50) bottom = hline(30) fill(top, bottom, color = color.new(#7352FF, 90))
Combined Spot Volume | Crypto v1.1 [kAos]
https://www.tradingview.com/script/Xdriiub4-Combined-Spot-Volume-Crypto-v1-1-kAos/
eAkosKovacs
https://www.tradingview.com/u/eAkosKovacs/
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/ // Script by @eAkosKovacs //@version=5 indicator('Combined Spot Volume | Crypto v1.1 [kAos]', 'CSV v1.1 [kAos]', precision=0, scale=scale.right) i_showMa = input(true, 'Show Volume MA', inline = '0') i_ma_period = input(20, '   Period', inline = '0') i_showExchanges = input(false, 'Plot individual exchanges') exchange_1 = input.string('BITFINEX' , 'Exchange 1', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_2 = input.string('COINBASE' , 'Exchange 2', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_3 = input.string('BITSTAMP' , 'Exchange 3', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_4 = input.string('KRAKEN' , 'Exchange 4', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_5 = input.string('BINANCE' , 'Exchange 5', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_6 = input.string('GEMINI' , 'Exchange 6', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_7 = input.string('BYBIT' , 'Exchange 7', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_8 = input.string('KUCOIN' , 'Exchange 8', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) exchange_9 = input.string('OKEX' , 'Exchange 9', inline = '1', group = 'If the Table shows "NaN" than check the spelling of the exchange or the "Tradingpair" might not be availabe on that exchange.' ) base = syminfo.basecurrency fiat = syminfo.currency exchange_1_volume = request.security(exchange_1 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_2_volume = request.security(exchange_2 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_4_volume = request.security(exchange_4 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_3_volume = request.security(exchange_3 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_5_volume = request.security(exchange_5 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_6_volume = request.security(exchange_6 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_7_volume = request.security(exchange_7 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_8_volume = request.security(exchange_8 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) exchange_9_volume = request.security(exchange_9 + ':' + base + fiat, timeframe.period, volume, ignore_invalid_symbol = true) Chart_volume = volume if syminfo.prefix == exchange_1 or syminfo.prefix == exchange_2 or syminfo.prefix == exchange_3 or syminfo.prefix == exchange_4 or syminfo.prefix == exchange_5 or syminfo.prefix == exchange_6 or syminfo.prefix == exchange_7 or syminfo.prefix == exchange_8 or syminfo.prefix == exchange_9 Chart_volume := 0.0 //Combining volime Combined_volume = nz(exchange_1_volume) + nz(exchange_2_volume) + nz(exchange_3_volume) + nz(exchange_4_volume) + nz(exchange_5_volume) + nz(exchange_6_volume) + nz(exchange_7_volume) + nz(exchange_8_volume) + nz(exchange_9_volume) + (syminfo.prefix == 'INDEX' ? 0 : nz(Chart_volume)) volumeMA = ta.sma(Combined_volume, i_ma_period) //Plot histogram color_hist = ta.change(close) < 0 ? color.new(color.red, 0) : color.new(color.teal, 0) plot(i_showExchanges ? na : Combined_volume, 'Combined Volume', style=plot.style_histogram, linewidth=3, color=color_hist) plot(i_showExchanges ? na : i_showMa ? volumeMA : na, 'Volume MA', color.new(color.orange, 0)) exchange_1_color = color.new(color.white, 70) exchange_2_color = color.new(color.blue, 70) exchange_3_color = color.new(color.green, 70) exchange_4_color = color.new(color.purple, 70) exchange_5_color = color.new(color.yellow, 70) exchange_6_color = color.new(color.gray, 70) exchange_7_color = color.new(color.orange, 70) exchange_8_color = color.new(color.teal, 70) exchange_9_color = color.new(color.red, 70) Chart_color = color.new(color.silver, 70) //Plot individual exchanges plot(i_showExchanges ? exchange_1_volume : na, 'Volume Exchange 1' , exchange_1_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_2_volume : na, 'Volume Exchange 2' , exchange_2_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_3_volume : na, 'Volume Exchange 3' , exchange_3_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_4_volume : na, 'Volume Exchange 4' , exchange_4_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_5_volume : na, 'Volume Exchange 5' , exchange_5_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_6_volume : na, 'Volume Exchange 6' , exchange_6_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_7_volume : na, 'Volume Exchange 7' , exchange_7_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_8_volume : na, 'Volume Exchange 8' , exchange_8_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? exchange_9_volume : na, 'Volume Exchange 9' , exchange_9_color, linewidth=2, style=plot.style_areabr) plot(i_showExchanges ? Chart_volume : na, 'Volume Chart' , Chart_color , linewidth=2, style=plot.style_areabr) var table info_table = table.new(position.bottom_right, 3, 4) table.cell(info_table, 0, 0, text = exchange_1 + '\n ' + str.tostring(exchange_1_volume, '#.#####'), bgcolor = exchange_1_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 0, 1, text = exchange_2 + '\n ' + str.tostring(exchange_2_volume, '#.#####'), bgcolor = exchange_2_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 0, 2, text = exchange_3 + '\n ' + str.tostring(exchange_3_volume, '#.#####'), bgcolor = exchange_3_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 1, 0, text = exchange_4 + '\n ' + str.tostring(exchange_4_volume, '#.#####'), bgcolor = exchange_4_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 1, 1, text = exchange_5 + '\n ' + str.tostring(exchange_5_volume, '#.#####'), bgcolor = exchange_5_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 1, 2, text = exchange_6 + '\n ' + str.tostring(exchange_6_volume, '#.#####'), bgcolor = exchange_6_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 2, 0, text = exchange_7 + '\n ' + str.tostring(exchange_7_volume, '#.#####'), bgcolor = exchange_7_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 2, 1, text = exchange_8 + '\n ' + str.tostring(exchange_8_volume, '#.#####'), bgcolor = exchange_8_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) table.cell(info_table, 2, 2, text = exchange_9 + '\n ' + str.tostring(exchange_9_volume, '#.#####'), bgcolor = exchange_9_color , text_color = color.white, text_halign = text.align_center, text_size = size.small) var label chart_vol_label = na if Chart_volume != 0 //table.cell(info_table, 2, 3, text = 'Chart volume: ' + str.tostring(Chart_volume, '#.#####'), bgcolor = Chart_color, text_color = color.white, text_halign = text.align_left, text_size = size.normal) chart_vol_label := label.new(bar_index + 5, Combined_volume, text = syminfo.tickerid + ' \n' + str.tostring(Chart_volume, '#.#####'), style = label.style_label_left, color = Chart_color, textcolor = color.white, size = size.small) label.delete(chart_vol_label[1])