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
Moving Avareges Cross
https://www.tradingview.com/script/GzvJViYT-Moving-Avareges-Cross/
ShahramAbaei
https://www.tradingview.com/u/ShahramAbaei/
37
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/ // © ShahramAbaei //@version=5 indicator(title = "Moving Avareges Cross", shorttitle="Moving Avareges Cross", overlay=true) len = input(10) o = ta.ema(open,len) c = ta.ema(close,len) h = ta.ema(high,len) l = ta.ema(low,len) haclose = 0.0 haopen = 0.0 hahigh = 0.0 halow = 0.0 haclose := (o+h+l+c)/4 haopen := na(haopen[1]) ? (o + c)/2 : (haopen[1] + haclose[1]) / 2 hahigh := math.max(h, math.max(haopen,haclose)) halow := math.min(l, math.min(haopen,haclose)) len2=input(10) o2 = ta.ema(haopen, len2) c2 = ta.ema(haclose, len2) h2 = ta.ema(hahigh, len2) l2 = ta.ema(halow, len2) col=o2>c2 ? #ff0000 : #00ff00 plotcandle(o2, h2, l2, c2, title="heikin smoothed", color=col,wickcolor=col) conversionPeriods = input.int(9, minval=1, title="Conversion Line Length") basePeriods = input.int(26, minval=1, title="Base Line Length") laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length") displacement = input.int(26, minval=1, title="Displacement") donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) plot(conversionLine, color=#2962FF, title="Conversion Line",display=display.none) plot(baseLine, color=#B71C1C, title="Base Line",display=display.none) plot(close, offset = -displacement + 1, color=color.white, title="Lagging Span",style=plot.style_cross) p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,title="Leading Span A",display=display.none) p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,title="Leading Span B",display=display.none) fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(255, 255, 255, 75) : color.rgb(255, 100, 100, 75)) lenma1 = input.int(21, minval=1, title="Length") lenma2 = input.int(233, minval=1, title="Length") lenma3 = input.int(55, minval=1, title="Length") src1 = input(low, title="EMA1 Source") src2 = input(close, title="EMA2 Source") src3 = input(close, title="EMA3 Source") offset = input.int(title="Offset", defval=0, minval=-500, maxval=500) out1 = ta.ema(src1, lenma1) out2 = ta.ema(src2, lenma2) out3 = ta.ema(src3, lenma3) plot(out1, title="EMA 1", color=color.orange, offset=offset) plot(out2, title="EMA 2", color=color.blue, offset=offset) plot(out3, title="EMA 3", color=color.green, offset=offset,display=display.none)
show bottom
https://www.tradingview.com/script/05F64oMz/
slmgtv1
https://www.tradingview.com/u/slmgtv1/
80
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © slmgtv1 //@version=5 indicator("五分钟K线数据+是否底分型", overlay = true) pos = input.float(title='显示距离%:', defval=0.0) title = "5min_K_data" low_di = low[1] n = 1 // 处理各类包含关系: low_2 = low[2] low_1 = low[1] low_0 = low high_2 = high[2] high_1 = high[1] high_0 = high // 1包2 if low[1]<low[2] and high[1]>high[2] low_2 := low[3] high_2:= high[3] // 1包2和3 if low[1]<low[2] and high[1]>high[2] and low[1]<low[3] and high[1]>high[3] low_2 := low[4] high_2:= high[4] // 1包2、3、4 if low[1]<low[2] and high[1]>high[2] and low[1]<low[3] and high[1]>high[3] and low[1]<low[4] and high[1]>high[4] low_2 := low[5] high_2:= high[5] // 1包2、3、4、5 if low[1]<low[2] and high[1]>high[2] and low[1]<low[3] and high[1]>high[3] and low[1]<low[4] and high[1]>high[4] and low[1]<low[5] and high[1]>high[5] low_2 := low[6] high_2:= high[6] // 2包1 if low[2]<low[1] and high[2]>high[1] low_2 := low[3] high_2:= high[3] low_1 := low[2] high_1:= high[2] low_di:= low[2] n:=2 // 3包1、2 if low[3]<low[1] and high[3]>high[1] and low[3]<low[2] and high[3]>high[2] low_2 := low[4] high_2:= high[4] low_1 := low[3] high_1:= high[3] low_di:= low[3] n:=3 // 4包1、2、3 if low[4]<low[1] and high[4]>high[1] and low[4]<low[2] and high[4]>high[2] and low[4]<low[3] and high[4]>high[3] low_2 := low[5] high_2:= high[5] low_1 := low[4] high_1:= high[4] low_di:= low[4] n:=4 // 5包1、2、3、4 if low[5]<low[1] and high[5]>high[1] and low[5]<low[2] and high[5]>high[2] and low[5]<low[3] and high[5]>high[3] and low[5]<low[4] and high[5]>high[4] low_2 := low[6] high_2:= high[6] low_1 := low[5] high_1:= high[5] low_di:= low[5] n:=5 var value_di = 0.0 var is_new_di = 0 var ts_di = 0 // 处理完毕,判断是否底分型 is_di = false if low_1<=low_0 and low_1<=low_2 and high_1<=high_0 and high_1<=high_2 is_di := true is_new_di := 1 ts_di := time[n] label.new(bar_index[n], low_1*(1-pos/100), str.tostring('底'), style=label.style_label_up, textcolor=color.white, size=size.normal) value_di := low_1 // 5min bar四价:group=3 msg1='{"ticker":"' + syminfo.ticker + '", "k_time": "'+ timeframe.period + '","type":"' + title + '", "timestamp": "' + str.tostring(time) + '", "open": "' + str.tostring(open, "#.000") + '", "close": "' + str.tostring(close, "#.000") + '", "high":"' + str.tostring(high, "#.000") + '", "low":"' + str.tostring(low, "#.000") + '", "is_di": "' + str.tostring(is_di) + '", "low_di": "' + str.tostring(low_di, "#.000") + '", "pos_di": "' + str.tostring(n) + '", "group":"' + str.tostring(3) + '" }' alert(msg1, alert.freq_once_per_bar_close) // 判断是否跌破底分型,破底时发送group=5 plot(value_di) msg2 = '{ "group": "5", "ticker": "'+ syminfo.ticker +'", "timestamp": "' + str.tostring(time) + '", "price": "' + str.tostring(close, "#.000") + '", "type": "passive_take_profit", "ts_di": "' + str.tostring(ts_di) + '" }' if close < value_di and close[1]>=value_di[1] and is_new_di==1 label.new(bar_index, high, str.tostring('破底'), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.normal) // label.new(bar_index, high, str.tostring(ts_di), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.normal) alert(msg2, alert.freq_once_per_bar_close) is_new_di := 0
D-VaR position sizing
https://www.tradingview.com/script/kkPs7K9Z-D-VaR-position-sizing/
shardison
https://www.tradingview.com/u/shardison/
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/ // © shardison //The D-VaR position sizing method was created by David Varadi. //It's based on the concept of Value at Risk (VaR) - a widely used measure of the risk of //loss in a portfolio based on the statistical analysis of historical price trends and volatilities. //The PosSizer will: //Take the "rolling" daily returns for an instrument, according to the specified sample period //Calculate the 5th percentile of returns (aka "max tail loss") //Accept a risk level expressed as a maximum daily loss. The default value is 1% (conservative), risk seekers can enter higher values e.g. 1.5% (aggressive) //Calculate the position size as the risk level divided by the absolute value of the "max tail loss" //Position may not exceed 200% //@version=5 indicator("D-VaR position sizing") alength = input(defval=100, title="Average Returns Period", tooltip="Averege Returns Period and Length of Max Tail Calc--Max Tail Calc should be >= 100 to get accurate percentile") returns = ((close - close[1]) / close[1])*100 a = array.new_float(0) for i = 0 to alength array.push(a, returns[i]) avgreturns = array.avg(a) //plot(avgreturns, title="Avg Returns", color=color.new(color.red, 0)) pctilecalc = input(defval=true, title="Max tail loss calc method", tooltip="max tail loss caculation using 'Percentile_nearest_rank' or 'Percentile_linear_interpolation' -- default is nearest_rank") pctile = pctilecalc ? ta.percentile_nearest_rank(avgreturns, alength, 5) : ta.percentile_linear_interpolation(avgreturns, alength, 5) //plot(pctile, title="Max Tail Loss", color=color.new(color.teal, 0)) pctrisk = input.float(defval = 1.0, title="Percent Risk", step=0.1, tooltip="Accept a risk level expressed as a maximum daily loss. The default value is 1% (conservative), risk seekers can enter higher values e.g. 1.5% (aggressive)") possize = pctrisk / math.abs(pctile) maxplot = math.min(possize,200) plot(maxplot, title="Uncapped Position Size", color=color.new(color.blue, 0)) possizecap = input(defval=25, title="Cap Postion at X% of Equity") dvarPositionSize = math.min(possize, possizecap) plot(dvarPositionSize, title="Capped Position Size", color=color.new(color.orange, 0))
Intrabar OBV/PVT
https://www.tradingview.com/script/JRPBvbVS-Intrabar-OBV-PVT/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
199
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Intrabar Volume", overlay=true) import HeWhoMustNotBeNamed/arrayutils/17 as pa maxItems = input.int(100, "Loopback", minval=10, maxval=100, step=10) resetOnNewBar = input.bool(true, "Reset On New Bar") statsPosition = input.string(defval=position.top_right, title='', options=[position.bottom_right, position.bottom_left, position.bottom_center, position.top_right, position.top_center, position.middle_left, position.middle_right], group='Table', inline="s1") lblSize = input.string(size.small, title='', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='Table', inline="s1") varip float[] cArray = array.new_float() varip float[] vArray = array.new_float() varip float[] obvArray = array.new_float() varip float[] pvtArray = array.new_float() varip intrabarObv = 0.0 varip intrabarPvt = 0.0 change = ta.change(close) if barstate.islast pa.unshift(cArray, close, maxItems) pa.unshift(vArray, volume, maxItems) if(array.size(cArray) >= 2) priceDiff = array.get(cArray, 0) - array.get(cArray, 1) volumeDiff = array.get(vArray, 0) - array.get(vArray, 1) if(volumeDiff >= 0) intrabarObv := priceDiff > 0? intrabarObv + volumeDiff*priceDiff/math.abs(priceDiff): priceDiff < 0? intrabarObv - volumeDiff : intrabarObv intrabarPvt := intrabarPvt + volumeDiff*priceDiff/array.get(cArray, 1) pa.unshift(obvArray, intrabarObv, maxItems) pa.unshift(pvtArray, intrabarPvt, maxItems) else if(resetOnNewBar) array.clear(cArray) array.clear(vArray) array.clear(obvArray) array.clear(pvtArray) else pa.unshift(obvArray, intrabarObv, maxItems) pa.unshift(pvtArray, intrabarPvt, maxItems) stats = table.new(position=statsPosition, columns=8, rows=maxItems + 2, border_width=1) table.cell(table_id=stats, column=0, row=0, text="Price", bgcolor=color.maroon, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=2, row=0, text="Volume", bgcolor=color.maroon, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=4, row=0, text="OBV", bgcolor=color.maroon, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=6, row=0, text="PVT", bgcolor=color.maroon, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=0, row=1, text="Value", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=1, row=1, text="Difference", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=2, row=1, text="Value", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=3, row=1, text="Difference", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=4, row=1, text="Value", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=5, row=1, text="MA", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=6, row=1, text="Value", bgcolor=color.teal, text_color=color.white, text_size=lblSize) table.cell(table_id=stats, column=7, row=1, text="MA", bgcolor=color.teal, text_color=color.white, text_size=lblSize) for i=0 to array.size(cArray) >= 2? array.size(cArray)-2 : na price = array.get(cArray, i) vol = array.get(vArray, i) lPrice = array.get(cArray, i+1) lVol = array.get(vArray, i+1) pChange = price - lPrice vChange = vol - lVol iObv = array.get(obvArray, i) iPvt = array.get(pvtArray, i) obvMA = array.avg(obvArray) pvtMA = array.avg(pvtArray) bColor = pChange > 0? color.lime : color.orange table.cell(table_id=stats, column=0, row=i+2, text=str.tostring(price), bgcolor=bColor, text_color=color.black, text_size=lblSize) table.cell(table_id=stats, column=2, row=i+2, text=str.tostring(vol), bgcolor=bColor, text_color=color.black, text_size=lblSize) table.cell(table_id=stats, column=1, row=i+2, text=str.tostring(pChange), bgcolor=bColor, text_color=color.black, text_size=lblSize) table.cell(table_id=stats, column=3, row=i+2, text=str.tostring(vChange), bgcolor=bColor, text_color=color.black, text_size=lblSize) obvColor = iObv > 0? (iObv >obvMA? color.green : color.orange) : (iObv >obvMA ? color.lime: color.red) table.cell(table_id=stats, column=4, row=i+2, text=str.tostring(math.round(iObv,2)), bgcolor=obvColor, text_color=color.black, text_size=lblSize) table.cell(table_id=stats, column=5, row=i+2, text=str.tostring(math.round(obvMA,2)), bgcolor=obvColor, text_color=color.black, text_size=lblSize) pvtColor = iPvt > 0? (iPvt > pvtMA? color.green : color.orange) : (iPvt > pvtMA? color.lime : color.red) table.cell(table_id=stats, column=6, row=i+2, text=str.tostring(math.round(iPvt, 2)), bgcolor=pvtColor, text_color=color.black, text_size=lblSize) table.cell(table_id=stats, column=7, row=i+2, text=str.tostring(math.round(pvtMA, 2)), bgcolor=pvtColor, text_color=color.black, text_size=lblSize) alertMessage = '\nOBV :'+str.tostring(math.round(intrabarObv,2))+' , OBVMA : '+str.tostring(math.round(array.avg(obvArray),2))+ '\nPVT : '+str.tostring(math.round(intrabarPvt,2))+' , PVTMA : '+str.tostring(math.round(array.avg(pvtArray),2))+ '\nClose : '+str.tostring(close)+ '\nChange : '+str.tostring(change)+ '\nPercent : '+str.tostring(math.round(change*100/close[1], 2))+'\n' alert(alertMessage, alert.freq_once_per_bar_close)
Max drawdown days
https://www.tradingview.com/script/fj8oA4G2-Max-drawdown-days/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
79
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator("Max drawdown days", overlay=true) i_startTime = input.time(defval=timestamp('01 Jan 2010 00:00 +0000'), title='Start Time', group='Backtest Window') i_endTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End Time', group='Backtest Window') inDateRange = time >= i_startTime and time <= i_endTime i_tablePosition = input.string(defval=position.top_right, title='Table Position', options=[position.bottom_right, position.bottom_center, position.bottom_left, position.middle_right, position.middle_center, position.middle_left, position.top_right, position.top_center, position.top_left], group='Display') i_text_size = input.string(size.normal, title='Text Size', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='Display') i_headerColor = color.maroon i_neutralColor = #FFEEBB get_ath_data()=> var recoveryDaysArray = array.new_int() var dipDaysArray = array.new_int() var dateStart = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) dateEnd = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) var ath = high var daysFromAth = 0 var localLow = low var daysFromAthToLocalLow = 0 var maxDaysFromAthToLowcalLow = 0 var maxDaysForRecovery = 0 ath := math.max(ath, high) var athDay = '' var localLowDay = '' lastRecoveryDay = '' var maxDrawdownAthDay = '' var maxDrawdownDipDay = '' var maxRecoveryAthDay = '' var maxRecoveryRecoveryDay = '' var stillInDip = false var stillInRecovery = false if ath == high if(daysFromAthToLocalLow >= nz(array.median(dipDaysArray), 1) and daysFromAth >= nz(array.median(recoveryDaysArray), 1)) array.push(recoveryDaysArray, daysFromAth) array.push(dipDaysArray, daysFromAthToLocalLow) daysFromAth := 0 localLow := low daysFromAthToLocalLow := 0 athDay := str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) stillInRecovery := false else daysFromAth += 1 localLow := math.min(localLow, low) lastRecoveryDay := str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) if(low == localLow) daysFromAthToLocalLow := daysFromAth localLowDay := str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) else stillInDip := false if(maxDaysFromAthToLowcalLow < daysFromAthToLocalLow) maxDaysFromAthToLowcalLow := daysFromAthToLocalLow maxDrawdownAthDay := athDay maxDrawdownDipDay := localLowDay stillInDip := true if(maxDaysForRecovery < daysFromAth) maxDaysForRecovery := daysFromAth maxRecoveryAthDay := athDay maxRecoveryRecoveryDay := lastRecoveryDay stillInRecovery := true localLowData = str.tostring(maxDaysFromAthToLowcalLow) + ' ('+maxDrawdownAthDay+' - '+maxDrawdownDipDay+')' localRecoveryData = str.tostring(maxDaysForRecovery) + ' ('+maxRecoveryAthDay+' - '+maxRecoveryRecoveryDay+')' currentLocalLowData = str.tostring(daysFromAthToLocalLow) + ' ('+athDay+' - '+localLowDay+')' currentLocalRecoveryData = str.tostring(daysFromAth) + ' ('+athDay+' - )' medianRecoveryBars = array.median(recoveryDaysArray) medianDipBars = array.median(dipDaysArray) timeframe = dateStart + ' - ' + dateEnd currentTimeframe = athDay+' - ' currentlyInDip = daysFromAth == daysFromAthToLocalLow and daysFromAth > medianDipBars currentlyInRecovery = daysFromAth > medianRecoveryBars [localLowData, localRecoveryData, timeframe, stillInDip, stillInRecovery, currentLocalLowData, currentLocalRecoveryData, currentTimeframe, currentlyInDip, currentlyInRecovery, medianDipBars, medianRecoveryBars] [localLowData, localRecoveryData, timeframe, stillInDip, stillInRecovery, currentLocalLowData, currentLocalRecoveryData, currentTimeframe, currentlyInDip, currentlyInRecovery, medianDipBars, medianRecoveryBars] = get_ath_data() var table stats = table.new(position=i_tablePosition, columns=6, rows=4, border_width=1) table.cell(table_id=stats, column=1, row=0, text='All Time', bgcolor=i_headerColor, text_color=color.white, text_size=i_text_size) table.cell(table_id=stats, column=0, row=2, text='Max drawdown bars', bgcolor=color.maroon, text_color=color.white, text_size=i_text_size) table.cell(table_id=stats, column=0, row=3, text='Max recovery bars', bgcolor=color.maroon, text_color=color.white, text_size=i_text_size) table.cell(table_id=stats, column=1, row=1, text=timeframe, bgcolor=color.blue, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=1, row=2, text=localLowData, bgcolor=stillInDip ? color.red : i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=1, row=3, text=localRecoveryData, bgcolor=stillInRecovery? color.red:i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=2, row=1, text='Median', bgcolor=color.blue, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=2, row=2, text=str.tostring(medianDipBars), bgcolor=i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=2, row=3, text=str.tostring(medianRecoveryBars),bgcolor=i_neutralColor, text_color=color.black, text_size=i_text_size) if(inDateRange) [_localLowData, _localRecoveryData, _timeframe, _stillInDip, _stillInRecovery,_,_,_,_,_,_medianDipBars,_medianRecoveryBars] = get_ath_data() table.cell(table_id=stats, column=3, row=0, text='Window', bgcolor=i_headerColor, text_color=color.white, text_size=i_text_size) table.cell(table_id=stats, column=3, row=1, text=_timeframe, bgcolor=color.blue, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=3, row=2, text=_localLowData, bgcolor=_stillInDip ? color.red : i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=3, row=3, text=_localRecoveryData, bgcolor=_stillInRecovery? color.red:i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=4, row=1, text='Median', bgcolor=color.blue, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=4, row=2, text=str.tostring(_medianDipBars), bgcolor=i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=4, row=3, text=str.tostring(_medianRecoveryBars),bgcolor=i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=5, row=0, text='Current', bgcolor=i_headerColor, text_color=color.white, text_size=i_text_size) table.cell(table_id=stats, column=5, row=1, text=currentTimeframe, bgcolor=color.blue, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=5, row=2, text=currentLocalLowData, bgcolor=currentlyInDip ? color.red : i_neutralColor, text_color=color.black, text_size=i_text_size) table.cell(table_id=stats, column=5, row=3, text=currentLocalRecoveryData, bgcolor=currentlyInRecovery? color.red:i_neutralColor, text_color=color.black, text_size=i_text_size)
100w EMA-SMA cloud, 200wSMA floor
https://www.tradingview.com/script/tGIj5NO4-100w-EMA-SMA-cloud-200wSMA-floor/
delrioo
https://www.tradingview.com/u/delrioo/
19
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/ // © delrioo //@version=4 study("100w EMA-SMA cloud, 200wSMA floor", overlay = true) a = ema(close,100) b = sma(close,100) c = sma(close,200) outSma = security(syminfo.tickerid, "W", b) outEma = security(syminfo.tickerid, "W", a) outsmaa = security(syminfo.tickerid, "W", c) smaPlot = plot(outSma, color=color.red, title="100w SMA") emaPlot = plot(outEma, color=color.green, title="100w EMA") smaaPlot = plot(outsmaa, color=color.black, title="200w SMA") fill(emaPlot, smaPlot, color=color.new(color.orange, 75), fillgaps=true)
The Rush
https://www.tradingview.com/script/Pafi9ob0-The-Rush/
zrrsys
https://www.tradingview.com/u/zrrsys/
166
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/ // © zrrsys //@version=5 indicator("The Rush", overlay=false) var oldvrb=0.0 var oldvrs=0.0 var data=0.0 var datas=0.0 vr=0.0 vrp=0.0 dif=0.0 avg=0.0 difv=0.0 avgv=0.0 fast = 25, slow = 52 fastMA = ta.sma(close, fast) slowMA = ta.sma(close, slow) if (open<open[1]) dif:=(open-open[1]) avg:=(open+open[1])/2 difv:=math.abs(volume-volume[1]) avgv:=(volume+volume[1])/2 //incr=(dif/volume[1])//*100 incr=(dif/avg)*100 incrv=(difv/avgv)*100 if (open>close and open<open[1])// and fastMA>slowMA)// and incr>=100) vr:=(incrv/incr) if (vr<0.0 and oldvrs>vr and oldvrs<0.0) datas:=datas-25 else datas:=0.0 //plotshape(vr, style=shape.triangleup) //plot(vr) plot(datas, "Heavy Bears selling", color.red, 4, plot.style_columns) oldvrs:=vr //plotshape(vr, style=shape.triangleup) vrb=0.0 if (open>open[1]) dif:=(open-open[1])//math.abs avg:=(open+open[1])/2 difv:=math.abs(volume-volume[1]) avgv:=(volume+volume[1])/2 //incrb=(dif/volume[1])//*100 incrb=(dif/avg)*100 incrbv=(difv/avgv)*100 if (open<close and open>open[1])// and fastMA<slowMA)// and incrb>=100) vrb:=(incrbv/incrb) if (vrb>0.0 and oldvrb<vrb and oldvrb>0.0) data:=data+25 else data:=0.0 //plotshape(data, style=shape.triangleup) plot(data, "Heavy Bulls buying", color.green, 4, plot.style_columns) oldvrb:=vrb
TrendLine
https://www.tradingview.com/script/yGaPNB1O-TrendLine/
omidbnb
https://www.tradingview.com/u/omidbnb/
896
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/ // © omidbnb //@version=4 study("TrendLineSample", overlay=true) shortPeriod = input(30, title="shortPeriod") longPeriod = input(100, title="longPeriod") if barstate.islast float lowest_y2 = 60000 float lowest_x2 = 0 float highest_y2 = 0 float highest_x2 = 0 for i = 1 to shortPeriod if low[i] < lowest_y2 lowest_y2 := low[i] lowest_x2 := i if high[i] > highest_y2 highest_y2 := high[i] highest_x2 := i float lowest_y1 = 60000 float lowest_x1 = 0 float highest_y1 = 0 float highest_x1 = 0 for j = shortPeriod + 1 to longPeriod if low[j] < lowest_y1 lowest_y1 := low[j] lowest_x1 := j if high[j] > highest_y1 highest_y1 := high[j] highest_x1 := j sup = line.new(x1=bar_index[lowest_x1], y1=lowest_y1, x2=bar_index[lowest_x2], y2=lowest_y2, extend=extend.right, width=2, color=color.green) res = line.new(x1=bar_index[highest_x1], y1=highest_y1, x2=bar_index[highest_x2], y2=highest_y2, extend=extend.right, width=2, color=color.red) line.delete(sup[1]) line.delete(res[1]) if crossunder(close, line.get_price(sup, bar_index[0])) alert("break support", freq=alert.freq_once_per_bar_close) if crossover(close, line.get_price(res, bar_index[0])) alert("break resistance", freq=alert.freq_once_per_bar_close)
Find Best Performing MA For Price Crossover
https://www.tradingview.com/script/lqKiGbsP-Find-Best-Performing-MA-For-Price-Crossover/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
469
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/ // © KioseffTrading // ----------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- // Shoutout to Duyck (JD) for instructing how to sort the elements in one array based on the values of a separate array!!! // https://www.tradingview.com/script/Mzc4dmq7-ma-sorter-sort-by-array-example-JD/ <----- (Duyck's original array script) // ----------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------------------------- // //@version=5 indicator("Find Best Performing MA For Price Crossover", overlay = true) dataType = input.string(defval = "Custom", title = "MA Data Type", options = ["Benchmark", "Custom"]) instructions = input.string(defval = "Off", title = "Indicator Instructions", options = ["Off", "On"]) c = input.source(close, title = "Benchmark MA Source") d = input.int(50, title = "Benchmark MA Length") a = input.source(close, title = "TEST MA Source") b = input.int(50, title = "TEST MA Length", minval = 2) MA = input.string(defval = "Best Performing", title = "Plot MA?", options = ["Best Performing", "SMA", "EMA", "ALMA", "HMA", "WMA", "VWMA", "LSMA", "OFF"]) show = input.string(title = "Show Other MAs ? (If Best Performing Is Selected)", defval = "Light", options = ["Light", "Full", "Off"], group = "Best Performing MA Customization") smaB = ta.sma(c, d) emaB = ta.ema(c, d) almaB = ta.alma(c, d, 0.85, 6) hmaB = ta.hma(c, d) wmaB = ta.wma(c, d) vwmaB = ta.vwma(c, d) rmaB = ta.rma(c, d) lsB = ta.linreg(c, d, 0) sma5 = ta.sma(a, b) ema5 = ta.ema(a, b) alma5 = ta.alma(a, b, 0.85, 6) hma5 = ta.hma(a, b) wma5 = ta.wma(a, b) vwma5 = ta.vwma(a, b) rma5 = ta.rma(a, b) ls5 = ta.linreg(a, b, 0) // SMA var int smacount = 0 var int smacount2 = 0 var float smap = 0.0 var float smap1 = 0.0 var int counts = 0 var int counts1 = 0 if ta.crossover(c, smaB) and smacount == 0 smap := close smacount := 1 counts := bar_index if ta.crossunder(c, smaB) and smacount == 1 smacount := 0 smap1 := ((close / smap) - 1) * 100 smap1 := smap1[1] + smap1 smacount2 += 1 counts1 := bar_index - counts counts1 := counts1[1] + counts1 finsmap = (smap1 / smacount2) fincounts = counts1 / smacount2 // EMA var int emacount = 0 var int emacount2 = 0 var float emap = 0.0 var float emap1 = 0.0 var int counte = 0 var int counte1 = 0 if ta.crossover(c, emaB) and emacount == 0 emap := close emacount := 1 counte := bar_index if ta.crossunder(c, emaB) and emacount == 1 emacount := 0 emap1 := ((close / emap) - 1) * 100 emap1 := emap1[1] + emap1 emacount2 += 1 counte1 := bar_index - counte counte1 := counte1[1] + counte1 finemap = (emap1 / emacount2) fincounte = counte1 / emacount2 // ALMA var int almacount = 0 var int almacount2 = 0 var float almap = 0.0 var float almap1 = 0.0 var int counta = 0 var int counta1 = 0 if ta.crossover(c, almaB) and almacount == 0 almap := close almacount := 1 counta := bar_index if ta.crossunder(c, almaB) and almacount == 1 almacount := 0 almap1 := ((close / almap) - 1) * 100 almap1 := almap1[1] + almap1 almacount2 += 1 counta1 := bar_index - counta counta1 := counta1[1] + counta1 finalmap = (almap1 / almacount2) fincounta = counta1 / almacount2 // HMA var int hmacount = 0 var int hmacount2 = 0 var float hmap = 0.0 var float hmap1 = 0.0 var int counth = 0 var int counth1 = 0 if ta.crossover(c, hmaB) and hmacount == 0 hmap := close hmacount := 1 counth := bar_index if ta.crossunder(c, hmaB) and hmacount == 1 hmacount := 0 hmap1 := ((close / hmap) - 1) * 100 hmap1 := hmap1[1] + hmap1 hmacount2 += 1 counth1 := bar_index - counth counth1 := counth1[1] + counth1 finhmap = (hmap1 / hmacount2) fincounth = counth1 / hmacount2 // WMA var int wmacount = 0 var int wmacount2 = 0 var float wmap = 0.0 var float wmap1 = 0.0 var int countw = 0 var int countw1 = 0 if ta.crossover(c, wmaB) and wmacount == 0 wmap := close wmacount := 1 countw := bar_index if ta.crossunder(c, wmaB) and wmacount == 1 wmacount := 0 wmap1 := ((close / wmap) - 1) * 100 wmap1 := wmap1[1] + wmap1 wmacount2 += 1 countw1 := bar_index - countw countw1 := countw1[1] + countw1 finwmap = (wmap1 / wmacount2) fincountw = countw1 / wmacount2 // VWMA var int vwmacount = 0 var int vwmacount2 = 0 var float vwmap = 0.0 var float vwmap1 = 0.0 var int countvw = 0 var int countvw1 = 0 if ta.crossover(c, vwmaB) and vwmacount == 0 vwmap := close vwmacount := 1 countvw := bar_index if ta.crossunder(c, vwmaB) and vwmacount == 1 vwmacount := 0 vwmap1 := ((close / vwmap) - 1) * 100 vwmap1 := vwmap1[1] + vwmap1 vwmacount2 += 1 countvw1 := bar_index - countvw countvw1 := countvw1[1] + countvw1 finvwmap = (vwmap1 / vwmacount2) fincountvw = countvw1 / vwmacount2 // ls var int lscount = 0 var int lscount2 = 0 var float lsp = 0.0 var float lsp1 = 0.0 var int countls = 0 var int countls1 = 0 if ta.crossover(c, lsB) and lscount == 0 lsp := close lscount := 1 countls := bar_index if ta.crossunder(c, lsB) and lscount == 1 lscount := 0 lsp1 := ((close / lsp) - 1) * 100 lsp1 := lsp1[1] + lsp1 lscount2 += 1 countls1 := bar_index - countls countls1 := countls1[1] + countls1 finlsp = (lsp1 / lscount2) fincountls = countls1 / lscount2 // SMA var int smacountx = 0 var int smacount2x = 0 var float smapx = 0.0 var float smap1x = 0.0 var int countsx = 0 var int countsx1 = 0 if ta.crossover(a, sma5) and smacountx == 0 smapx := close smacountx := 1 countsx := bar_index if ta.crossunder(a, sma5) and smacountx == 1 smacountx := 0 smap1x := ((close / smapx) - 1) * 100 smap1x := smap1x[1] + smap1x smacount2x += 1 countsx1 := bar_index - countsx countsx1 := countsx1[1] + countsx1 finsmapx = (smap1x / smacount2x) fincountsx = countsx1 / smacount2x // EMA var int emacountx = 0 var int emacount2x = 0 var float emapx = 0.0 var float emap1x = 0.0 var int countex = 0 var int countex1 = 0 if ta.crossover(a, ema5) and emacountx == 0 emapx := close emacountx := 1 countex := bar_index if ta.crossunder(a, ema5) and emacountx == 1 emacountx := 0 emap1x := ((close / emapx) - 1) * 100 emap1x := emap1x[1] + emap1x emacount2x += 1 countex1 := bar_index - countex countex1 := countex1[1] + countex1 finemapx = (emap1x / emacount2x) fincountex = countex1 / emacount2x // ALMA var int almacountx = 0 var int almacount2x = 0 var float almapx = 0.0 var float almap1x = 0.0 var int countax = 0 var int countax1 = 0 if ta.crossover(a, alma5) and almacountx == 0 almapx := close almacountx := 1 countax := bar_index if ta.crossunder(a, alma5) and almacountx == 1 almacountx := 0 almap1x := ((close / almapx) - 1) * 100 almap1x := almap1x[1] + almap1x almacount2x += 1 countax1 := bar_index - countax countax1 := countax1[1] + countax1 finalmapx = (almap1x / almacount2x) fincountax = countax1 / almacount2x // HMA var int hmacountx = 0 var int hmacount2x = 0 var float hmapx = 0.0 var float hmap1x = 0.0 var int counthx = 0 var int counthx1 = 0 if ta.crossover(a, hma5) and hmacountx == 0 hmapx := close hmacountx := 1 counthx := bar_index if ta.crossunder(a, hma5) and hmacountx == 1 hmacountx := 0 hmap1x := ((close / hmapx) - 1) * 100 hmap1x := hmap1x[1] + hmap1x hmacount2x += 1 counthx1 := bar_index - counthx counthx1 := counthx1[1] + counthx1 finhmapx = (hmap1x / hmacount2x) fincounthx = counthx1 / hmacount2x // WMA var int wmacountx = 0 var int wmacount2x = 0 var float wmapx = 0.0 var float wmap1x = 0.0 var int countwx = 0 var int countwx1 = 0 if ta.crossover(a, wma5) and wmacountx == 0 wmapx := close wmacountx := 1 countwx := bar_index if ta.crossunder(a, wma5) and wmacountx == 1 wmacountx := 0 wmap1x := ((close / wmapx) - 1) * 100 wmap1x := wmap1x[1] + wmap1x wmacount2x += 1 countwx1 := bar_index - countwx countwx1 := countwx1[1] + countwx1 finwmapx = (wmap1x / wmacount2x) fincountwx = countwx1 / wmacount2x // VWMA var int vwmacountx = 0 var int vwmacount2x = 0 var float vwmapx = 0.0 var float vwmap1x = 0.0 var int countvwx = 0 var int countvwx1 = 0 if ta.crossover(a, vwma5) and vwmacountx == 0 vwmapx := close vwmacountx := 1 countvwx := bar_index if ta.crossunder(a, vwma5) and vwmacountx == 1 vwmacountx := 0 vwmap1x := ((close / vwmapx) - 1) * 100 vwmap1x := vwmap1x[1] + vwmap1x vwmacount2x += 1 countvwx1 := bar_index - countvwx countvwx1 := countvwx1[1] + countvwx1 finvwmapx= (vwmap1x / vwmacount2x) fincountvwx = countvwx1 / vwmacount2x // ls var int lscountx = 0 var int lscount2x = 0 var float lspx = 0.0 var float lsp1x = 0.0 var int countlsx = 0 var int countlsx1 = 0 if ta.crossover(a, ls5) and lscountx == 0 lspx := close lscountx := 1 countlsx := bar_index if ta.crossunder(a, ls5) and lscountx == 1 lscountx := 0 lsp1x := ((close / lspx) - 1) * 100 lsp1x := lsp1x[1] + lsp1x lscount2x += 1 countlsx1 := bar_index - countlsx countlsx1 := countlsx1[1] + countlsx1 finlspx = (lsp1x / lscount2x) fincountlsx = countlsx1 / lscount2x f_sort_by_array(_array1, _array2, _array3, _array4) => _array1_size = array.size(_array1) _array1_sorted = array.new_string(_array1_size) _array3_sorted = array.copy(_array3) _array4_sorted = array.copy(_array4) _array2_sorted = array.copy(_array2) if _array1_size == array.size(_array2) and _array1_size == array.size(_array2) array.sort(_array2_sorted, order.descending) for i = 0 to _array1_size - 1 _sorted_value = array.get(_array2_sorted, i) _unsorted_index = math.max(0, array.indexof(_array2, _sorted_value)) _unsorted_value = array.get (_array1, _unsorted_index) _unsorted_value2 = array.get(_array3, _unsorted_index) _unsorted_value3 = array.get(_array4, _unsorted_index) array.set(_array1_sorted, i, _unsorted_value) array.set(_array3_sorted, i, _unsorted_value2) array.set(_array4_sorted, i, _unsorted_value3) [_array1_sorted, _array2_sorted, _array3_sorted, _array4_sorted] f_sort_by_array(_array1x, _array2x) => _array1_sizex = array.size(_array1x) _array1_sortedx = array.new_string(_array1_sizex) _array2_sortedx = array.copy(_array2x) if _array1_sizex == array.size(_array2x) array.sort(_array2_sortedx, order.descending) for i = 0 to _array1_sizex - 1 _sorted_valuex = array.get(_array2_sortedx, i) _unsorted_indexx = math.max(0, array.indexof(_array2x, _sorted_valuex)) _unsorted_valuex = array.get (_array1x, _unsorted_indexx) array.set(_array1_sortedx, i, _unsorted_valuex) [_array1_sortedx, _array2_sortedx] best = array.new_float(7) array.set(best, 0, dataType == "Benchmark" ? smap1 : smap1x), array.set(best, 1, dataType == "Benchmark" ? emap1 : emap1x), array.set(best, 2,dataType == "Benchmark" ? almap1 : almap1x) array.set(best, 3, dataType == "Benchmark" ? hmap1 : hmap1x), array.set(best, 4, dataType == "Benchmark" ? wmap1 : wmap1x), array.set(best, 5, dataType == "Benchmark" ? vwmap1 : vwmap1x) array.set(best, 6, dataType == "Benchmark" ? lsp1 : lsp1x) best1 = array.new_string(7) array.set(best1, 0, "SMA"), array.set(best1, 1, "EMA"), array.set(best1, 2, "ALMA") array.set(best1, 3, "HMA"), array.set(best1, 4, "WMA"), array.set(best1, 5, "VWMA") array.set(best1, 6, "LSMA") [bestname_sorted, best_sorted] = f_sort_by_array(best1, best) array.reverse(best_sorted) array.reverse(bestname_sorted) orgname = array.new_string(7) org = array.new_float(7) org1 = array.new_float(7) org2 = array.new_int(7) sma = finsmap, array.set(orgname, 0, "SMA"), array.set(org, 0, dataType == "Benchmark" ? finsmap : finsmapx), array.set(org1, 0, dataType == "Benchmark" ? fincounts : fincountsx), array.set(org2, 0, dataType == "Benchmark" ? smacount2 : smacount2x) ema = finemap, array.set(orgname, 1, "EMA"), array.set(org, 1, dataType == "Benchmark" ? finemap : finemapx), array.set(org1, 1, dataType == "Benchmark" ? fincounte : fincountex), array.set(org2, 1, dataType == "Benchmark" ? emacount2 : emacount2x) alma = finalmap, array.set(orgname, 2, "ALMA"), array.set(org, 2, dataType == "Benchmark" ? finalmap : finalmapx), array.set(org1, 2, dataType == "Benchmark" ? fincounta : fincountax), array.set(org2, 2, dataType == "Benchmark" ? almacount2 : almacount2x) hma = finhmap, array.set(orgname, 3, "HMA"), array.set(org, 3, dataType == "Benchmark" ? finhmap : finhmapx), array.set(org1, 3, dataType == "Benchmark" ? fincounth : fincounthx), array.set(org2, 3, dataType == "Benchmark" ? hmacount2 : hmacount2x) wma = finwmap, array.set(orgname, 4, "WMA"), array.set(org, 4, dataType == "Benchmark" ? finwmap : finwmapx), array.set(org1, 4, dataType == "Benchmark" ? fincountw : fincountwx), array.set(org2, 4, dataType == "Benchmark" ? wmacount2 : wmacount2x) vwma = finvwmap, array.set(orgname, 5, "VWMA"), array.set(org, 5, dataType == "Benchmark" ? finvwmap : finvwmapx), array.set(org1, 5, dataType == "Benchmark" ? fincountvw : fincountvwx), array.set(org2, 5, dataType == "Benchmark" ? vwmacount2 : vwmacount2x) lsma = finlsp, array.set(orgname, 6, "LSMA"), array.set(org, 6,dataType == "Benchmark" ? finlsp : finlspx), array.set(org1, 6, dataType == "Benchmark" ? fincountls : fincountlsx), array.set(org2, 6, dataType == "Benchmark" ? lscount2 : lscount2x) [orgname_sorted, org_sorted, org1_sorted, org2_sorted] = f_sort_by_array(orgname, org, org1, org2) x = plot(MA == "Best Performing" ? sma5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 0) ? color.from_gradient(close, sma5 - 10, sma5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,0) and show == "Full" ? color.green : MA == "Best Performing" and array.max(best) != array.get(best,0) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x1 = plot(MA == "Best Performing" ? ema5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 1) ? color.from_gradient(close, ema5 - 10, ema5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,1) and show == "Full" ? color.orange : MA == "Best Performing" and array.max(best) != array.get(best,1) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x2 = plot(MA == "Best Performing" ? alma5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 2) ? color.from_gradient(close, alma5 - 10, alma5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,2) and show == "Full" ? color.yellow : MA == "Best Performing" and array.max(best) != array.get(best,2) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x3 = plot(MA == "Best Performing" ? hma5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 3) ? color.from_gradient(close, hma5 - 10, hma5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,3) and show == "Full" ? color.blue : MA == "Best Performing" and array.max(best) != array.get(best,3) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x4 = plot(MA == "Best Performing" ? wma5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 4) ? color.from_gradient(close, wma5 - 10, wma5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,4) and show == "Full" ? color.purple : MA == "Best Performing" and array.max(best) != array.get(best,4) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x5 = plot(MA == "Best Performing" ? vwma5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 5) ? color.from_gradient(close, vwma5 - 10, vwma5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,5) and show == "Full" ? color.gray : MA == "Best Performing" and array.max(best) != array.get(best,5) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) x6 = plot(MA == "Best Performing" ? ls5 : na, color = MA == "Best Performing" and array.max(best) == array.get(best, 6) ? color.from_gradient(close, ls5 - 10, ls5 + 10, #ff0500, #03ff00) : MA == "Best Performing" and array.max(best) != array.get(best,6) and show == "Full" ? color.teal : MA == "Best Performing" and array.max(best) != array.get(best,6) and show == "Light" ? color.new(color.black, 50) : color.new(color.black, 100), linewidth = 2) var table t2 = na if MA == "Best Performing" and barstate.islast t2 := table.new(position.top_right, 10, 10, bgcolor = array.max(best) == array.get(best, 0) ? color.from_gradient(close, sma5 - 10, sma5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 1) ? color.from_gradient(close, ema5 - 10, ema5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 2) ? color.from_gradient(close, alma5 - 10, alma5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 3) ? color.from_gradient(close, hma5 - 10, hma5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 4) ? color.from_gradient(close, wma5 - 10, wma5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 5) ? color.from_gradient(close, vwma5 - 10, vwma5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : array.max(best) == array.get(best, 6) ? color.from_gradient(close, ls5 - 10, ls5 + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : MA != "Best Performing" ? color.new(color.white, 100) : na ) sourceS = a == close ? "Close" : a == open ? "Open" : a == high ? "High" : a == low ? "Low" : a == hl2 ? "HL" : a == hlc3 ? "HLC" : a == ohlc4 ? "OHLC" : a == hlcc4 ? "HLCC" : a == ta.obv ? "OBV" : " Other" if MA == "Best Performing" and barstate.islast table.cell(t2, 0, 0, text = MA == "Best Performing" and array.max(best) == array.get(best, 0) ? "Plotted: SMA " + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 1) ? "Plotted: EMA " + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 2) ? "Plotted: ALMA " + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 3) ? "Plotted: HMA" + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 4) ? "Plotted: WMA " + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 5) ? "Plotted: VWMA " + str.tostring(b) + " (" + sourceS + ")" : MA == "Best Performing" and array.max(best) == array.get(best, 6) ? "Plotted: LSMA " + str.tostring(b) + " (" + sourceS + ")" : na, bgcolor = MA != "Best Performing" ? color.new(color.white, 100) : na, text_color = color.white ) orgtext = "" besttext = "" table1 = table.new(position.bottom_right, 10, 10, bgcolor = color.new(color.white, 100)) if barstate.islast and dataType == "Custom" table.cell(table1, 0,0,text = "Price Crossover Performance" + "\n" + "\n" + str.tostring(sourceS) + "/" + str.tostring(b) + " (MA)", text_color = color.blue, text_size = size.normal) for i = 0 to array.size(org) - 1 orgtext := orgtext + array.get(orgname_sorted, i) + ": " + str.tostring(array.get(org_sorted, i), format.percent) + " (" +str.tostring(array.get(org1_sorted, i), '#') + " Candles" + ")" + " (" + str.tostring(array.get(org2_sorted, i), "#") + " Crosses)" + "\n" +"\n" table.cell(table1, 0,1,text = orgtext, text_color = color.white) for i = 0 to array.size(best) - 1 besttext := "Highest Cumulative Gains: " + str.tostring(array.get(best_sorted, i), format.percent)+ " (" + array.get(bestname_sorted,i) + ")" + "\n" + "\n" table.cell(table1, 0, 2, text = besttext, text_color = color.green) else if barstate.islast and dataType != "Custom" table.cell(table1, 0,0,text = "Price Crossover Performance (Benchmark) \n \n" + str.tostring(sourceS) + "/" + str.tostring(d) +" (MA)", text_color = color.blue, text_size = size.normal) for i = 0 to array.size(org) - 1 orgtext := orgtext + array.get(orgname_sorted, i) + ": " + str.tostring(array.get(org_sorted, i), format.percent) + " (" +str.tostring(array.get(org1_sorted, i), '#') + " Candles" + ")" + " (" + str.tostring(array.get(org2_sorted, i), "#") + " Crosses)" + "\n" +"\n" table.cell(table1, 0,1,text = orgtext, text_color = color.white) for i = 0 to array.size(best) - 1 besttext := "Highest Cumulative Gains: " + str.tostring(array.get(best_sorted, i), format.percent)+ " (" + array.get(bestname_sorted,i) + ")" + "\n" + "\n" table.cell(table1, 0, 2, text = besttext, text_color = color.green) if instructions == "On" and barstate.islast table.cell(table1, 0,6, text = "The script calculates and compares asset performance after \nan MA/price crossover (source [i.e. close] crossover MA)" + "\n" + "\nThe best performing moving averages are listed in descending order!" + "\nWorks for any asset on any timeframe!" + "\n" + "\n" + "The integers inside parentheses indicate the AVERAGE\n number of candles that the source \n remains above the MA following\n following a crossover!" + "\n\n The gradient color MA is the best performing MA. \nWhen prices trade above the MA it will turn green \nWhen prices trade below the MA it will turn red!", text_color = color.green) plot(MA == "SMA" ? sma5 : MA == "EMA" ? ema5 : MA == "ALMA" ? alma5 : MA == "HMA" ? hma5 : MA == "WMA" ? wma5 : MA == "VWMA" ? vwma5 : MA == "LSMA" ? ls5 : na, color = MA == "SMA" ? color.green : MA == "EMA" ? color.orange : MA == "ALMA" ? color.yellow : MA == "HMA" ? color.blue : MA == "WMA" ? color.purple : MA == "VWMA" ? color.gray : MA == "LSMA" ? color.teal : na, linewidth = 2)
Trading Made Easy Pressure Oscillator
https://www.tradingview.com/script/RLkJPO0d-Trading-Made-Easy-Pressure-Oscillator/
christoefert
https://www.tradingview.com/u/christoefert/
190
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/ // © christoefert //@version=5 indicator(title="Trading Made Easy Pressure Oscillator", shorttitle="TME_PO", format=format.price, precision=2, timeframe="", timeframe_gaps=true) //Pressure Oscillator Setup shortlen=input.int(8, "Short Length", minval=1) longlen=input.int(21, "Long Length", minval=1) src = input(close, title="Momentum Oscillator Source") exp = input(false, "exponential") esma(source, length)=> s = ta.sma(source, length) e = ta.ema(source, length) exp ? e : s short = esma(src, shortlen) long = esma(src, longlen) po = (short - long) //Histogram Colouring iff_1 = po > nz(po[1]) ? color.new(color.white, 0) : color.new(color.gray, 0) iff_2 = po < nz(po[1]) ? color.new(color.orange, 0) : color.new(color.yellow, 0) momentum_color = po > 0 ? iff_1 : iff_2 //Squeeze Criteria Using Bollinger Bands Width length = input.int(20, minval=1) src2 = input(close, title="Source for Pressure") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") basis = ta.sma(src2, length) dev = mult * ta.stdev(src2, length) upper = basis + dev lower = basis - dev bbw = (upper-lower)/basis Trigger = ta.ema(bbw, 21) //Pressure Conditions NoSqz = bbw > Trigger Sqz = bbw < Trigger sq_color = Sqz ? color.new(color.red, 0) : color.new(color.green, 0) //Plot Everything plot(po, color=momentum_color, style=plot.style_columns, title="Momentum Oscillator") plot(0, title='Pressure', color=sq_color, style=plot.style_circles, linewidth=2)
Renko Candles Overlay
https://www.tradingview.com/script/rZs7YdMI-Renko-Candles-Overlay/
LonesomeTheBlue
https://www.tradingview.com/u/LonesomeTheBlue/
5,030
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/ // © LonesomeTheBlue //@version=5 indicator("Renko Candles Overlay", overlay = true, max_bars_back = 2001, max_boxes_count = 500) mode =input.string(title = "Method", defval = 'ATR/2', options=['Traditional', 'ATR', 'ATR/2', 'ATR/4', 'Percentage'], group = 'SETUP') modevalue = input.int(title =" Atr Period", defval = 14, minval = 1, group = 'SETUP') tboxsize = input.float(title =" Brick Size", defval = 10.0, minval = 0.000000000000001, group = 'SETUP') percentagebs = input.float(title =" Percentage %", defval = 0.1, minval = 0.00001, step = 0.1, group = 'SETUP') period = input.int(defval = 140, title = " Number of Bricks", minval = 10, maxval = 280, group = 'SETUP') putlabels = input.bool(defval = true, title = "Levels & Lines for new Bricks", inline = "labels") linestyle = input.string(defval = 'dashed', title = "", options = ['dashed', 'dotted', 'solid'], inline = "labels") colup = input.color(defval = #5b9cf6, title = " Color Up", group = 'BRICKS') coldn = input.color(defval = #0c3299, title = " Color Down", group = 'BRICKS') coluc = input.color(defval = color.gray, title = " Unconfirmed", group = 'BRICKS') bwidth = input.int(defval = 2, title = " Width", minval = 1, maxval = 10, group = 'BRICKS') bcolup = input.color(defval = color.lime, title = " Color Up", group = 'BORDERS') bcoldn = input.color(defval = color.red, title = " Color Down", group = 'BORDERS') borderwidth = input.int(defval = 1, title = " Width", minval = 0, maxval = 2, group = 'BORDERS') changebrol = input.bool(defval = false, title = "Change Bar Color", group = "CANDLES") barcolup = input.color(defval = color.lime, title = " Color Up", group = "CANDLES") barcoldn = input.color(defval = color.red, title = " Color Down", group = "CANDLES") get_b_size(value)=> var num = math.pow(10, str.length(str.tostring(syminfo.mintick)) - 2) float ret = value if na(ret) ret := ta.tr(true) if ret < 1 ret := math.round(ret * num) / num else pw = ret >= 10 ? math.pow(10, math.max(str.length(array.get(str.split(str.tostring(ret), '.'), 0)) - 2, 1)) : 1 ret := math.round(ret / pw) * pw math.max(ret, syminfo.mintick) // calculate brick size float boxsize = mode == 'ATR' ? get_b_size(ta.atr(modevalue)) : mode == 'ATR/2' ? math.max(get_b_size(ta.atr(modevalue)) / 2, syminfo.mintick) : mode == 'ATR/4' ? math.max(get_b_size(ta.atr(modevalue)) / 4, syminfo.mintick) : mode == 'Percentage' ? get_b_size(percentagebs * close / 100) : tboxsize addbricks(rclose, numbrick, start, bsize)=> for x = 1 to numbrick array.unshift(rclose, start + x * bsize) var float boxs = boxsize var int trend = 0 var rclose = array.new_float(1, math.floor(open / boxs) * boxs) float currentprice = close float lastclose = array.get(rclose, 0) int numcell = math.floor(math.abs(lastclose - currentprice) / boxs) int unconfirmed = -1 if numcell > 0 if trend == 0 if numcell >= 2 trend := (lastclose < currentprice ? 1 : -1) addbricks(rclose, numcell, lastclose, trend * boxs) else if lastclose * trend < currentprice * trend addbricks(rclose, numcell, lastclose, trend * boxs) else if numcell >= 2 trend *= -1 addbricks(rclose, numcell - 1, lastclose + trend * boxs, trend * boxs) // trend changed // change boxsize when trend changed if lastclose != array.get(rclose, 0) boxs := boxsize if not barstate.ishistory and barstate.isrealtime unconfirmed := numcell - (trend != trend[1] ? 1 : 0) // delete old elements while array.size(rclose) > period + 3 array.pop(rclose) if putlabels and trend != 0 var hlstyle = linestyle == 'dashed' ? line.style_dashed : linestyle == 'dotted' ? line.style_dotted : line.style_solid up = trend == 1 ? array.get(rclose, 0) + boxs : array.get(rclose, 0) + boxs * 2 dn = trend == 1 ? array.get(rclose, 0) - boxs * 2 : array.get(rclose, 0) - boxs var line upline = na, line.delete(upline), var label uplabel = na, label.delete(uplabel) var line dnline = na, line.delete(dnline), var label dnlabel = na, label.delete(dnlabel) upline := line.new(x1 = bar_index, y1 = up, x2 = bar_index - 1, y2 = up, color = color.gray, style = hlstyle, extend = extend.both) dnline := line.new(x1 = bar_index, y1 = dn, x2 = bar_index - 1, y2 = dn, color = color.gray, style = hlstyle, extend = extend.both) uplabel := label.new(x = bar_index + 10, y = up, text = str.tostring(up), color = colup, textcolor = color.black, style = label.style_label_down) dnlabel := label.new(x = bar_index + 10, y = dn, text = str.tostring(dn), color = coldn, textcolor = color.white, style = label.style_label_up) if barstate.islast if array.size(rclose) >= 2 var bricks = array.new_box(0) for x = 0 to (array.size(bricks) > 0 ? array.size(bricks) - 1 : na) box.delete(array.pop(bricks)) int start = array.size(rclose) - 3 for x = array.size(rclose) - 3 to 0 if array.get(rclose, x) > array.get(rclose, x + 1) and array.get(rclose, x + 1) > array.get(rclose, x + 2) or array.get(rclose, x) < array.get(rclose, x + 1) and array.get(rclose, x + 1) < array.get(rclose, x + 2) start := x break int colnum = (start + 1) * bwidth int trnd = array.get(rclose, start) > array.get(rclose, start + 1) ? 1 : -1 float lasttb = array.get(rclose, start) for x = start + 1 to 0 oldtrnd = trnd trnd := array.get(rclose, x) > array.get(rclose, x + 1) ? 1 : -1 col = x < unconfirmed ? coluc : trnd == 1 ? colup : coldn bcol = trnd == 1 ? bcolup : bcoldn topbottom = oldtrnd == trnd ? array.get(rclose, x + 1) : lasttb if bar_index - colnum - bwidth > 1 and colnum < 285 array.push(bricks, box.new(left = bar_index - colnum, top = array.get(rclose, x), right = bar_index - colnum - bwidth, bottom = topbottom, border_width = borderwidth, border_color = bcol, bgcolor = col)) colnum -= bwidth lasttb := topbottom barcolor(changebrol ? trend == 1 ? barcolup : barcoldn : na) alertcondition(trend[1] == -1 and trend == 1, title = "Trend is UP", message = "Trend is UP") alertcondition(trend[1] == 1 and trend == -1, title = "Trend is DOWN", message = "Trend is DOWN")
NY-Session + lunch break
https://www.tradingview.com/script/QhFWe8Mt-NY-Session-lunch-break/
Se7en777
https://www.tradingview.com/u/Se7en777/
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/ // © Se7en777 //@version=5 indicator("NY-Session", overlay=true) //version = 1.0.0 session = time(timeframe.period, "0830-1200,1300-1630", "America/New_York") lunch = time(timeframe.period, "1200-1300", "America/New_York") bgcolor(session ? #d1d4dc35 : na, title = "Session") bgcolor(lunch ? #ff525215 : na, title = "Lunch")
AltSession
https://www.tradingview.com/script/pBVrzWwi-AltSession/
Altsignals
https://www.tradingview.com/u/Altsignals/
683
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/ // © KryptoGostek aka MrCode X AltSignals.io Enjoy =) // This script is a modification of boitoki's session script. Include some fixes, new features and options. //@version=5 indicator('AltSessions', overlay=true, max_boxes_count=220, max_labels_count=400, max_lines_count=400, max_bars_back=550) /////////////// // Groups /////////////// g0 = 'SETTINGS' g1 = '♯1 SESSION' g2 = '♯2 SESSION' g3 = '♯3 SESSION' g4 = 'SESSION BOX STYLE' g5 = 'DATA LABELS SHOW & STYLE' g6 = 'INFOBOX SHOW & STYLE' g7 = 'MIN/MAX SHOW & STYLE' g81 = 'SESSION #1' g82 = 'SESSION #2' g83 = 'SESSION #3' g9 = 'NY MIDNIGHT OPEN' /////////////// // Defined /////////////// show = true pips = syminfo.mintick * 10 max_bars = 500 option_yes = 'Yes' option_no = 'No' fmt_price = '{0,number,#.#####}' fmt_pips = '{0,number,#.#}' icon_separator = ' • ' empty_character = ' ' // U+2003 c_none = color.new(color.black, 100) valLab_offset = 3 // number of bars added to x2 as an offset for value label label_NYMO_offset = 15 // number of bars added to x as an offset for NYMO label var float mo = na mo := ta.valuewhen(ta.change(time("D","0000-0000","GMT-5")), open, 0) // NY Midnight Open /////////////// // Functions /////////////// f_get_started (_session) => na(_session[1]) and _session // previous bar wasn't in session, current one is in session time f_get_ended (_session) => na(_session) and _session[1] // previous bar was in session time, current one isn't in session time f_inSession (_session, _timezone) => na(time(timeframe.period, _session + ":1234567", _timezone)) == false // function for detecting if current bar falls within specified custom time period (session) f_get_period (_session, _start, _lookback) => // check i bars back if they are in session or not, if the first bar of session is found - break, the result is session duration in bars result = math.max(_start, 1) for i = result to _lookback if f_get_started(_session) result := 1 break else if na(_session[i+1]) and _session[i] result := i+1 break result f_get_label_position (_y) => // set label position according to inputs data switch _y 'top' => label.style_label_lower_left 'bottom' => label.style_label_upper_left f_get_day (n) => // set day name switch n 1 => 'Sun' 2 => 'Mon' 3 => 'Tue' 4 => 'Wed' 5 => 'Thu' 6 => 'Fri' 7 => 'Sat' /////////////// // Inputs /////////////// // Timezone & history switch i_tz = input.string(title="🕑 Timezone", defval="GMT", options=["GMT-10","GMT-9","GMT-8","GMT-7","GMT-6","GMT-5","GMT-4","GMT-3","GMT-2","GMT-1","GMT","GMT+1","GMT+2","GMT+3","GMT+3:30","GMT+4","GMT+5","GMT+5:30","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+10:30","GMT+11","GMT+12","GMT+13","GMT+13:45"], group=g0) i_show_history = input.string(option_no, 'Show history', options=[option_yes, option_no], group=g0) == option_yes i_encapsulate = input.bool(true, 'Encapsulate the last session candle', group=g0) sess_offset = i_encapsulate ? 0 : 1 // (should be 1 or 0) subtract number of candles from end of session to encapsulate last session candle or not i_lookback = 12 * 60 // 720 lookback period for calculation of session bars number - max session duration 12h on 1m chart, 6h on 30sec etc. // Sessions i_show_sess1 = input.bool(true, title="Session", inline="asia", group=g81) i_sess1_label = input.string('Tokyo',':', inline="asia", group=g81) i_sess1 = input.session(title=" ", defval="0100-0400", inline="asia", group=g81) i_sess1_bgCol = input.color(color.new(color.yellow,0), title="color", inline="asia", group=g81) i_sess1_minCol = input.color(color.rgb(207, 205, 66), title="Min", inline="asia", group=g81) i_sess1_maxCol = input.color(color.rgb(207, 205, 66), title="Max", inline="asia", group=g81) i_sess1_minmax = input.bool(true, title="Show Min/Max lines", inline="asia_mm", group=g81) i_sess1_extend = input.bool(false, 'Extend Min/Max lines', inline="asia_mm", group=g81) i_show_sess2 = input.bool(true, title="Session", inline="euro", group=g82) i_sess2_label = input.string('London',':', inline="euro", group=g82) i_sess2 = input.session(title=" ", defval="0700-1100", inline="euro", group=g82) i_sess2_bgCol = input.color(color.new(color.blue,0), title="color", inline="euro", group=g82) i_sess2_minCol = input.color(color.rgb(42, 129, 215), title="Min", inline="euro", group=g82) i_sess2_maxCol = input.color(color.rgb(42, 129, 215), title="Max", inline="euro", group=g82) i_sess2_minmax = input.bool(true, title="Show Min/Max lines", inline="euro_mm", group=g82) i_sess2_extend = input.bool(false, 'Extend Min/Max lines', inline="euro_mm", group=g82) i_show_sess3 = input.bool(true, title="Session", inline="america", group=g83) i_sess3_label = input.string('New York',':', inline="america", group=g83) i_sess3 = input.session(title=" ", defval="1430-2000", inline="america", group=g83) i_sess3_bgCol = input.color(color.new(color.red,0), title="color", inline="america", group=g83) i_sess3_minCol = input.color(color.rgb(200, 75, 75), title="Min", inline="america", group=g83) i_sess3_maxCol = input.color(color.rgb(200, 75, 75), title="Max", inline="america", group=g83) i_sess3_minmax = input.bool(true, title="Show Min/Max lines", inline="america_mm", group=g83) i_sess3_extend = input.bool(false, 'Extend Min/Max lines', inline="america_mm", group=g83) // Session Box Show & Styles i_sess_border_style = input.string(line.style_dashed, 'Border Style', options=[line.style_solid, line.style_dotted, line.style_dashed], inline='sess_box_style', group=g4) i_sess_border_width = input.int(1, 'width', minval=0, inline='sess_box_style', group=g4) i_sess_bgopacity = input.int(94, 'Background Opacity (100 = no color)', minval=0, maxval=100, step=1, group=g4) // Session MinMax Show & Styles i_minmax_lineStyle = input.string(line.style_solid, title="Line Style", options=[line.style_solid, line.style_dotted, line.style_dashed], inline="line_style", group=g7) i_minmax_lineWidth = input.int(2, title="width", inline="line_style", group=g7) i_show_minmax_lines = input.bool(true, title="Toggle showing min/max lines for all sessions", group=g7) i_show_minmax_val = input.bool(true, title="Toggle showing min/max values for all sessions", group=g7) // Data Label i_label_show = input.bool(true, 'Show labels', inline='label_show', group=g5) and show i_label_size = str.lower(input.string('Normal', '', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], inline='label_show', group=g5)) i_label_position_y = str.lower(input.string('Top', '', options=['Top', 'Bottom'], inline='label_show', group=g5)) i_label_position = f_get_label_position(i_label_position_y) i_label_format_name = input.bool(true, 'Name', inline='label_format', group=g5) i_label_format_day = input.bool(false, 'Day', inline='label_format', group=g5) i_label_format_price = input.bool(false, 'Price range', inline='label_format', group=g5) i_label_format_pips = input.bool(false, 'Pips range', inline='label_format', group=g5) // NY Midnight Open i_mo = input.bool(true, 'Midnight Open', inline="mo", group=g9) i_moCol = input.color(color.rgb(216, 68, 226), title="color", inline="mo", group=g9) i_mo_lineStyle = input.string(line.style_dotted, 'Line Style', options=[line.style_solid, line.style_dotted, line.style_dashed], inline='mo_style', group=g9) i_mo_lineWidth = input.int(2, title="width", inline="mo_style", group=g9) i_mo_label = input.bool(true, 'Show price label', inline="mo_extend", group=g9) i_mo_extend = input.bool(false, 'Extend line', inline="mo_extend", group=g9) // InfoBox table i_table_InfoBox_show = input.bool(true, 'Show InfoBox', group=g6) i_tableCol = input.color(color.new(color.blue, 0), title="Background", inline="sessionBox", group=g6) i_tableCell_txtCol = input.color(color.new(color.white,0), title="Text", inline="sessionBox", group=g6) // ------------------------ // Drawing labels // ------------------------ f_render_dataLabel (_show, _session, _is_started, _color, _top, _bottom, _text, _delete_history) => var label my_label = na var int start_time = na v_position_y = (i_label_position_y == 'top') ? _top : _bottom v_label = array.new_string() v_chg = _top - _bottom // price range if _is_started start_time := time if i_label_format_name and not na(_text) // session name array.push(v_label, _text) if i_label_format_day array.push(v_label, f_get_day(dayofweek(start_time, i_tz))) // day name if i_label_format_price array.push(v_label, str.format(fmt_price, v_chg)) // price range if i_label_format_pips array.push(v_label, str.format(fmt_pips, v_chg / pips) + ' pips') // pips range if _show if _is_started // check if bar is the firts bar of session my_label := label.new(time, v_position_y, array.join(v_label, icon_separator), textcolor=_color, color=c_none, size=i_label_size, style=i_label_position, xloc=xloc.bar_time, text_font_family=font.family_monospace) // create label if _delete_history // delete history label according to input label.delete(my_label[1]) if _session // if in session,change y parameter and update text label.set_y(my_label, v_position_y) label.set_text(my_label, array.join(v_label, icon_separator)) f_drawValLabel (_show, _session, _is_started, _is_ended, _x, _y, _textColor, _delete_history) => // Function to draw labels with min/max values var label level_label = na if _show if _is_started level_label := label.new(_x+valLab_offset, _y, '    ' + str.tostring(_y), xloc.bar_index, yloc.price, #00000000, label.style_none, _textColor, textalign=text.align_left, text_font_family=font.family_monospace) if _delete_history // delete history label according to input label.delete(level_label[1]) else if _session label.set_x(level_label, _x+valLab_offset) label.set_y(level_label, _y) label.set_text(level_label, str.tostring(_y)) else if _is_ended label.set_x(level_label, bar_index-sess_offset) // ------------------------ // Drawing session boxes // ------------------------ f_render_session (_show, _session, _is_started, _is_ended, _color, _top, _bottom, _extend, _delete_history) => var box my_box = na x0_1 = ta.valuewhen(na(_session[1]) and _session, bar_index, 1) // barindex on the previous session start x0_2 = ta.valuewhen(na(_session) and _session[1], bar_index, 0) // barindex on the last session end var x1 = 0 var x2 = 0 var session_open = 0.0 var session_high = 0.0 var session_low = 0.0 if _show if _is_started diff = math.abs(x0_2 - x0_1)-sess_offset // previous session duration in bars x1 := bar_index x2 := bar_index + (math.min(diff, max_bars)) my_box := box.new(x1, _top, x2, _bottom, _color, i_sess_border_width, i_sess_border_style, bgcolor=color.new(_color, i_sess_bgopacity)) session_open := open session_high := _top session_low := _bottom // if _extend //_is_extend // box.set_extend(my_box, extend.right) if _delete_history box.delete(my_box[1]) else if _session box.set_top(my_box, _top) box.set_bottom(my_box, _bottom) session_high := _top session_low := _bottom else if _is_ended session_open := na box.set_right(my_box, bar_index-sess_offset) [x1, x2, session_open, session_high, session_low] // ------------------------ // Drawing lines // ------------------------ f_drawLine (_show ,_session, _is_started, _is_ended, _x1, _x2, _y1, _color, _extend, _delete_history) => var line lineMinMax = na if _show if _is_started lineMinMax := line.new(_x1, _y1, _x2, _y1, xloc = xloc.bar_index, extend=_delete_history and _extend ?extend.right:extend.none, color=_color, style=i_minmax_lineStyle, width=i_minmax_lineWidth) if _delete_history // delete history label according to input line.delete(lineMinMax[1]) else if _session line.set_y1(lineMinMax, _y1) line.set_y2(lineMinMax, _y1) else if _is_ended line.set_x2(lineMinMax, bar_index-sess_offset) // ------------------------ // Drawing NY midnigh open // ------------------------ f_drawNYMO() => var line line_NYMO = na var label label_NYMO = na var int x1 = bar_index var int x2 = bar_index float y1 = mo delete_history = (not i_show_history) or i_mo_extend if mo[1] != mo x1 := bar_index x2 := bar_index line_NYMO := line.new(x1, mo, x2, mo, xloc = xloc.bar_index, extend=delete_history and i_mo_extend ?extend.right:extend.none, color=i_moCol, style=i_mo_lineStyle, width=i_mo_lineWidth) if i_mo_label label_NYMO := label.new(x2+label_NYMO_offset, mo, str.tostring(mo) + ' NY Midnight Open', xloc.bar_index, yloc.price, #FFFFFF, label.style_none, i_moCol, textalign=text.align_left, text_font_family=font.family_monospace) if delete_history // delete history line according to input line.delete(line_NYMO[1]) label.delete(label_NYMO[1]) else if mo == mo[1] line.set_x2(line_NYMO, bar_index) label.set_x(label_NYMO, bar_index+label_NYMO_offset) // ------------------------ // Drawing // ------------------------ draw (_show, _session, _bgcolor, _show_minmax, _maxcol, _mincol, _label, _extend, _lookback) => is_started = f_get_started(_session) // check if bar is the first bar of session is_ended = f_get_ended(_session) // check if bar is the first bar after the session max = f_get_period(_session, 1, _lookback) // get session duration in bars // is_started ? 1 : is_started[1] ? 2 : top = ta.highest(high, max) // get top of the session bottom = ta.lowest(low, max) // get bottom of the session delete_history = (not i_show_history) or _extend // check if history drawings and labels should be deleted, showing only the last ones [x1, x2, _open, _high, _low] = f_render_session(_show, _session, is_started, is_ended, _bgcolor, top, bottom, _extend, delete_history) // draw a session box if i_label_show f_render_dataLabel(_show, _session, is_started, _bgcolor, top, bottom, _label, delete_history) // draw a session label if needed if i_show_minmax_lines and _show_minmax f_drawLine(_show, _session, is_started, is_ended, x1, x2, _high, _maxcol, _extend, delete_history) f_drawLine(_show, _session, is_started, is_ended, x1, x2, _low, _mincol, _extend, delete_history) if i_show_minmax_val f_drawValLabel(_show, _session, is_started, is_ended, x2, _high, _maxcol, delete_history) f_drawValLabel(_show, _session, is_started, is_ended, x2, _low, _mincol, delete_history) [_session, _open, _high, _low, max] // return session, open, top, low /////////////////// // Calculating /////////////////// int sess1 = time(timeframe.period, i_sess1, i_tz) // convert session to timezone from input int sess2 = time(timeframe.period, i_sess2, i_tz) int sess3 = time(timeframe.period, i_sess3, i_tz) /////////////////// // Plotting /////////////////// [is_sess1, sess1_open, sess1_high, sess1_low, sess1_max] = draw(i_show_sess1, sess1, i_sess1_bgCol, i_sess1_minmax, i_sess1_maxCol, i_sess1_minCol, i_sess1_label, i_sess1_extend, i_lookback) // draw session box and label [is_sess2, sess2_open, sess2_high, sess2_low, sess2_max] = draw(i_show_sess2, sess2, i_sess2_bgCol, i_sess2_minmax, i_sess2_maxCol, i_sess2_minCol, i_sess2_label, i_sess2_extend, i_lookback) [is_sess3, sess3_open, sess3_high, sess3_low, sess3_max] = draw(i_show_sess3, sess3, i_sess3_bgCol, i_sess3_minmax, i_sess3_maxCol, i_sess3_minCol, i_sess3_label, i_sess3_extend, i_lookback) // Create table - InfoBox var table infoBoxTable = table.new(position.top_right, 1, 1, border_width = 3) is_asia_sess = f_inSession(i_sess1, i_tz) and i_show_sess1 is_euro_sess = f_inSession(i_sess2, i_tz) and i_show_sess2 is_america_sess = f_inSession(i_sess3, i_tz) and i_show_sess3 cell_text = is_america_sess and is_asia_sess and is_euro_sess ? i_sess1_label + "\n" + i_sess2_label + "\n" + i_sess3_label : is_america_sess and is_asia_sess ? i_sess3_label + "\n" + i_sess1_label : is_asia_sess and is_euro_sess ? i_sess1_label + "\n" + i_sess2_label : is_euro_sess and is_america_sess ? i_sess2_label + "\n" + i_sess3_label : is_america_sess ? i_sess3_label : is_asia_sess ? i_sess1_label : is_euro_sess ? i_sess2_label : "None" f_fillCell(_table, _column, _row, _text) => table.cell(_table, _column, _row, _text, bgcolor = i_tableCol, text_color = i_tableCell_txtCol, width = 6) if barstate.islast and i_table_InfoBox_show f_fillCell(infoBoxTable, 0, 0, cell_text) // Draw NY Midnight Open line if i_mo f_drawNYMO()
[FTX Funding Colored Candles] [third eye]
https://www.tradingview.com/script/fboJ7IwD-FTX-Funding-Colored-Candles-third-eye/
junglockahashi
https://www.tradingview.com/u/junglockahashi/
338
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/ // © junglockahashi //@version=5 indicator("[FTX Funding Colored Candles] [third eye]", shorttitle = "[FTX Funding Colored Candles] [third eye]", overlay = true) res = timeframe.period FTX_BTCPERP = request.security("FTX:BTCPERP", res ,close) FTX_USD = request.security("FTX:BTCUSD", res ,close) * 0.125 BINANCE_USDC = request.security("BINANCE:BTCUSDC", res ,close) * 0.125 OKEX_USDC = request.security("OKEX:BTCUSDC", res ,close) * 0.125 COINBASE_USD = request.security("COINBASE:BTCUSD", res ,close) * 0.125 COINBASE_USDC = request.security("COINBASE:BTCUSDC", res ,close) * 0.125 KRAKEN_USD = request.security("KRAKEN:BTCUSD", res ,close) * 0.125 BITSTAMP_USD = request.security("BITSTAMP:BTCUSD", res ,close) * 0.125 BITTREX_USD = request.security("BITTREX:BTCUSD", res ,close) * 0.125 FTX_SPOT_INDEX = FTX_USD + BINANCE_USDC + OKEX_USDC + COINBASE_USD + COINBASE_USDC + KRAKEN_USD + BITSTAMP_USD + BITTREX_USD Basis = FTX_BTCPERP - FTX_SPOT_INDEX Basis_above_100 = Basis > 100 plotcandle(Basis_above_100 ? open : na, Basis_above_100 ? high : na, Basis_above_100 ? low : na, Basis_above_100 ? close : na, "Basis above 100", color = color.orange, wickcolor = color.orange, bordercolor=color.orange) Basis_between_75_and_100 = Basis > 75 and Basis < 100 plotcandle(Basis_between_75_and_100 ? open : na, Basis_between_75_and_100 ? high : na, Basis_between_75_and_100 ? low : na, Basis_between_75_and_100 ? close : na, "Between 75 and 100", color = color.orange, wickcolor = color.orange, bordercolor=color.orange) Basis_between_50_and_75 = Basis > 50 and Basis < 75 plotcandle(Basis_between_50_and_75 ? open : na, Basis_between_50_and_75 ? high : na, Basis_between_50_and_75 ? low : na, Basis_between_50_and_75 ? close : na, "Between 50 and 75", color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003) Basis_between_40_and_50 = Basis > 40 and Basis < 50 plotcandle(Basis_between_40_and_50 ? open : na, Basis_between_40_and_50 ? high : na, Basis_between_40_and_50 ? low : na, Basis_between_40_and_50 ? close : na, "Between 40 and 50", color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003) Basis_between_30_and_40 = Basis > 30 and Basis < 40 plotcandle(Basis_between_30_and_40 ? open : na, Basis_between_30_and_40 ? high : na, Basis_between_30_and_40 ? low : na, Basis_between_30_and_40 ? close : na, "Between 30 and 40", color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003) Basis_between_20_and_30 = Basis > 20 and Basis < 30 plotcandle(Basis_between_20_and_30 ? open : na, Basis_between_20_and_30 ? high : na, Basis_between_20_and_30 ? low : na, Basis_between_20_and_30 ? close : na, "Between 20 and 30", color = #fc2003, wickcolor = #fc2003, bordercolor = #fc2003) Basis_between_10_and_20 = Basis > 10 and Basis < 20 plotcandle(Basis_between_10_and_20 ? open : na, Basis_between_10_and_20 ? high : na, Basis_between_10_and_20 ? low : na, Basis_between_10_and_20 ? close : na, "Between 10 and 20", color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0) Basis_between_0_and_10 = Basis > 0 and Basis < 10 plotcandle(Basis_between_0_and_10 ? open : na, Basis_between_0_and_10 ? high : na, Basis_between_0_and_10 ? low : na, Basis_between_0_and_10 ? close : na, "Between 0 and 10", color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0) Basis_between_0_and_neg10 = Basis < 0 and Basis > -10 plotcandle(Basis_between_0_and_neg10 ? open : na, Basis_between_0_and_neg10 ? high : na, Basis_between_0_and_neg10 ? low : na, Basis_between_0_and_neg10 ? close : na, "Between 0 and -10", color = #f0a1c0, wickcolor = #f0a1c0, bordercolor = #f0a1c0) Basis_between_neg10_and_neg15 = Basis < -10 and Basis > -15 plotcandle(Basis_between_neg10_and_neg15 ? open : na, Basis_between_neg10_and_neg15 ? high : na, Basis_between_neg10_and_neg15 ? low : na, Basis_between_neg10_and_neg15 ? close : na, "Between -10 and -15", color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad ) Basis_between_neg15_and_neg30 = Basis < -15 and Basis > -30 plotcandle(Basis_between_neg15_and_neg30 ? open : na, Basis_between_neg15_and_neg30 ? high : na, Basis_between_neg15_and_neg30 ? low : na, Basis_between_neg15_and_neg30 ? close : na, "Between -15 and -30", color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad ) Basis_between_neg30_and_neg40 = Basis < -30 and Basis > -40 plotcandle(Basis_between_neg30_and_neg40 ? open : na, Basis_between_neg30_and_neg40 ? high : na, Basis_between_neg30_and_neg40 ? low : na, Basis_between_neg30_and_neg40 ? close : na, "Between -30 and -40", color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad ) Basis_between_neg40_and_neg100 = Basis < -40 and Basis > -100 plotcandle(Basis_between_neg40_and_neg100 ? open : na, Basis_between_neg40_and_neg100 ? high : na, Basis_between_neg40_and_neg100 ? low : na, Basis_between_neg40_and_neg100 ? close : na, "Between -40 and -100", color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad ) Basis_between_neg100_and_neg200 = Basis < -100 and Basis > -200 plotcandle(Basis_between_neg100_and_neg200 ? open : na, Basis_between_neg100_and_neg200 ? high : na, Basis_between_neg100_and_neg200 ? low : na, Basis_between_neg100_and_neg200 ? close : na, "Below -100", color = #6228ad , wickcolor = #6228ad, bordercolor = #6228ad )
Market Hedge Ratio
https://www.tradingview.com/script/2pbj6eU3-Market-Hedge-Ratio/
capriole_charles
https://www.tradingview.com/u/capriole_charles/
797
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/ // © capriole_charles //@version=5 indicator("Market Hedge Ratio (Capriole Investments)",overlay=false) market = input.string("all","market to use",options=['all','btc','eth','eth_to_btc']) len= input(200) mu = input(1.2) ml = input(1.2) smooth=input(true) len_smooth=input(10) data_available = time >= timestamp(2019, 7, 1, 00, 00) //https://coinmarketcap.com/view/stablecoin/ mcap_total = request.security("CRYPTOCAP:TOTAL",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_btc = request.security("CRYPTOCAP:BTC",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_eth = request.security("CRYPTOCAP:ETH",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_usdt = request.security("CRYPTOCAP:USDT",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_usdc = request.security("CRYPTOCAP:USDC",timeframe.period,close,lookahead=barmerge.lookahead_on) //mcap_busd = request.security("CRYPTOCAP:BUSD",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_dai = request.security("CRYPTOCAP:DAI",timeframe.period,close,lookahead=barmerge.lookahead_on) mcap_stables = nz(mcap_usdt,0) + nz(mcap_usdc,0) + nz(mcap_dai,0) r_btc = mcap_btc/mcap_stables r_eth = mcap_eth/mcap_stables r_all = mcap_total/mcap_stables r_ethbtc = mcap_eth/mcap_btc m = market=='all' ? r_all : market=='btc' ? r_btc : market=='eth' ? r_eth : market=='eth_to_btc' ? r_ethbtc : na m := smooth ? ta.ema(m,len_smooth) : m sma = ta.sma(m,len) std = ta.stdev(m,len) u = sma + mu*std l = sma - ml*std plot(data_available ? m : na,color=color.blue,title="ALL") plot(data_available ? u : na,color=color.gray,title="") plot(data_available ? l : na,color=color.gray,title="") buy = (timeframe.period=='D' and m<l) or(timeframe.period!='D' and timeframe.multiplier<=240 and m>u) sell = (timeframe.period=='D' and m>u) or(timeframe.period!='D' and timeframe.multiplier<=240 and m<l) bgcolor(buy?color.new(color.green,50):sell?color.new(color.red,50):na) // Sourcing var table_source = table(na) table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1) table.cell(table_source, 0, 0, text="Source: Capriole Investments Limited", bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left)
Breadth Ratio Bubbles
https://www.tradingview.com/script/3kEHUxKS-Breadth-Ratio-Bubbles/
auron9000
https://www.tradingview.com/u/auron9000/
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/ // © auron9000 //@version=5 indicator("Breadth Ratio Bubbles", overlay=true) //Up and down VOL for NYSE and NASDAQ UVOL = request.security("UVOL","",close) DVOL = request.security("DVOL","",close) UVOLQ = request.security("UVOLQ","",close) DVOLQ = request.security("DVOLQ","",close) //NYSE Breadth NYSEratio = UVOL >= DVOL ? UVOL/DVOL : -(DVOL/UVOL) //plot(NYSEratio) //NASDAQ Breadth NASDAQratio = UVOLQ >= DVOLQ ? UVOLQ/DVOLQ : -(DVOLQ/UVOLQ) //plot(NASDAQratio) //Table Creation var table breadthTable = table.new(position.top_left, 2, 1, border_color = color.black, border_width = 2) //Plot Table if barstate.islast table.cell(breadthTable, 0, 0, str.tostring(NYSEratio, format.mintick) + ":1 NYSE", text_size = size.large, text_color = #000000, bgcolor = NYSEratio > 0 ? color.green : color.red) table.cell(breadthTable, 1, 0, str.tostring(NASDAQratio, format.mintick) + ":1 NASD", text_size = size.large, text_color = #000000, bgcolor = NASDAQratio > 0 ? color.green : color.red) // Plot Zero Line plot(0, color = NYSEratio > 0 ? color.green : color.red)
multicolor Bollinger Bands (BB <-> KC)
https://www.tradingview.com/script/AjB1ddnY-multicolor-Bollinger-Bands-BB-KC/
Indicator-Jones
https://www.tradingview.com/u/Indicator-Jones/
138
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/ // multicolor Bollinger Bands (BB <-> KC) © by Indicator-Jones // Concept: After every low volatile phase comes a high volatile phase and after every high volatile phase comes a low volatile phase. // If the Bollinger bands are smaller then the Keltner channel, the price action is low in volatility… meaning a breakout will happen soon ;) // This script is a combination of the 2 standard indicators (Bollinger Bands & Keltner Channel) from TradingView. // If Bollinger bands > Keltner channel = green // If Bollinger bands < Keltner channel = red // If multicolor BB is disabled = blue (tradingview default color) // customize colors to your liking under settings -> style // To get alerts for all coins // ------------------------------- // 1. visit » tradingview.com/crypto-screener // 2. set the filter to » // Bollinger Upper Band (20) below Keltner Channels Upper Band (20) // Bollinger Lower Band (20) above Keltner Channels Lower Bands (20) // 3. add your own custom filters, like: exchange, marketcap, etc… // 4. choose the timeframe you want // 5. enable alerts // last update: 01.03.2022 - added Alerts // 14.02.2022 - added Vix Fix for marking highs and lows // 13.02.2022 - changed 'Multiplier' inputs to float. now steps of 0.1 possible. // new default value of Keltner Multiplier now 1.5 + added comparison of BB width & KC width to make it highly accurate ;) //@version=5 indicator('Explosive Bollinger Bands (BB <-> KC) multicolor', shorttitle="multicol BB<->KC", overlay=true, timeframe="", timeframe_gaps=false) // ------ Keltner Channel --------- showKC=input.bool(false, title="show Keltner Channel?", group='Keltner Channel') lengthKC = input.int(20, minval=1, title="Length KC", group='Keltner Channel') srcKC = input(close, title="Source KC", group='Keltner Channel') multKC = input.float(1.5, "Multiplier", group='Keltner Channel', step=0.1, minval=0, maxval=100) exp = input(true, "Use Exponential MA", group='Keltner Channel') BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style", group='Keltner Channel') atrlength = input(10, "ATR Length", group='Keltner Channel') esma(source, lengthKC)=> s = ta.sma(source, lengthKC) e = ta.ema(source, lengthKC) exp ? e : s ma = esma(srcKC, lengthKC) rangema = BandsStyle == "True Range" ? ta.tr(true) : BandsStyle == "Average True Range" ? ta.atr(atrlength) : ta.rma(high - low, lengthKC) upperKC = ma + rangema * multKC lowerKC = ma - rangema * multKC KCwidth = (upperKC-lowerKC)/ma uKC = plot(showKC ? upperKC : na, color=color.new(#00bcd4,0), title="Upper KC") plot(showKC ? ma : na, color=color.new(#00bcd4,0), title="Basis KC") lKC = plot(showKC ? lowerKC : na, color=color.new(#00bcd4,0), title="Lower KC") fill(uKC, lKC, color=color.rgb(0, 188, 212, 95), title="Background KC") // -------- Bollinger Bands ------------ showBB=input.bool(true, title="Show Bolliniger Bands?", group='Bollinger Bands') multicolor = input.bool(title="Multicolor Bands (BB < KC = red, BB > KC = green)", defval=true, group='Bollinger Bands') fillBB=input.bool(true, title="Background color? (red zone = 💣💥 incoming!!!)", group='Bollinger Bands') showAlerts=input.bool(true, title="Show Alerts? 🔺🔻", group='Bollinger Bands', tooltip='Right click on the indicator -> "Add alert on multicol BB" to create alerts') lengthBB = input.int(20, minval=1, title="Length BB", group='Bollinger Bands') srcBB = input(close, title="Source BB", group='Bollinger Bands') multBB = input.float(2.0, step=0.1, minval=0, maxval=100, title="Multiplier", group='Bollinger Bands') basis = ta.sma(srcBB, lengthBB) dev = multBB * ta.stdev(srcBB, lengthBB) upperBB = basis + dev lowerBB = basis - dev BBwidth = (upperBB-lowerBB)/basis offset = input.int(0, "Offset", minval = -500, maxval = 500) bool BBupGtKCup = upperBB > upperKC plot(showBB ? basis : na, color=color.new(#FF6D00,0), offset = offset, title="Basis BB") p1 = plot(showBB ? upperBB : na, color=multicolor ? (upperBB < upperKC ? color.red : color.green) : color.new(#2962FF,0), offset = offset, title="Upper BB") p2 = plot(showBB ? lowerBB : na, color=multicolor ? (lowerBB > lowerKC ? color.red : color.green) : color.new(#2962FF,0), offset = offset, title="Upper BB") redZone = upperBB < upperKC and lowerBB > lowerKC and BBwidth < KCwidth greenZone = upperBB > upperKC and lowerBB < lowerKC and BBwidth > KCwidth redZoneStart=redZone[1] == false and redZone[0] == true redZoneEnd=redZone[1] == true and redZone[0] == false fill(p1, p2, title = "Background BB", color=multicolor and fillBB ? ( redZone ? color.new(#FF5252,75) : color.new(#4CAF50,95)) : color.rgb(33, 150, 243, 95) ) plotshape(showAlerts ? redZoneStart : na, style=shape.triangledown, color=color.new(color.red, 0), location=location.top, textcolor=color.new(color.black, 0), text='', size=size.tiny) plotshape(showAlerts ? redZoneEnd : na, style=shape.triangleup, color=color.new(color.green, 0), location=location.bottom, textcolor=color.new(color.black, 0), text='', size=size.tiny) alertcondition(redZoneStart, title='🚨 low volatility alert (BB<KC)', message='🚨 low volatility alert (BB<KC)') alertcondition(redZoneEnd, title='💣 high volatility alert (BB>KC)', message='💣 high volatility alert (BB>KC)') // -------- Vix Fix ------------ // ++++++++++ INPUTS ++++++++++ // VIXFix_length = input(20, title='VIX Fix Length', group='Vix Fix') VIXFix_back = input(20, title='The number of periods among which to look for lows and highs', group='Vix Fix') plotMarks = input(title='Plot high/low marks', defval=false, group='Vix Fix') useFilter = input.bool(true, title='Use ADX filter?', group='Vix Fix') adxMinVal = input.int(17, title='Do not show signals if ADX is below', group='Vix Fix', minval=0, maxval=100) adxlen = input.int(14, title='ADX Smoothing (optional)', group='Vix Fix') dilen = input.int(14, title='DI Length (optional)', group='Vix Fix') // ++++++++++ LOGIC ++++++++++ // // Vix current VIXFix_classic = (ta.highest(close, VIXFix_length) - low) / ta.highest(close, VIXFix_length) * -100 VIXFix_reverse = (ta.lowest(close, VIXFix_length) - high) / ta.lowest(close, VIXFix_length) * -100 // ADX Filter dirmov(len) => 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 truerange = ta.rma(ta.tr, len) plus = fixnan(100 * ta.rma(plusDM, len) / truerange) minus = fixnan(100 * ta.rma(minusDM, len) / truerange) [plus, minus] adx(dilen, adxlen) => [plus, minus] = dirmov(dilen) sum = plus + minus adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen) adx sig = adx(dilen, adxlen) // Minimaxis isMaxUp = ta.highest(VIXFix_reverse, VIXFix_back) == VIXFix_reverse // Top peaks isMaxDown = ta.lowest(VIXFix_classic, VIXFix_back) == VIXFix_classic // Top bottoms isMinUp = ta.lowest(VIXFix_reverse, VIXFix_back) == VIXFix_reverse // Min peaks isMinDown = ta.highest(VIXFix_classic, VIXFix_back) == VIXFix_classic // Min bottoms // Signals buySignal = isMaxDown or isMinUp sellSignal = isMinDown or isMaxUp // Filtred signals buySignalFiltred = buySignal and sig > adxMinVal sellSignalFiltred = sellSignal and sig > adxMinVal // ++++++++++ PLOT - Marks ++++++++++ // plotshape((useFilter ? sellSignalFiltred : sellSignal) and plotMarks, title='Sell', color=color.new(color.red, 0), style=shape.circle, location=location.abovebar, size=size.tiny) plotshape((useFilter ? buySignalFiltred : buySignal) and plotMarks, title='Buy', color=color.new(color.green, 0), style=shape.circle, location=location.belowbar, size=size.tiny)
How To Identify Type Of Number
https://www.tradingview.com/script/1xOUzkP4-How-To-Identify-Type-Of-Number/
allanster
https://www.tradingview.com/u/allanster/
25
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © allanster //@version=5 indicator(title = "How To Identify Type Of Number", shorttitle = 'number type', overlay = true, precision = 16) // Example function accepts loading of _value for types float, int, or string, then identifies whether the // loaded _value is a string number, string, or number. // === Function === f_idType(_value) => // input: type float, int, string | output: returns string of input 'type' concaten = _value + _value // concatenate or addition to5tring = str.tostring(_value) // cast type to string addition = str.tonumber(str.tostring(_value)) * 2 // add _value + _value is_Strng = str.tostring(concaten) != str.tostring(addition) // compare is_Numbr = not na(str.tonumber(to5tring)) // is number & maybe string is_Float = is_Numbr and not na(str.pos(to5tring, '.')) // is float & maybe string is_Intgr = is_Numbr and not is_Float // is integer & maybe string identify = is_Strng and is_Intgr ? 'String Integer' : is_Strng and is_Float ? 'String Float' : is_Strng ? 'String' : is_Float ? 'Number Float' : is_Intgr ? 'Number Integer' : string(na) // return string of number type // === EXAMPLE VALUES === float cnt0 = 0.123456789 // form const type float int cnt1 = 12345678901 // form const type integer string cnt2 = '0.123456789' // form const type string string cnt3 = '12345678901' // form const type string string cnt4 = 'hello world' // form const type string float inp0 = input( 0.123456789, 'Float') // form input type float int inp1 = input( 12345678901, 'Integer') // form input type integer string inp2 = input('0.123456789', 'String') // form input type string string inp3 = input('12345678901', 'String') // form input type string string inp4 = input('hello world', 'String') // form input type string float smp0 = syminfo.mintick // form simple type float int smp1 = timeframe.multiplier // form simple type integer string smp2 = timeframe.period // form simple type string float ser0 = close > open ? cnt0 : cnt0 // form series type float int ser1 = close > open ? cnt1 : cnt1 // form series type integer string ser2 = close > open ? cnt2 : cnt2 // form series type string string ser3 = close > open ? cnt3 : cnt3 // form series type string string ser4 = close > open ? cnt4 : cnt4 // form series type string // === EXAMPLE OUTPUT === C_(_str, _column, _row, _t) => // single cell of string _str of number _column of number _row of table _t table.cell(_t, _column, _row, _str, text_color = #ffffff, text_halign = text.align_center) R_(_t, _row, _strC0, _strC1, _strC2) => // single row of table _t of number _row of string columns _strCn C_(_strC0, 0, _row, _t), C_(_strC1, 1, _row, _t), C_(_strC2, 2, _row, _t) if barstate.islast var T = table.new(position.middle_right, 3, 19, bgcolor = color.new(#3f3f3f, 0), border_color = #bfbfbf, border_width = 1, frame_color = #7f7f7f, frame_width = 2) R_(T, 0, 'FORM TYPE', 'LOADED VALUE', 'f_idType(_value)') R_(T, 1, 'const float', '0.123456789', str.tostring(f_idType(cnt0))) R_(T, 2, 'const int', '12345678901', str.tostring(f_idType(cnt1))) R_(T, 3, 'const strng', '"0.123456789"', str.tostring(f_idType(cnt2))) R_(T, 4, 'const strng', '"12345678901"', str.tostring(f_idType(cnt3))) R_(T, 5, 'const strng', '"hello world"', str.tostring(f_idType(cnt4))) R_(T, 6, 'input float', str.tostring(inp0), str.tostring(f_idType(inp0))) R_(T, 7, 'input int', str.tostring(inp1), str.tostring(f_idType(inp1))) R_(T, 8, 'input strng', '"' + str.tostring(inp2) + '"', str.tostring(f_idType(inp2))) R_(T, 9, 'input strng', '"' + str.tostring(inp3) + '"', str.tostring(f_idType(inp3))) R_(T, 10, 'input strng', '"' + str.tostring(inp4) + '"', str.tostring(f_idType(inp4))) R_(T, 11, 'simple float', 'syminfo.mintick', str.tostring(f_idType(smp0))) R_(T, 12, 'simple int', 'timeframe.multiplier', str.tostring(f_idType(smp1))) R_(T, 13, 'simple strng', 'timeframe.period', str.tostring(f_idType(smp2))) R_(T, 14, 'series float', '0.123456789', str.tostring(f_idType(ser0))) R_(T, 15, 'series int', '12345678901', str.tostring(f_idType(ser1))) R_(T, 16, 'series strng', '"0.123456789"', str.tostring(f_idType(ser2))) R_(T, 17, 'series strng', '"12345678901"', str.tostring(f_idType(ser3))) R_(T, 18, 'series strng', '"hello world"', str.tostring(f_idType(ser4)))
Alligator: Three signals confirmation with Alerts
https://www.tradingview.com/script/S8ZCG4Ic-Alligator-Three-signals-confirmation-with-Alerts/
HerschelleGirnari
https://www.tradingview.com/u/HerschelleGirnari/
145
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/ // © HerschelleGirnari //@version=5 indicator("Alligator: Three signals confirmation with Alerts", shorttitle="HersG Alli alerts", overlay=true) // >>>>>>>> Inputs AlliTooltips = "Numbers are Fibonacci numbers. Offset will shift plot data right or left to given number of bars. Min = -4 to Max = 4." src = input.source(close, title = "Source Data", group = "Moving Average") MAtype = input.string("EMA", title = "Type", options = ["SMA", "EMA"], group = "Moving Average" ) ALips = input.int(5, title = "Lips", options = [5,8,13,21,34], tooltip = AlliTooltips, inline = "LIPS", group = "Alligator") AlipsOffset = input.int(3, title = "Offset", minval = -4, maxval = 4, step = 1, tooltip = AlliTooltips, inline = "LIPS", group = "Alligator") ATeeth = input.int(13, title = "Teeth", options = [8,13,21,34,55], tooltip = AlliTooltips, inline = "TEETH", group = "Alligator") AteethOffset = input.int(2, title = "Offset", minval = -4, maxval = 4, step = 1, tooltip = AlliTooltips, inline = "TEETH", group = "Alligator") AJaws = input.int(21, title = "Jaws", options = [21,34,55,89,144], tooltip = AlliTooltips, inline = "JAWS", group = "Alligator") AjawsOffset = input.int(0, title = "Offset", minval = -4, maxval = 4, step = 1, tooltip = AlliTooltips, inline = "JAWS", group = "Alligator") // >>>>>> Calculation float AlliLips = 0.0 float AlliTeeth = 0.0 float AlliJaws = 0.0 if MAtype == "SMA" AlliLips := ta.sma(src, ALips) AlliTeeth := ta.sma(src, ATeeth) AlliJaws := ta.sma(src, AJaws) else AlliLips := ta.ema(src, ALips) AlliTeeth := ta.ema(src, ATeeth) AlliJaws := ta.ema(src, AJaws) UpMomentum = false DownMomentum = false UpCounter = 0 DownCounter = 0 if barstate.isconfirmed UpMomentum := hl2 > AlliLips and AlliJaws and AlliTeeth DownMomentum := hl2 < AlliJaws and AlliLips and AlliTeeth for i = 0 to 2 if UpMomentum[i] and (UpMomentum[i] != DownMomentum[i]) UpCounter := UpCounter + 1 else UpCounter := 0 for i = 0 to 2 if DownMomentum[i] and (DownMomentum[i] != UpMomentum[i]) DownCounter := DownCounter + 1 else DownCounter := 0 // >>>>>>>>>>> Display plot(AlliLips, title = "Lips", color = color.green, offset = AlipsOffset) plot(AlliTeeth, title = "Teeth", color = color.red, offset = AlipsOffset) plot(AlliJaws, title = "Jaws", color = color.blue, linewidth = 2, offset = AlipsOffset) plotshape(UpCounter == 3, title = "Up Momentum", style = shape.cross, location = location.bottom, color = color.green, size = size.small) plotshape(DownCounter == 3, title = "Down Momentum", style = shape.cross, location = location.top, color = color.red, size = size.small) // >>>>>>>>>>> Alerts if UpCounter == 3 alert(message = "Up Momentum", freq = alert.freq_once_per_bar_close) else if DownCounter == 3 alert(message = "Down Momentum", freq = alert.freq_once_per_bar_close) else na
MMMRI*VIX
https://www.tradingview.com/script/8TpI2ORT-MMMRI-VIX/
HARRYDAN2
https://www.tradingview.com/u/HARRYDAN2/
45
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HARRYDAN2 //@version=5 indicator(title='MMMRI*VIX', shorttitle='MMMRI*VIX', overlay=false, scale=scale.right, format=format.price) var table risk = table.new(position=position.top_right, columns=1, rows=1) lowRisk = input(title='Low Risk', defval=100) moderateRisk = input(title='Moderate Risk', defval=150) highRisk = input(title='High Risk', defval=200) extremeRisk = input(title='Extreme Risk', defval=250) tardMode = input(title=' Tard Mode', defval=300) somethingsawry = input(title='Somethings Awry', defval=350) buyputs = input(title='Buy Puts', defval=400) getstock = input(title = 'Request Stock Certificate', defval = 500) systemerror = input(title = 'System Error Imminent', defval = 600) maLength = input(title="SMA Length", defval=50) hideSma = input.bool(title="Hide SMA", defval=false) highlight(mmri) => col = color.green if mmri > lowRisk and mmri < moderateRisk col := color.yellow col if mmri >= moderateRisk and mmri < highRisk col := color.orange col if mmri >= highRisk and mmri < extremeRisk col := color.red col if mmri >= extremeRisk and mmri < tardMode col := color.white col if mmri >= tardMode and mmri < somethingsawry col := color.blue col if mmri >= somethingsawry and mmri < buyputs col := color.purple col if mmri >= buyputs and mmri < getstock col := color.rgb(12, 211, 151) col if mmri >= getstock and mmri < systemerror col := color.rgb(55, 0, 255) col if mmri > systemerror col := color.rgb(255, 109, 52) col riskLevel(mmri) => text_1 = 'Low Risk' if mmri > lowRisk and mmri < moderateRisk text_1 := 'Moderate Risk' text_1 if mmri >= moderateRisk and mmri < highRisk text_1 := 'High Risk' text_1 if mmri >= highRisk text_1 := 'Extreme Risk' text_1 if mmri >= extremeRisk text_1 := 'Tard Mode' text_1 if mmri >= tardMode text_1 := 'Somethings Awry' text_1 if mmri >= somethingsawry text_1 := 'Buy Puts or Calls, RIsk is a Double Edged Sword' text_1 if mmri >= buyputs text_1 := 'Request Stock Certificate' text_1 if mmri >= getstock text_1 := 'System Error Imminent' text_1 text_1 vixSymbol = input.symbol(title='Vix Symbol', defval='vix') dollarSymbol = input.symbol(title='Dollar Symbol', defval='dxy') yieldSymbol = input.symbol(title='Yield Symbol', defval='tnx') mmriConstant = input(title='Divisor', defval=1.61) debtgdpConstant = input(title='Multiplier', defval=1.356) vix = request.security(symbol=vixSymbol, timeframe='', expression=close) dxy = request.security(symbol=dollarSymbol, timeframe='', expression=close) yield = request.security(symbol=yieldSymbol, timeframe='', expression=close) mmmri = (((dxy * yield)/(mmriConstant)) * (debtgdpConstant) * (vix/16.10))/(1.61) table.set_bgcolor(risk, highlight(mmmri)) table.cell(risk, 0, 0, str.tostring(riskLevel(mmmri))) plot(series=mmmri, title="MMRI", trackprice=false, color=highlight(mmmri)) plot(series=hideSma ? na : ta.sma(mmmri, maLength), title="SMA", color=color.new(color.blue, 50))
Anna-Lysa
https://www.tradingview.com/script/oaPTSe1B-Anna-Lysa/
MartinKostov
https://www.tradingview.com/u/MartinKostov/
93
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/ // © MartinKostov //@version=5 // Premarket High/Low + LastDayHigh/Low + ATR + VWAP + 3xDailyMA + 2 FrameEMA + Volume% AVG Daily Volume ... indicator('Anna-Lysa', shorttitle="Analyse", overlay=true) import TradingView/ta/6 aftermarket = input.bool(title='Include Aftermarket', defval=false, group='Overnight Session') ending_hour = input.int(defval=9, title='PM Ending Hour', group='Overnight Session', inline='Input 0') ending_minute = input.int(defval=30, title=' Minute', group='Overnight Session', inline='Input 0') spm = input.bool(true, title='Show Premarket High/Low ', group='Overnight Session', inline='Input 1') pmColor = input.color(color.new(color.yellow, 30), title='', group='Overnight Session', inline='Input 1') pmwidth = input.int(1, title="line", options=[1, 2, 3, 4], group='Overnight Session', inline='Input 1') sy = input.string(title='Show Lastday High/Low ', group='Show Day / Week / Month high/low ', options=['on', 'off'], defval='on', inline='Input 0') syColor = input.color(color.new(color.red, 30), title='', group='Show Day / Week / Month high/low ', inline='Input 0') sywidth = input.int(1, title='line', options=[1, 2, 3, 4], group='Show Day / Week / Month high/low ', inline='Input 0') sw = input.string(title='Show Lastweek High/Low' + ' ', group='Show Day / Week / Month high/low ', options=['off', 'current', 'last'], defval='off', inline='Input 1') swColor = input.color(color.new(color.green, 30), title='', group='Show Day / Week / Month high/low ', inline='Input 1') swwidth = input.int(1, title='line', options=[1, 2, 3, 4], group='Show Day / Week / Month high/low ', inline='Input 1') sm = input.string(title='Show Lastmonth High/Low', group='Show Day / Week / Month high/low ', options=['off', 'current', 'last'], defval='off', inline='Input 2') smColor = input.color(color.new(color.lime, 30), title='', group='Show Day / Week / Month high/low ', inline='Input 2') smwidth = input.int(1, title='line', options=[1, 2, 3, 4], group='Show Day / Week / Month high/low ', inline='Input 2') svwap = input.bool(true, title='Show VWAP', group='VWAP and stdev ops ', inline='Input 0') source = input.source(hlc3, title='', group='VWAP and stdev ops ', inline='Input 0') svwapPColor = input.color(color.new(color.lime, 30), title='', group='VWAP and stdev ops ', inline='Input 0') svwapNColor = input.color(color.new(color.red, 30), title='', group='VWAP and stdev ops ', inline='Input 0') svwapStyle = input.string('dotted', title='', options=['line','dotted'], group='VWAP and stdev ops ', inline='Input 0') sstdev = input.bool(false, title='Show Stdev1', group='VWAP and stdev ops ', inline='Input 1') devNum = input.int(1, title='Number', group='VWAP and stdev ops ', inline='Input 1') sstdevColor = input.color(color.new(color.gray, 30), title='', group='VWAP and stdev ops ', inline='Input 1') sstdev2 = input.bool(false, title='Show Stdev2', group='VWAP and stdev ops ', inline='Input 2') devNum2 = input.int(2, title='Number', group='VWAP and stdev ops ', inline='Input 2') sstdev2Color = input.color(color.new(color.gray, 30), title='', group='VWAP and stdev ops ', inline='Input 2') sstdev3 = input.bool(false, title='Show Stdev3', group='VWAP and stdev ops ', inline='Input 3') devNum3 = input.int(3, title='Number', group='VWAP and stdev ops ', inline='Input 3') sstdev3Color = input.color(color.new(color.gray, 30), title='', group='VWAP and stdev ops ', inline='Input 3') sWvwap = input.bool(false, title='Show Weekly VWAP', group='VWAP and stdev ops ', inline='Input 4') sWvwapColor = input.color(color.new(color.gray, 30), title='', group='VWAP and stdev ops ', inline='Input 4') sMvwap = input.bool(false, title='Show Monthly VWAP', group='VWAP and stdev ops ', inline='Input 5') sMvwapColor = input.color(color.new(color.gray, 30), title='', group='VWAP and stdev ops ', inline='Input 5') wt = time('W') mt = time('M') wstart = na(wt[1]) or wt > wt[1] mstart = na(mt[1]) or mt > mt[1] wsumSrc = source * volume wsumVol = volume wsumSrc := wstart ? wsumSrc : wsumSrc + wsumSrc[1] wsumVol := wstart ? wsumVol : wsumVol + wsumVol[1] wvw = wsumSrc / wsumVol msumSrc = source * volume msumVol = volume msumSrc := mstart ? msumSrc : msumSrc + msumSrc[1] msumVol := mstart ? msumVol : msumVol + msumVol[1] mvw = msumSrc / msumVol satr1 = input.bool(true, title='Show ATR1', group='Daily ATR', inline='Input 1') atr_factor1 = input.float(title='Faktor', group='Daily ATR', inline='Input 1', defval=1) atr_days1 = input.int(title='Days', group='Daily ATR', inline='Input 1', defval=10) satr1Color = input.color(color.new(color.silver, 30), title='', group='Daily ATR', inline='Input 1') //satr1width = input.int(1, title='', options=[1, 2, 3, 4], group='Daily ATR', inline='Input 1') satr2 = input.bool(false, title='Show ATR2', group='Daily ATR', inline='Input 2') atr_factor2 = input.float(title='Faktor', group='Daily ATR', inline='Input 2', defval=2) atr_days2 = input.int(title='Days', group='Daily ATR', inline='Input 2', defval=10) satr2Color = input.color(color.new(color.silver, 30), title='', group='Daily ATR', inline='Input 2') //satr2width = input.int(1, title='line', options=[1, 2, 3, 4], group='Daily ATR', inline='Input 2') satr3 = input.bool(false, title='Show ATR3', group='Daily ATR', inline='Input 3') atr_factor3 = input.float(title='Faktor', group='Daily ATR', inline='Input 3', defval=3) atr_days3 = input.int(title='Days', group='Daily ATR', inline='Input 3', defval=10) satr3Color = input.color(color.new(color.silver, 30), title='', group='Daily ATR', inline='Input 3') //satr3width = input.int(1, title='line', options=[1, 2, 3, 4], group='Daily ATR', inline='Input 3') satr4 = input.bool(false, title='Show ATR4', group='Daily ATR', inline='Input 4') atr_factor4 = input.float(title='Faktor', group='Daily ATR', inline='Input 4', defval=4) atr_days4 = input.int(title='Days', group='Daily ATR', inline='Input 4', defval=10) satr4Color = input.color(color.new(color.silver, 30), title='', group='Daily ATR', inline='Input 4') //satr4width = input.int(1, title='line', options=[1, 2, 3, 4], group='Daily ATR', inline='Input 4') satr5 = input.bool(false, title='Show ATR5', group='Daily ATR', inline='Input 5') atr_factor5 = input.float(title='Faktor', group='Daily ATR', inline='Input 5', defval=5) atr_days5 = input.int(title='Days', group='Daily ATR', inline='Input 5', defval=10) satr5Color = input.color(color.new(color.silver, 30), title='', group='Daily ATR', inline='Input 5') //satr5width = input.int(1, title='line', options=[1, 2, 3, 4], group='Daily ATR', inline='Input 5') //satr6 = input(false, title="Show ATR6", group = "ATR", inline = "Input 6") //atr_factor6 = input(title="Faktor", group = "ATR", inline = "Input 6", type=input.float, defval=6) //atr_days6 = input(title="Days", group = "ATR", inline = "Input 6", type=input.integer, defval=10) //satr6Color = input(color.gray, title="", group = "ATR", inline = "Input 6") slen1 = input.bool(true, title='Show Daily MA', group='Daily moving averages Lines', inline='Input 1') len1 = input.int(20, '', minval=1, group='Daily moving averages Lines', inline='Input 1') slen1Color = input.color(color.new(color.blue, 30), title='', group='Daily moving averages Lines', inline='Input 1') slen2 = input.bool(true, title='Show Daily MA', group='Daily moving averages Lines', inline='Input 2') len2 = input.int(100, '', minval=1, group='Daily moving averages Lines', inline='Input 2') slen2Color = input.color(color.new(color.blue, 30), title='', group='Daily moving averages Lines', inline='Input 2') slen3 = input.bool(true, title='Show Daily MA', group='Daily moving averages Lines', inline='Input 3') len3 = input.int(200, '', minval=1, group='Daily moving averages Lines', inline='Input 3') slen3Color = input.color(color.new(color.blue, 30), title='', group='Daily moving averages Lines', inline='Input 3') slenEMA1 = input.bool(true, title='Show Frame EMA', group='Timeframe exponential moving average', inline='Input 1') lenEMA1 = input.int(8, minval=1, title='', group='Timeframe exponential moving average', inline='Input 1') srcEMA1 = close // input(close, title="Source", group = "Timeframe MA", inline = "Input 1") offsetEMA1 = 0 // input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500, group = "Timeframe MA", inline = "Input 1") slenEMA1Color = input.color(color.new(color.lime, 60), title='', group='Timeframe exponential moving average', inline='Input 1') slenEMA2 = input.bool(true, title='Show Frame EMA', group='Timeframe exponential moving average', inline='Input 2') lenEMA2 = input.int(21, minval=1, title='', group='Timeframe exponential moving average', inline='Input 2') srcEMA2 = close // input(close, title="SourceEMA2", group = "Timeframe MA", inline = "Input 2") offsetEMA2 = 0 //input(title="OffsetEMA2", type=input.integer, defval=0, minval=-500, maxval=500, group = "Timeframe MA", inline = "Input 2") slenEMA2Color = input.color(color.new(color.orange, 60), title='', group='Timeframe exponential moving average', inline='Input 2') sVM = input.bool(true, title='Show AvgVolume %', group='Show / Hide Volume %', inline='Input 0', tooltip='Volume % from Average Volume last x Candles') VolumeColor = input.color(color.new(color.orange, 30), title='', group='Show / Hide Volume %', inline='Input 0') Vsma = input.int(title='Last Candles', defval=10, group='Show / Hide Volume %', inline='Input 0') stbl = input.bool(true, title='Show at ', group="Table", inline="0") tablePositionY = input.string('top', title='Y-Pos', options=['top', 'middle', 'bottom'], group="Table", inline="0") tablePositionX = input.string('right', title='X-Pos', options=['left', 'center', 'right'], group="Table", inline="0") tableTextColor = input(color.new(color.silver, 80), "Table Text ", group="Table", inline="1") tableBgColor = input(color.new(color.black,95), "Table Background ", group="Table", inline="1") DRlength = input.int(title="Ø Days Range ", defval=10, minval=1, group="Table", inline="2") DVlength = input.int(title="Ø Days Volume", defval=10, minval=1, group="Table", inline="3") FrameATRlength = input.int(title="ATR Ø Last Candles", defval=2, minval=1, group="Table", inline="4") RvolLength = input.int(title="RVOL at Time Lenght", defval=5, minval=1, group="Table", inline="5") y= year(timenow) m= month(timenow) d= dayofmonth(timenow) start= timestamp(y, m, d, 06, 00) end= timestamp(y, m, d, 16, 00) float vwapsum = na float volumesum = na float v2sum = na change_1 = ta.change(dayofweek) newSession = change_1 ? 1 : 0 vwapsum := newSession ? hl2 * volume : vwapsum[1] + hl2 * volume volumesum := newSession ? volume : volumesum[1] + volume v2sum := newSession ? volume * hl2 * hl2 : v2sum[1] + volume * hl2 * hl2 myvwap = vwapsum / volumesum dev = math.sqrt(math.max(v2sum / volumesum - myvwap * myvwap, 0)) pdh = timeframe.isintraday ? time('1440', '0000-0930:23456') ? request.security(syminfo.tickerid, 'D', high[0]) : request.security(syminfo.tickerid, 'D', high[1]) : na pdl = timeframe.isintraday ? time('1440', '0000-0930:23456') ? request.security(syminfo.tickerid, 'D', low[0]) : request.security(syminfo.tickerid, 'D', low[1]) : na volumeDailyAVG = request.security(syminfo.tickerid, 'D', ta.sma(volume, Vsma)) volumelastAVG = ta.sma(volume, Vsma) volumeToday = request.security(syminfo.tickerid, 'D', volume) percentageToday = volumeToday / volumeDailyAVG * 100 percentage = volume / volumeDailyAVG * 100 percentage2 = volume / volumelastAVG * 100 color_1 = color.new(#f23535, 50) color_2 = color.new(#58a9f5, 50) out1 = request.security(syminfo.tickerid, 'D', ta.sma(close, len1)) out2 = request.security(syminfo.tickerid, 'D', ta.sma(close, len2)) out3 = request.security(syminfo.tickerid, 'D', ta.sma(close, len3)) outEMA1 = ta.ema(srcEMA1, lenEMA1) outEMA2 = ta.ema(srcEMA2, lenEMA2) vwapcond = timeframe.isintraday ? ta.vwap(source) : na lastClose = request.security(syminfo.tickerid, 'D', close[1], lookahead=barmerge.lookahead_on) t = aftermarket == false ? time('1440', '0400-0930:23456') : time('1440', '1600-0930:23456') // 1440=60*24 is the number of minutes in a whole day. You may use "0930-1600" as second session parameter is_first = na(t[1]) and not na(t) or t[1] < t day_high = float(na) day_low = float(na) k = int(na) if is_first and barstate.isnew and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute) day_high := high day_low := low day_low else day_high := day_high[1] day_low := day_low[1] day_low if high > day_high and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute) day_high := high day_high if low < day_low and (hour < ending_hour or hour >= 16 or hour == ending_hour and minute < ending_minute) day_low := low day_low dailyATR1 = request.security(syminfo.tickerid, 'D', ta.atr(atr_days1)) dailyATR2 = request.security(syminfo.tickerid, 'D', ta.atr(atr_days2)) dailyATR3 = request.security(syminfo.tickerid, 'D', ta.atr(atr_days3)) dailyATR4 = request.security(syminfo.tickerid, 'D', ta.atr(atr_days4)) dailyATR5 = request.security(syminfo.tickerid, 'D', ta.atr(atr_days5)) //dailyATR6 = security(syminfo.tickerid, 'D', atr(atr_days6)) davg0 = request.security(syminfo.tickerid, 'D', high[0] - low[0]) adr= ( request.security(syminfo.tickerid, 'D', high[1] - low[1]) + request.security(syminfo.tickerid, 'D', high[2] - low[2]) + request.security(syminfo.tickerid, 'D', high[3] - low[3]) + request.security(syminfo.tickerid, 'D', high[4] - low[4]) + request.security(syminfo.tickerid, 'D', high[5] - low[5]) + request.security(syminfo.tickerid, 'D', high[6] - low[6]) + request.security(syminfo.tickerid, 'D', high[7] - low[7]) + request.security(syminfo.tickerid, 'D', high[8] - low[8]) + request.security(syminfo.tickerid, 'D', high[9] - low[9]) + request.security(syminfo.tickerid, 'D', high[10] - low[10]) ) / 10 FrameATR = request.security(syminfo.tickerid,'', ta.sma(ta.tr(true),FrameATRlength)) [currentVolume, pastVolume, _] = ta.relativeVolume( RvolLength, "1D", true) if stbl var table dataTable = table.new(tablePositionY + '_' + tablePositionX, 4, 5, border_width=7) table.cell(dataTable, 1, 0, text= "Daily Range Ø\n" + str.tostring(100-(adr-davg0)/adr*100 ,"0.00") +" %\n" + ( 100-(adr-davg0)/adr*100 < 100 ? " " + str.tostring(davg0 - adr ,"0.00")+ " $" : "+ " + str.tostring(davg0 - adr ,"0.00")+ "$" ) , bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) table.cell(dataTable, 2, 0, text= "Daily Volume Ø\n " + str.tostring(100-(volumeDailyAVG-volumeToday)/volumeDailyAVG*100 ,"0.00") +" %\n" + ( 100-(volumeDailyAVG-volumeToday)/volumeDailyAVG*100 > 100 ? "+ " + str.tostring(volumeToday-volumeDailyAVG , format.volume) : "- " + str.tostring(volumeDailyAVG - volumeToday , format.volume) ), bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) table.cell(dataTable, 1, 1, text= "Atr Ø SL\n" + str.tostring(FrameATR , "0.00") +" $", bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) table.cell(dataTable, 2, 1, text= "RVOL at Time (1D)\n" + str.tostring( currentVolume / pastVolume , "0.00") , bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ") MarketCap = TSO * close[1] //table.cell(dataTable, 1, 2, text= "Market Cap\n"+ str.tostring(MarketCap , format.volume) , bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) //table.cell(dataTable, 2, 2, text= " " , bgcolor=tableBgColor, text_color=tableTextColor,text_size=size.auto) plot(spm and day_high ? day_high : na, title='PMH Line', trackprice=true, offset=-9999, color=pmColor, linewidth=pmwidth, style=plot.style_line, editable=false) var l1 = label.new(bar_index, day_high, 'PMH ', color=tableBgColor, textcolor=pmColor, style=label.style_label_down, tooltip='Premarket High') label.set_xy(l1, bar_index + 50, spm and day_high ? day_high : na) label.set_text(l1, 'PMH ' + str.tostring(spm and day_high ? day_high : na, '0.00')) plot(spm and day_low ? day_low : na, title='PML Line', trackprice=true, offset=-9999, color=pmColor, linewidth=pmwidth, editable=false) var l2 = label.new(bar_index, day_low, 'PML ', color=tableBgColor, textcolor=pmColor, style=label.style_label_down, tooltip='Premarket Low') label.set_xy(l2, bar_index + 50, spm and day_low ? day_low : na) label.set_text(l2, 'PML ' + str.tostring(spm and day_low ? day_low : na, '0.00')) plot(sy == 'on' and pdh ? pdh : na, title='Previous Daily High', style=plot.style_line, trackprice=true, offset=-9999, color=syColor, linewidth=sywidth, editable=false) var l3 = label.new(bar_index, pdh, 'LDH ', color=tableBgColor, textcolor=syColor, style=label.style_label_down, tooltip='Last Day High') label.set_xy(l3, bar_index + 30, sy == 'on' and pdh ? pdh : na) label.set_text(l3, 'LDH ' + str.tostring(sy == 'on' and pdh ? pdh : na, '0.00')) plot(sy == 'on' and pdl ? pdl : na, title='Previous Daily Low', style=plot.style_line, trackprice=true, offset=-9999, color=syColor, linewidth=sywidth, editable=false) var l4 = label.new(bar_index, pdl, 'LDL ', color=tableBgColor, textcolor=syColor, style=label.style_label_down, tooltip='Last Day Low') label.set_xy(l4, bar_index + 30, sy == 'on' and pdl ? pdl : na) label.set_text(l4, 'LDL ' + str.tostring(sy == 'on' and pdl ? pdl : na, '0.00')) plot(sw == 'current' ? request.security(syminfo.tickerid, 'W', high[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', high[1]) : na, title='WeekHigh Line', trackprice=true, offset=-9999, color=swColor, linewidth=swwidth, editable=false) var l17 = label.new(bar_index, lastClose, 'WH ', color=tableBgColor, textcolor=swColor, style=label.style_label_down, tooltip='Weekly High ') label.set_xy(l17, bar_index + 70, sw == 'current' ? request.security(syminfo.tickerid, 'W', high[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', high[1]) : na) label.set_text(l17, 'WH ' + str.tostring(sw == 'current' ? request.security(syminfo.tickerid, 'W', high[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', high[1]) : na, '0.00')) plot(sw == 'current' ? request.security(syminfo.tickerid, 'W', low[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', low[1]) : na, title='WeekLow Line', trackprice=true, offset=-9999, color=swColor, linewidth=swwidth, editable=false) var l18 = label.new(bar_index, lastClose, 'WL ', color=tableBgColor, textcolor=swColor, style=label.style_label_down, tooltip='Weekly Low ') label.set_xy(l18, bar_index + 70, sw == 'current' ? request.security(syminfo.tickerid, 'W', low[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', low[1]) : na) label.set_text(l18, 'WL ' + str.tostring(sw == 'current' ? request.security(syminfo.tickerid, 'W', low[0]) : sw == 'last' ? request.security(syminfo.tickerid, 'W', low[1]) : na, '0.00')) plot(sm == 'current' ? request.security(syminfo.tickerid, 'M', high[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', high[1]) : na, title='MonthHigh Line', trackprice=true, offset=-9999, color=smColor, linewidth=smwidth, editable=false) var l19 = label.new(bar_index, lastClose, 'MH ', color=tableBgColor, textcolor=smColor, style=label.style_label_down, tooltip='Monthly High ') label.set_xy(l19, bar_index + 70, sm == 'current' ? request.security(syminfo.tickerid, 'M', high[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', high[1]) : na) label.set_text(l19, 'MH ' + str.tostring(sm == 'current' ? request.security(syminfo.tickerid, 'M', high[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', high[1]) : na, '0.00')) plot(sm == 'current' ? request.security(syminfo.tickerid, 'M', low[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', low[1]) : na, title='MonthLow Line', trackprice=true, offset=-9999, color=smColor, linewidth=smwidth, editable=false) var l20 = label.new(bar_index, lastClose, 'ML ', color=tableBgColor, textcolor=smColor, style=label.style_label_down, tooltip='Monthly Low ') label.set_xy(l20, bar_index + 70, sm == 'current' ? request.security(syminfo.tickerid, 'M', low[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', low[1]) : na) label.set_text(l20, 'ML ' + str.tostring(sm == 'current' ? request.security(syminfo.tickerid, 'M', low[0]) : sm == 'last' ? request.security(syminfo.tickerid, 'M', low[1]) : na, '0.00')) plot(satr1 and lastClose + dailyATR1 * atr_factor1 ? lastClose + dailyATR1 * atr_factor1 : na, title='ATRH1 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr1Color, linewidth=1, editable=false) var l5 = label.new(bar_index, lastClose, 'ATR-H ', color=tableBgColor, textcolor=satr1Color, style=label.style_label_down, tooltip='High of the daily ATR') label.set_xy(l5, bar_index + 70, satr1 and lastClose + dailyATR1 * atr_factor1 ? lastClose + dailyATR1 * atr_factor1 : na) label.set_text(l5, 'ATR-H ' + str.tostring(satr1 and lastClose + dailyATR1 * atr_factor1 ? lastClose + dailyATR1 * atr_factor1 : na, '0.00')) plot(satr1 and lastClose - dailyATR1 * atr_factor1 ? lastClose - dailyATR1 * atr_factor1 : na, title='ATRL1 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr1Color, linewidth=1, editable=false) var l6 = label.new(bar_index, lastClose, 'ATR-L ', color=tableBgColor, textcolor=satr1Color, style=label.style_label_down, tooltip='Low of the daily ATR') label.set_xy(l6, bar_index + 70, satr1 and lastClose - dailyATR1 * atr_factor1 ? lastClose - dailyATR1 * atr_factor1 : na) label.set_text(l6, 'ATR-L ' + str.tostring(satr1 and lastClose - dailyATR1 * atr_factor1 ? lastClose - dailyATR1 * atr_factor1 : na, '0.00')) plot(satr2 and lastClose + dailyATR2 * atr_factor2 ? lastClose + dailyATR2 * atr_factor2 : na, title='ATRH2 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr2Color, linewidth=1, editable=false) var l7 = label.new(bar_index, lastClose, 'ATR2-H ', color=tableBgColor, textcolor=satr2Color, style=label.style_label_down, tooltip='High of the daily ATR 2') label.set_xy(l7, bar_index + 70, satr2 and lastClose + dailyATR2 * atr_factor2 ? lastClose + dailyATR2 * atr_factor2 : na) label.set_text(l7, 'ATR2-H ' + str.tostring(satr2 and lastClose + dailyATR2 * atr_factor2 ? lastClose + dailyATR2 * atr_factor2 : na, '0.00')) plot(satr2 and lastClose - dailyATR2 * atr_factor2 ? lastClose - dailyATR2 * atr_factor2 : na, title='ATRL2 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr2Color, linewidth=1, editable=false) var l8 = label.new(bar_index, lastClose, 'ATR2-L ', color=tableBgColor, textcolor=satr2Color, style=label.style_label_down, tooltip='Low of the daily ATR 2') label.set_xy(l8, bar_index + 70, satr2 and lastClose - dailyATR2 * atr_factor2 ? lastClose - dailyATR2 * atr_factor2 : na) label.set_text(l8, 'ATR2-L ' + str.tostring(satr2 and lastClose - dailyATR2 * atr_factor2 ? lastClose - dailyATR2 * atr_factor2 : na, '0.00')) plot(satr3 and lastClose + dailyATR3 * atr_factor3 ? lastClose + dailyATR3 * atr_factor3 : na, title='ATRH3 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr3Color, linewidth=1, editable=false) var l9 = label.new(bar_index, lastClose, 'ATR3-H ', color=tableBgColor, textcolor=satr3Color, style=label.style_label_down, tooltip='High of the daily ATR 3') label.set_xy(l9, bar_index + 70, satr3 and lastClose + dailyATR3 * atr_factor3 ? lastClose + dailyATR3 * atr_factor3 : na) label.set_text(l9, 'ATR3-H ' + str.tostring(satr3 and lastClose + dailyATR3 * atr_factor3 ? lastClose + dailyATR3 * atr_factor3 : na, '0.00')) plot(satr3 and lastClose - dailyATR3 * atr_factor3 ? lastClose - dailyATR3 * atr_factor3 : na, title='ATRL3 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr3Color, linewidth=1, editable=false) var l10 = label.new(bar_index, lastClose, 'ATR3-L ', color=tableBgColor, textcolor=satr3Color, style=label.style_label_down, tooltip='Low of the daily ATR 3') label.set_xy(l10, bar_index + 70, satr3 and lastClose - dailyATR3 * atr_factor3 ? lastClose - dailyATR3 * atr_factor3 : na) label.set_text(l10, 'ATR3-L ' + str.tostring(satr3 and lastClose - dailyATR3 * atr_factor3 ? lastClose - dailyATR3 * atr_factor3 : na, '0.00')) plot(satr4 and lastClose + dailyATR4 * atr_factor4 ? lastClose + dailyATR4 * atr_factor4 : na, title='ATRH4 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr4Color, linewidth=1, editable=false) var l11 = label.new(bar_index, lastClose, 'ATR4-H ', color=tableBgColor, textcolor=satr4Color, style=label.style_label_down, tooltip='High of the daily ATR 4') label.set_xy(l11, bar_index + 70, satr4 and lastClose + dailyATR4 * atr_factor4 ? lastClose + dailyATR4 * atr_factor4 : na) label.set_text(l11, 'ATR4-H ' + str.tostring(satr4 and lastClose + dailyATR4 * atr_factor4 ? lastClose + dailyATR4 * atr_factor4 : na, '0.00')) plot(satr4 and lastClose - dailyATR4 * atr_factor4 ? lastClose - dailyATR4 * atr_factor4 : na, title='ATRL4 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr4Color, linewidth=1, editable=false) var l12 = label.new(bar_index, lastClose, 'ATR4-L ', color=tableBgColor, textcolor=satr4Color, style=label.style_label_down, tooltip='Low of the daily ATR 4') label.set_xy(l12, bar_index + 70, satr4 and lastClose - dailyATR4 * atr_factor4 ? lastClose - dailyATR4 * atr_factor4 : na) label.set_text(l12, 'ATR4-L ' + str.tostring(satr4 and lastClose - dailyATR4 * atr_factor4 ? lastClose - dailyATR4 * atr_factor4 : na, '0.00')) plot(satr5 and lastClose + dailyATR5 * atr_factor5 ? lastClose + dailyATR5 * atr_factor5 : na, title='ATRH5 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr5Color, linewidth=1, editable=false) var l13 = label.new(bar_index, lastClose, 'ATR5-H ', color=tableBgColor, textcolor=satr5Color, style=label.style_label_down, tooltip='High of the daily ATR 5') label.set_xy(l13, bar_index + 70, satr5 and lastClose + dailyATR5 * atr_factor5 ? lastClose + dailyATR5 * atr_factor5 : na) label.set_text(l13, 'ATR5-H ' + str.tostring(satr5 and lastClose + dailyATR5 * atr_factor5 ? lastClose + dailyATR5 * atr_factor5 : na, '0.00')) plot(satr5 and lastClose - dailyATR5 * atr_factor5 ? lastClose - dailyATR5 * atr_factor5 : na, title='ATRL5 Line', style=plot.style_line, trackprice=true, offset=-9999, color=satr5Color, linewidth=1, editable=false) var l14 = label.new(bar_index, lastClose, 'ATR5-L ', color=tableBgColor, textcolor=satr5Color, style=label.style_label_down, tooltip='Low of the daily ATR 5') label.set_xy(l14, bar_index + 70, satr5 and lastClose - dailyATR5 * atr_factor5 ? lastClose - dailyATR5 * atr_factor5 : na) label.set_text(l14, 'ATR5-L ' + str.tostring(satr5 and lastClose - dailyATR5 * atr_factor5 ? lastClose - dailyATR5 * atr_factor5 : na, '0.00')) //plot(satr6 and lastClose + dailyATR6*atr_factor6 ? lastClose + dailyATR6*atr_factor6 : na, title='ATRH6 Line',style=plot.style_line, trackprice=true, offset=-9999, color=satr6Color, linewidth=1) //var l15 = label.new(bar_index, lastClose, "ATR6-H " ,color=tableBgColor, textcolor=color.new(satr6Color, 0) , style=label.style_label_down, tooltip="High of the daily ATR 6" ) //label.set_xy(l15, bar_index+70, satr6 and lastClose + dailyATR6*atr_factor6 ? lastClose + dailyATR6*atr_factor6 : na) //label.set_text(l15, "ATR6-H " + tostring(satr6 and lastClose + dailyATR6*atr_factor6 ? lastClose + dailyATR6*atr_factor6 : na, '0.00')) //plot(satr6 and lastClose - dailyATR6*atr_factor6 ? lastClose - dailyATR6*atr_factor6 : na, title='ATRL6 Line',style=plot.style_line, trackprice=true, offset=-9999, color=satr6Color, linewidth=1) //var l16 = label.new(bar_index, lastClose, "ATR6-L " ,color=tableBgColor, textcolor=color.new(satr6Color, 0) , style=label.style_label_down, tooltip="Low of the daily ATR 6" ) //label.set_xy(l16, bar_index+70, satr6 and lastClose - dailyATR6*atr_factor6 ? lastClose - dailyATR6*atr_factor6 : na) //label.set_text(l16, "ATR6-L " + tostring(satr6 and lastClose - dailyATR6*atr_factor6 ? lastClose - dailyATR6*atr_factor6 : na, '0.00')) plot(slen1 and out1 ? out1 : na, style=plot.style_circles, title='ma1 Line ', color=slen1Color, trackprice=true, offset=-9999, editable=false) var l21 = label.new(bar_index, lastClose, 'Ma' + str.tostring(len1), color=tableBgColor, textcolor=slen1Color, style=label.style_label_down, tooltip='Ma' + str.tostring(len1)) label.set_xy(l21, bar_index + 120, slen1 and out1 ? out1 : na) label.set_text(l21, 'Ma' + str.tostring(len1) + ' ' + str.tostring(slen1 and out1 ? out1 : na, '0.00')) plot(slen2 and out2 ? out2 : na, style=plot.style_circles, title='ma2 Line', color=slen2Color, trackprice=true, offset=-9999, editable=false) var l22 = label.new(bar_index, lastClose, 'Ma' + str.tostring(len2), color=tableBgColor, textcolor=slen1Color, style=label.style_label_down, tooltip='Ma' + str.tostring(len2)) label.set_xy(l22, bar_index + 120, slen2 and out2 ? out2 : na) label.set_text(l22, 'Ma' + str.tostring(len2) + ' ' + str.tostring(slen2 and out2 ? out2 : na, '0.00')) plot(slen3 and out3 ? out3 : na, style=plot.style_circles, title='ma3 Line', color=slen3Color, trackprice=true, offset=-9999, editable=false) var l23 = label.new(bar_index, lastClose, 'Ma' + str.tostring(len3), color=tableBgColor, textcolor=slen3Color, style=label.style_label_down, tooltip='Ma' + str.tostring(len3)) label.set_xy(l23, bar_index + 120, slen3 and out3 ? out3 : na) label.set_text(l23, 'Ma' + str.tostring(len3) + ' ' + str.tostring(slen3 and out3 ? out3 : na, '0.00')) plot(slenEMA1 and outEMA1 ? outEMA1 : na, title='EMA1', color=slenEMA1Color, offset=offsetEMA1, editable=false) plot(slenEMA2 and outEMA2 ? outEMA2 : na, title='EMA2', color=slenEMA2Color, offset=offsetEMA2, editable=false) plot(svwap and vwapcond ? vwapcond : na, title='VWAP', color=ta.rising(vwapcond, 2) ? svwapPColor : svwapNColor, linewidth=1, style= svwapStyle == 'line' ? plot.style_line : plot.style_circles, trackprice=true, editable=false) var l24 = label.new(bar_index, ta.vwap and vwapcond ? vwapcond : na, 'VWAP ' + str.tostring(ta.vwap and vwapcond ? vwapcond : na), color=tableBgColor, textcolor = ta.rising(vwapcond, 2) ? svwapPColor : svwapNColor, style=label.style_label_down, tooltip='volume weighted average price') label.set_xy(l24, bar_index + 50, svwap and vwapcond ? vwapcond : na) label.set_text(l24, 'VWAP ' + str.tostring(svwap and vwapcond ? vwapcond : na, '0.00')) label.set_textcolor(l24, textcolor= ta.rising(vwapcond, 2) ? svwapPColor : svwapNColor) plot(timeframe.isintraday and sWvwap ? wvw : na, title='W-VWAP', color=sWvwapColor, style=plot.style_circles, editable=false) plot(timeframe.isintraday and sMvwap ? mvw : na, title='M-VWAP', color=sMvwapColor, style=plot.style_circles, editable=false) plot(sstdev and myvwap + devNum * dev ? myvwap + devNum * dev : na, title='VWAP Upper Stdev', color=sstdevColor, style=plot.style_line, linewidth=1, editable=false) plot(sstdev and myvwap - devNum * dev ? myvwap - devNum * dev : na, title='VWAP Lower Stdev', color=sstdevColor, style=plot.style_line, linewidth=1, editable=false) plot(sstdev2 and myvwap + devNum2 * dev ? myvwap + devNum2 * dev : na, title='VWAP Upper Stdev2', color=sstdev2Color, style=plot.style_line, linewidth=1, editable=false) plot(sstdev2 and myvwap - devNum2 * dev ? myvwap - devNum2 * dev : na, title='VWAP Lower Stdev2', color=sstdev2Color, style=plot.style_line, linewidth=1, editable=false) plot(sstdev3 and myvwap + devNum3 * dev ? myvwap + devNum3 * dev : na, title='VWAP Upper Stdev3', color=sstdev3Color, style=plot.style_line, linewidth=1, editable=false) plot(sstdev3 and myvwap - devNum3 * dev ? myvwap - devNum3 * dev : na, title='VWAP Lower Stdev3', color=sstdev3Color, style=plot.style_line, linewidth=1, editable=false) //dt = time - time[1] if barstate.islast and sVM var l25 = label.new(bar_index, na, style=label.style_none, text=str.tostring(percentage2, '#.##') + ' %', textcolor=VolumeColor, yloc=yloc.abovebar, tooltip='% Average Volume last x Candle. Prints Velocity ') label.delete(l25[1])
Donchian Screener
https://www.tradingview.com/script/Ji2cOyGa-Donchian-Screener/
starbolt
https://www.tradingview.com/u/starbolt/
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/ // © starbolt //@version=5 indicator('Donchian Screener', overlay=true) _remove_exchange(ticker) => res = ticker == '' ? '' : array.get(str.split(ticker, ':'), 1) res _donchian(len, hilo, offset) => highest = ta.highest(high, len) lowest = ta.lowest(low, len) hi = hilo ? high : close lo = hilo ? low : close signal = hi > highest[offset] and hi[1] < highest[offset + 1] ? 1 : lo < lowest[offset] and lo[1] > lowest[offset + 1] ? -1 : 0 signal use_hilo = input.bool(true, "Use High/Low Price Breakouts") offset = input.int(1, "Upper/Lower Band Breakout Offset", minval=0, step=1) pos = input.string("Top Right", "Panel Position", ["Top Right", "Middle Right", "Bottom Right"]) timeframe = input.timeframe("D", "Default Timeframe") t1 = input.symbol('BMFBOVESPA:VALE3', 'Ticker 1') t1len = input.int(20, 'Length 1', step=1, minval=1) t2 = input.symbol('', 'Ticker 2') t2len = input.int(20, 'Length 2', step=1, minval=1) t3 = input.symbol('', 'Ticker 3') t3len = input.int(20, 'Length 3', step=1, minval=1) t4 = input.symbol('', 'Ticker 4') t4len = input.int(20, 'Length 4', step=1, minval=1) t5 = input.symbol('', 'Ticker 5') t5len = input.int(20, 'Length 5', step=1, minval=1) t6 = input.symbol('', 'Ticker 6') t6len = input.int(20, 'Length 6', step=1, minval=1) t7 = input.symbol('', 'Ticker 7') t7len = input.int(20, 'Length 7', step=1, minval=1) t8 = input.symbol('', 'Ticker 8') t8len = input.int(20, 'Length 8', step=1, minval=1) t9 = input.symbol('', 'Ticker 9') t9len = input.int(20, 'Length 9', step=1, minval=1) t10 = input.symbol('', 'Ticker 10') t10len = input.int(20, 'Length 10', step=1, minval=1) t1name = _remove_exchange(t1) t2name = _remove_exchange(t2) t3name = _remove_exchange(t3) t4name = _remove_exchange(t4) t5name = _remove_exchange(t5) t6name = _remove_exchange(t6) t7name = _remove_exchange(t7) t8name = _remove_exchange(t8) t9name = _remove_exchange(t9) t10name = _remove_exchange(t10) h1 = t1 == '' ? 0 : request.security(t1, timeframe, _donchian(t1len, use_hilo, offset)) h2 = t2 == '' ? 0 : request.security(t2, timeframe, _donchian(t2len, use_hilo, offset)) h3 = t3 == '' ? 0 : request.security(t3, timeframe, _donchian(t3len, use_hilo, offset)) h4 = t4 == '' ? 0 : request.security(t4, timeframe, _donchian(t4len, use_hilo, offset)) h5 = t5 == '' ? 0 : request.security(t5, timeframe, _donchian(t5len, use_hilo, offset)) h6 = t6 == '' ? 0 : request.security(t6, timeframe, _donchian(t6len, use_hilo, offset)) h7 = t7 == '' ? 0 : request.security(t7, timeframe, _donchian(t7len, use_hilo, offset)) h8 = t8 == '' ? 0 : request.security(t8, timeframe, _donchian(t8len, use_hilo, offset)) h9 = t9 == '' ? 0 : request.security(t9, timeframe, _donchian(t9len, use_hilo, offset)) h10 = t10 == '' ? 0 : request.security(t10, timeframe, _donchian(t10len, use_hilo, offset)) ut1 = h1 == 1 ut2 = h2 == 1 ut3 = h3 == 1 ut4 = h4 == 1 ut5 = h5 == 1 ut6 = h6 == 1 ut7 = h7 == 1 ut8 = h8 == 1 ut9 = h9 == 1 ut10 = h10 == 1 dt1 = h1 == -1 dt2 = h2 == -1 dt3 = h3 == -1 dt4 = h4 == -1 dt5 = h5 == -1 dt6 = h6 == -1 dt7 = h7 == -1 dt8 = h8 == -1 dt9 = h9 == -1 dt10 = h10 == -1 up_label = 'UP TREND \n\n' up_label := ut1 ? up_label + t1name + '\n' : up_label up_label := ut2 ? up_label + t2name + '\n' : up_label up_label := ut3 ? up_label + t3name + '\n' : up_label up_label := ut4 ? up_label + t4name + '\n' : up_label up_label := ut5 ? up_label + t5name + '\n' : up_label up_label := ut6 ? up_label + t6name + '\n' : up_label up_label := ut7 ? up_label + t7name + '\n' : up_label up_label := ut8 ? up_label + t8name + '\n' : up_label up_label := ut9 ? up_label + t9name + '\n' : up_label up_label := ut10 ? up_label + t10name + '\n' : up_label down_label = 'DOWN TREND \n\n' down_label := dt1 ? down_label + t1name + '\n' : down_label down_label := dt2 ? down_label + t2name + '\n' : down_label down_label := dt3 ? down_label + t3name + '\n' : down_label down_label := dt4 ? down_label + t4name + '\n' : down_label down_label := dt5 ? down_label + t5name + '\n' : down_label down_label := dt6 ? down_label + t6name + '\n' : down_label down_label := dt7 ? down_label + t7name + '\n' : down_label down_label := dt8 ? down_label + t8name + '\n' : down_label down_label := dt9 ? down_label + t9name + '\n' : down_label down_label := dt10 ? down_label + t10name + '\n' : down_label position = pos == "Bottom Right" ? position.bottom_right : pos == "Middle Right" ? position.middle_right : position.top_right var table perfTable = table.new(position, 1, 2, border_width = 3) f_fillCell(_table, _column, _row, _value, _color) => _c_color = _color _transp = 80 _cellText = str.tostring(_value) table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color, _transp), text_color = _c_color, width = 10) f_fillCell(perfTable, 0, 0, up_label, #239B56) f_fillCell(perfTable, 0, 1, down_label, #E74C3C)
Explaining nz
https://www.tradingview.com/script/wZ0tnAs0-Explaining-nz/
fikira
https://www.tradingview.com/u/fikira/
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/ // © fikira //@version=5 indicator("Explaining nz") // This script is part of a collection of educational scripts // If you want to return to the open source INDEX page, click the link in the comments: // -> https://www.tradingview.com/script/TUeC9XDq-Education-INDEX/ // -------[ This is meant for Pine Script coders who have trouble with the use of 'nz' ]------- // -------[ Best to use on a Monthly Timeframe with a Ticker that exists longer then 2 years (example Bitcoin) ]------- // -------[ Then open the console so you can read and follow the instructions and explanation in the script ]------- options = input.string('A[1]', title='options', options=['A', 'A[1]', 'nz(A[1])', 'nz(A[1], 1)', 'B', 'nz(close[20])']) // Let's start with this -> choose -> settings -> Options -> 'A': A = 0 // plot -> A plot(options == 'A' ? A : na) // On every bar, also the first one, A is declared as 0 // -> the code 'says' -> on every bar -> make a new variable which has the value 0 // Importantly -> everything is put in a 'log' -> this makes a 'series', so when plotting A, this is done out of the log and shows everything what happened bar per bar // example and recap: // plot A -> first bar -> A is declared as 0, at the close of this bar -> put data in log ( = 0) and delete A // second bar -> A is declared as 0, at the close of this bar -> put data in log ( = 0) and delete A // third bar -> A is declared as 0, at the close of this bar -> put data in log ( = 0) and delete A // forth bar -> A is declared as 0, at the close of this bar -> put data in log ( = 0) and delete A // ... // Therefore in this case we get a line with all zero's // Now choose -> settings -> Options -> 'A[1]': plot(options == 'A[1]' ? A[1] : na) // -> the code 'says' -> On every bar -> Show the previous value (A[1] = previous A) // -> From the log data -> data (A) of previous bar ([1]) is pulled out and plotted as a line // plot -> A[1] // Everything is the same, except the first one (nothing shows), why? // There is NOTHING before the first bar -> it is Not Available (= n/a ) so if you want to show previous data of this first bar, this is impossible! // The second bar is no problem, since the FIRST bar was declared as 0, so if you'd plot previous data on this second bar, then you'll get data from the first bar -> which is 0 // Now, if you do this -> choose -> settings -> Options -> 'nz(A[1])' : // plot -> nz(A[1]) plot(options == 'nz(A[1])' ? nz(A[1]) : na) // -> the first bar is visible again // Why? // A task is set on every bar -> when data between brackets - nz(data) - is n/a -> replace this data by 0 // First bar -> A[1] = n/a -> replaced by 0 // without nz -> on the FIRST bar A[1] = n/a // with nz -> on the FIRST bar nz(A[1]) -> A[1] = n/a -> replace this by 0 -> nz(A[1]) = 0 // You can also replace the 0 by another number (in the case the variable uses numbers) // example (Choose -> settings -> Options -> 'nz(A[1], 1)'): plot(options == 'nz(A[1], 1)' ? nz(A[1], 1) : na) // Since ONLY the first bar's data was n/a -> ONLY this data is altered, now by 1 // Why is all of this important? // Because it is not just about the first bar // example: // Choose -> settings -> Options -> 'B' B = 0 B := close > close[20] ? 1 : B[1] plot(options == 'B' ? B : na) // (*) := -> means -> adjust 'B' into '1' if 'close > close[20]' is indeed true -> ELSE ( : ) -> remember the previous value of 'B' // Here the code says -> Replace B by 1 IF the close of this bar is greater than the close of 20 bars ago // FIRST bar -> there is NO close found 20 bars back -> this task is impossible for this bar (and the following 20 bars) // since this is impossible -> the code now must remember its previous value (B[1] -> see -> (*) ) but this is n/a ! So it remembers -> n/a // This continues until 20 bars further -> which means you cannot do anything with these first 20 bars // Now choose -> settings -> Options -> 'nz(close[20])' // This is exactly the same code but with nz -> the code replaces the unavailable data with 0 C = 0 C := close > nz(close[20]) ? 1 : C[1] plot(options == 'nz(close[20])' ? C : na) // Now you can use data of these first 20 bars, or MORE IMPORTANTLY -> you wouldn't get into trouble with calculations with n/a
Explaining VAR
https://www.tradingview.com/script/f9Yrc0LO-Explaining-VAR/
fikira
https://www.tradingview.com/u/fikira/
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/ // © fikira //@version=5 // This script is part of a collection of educational scripts // If you want to return to the open source INDEX page, click the link in the comments: // -> https://www.tradingview.com/script/TUeC9XDq-Education-INDEX/ indicator("Explaining VAR", overlay=false, max_labels_count=500) i_show = input.bool(false, title='show what happened 3 bars back (\'LOG\')') // -------[ This is meant for Pine Script coders who have trouble with the distinction between ]------- // -------[ 'var' declared variables and 'non var' declared variables ]------- // -------[ Best to use on a Monthly Timeframe with a Ticker that exists longer then 2 years (example Bitcoin) ]------- // -------[ Then open the console so you can read and follow the instructions and explanation in the script ]------- // [---------------------------------------------–] // [ -> Enable 'show labels' in settings ] // [---------------------------------------------–] // IMPORTANT to know, what happens on every bar is kept in a 'log', so if a variable is declared as var or not, the log always can be used to look back // a (-> var a) = declared on the first bar and it holds its memory // The code 'says' -> On the first bar 'A' IS 0 -> at the end of each bar -> put data in 'log', remember what happened to it -> move forward // b is declared on every bar, again and again -> no long term memory // The code 'says' -> On the EVERY bar 'B' IS 0 -> at the end of each bar -> put data in 'log', then just 'forget' // [---------------------------------------------–] // [ -> Disable 'show labels' in settings ] // [---------------------------------------------–] // So... var a = 10 // 'Long Time Memory' b = 10 // 'Short Time Memory' -> what happened is recorded in the log -> variable then 'disappears' and gets rebuild agian the next bar // [---------------------------------------------–] // [ -> Look at the chart (first 5 bars 0 -> 4) ] // [---------------------------------------------–] // Both a(green) and b(blue) have a value of 10 the first 5 bars // // bar 1 (n° 0): // - var a = 10 // - b = 10 // // bar 1 (n° 0): // - a checks in his memory (was 10) -> on this bar no extra task -> stays 10 // - b = again declared as 10 (new) -> on this bar no extra task -> stays 10 // // bar 2 (n° 1): // - a checks in his memory (was 10) -> on this bar no extra task -> stays 10 // - b = again declared as 10 (new) -> on this bar no extra task -> stays 10 // // ... // // // bar 4 (n° 3): // - a checks in his memory (was 10) -> on this bar no extra task -> stays 10 // - b = again declared as 10 (new) -> on this bar no extra task -> stays 10 // // [---------------------------------------------–] // [ -> Look at the chart (next 10 bars 5 -> 14) ] // [---------------------------------------------–] // ---------------------[ // FIRST TASK -> From bar 5 till ... -> add 1 on EVERY BAR // ]--------------------- // ] if bar_index >= 5 // ] a += 1 // ] b += 1 // ] // ] // ---------------------[ // -------------------------------------------------------------- // ]--------------------- // // bar 5 (n° 4): // - a checks in his memory (was 10) -> on this bar NO task -> 10 // - b = again declared as 10 (new) -> on this bar NO task -> 10 // // bar 6 (n° 5): // - a checks in his memory (was 10) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // bar 7 (n° 6): // - a checks in his memory (was 11) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 12 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // bar 8 (n° 7): // - a checks in his memory (was 12) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 13 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // ... // // [---------------------------------------------–] // [ -> Look at the chart (next 10 bars 15 -> 24) ] // [---------------------------------------------–] // ---------------------[ // SECOND TASK -> ONLY on bar 15 and bar 25 -> add 7 on THAT BAR // ]--------------------- // ] if bar_index == 15 // ] a += 7 // ] b += 7 // ] // ] // ---------------------[ // ------------------------------------------------------------- // ]--------------------- // bar 15 (n° 14): // - a checks in his memory (was 19) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 20 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // bar 16 (n° 15) : // - a checks in his memory (was 20) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 21 // also on this bar EXTRA task ('SECOND' task, see code) -> add 7 -> 28 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // also on this bar EXTRA task ('SECOND' task, see code) -> add 7 -> 18 // // bar 17 (n° 16): // - a checks in his memory (was 28) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 29 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // bar 18 (n° 17): // - a checks in his memory (was 29) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 30 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // ... // // [---------------------------------------------–] // [ -> Look at the chart (next 10 bars 24 -> ... ] // [---------------------------------------------–] // ---------------------[ // THIRD TASK -> ONLY on bar 25 -> add 9 on THAT BAR // ]--------------------- // ] if bar_index == 25 // ] a += 9 // ] b += 9 // ] // ] // ---------------------[ // ------------------------------------------------------------- // ]--------------------- // bar 25 (n° 24): // - a checks in his memory (was 36) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 37 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // bar 26 (n° 25): // - a checks in his memory (was 37) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 38 // also on this bar EXTRA task ('SECOND' task, see code) -> add 9 -> 47 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // also on this bar EXTRA task ('SECOND' task, see code) -> add 9 -> 20 // // bar 27 (n° 26): // - a checks in his memory (was 45) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 48 // - b = again declared as 10 (new) -> on this bar EXTRA task ('FIRST' task, see code) -> add 1 -> 11 // // ... // // Again, IMPORTANT to know, what happens on every bar is kept in a log, so if a variable is declared as var or not, the log always can be used to look back // // Log = series // // [------------------------------------------------------------------------------------------–---------–] // [ Go to settings -> disable 'show labels' for visibility and ENABLE 'show what happened 3 bars back' ] // [------------------------------------------------------------------------------------–---------------–] // THIRD task -> on EVERY bar -> show what happened 3 bars back // // ] plot(a, color=i_show ? color.new(color.lime, 85) : color.new(color.lime, 0), title='a') // ] plot(b, color=i_show ? color.new(color.blue, 85) : color.new(color.blue, 0), title='b') // ] // ] // ---------------------[ // ------------------------------------------------------------- // ]--------------------- // ---------------------[ // THIRD TASK -> on EVERY bar -> 'show what happened 3 bars back' // ]--------------------- // ] plot(i_show ? a[3] : na, color=color.lime, title='a') // ] plot(i_show ? b[3] : na, color=color.blue, title='b') // ] // ] // ---------------------[ // -------------------------------------------------------------- // ]--------------------- // // When 'show what happened 3 bars back' is enabled -> you'll see both lines moving 3 bars further // this because the task is -> Show on EVERY bar what happened 3 bars ago, this effect is the same on bot a and b // // The first 3 bars will show nothing, because 3 bars before bar 0 there was nothing, also 3 bars before bar 1, 2, 3 there was nothing // The 4th bar ('3') can show the value 3 bars back -> the value of '0' -> 10 i_lab = input.bool(false, title='show labels') if barstate.isfirst and i_lab label.new(bar_index , 10, text='It all\nstarts\nhere' , size=size.small) label.new(bar_index , 10, text='var a\ndeclared once\nit holds his memory', style=label.style_label_upper_right, size=size.small) label.new(bar_index , 10, text='b \n declared \nevery bar' , style=label.style_label_upper_left , size=size.small) label.new(bar_index + 1, 10, text='b \n declared \nevery bar' , style=label.style_label_upper_left , size=size.small) label.new(bar_index + 2, 10, text='b \n declared \nevery bar' , style=label.style_label_upper_left , size=size.small) label.new(bar_index + 3, 10, text='b \n ...' , style=label.style_label_upper_left , size=size.small) label.new(bar_index, a, text=str.tostring(bar_index), color=color.new(color.blue, 100), textcolor=color.new(color.lime, 10), style=label.style_label_down, size=size.small) label.new(bar_index, b, text=str.tostring(bar_index), color=color.new(color.blue, 100), textcolor=color.new(color.blue, 10), style=label.style_label_up , size=size.small)
The 20MA game
https://www.tradingview.com/script/hgcBLD52-The-20MA-game/
Wilson-IV
https://www.tradingview.com/u/Wilson-IV/
93
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/ // © Wilson-IV //@version=5 indicator("The 20MA game", max_labels_count = 500, max_bars_back = 5000, overlay = true) //=============================================================================== // === Discription === //=============================================================================== // Strategy name : The 20MA game // Developer : Wilson-IV // Change log: // ----------------------------------------------------------------------------- // Version 2.5 // - Entry Level added // Version 2.4 // - Suggested Entrypoints improved // Version 2.3 // - Suggested Entrypoints added // Version 2.2 // - Nitfty Box added: just a simple Nitfty box to make analyzing your chart more comfortable // Version 2.1 // - 200 EMA Channel added: this is the area between the 200 EMA High price and the 200 EMA low price // - Black background removed // Version 2.0 // - Upperband and Lowerband 20MA of the 20 MA line // - LONG/ SHORT area added // - Option to plot 20MA, 200MA and/or 20MA of the 20MA line // - LONG/SHORT Labels removed // Version 1.0 // - Initial release //=============================================================================== //=============================================================================== //=== Tooltips, Group- and Inline names === //=============================================================================== // === Inline === string inline_Date = "Date" // === Group names === string group_Starting_date = "Starting date" string group_Plottings = "Plottings" string group_Suggested_Entrypoints = "Suggested Entrypoints" string group_Variables = "Variables" //=============================================================================== //=============================================================================== //=== Backtest date settings === //=============================================================================== startDate = input.int(title = "Start Date" , defval = 1 , minval = 1 , maxval = 31 , group = group_Starting_date , inline = inline_Date) startMonth = input.int(title = "Start Month" , defval = 1 , minval = 1 , maxval = 12 , group = group_Starting_date , inline = inline_Date) startYear = input.int(title = "Start Year" , defval = 2023 , minval = 1800 , maxval = 2100 , group = group_Starting_date , inline = inline_Date) startHour = input.int(title = "Start Hour" , defval = 0 , minval = 0 , maxval = 23 , group = group_Starting_date , inline = inline_Date) startMinute = input.int(title = "Start Minute" , defval = 0 , minval = 0 , maxval = 59 , group = group_Starting_date , inline = inline_Date) startGMT = input.int(title = "GMT + " , defval = 2 , minval = 0 , maxval = 12 , group = group_Starting_date , inline = inline_Date) //=== Start date for Backtesting [Change the GMT setting for your country. E.g.: Amsterdam is GMT+2] === Start_backtest = time >= timestamp(("GMT+" + str.tostring(startGMT)), startYear, startMonth, startDate, startHour, startMinute) ? true : false //=============================================================================== //=============================================================================== //=== Variables === //=============================================================================== //=== Source === float Source = input.source(close, "Source", group = group_Variables) //=== MA === float _20MA = ta.ema(Source, 20) float _200MA = ta.ema(Source, 200) float _20MA_of_20MA = ta.ema(_20MA, 20) bool bln_20MA_IS_UP = _20MA > _20MA[1] bool bln_20MA_IS_DOWN = _20MA <= _20MA[1] bool bln_20MA_of_20MA_IS_UP = _20MA_of_20MA > _20MA_of_20MA[1] bool bln_20MA_of_20MA_IS_DOWN = _20MA_of_20MA <= _20MA_of_20MA[1] int int_20MA_of_20MA_START_GOING_UP = ta.barssince(bln_20MA_of_20MA_IS_DOWN) int int_20MA_of_20MA_START_GOING_DOWN = ta.barssince(bln_20MA_of_20MA_IS_UP) //=== 200MA Channel === float _200MA_HIGH = ta.ema(high, 200) float _200MA_LOW = ta.ema(low, 200) //=== Upperband / Lowerband 20MA of the 20MA === float dbl_Average_distance_from_High_to_20MA_of_20MA_part_1 = high >= _20MA_of_20MA ? high -_20MA_of_20MA : 0 float dbl_Average_distance_from_Low_to_20MA_of_20MA_part_1 = low <= _20MA_of_20MA ? _20MA_of_20MA - low : 0 float dbl_Average_distance_from_High_to_20MA_of_20MA_part_2 = ta.sma(dbl_Average_distance_from_High_to_20MA_of_20MA_part_1, 20) float dbl_Average_distance_from_Low_to_20MA_of_20MA_part_2 = ta.sma(dbl_Average_distance_from_Low_to_20MA_of_20MA_part_1, 20) float dbl_Upperband_High = _20MA_of_20MA + ta.sma(dbl_Average_distance_from_High_to_20MA_of_20MA_part_2, 3) float dbl_Upperband_Low = _20MA_of_20MA - ta.sma(dbl_Average_distance_from_Low_to_20MA_of_20MA_part_2, 3) bool bln_Area_LONG = ((dbl_Upperband_High[2] <= dbl_Upperband_High[1]) and (dbl_Upperband_High[1] <= dbl_Upperband_High)) ? true : bln_20MA_of_20MA_IS_UP ? true : false bool bln_Area_SHORT = ((dbl_Upperband_Low[2] >= dbl_Upperband_Low[1]) and (dbl_Upperband_Low[1] >= dbl_Upperband_Low)) ? true : bln_20MA_of_20MA_IS_DOWN ? true : false //=== Candlestick === Candle_WhiteBody = open < close Candle_BlackBody = open > close Candle_NoBody = open == close //=== Entry Level === var float dbl_Entry_Level = 0. dbl_Entry_Level := bln_20MA_of_20MA_IS_UP and bln_20MA_of_20MA_IS_DOWN[1] ? close : bln_20MA_of_20MA_IS_UP[1] and bln_20MA_of_20MA_IS_DOWN ? close : nz(dbl_Entry_Level[1],0) //=============================================================================== //=============================================================================== //=== Suggested Entrypoints === //=============================================================================== //Bars 20MA of 20MA start going UP/DOWN int int_Bars_20MA_of_20MA_START_GOING_UP = input.int(title = "Bars 20MA_of_20MA start going UP" , defval = 7 , minval = 1 , maxval = 500 , step = 1, group = group_Suggested_Entrypoints) int int_Bars_20MA_of_20MA_START_GOING_DOWN = input.int(title = "Bars 20MA_of_20MA start going DOWN" , defval = 7 , minval = 1 , maxval = 500 , step = 1, group = group_Suggested_Entrypoints) //Distance between each Suggested Entrypoints float dbl_Delta_LONG = input.float(title = "Distance between each Suggested Entrypoints LONG (%)" , defval = 0.5 , minval = 0.5 , maxval = 25 , step = 0.25, group = group_Suggested_Entrypoints) * 0.01 float dbl_Delta_SHORT = input.float(title = "Distance between each Suggested Entrypoints SHORT (%)" , defval = 0.5 , minval = 0.5 , maxval = 25 , step = 0.25, group = group_Suggested_Entrypoints) * 0.01 var float dbl_Start_Price = 0. //Sarting price when the cart changes from Green to Red or visaversa var float dbl_MAX_price_20MA_of_20MA_IS_UP = 0. //MAX price when the 20MA is in the green(upwards) var float dbl_MAX_price_20MA_of_20MA_IS_DOWN = 9999999. //MAX price when the 20MA is in the red(downwards) bool bln_Suggested_Entrypoint_LONG = false //When to Enter LONG var float dbl_Suggested_Entrypoint_price_LONG = 0. //Price when to Enter LONG var float dbl_Suggested_Entrypoint_previous_price_LONG = 0. //Previous Price when to Enter LONG bool bln_Suggested_Entrypoint_SHORT = false //When to Enter SHORT var float dbl_Suggested_Entrypoint_price_SHORT = 0. //Price when to Enter SHORT var float dbl_Suggested_Entrypoint_previous_price_SHORT = 0. //Previous Price when to Enter SHORT var bool bln_Pierced_LONG = false //The moment the price pierced through the previous Entrypoint price LONG var bool bln_Pierced_SHORT = false //The moment the price pierced through the previous Entrypoint price SHORT var bool bln_Show_Suggested_Entrypoint_price = false //Show Suggested Entrypoint price if Start_backtest //Entrypoint LONG if bln_20MA_of_20MA_IS_UP and bln_20MA_of_20MA_IS_DOWN[1] dbl_MAX_price_20MA_of_20MA_IS_UP := 0 dbl_MAX_price_20MA_of_20MA_IS_DOWN := 9999999. dbl_Suggested_Entrypoint_price_LONG := 0 dbl_Suggested_Entrypoint_previous_price_LONG := 0 dbl_Suggested_Entrypoint_price_SHORT := 0 dbl_Suggested_Entrypoint_previous_price_SHORT := 0 bln_Pierced_LONG := false bln_Pierced_SHORT := false dbl_Start_Price := na if bln_20MA_of_20MA_IS_UP dbl_MAX_price_20MA_of_20MA_IS_DOWN := na dbl_MAX_price_20MA_of_20MA_IS_UP := math.max(dbl_MAX_price_20MA_of_20MA_IS_UP, close) //=== Criteria LONG === bool Criteria_01 = dbl_MAX_price_20MA_of_20MA_IS_UP[1] > dbl_MAX_price_20MA_of_20MA_IS_UP[2] bool Criteria_02 = dbl_MAX_price_20MA_of_20MA_IS_DOWN[2] > 0 and dbl_MAX_price_20MA_of_20MA_IS_UP[1] > 0 bool Criteria_03 = close <= (1 + dbl_Delta_LONG) * _20MA_of_20MA bool Criteria_04 = int_20MA_of_20MA_START_GOING_UP <= int_Bars_20MA_of_20MA_START_GOING_UP if ((Criteria_01 or Criteria_02) and Candle_BlackBody) or (Criteria_03 and Criteria_04) if dbl_Suggested_Entrypoint_price_LONG == 0 dbl_Suggested_Entrypoint_previous_price_LONG := 0 dbl_Suggested_Entrypoint_price_LONG := close bln_Suggested_Entrypoint_LONG := true bln_Pierced_LONG := false else if close >= (1 + dbl_Delta_LONG) * dbl_Suggested_Entrypoint_price_LONG dbl_Suggested_Entrypoint_previous_price_LONG := dbl_Suggested_Entrypoint_price_LONG dbl_Suggested_Entrypoint_price_LONG := close if bln_Pierced_LONG == true bln_Show_Suggested_Entrypoint_price := true bln_Suggested_Entrypoint_LONG := true bln_Pierced_LONG := false else bln_Show_Suggested_Entrypoint_price := false if low <= dbl_Suggested_Entrypoint_previous_price_LONG bln_Pierced_LONG := true //Entrypoint SHORT if bln_20MA_of_20MA_IS_UP[1] and bln_20MA_of_20MA_IS_DOWN dbl_MAX_price_20MA_of_20MA_IS_UP := 0 dbl_MAX_price_20MA_of_20MA_IS_DOWN := 9999999. dbl_Suggested_Entrypoint_price_LONG := 0 dbl_Suggested_Entrypoint_previous_price_LONG := 9999999. dbl_Suggested_Entrypoint_price_SHORT := 0 dbl_Suggested_Entrypoint_previous_price_SHORT := 9999999. bln_Pierced_LONG := false bln_Pierced_SHORT := false dbl_Start_Price := na if bln_20MA_of_20MA_IS_DOWN dbl_MAX_price_20MA_of_20MA_IS_UP := na dbl_MAX_price_20MA_of_20MA_IS_DOWN := math.min(dbl_MAX_price_20MA_of_20MA_IS_DOWN, close) //=== Criteria SHORT === bool Criteria_01 = dbl_MAX_price_20MA_of_20MA_IS_DOWN[1] < dbl_MAX_price_20MA_of_20MA_IS_DOWN[2] bool Criteria_02 = dbl_MAX_price_20MA_of_20MA_IS_DOWN[1] > 0 and dbl_MAX_price_20MA_of_20MA_IS_UP[2] > 0 bool Criteria_03 = close >= (1 - dbl_Delta_SHORT) * _20MA_of_20MA bool Criteria_04 = int_20MA_of_20MA_START_GOING_DOWN <= int_Bars_20MA_of_20MA_START_GOING_DOWN if ((Criteria_01 or Criteria_02) and Candle_WhiteBody) or (Criteria_03 and Criteria_04) if dbl_Suggested_Entrypoint_price_SHORT == 0 dbl_Suggested_Entrypoint_previous_price_SHORT := 9999999. dbl_Suggested_Entrypoint_price_SHORT := close bln_Suggested_Entrypoint_SHORT := true bln_Pierced_SHORT := false bln_Show_Suggested_Entrypoint_price := true else if close <= (1 - dbl_Delta_SHORT) * dbl_Suggested_Entrypoint_price_SHORT dbl_Suggested_Entrypoint_previous_price_SHORT := dbl_Suggested_Entrypoint_price_SHORT dbl_Suggested_Entrypoint_price_SHORT := close if bln_Pierced_SHORT == true bln_Show_Suggested_Entrypoint_price := true bln_Suggested_Entrypoint_SHORT := true bln_Pierced_SHORT := false else bln_Show_Suggested_Entrypoint_price := false if high >= dbl_Suggested_Entrypoint_previous_price_SHORT bln_Pierced_SHORT := true //=============================================================================== //=============================================================================== //=== Plottings === //=============================================================================== //=== Use plottings ? === bool blnUse_20MA = input.bool(title = "Use 20MA plot ?" , defval = false , group = group_Plottings) bool blnUse_200MA = input.bool(title = "Use 200MA plot ?" , defval = false , group = group_Plottings) bool blnUse_200MA_bands = input.bool(title = "Use 200MA bands ?" , defval = false , group = group_Plottings) bool blnUse_20MA_of_20MA_bands = input.bool(title = "Use 20MA of 20MA_bands ?" , defval = false , group = group_Plottings) bool blnShow_Suggested_Entrypoint = input.bool(title = "Show Suggested Entrypoint ?" , defval = false , group = group_Plottings) bool blnShow_Entry_Level = input.bool(title = "Show Entry Levels ?" , defval = true , group = group_Plottings) //=== 20MA + 200MA === plot(0. , title = "------------------------------" , color = color.new(color.white, 100)) plot(0. , title = "--- 20MA + 200MA --------" , color = color.new(color.white, 100)) P20MA = plot(Start_backtest and blnUse_20MA ? _20MA : na, title = "20MA", color = color.new(color.yellow , 0) , linewidth = 1) P200MA = plot(Start_backtest and blnUse_200MA ? _200MA : na, title = "200MA", color = color.new(color.blue , 0) , linewidth = 3) P20MA20MA = plot(Start_backtest ? _20MA_of_20MA : na, title = "20MA of the 20MA", color = _20MA_of_20MA[1] < _20MA_of_20MA ? color.new(#00FF00 , 0) : color.new(#FF0000 , 0) , linewidth = 3) UPPERBAND_HIGH = plot(Start_backtest and blnUse_20MA_of_20MA_bands ? dbl_Upperband_High : na, title = "Upperband High" , color = bln_Area_LONG ? color.new(color.green, 70) : color.new(color.red, 70), style = plot.style_circles, linewidth = 1) UPPERBAND_LOW = plot(Start_backtest and blnUse_20MA_of_20MA_bands ? dbl_Upperband_Low : na, title = "Upperband Low" , color = bln_Area_SHORT ? color.new(color.red, 70) : color.new(color.green, 70), style = plot.style_circles, linewidth = 1) fill(P20MA20MA, UPPERBAND_HIGH, title = "LONG area", color = blnUse_20MA_of_20MA_bands ? (bln_Area_LONG ? color.new(color.green, 70) : color.new(color.red, 70)) : na) fill(UPPERBAND_LOW, P20MA20MA, title = "SHORT area", color = blnUse_20MA_of_20MA_bands ? (bln_Area_SHORT ? color.new(color.red, 70) : color.new(color.green, 70)): na) //=== 200MA Channel === _200EMA_HIGH = plot(Start_backtest and blnUse_200MA_bands ? _200MA_HIGH : na, title = "_200MA_HIGH" , color = color.new(#ffffff, 30) , style = plot.style_line , linewidth = 1) _200EMA_LOW = plot(Start_backtest and blnUse_200MA_bands ? _200MA_LOW : na, title = "_200MA_LOW" , color = color.new(#ffffff , 30) , style = plot.style_line , linewidth = 1) fill(_200EMA_HIGH, _200EMA_LOW, title = "200 EMA Channel", color = color.new(#ffffff , 95)) //=== Suggested Entrypoints === plot(Start_backtest and blnShow_Suggested_Entrypoint and bln_Suggested_Entrypoint_LONG ? dbl_Suggested_Entrypoint_price_LONG : na, 'Suggested Entrypoint LONG', color=color.new(color.green, 0), style = plot.style_circles, linewidth = 7) plot(Start_backtest and blnShow_Suggested_Entrypoint and bln_Show_Suggested_Entrypoint_price ? dbl_Suggested_Entrypoint_price_LONG : na, 'Entrpoint price LONG', color=color.new(color.white, 0), style=plot.style_circles, linewidth = 1) plotshape(Start_backtest and blnShow_Suggested_Entrypoint and bln_Suggested_Entrypoint_LONG, size = size.small, style= shape.triangledown, color=color.new(color.green, 0), location = location.abovebar) plot(Start_backtest and blnShow_Suggested_Entrypoint and bln_Suggested_Entrypoint_SHORT ? dbl_Suggested_Entrypoint_price_SHORT : na, 'Suggested Entrypoint SHORT', color=color.new(#ff4343, 0), style = plot.style_circles, linewidth = 7) plot(Start_backtest and blnShow_Suggested_Entrypoint and bln_Show_Suggested_Entrypoint_price ? dbl_Suggested_Entrypoint_price_SHORT : na, 'Entrpoint price SHORT', color=color.new(color.white, 0), style=plot.style_circles, linewidth = 1) plotshape(Start_backtest and blnShow_Suggested_Entrypoint and bln_Suggested_Entrypoint_SHORT, size = size.small, style= shape.triangleup, color=color.new(#ff4343, 0), location = location.belowbar) //=== Entry Level === plot(Start_backtest and blnShow_Entry_Level ? dbl_Entry_Level : na, color = _20MA_of_20MA[1] < _20MA_of_20MA ? color.new(#00FF00 , 30) : color.new(#FF0000 , 30) , style = plot.style_circles , linewidth = 1) //===============================================================================
Minimalistic ATR
https://www.tradingview.com/script/XoSoHpdb-Minimalistic-ATR/
FloppyDisque
https://www.tradingview.com/u/FloppyDisque/
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/ //© FloppyDisque //@version=5 indicator("ATR", overlay = true) length = input.int(14, "Length", minval = 1) smoothing = input.string("RMA", title = "Smoothing", options = ["RMA", "SMA", "EMA", "WMA"]) ma_function(source, length) => switch smoothing "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "WMA"=> ta.wma(source, length) plotchar(ma_function(ta.tr(true), length), title = "ATR", char = "", color = color.new(color.blue, 100))
Trends
https://www.tradingview.com/script/UrVsj3q5-Trends/
FakePilot
https://www.tradingview.com/u/FakePilot/
203
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/ // © FakePilot Trends v2.3 // This indicator have been tested mostly on Daily candles with BTC // Set alarms, exit or enter with Bull, Neutral and Bear triggers //@version=5 indicator('Trends', overlay=true) // User Input emaTop = input(defval=32, title='Length EMA Fast') emaMiddle = input(defval=45, title='Length EMA Middle') emaBottom = input(defval=57, title='Length EMA Slow') marginATR = input(defval=15, title='ATR Bars Margin') rangeATRmult = input.float(defval=0.60, title='Smoothing Multiplier', step=0.45) middleToggle = input(defval=false, title='Middle line ON/OFF') //Moving Averages emaFast = ta.ema(close, emaTop) emaMedium = ta.ema(close, emaMiddle) emaSlow = ta.ema(close, emaBottom) emaDiff = emaFast - emaSlow emaMargin = rangeATRmult * ta.atr(marginATR) // Case Differentiation emaBull = emaDiff > emaMargin emaBear = emaDiff < -emaMargin emaNeutral = emaDiff < emaMargin and emaDiff > -emaMargin var bool inBull = na var bool inBear = na var bool inNeutral = na if emaBull inBull := true inBear := false inNeutral := false if emaBear inBull := false inBear := true inNeutral := false if emaNeutral inBull := false inBear := false inNeutral := true // Colors colorBull = color.new(color(#4caf50), 0) colorBullFill = color.new(color(#4caf50), 90) colorBear = color.new(color(#f23645), 0) colorBearFill = color.new(color(#f23645), 90) colorNeutral = color.new(color(#ff9800), 0) colorNeutralFill = color.new(color(#ff9800), 90) // Plotting bear = emaBear ? colorBear : colorNeutral bearFill = emaBear ? colorBearFill : colorNeutralFill // Draw EMA top Line emaFastPlot = plot(emaFast, linewidth=2, title='Fast', color=emaBull ? colorBull : bear) // Draw EMA middle Line emaMediumPlot = plot(middleToggle and emaMedium ? emaMedium : na, title='Middle', linewidth=1, color=emaBull ? colorBull : bear) // Draw EMA bottom Line emaSlowPlot = plot(emaSlow, linewidth=2, title='Slow', color=emaBull ? colorBull : bear) // Fill between EMA top and bottom lines fill(emaFastPlot, emaSlowPlot, color=emaBull ? colorBullFill : bearFill) // Alerts (the [1] means 1 candle backwards) alertcondition(condition = inBull and not inBull[1], title = "Bull", message = "Bull") alertcondition(condition = inBear and not inBear[1], title = "Bear", message = "Bear") alertcondition(condition = inNeutral and not inNeutral[1], title ="Neutral", message = "Neutral")
Volume Spike Retracement
https://www.tradingview.com/script/1bmPQFS6-Volume-Spike-Retracement/
RickSimpson
https://www.tradingview.com/u/RickSimpson/
965
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/ // © RickSimpson //@version=5 indicator("Volume Spike Retracement", 'Volume Spike Retracement', overlay=true, max_bars_back=500, max_lines_count=500, max_labels_count=500) //Inputs highcolor = input.color(defval=color.red, title='Top Retracement', group='Chart Customization', inline='customcolor') lowcolor = input.color(defval=color.green, title='Bottom Retracement', group='Chart Customization', inline='customcolor') vsprice = input.bool(defval=true, title='Show Historical Price Labels?', group='Volume Spike Settings') vsvlength = input.bool(defval=true, title='Show Historical Volume Length Labels?', group='Volume Spike Settings') vslength = input.int(defval=89, title='Volume Spike Length', minval=1, group='Volume Spike Settings') multiplier = input.float(defval=0.5, title='Multiplier', minval=0.1, step=.1, group='Volume Spike Settings') linecount = input.int(defval=10, title='Maximum Lines', minval=1, maxval=200, group='Retracement Settings') layout = input.string(defval='Wick', title='Lines Type', options=['Wick', 'Zone'], group='Retracement Settings', inline='lines') linestyle = input.string(defval='Solid', title='Lines Style', options=['Solid', 'Dotted', 'Dashed'], group='Retracement Settings', inline='lines') linessize = input.int(defval=1, title='Lines Size', minval=1, maxval=3, group='Retracement Settings', inline='lines') extend = input.bool(defval=false, title='Extend Lines?', group='Retracement Settings', inline='lines') vsalerts = input.bool(defval=true, title='Enable Volume Spike Limit Alerts?', group='Alerts Setup') crossalerts = input.bool(defval=false, title='Enable Top/Bottom Lines Crossed Alerts?', group='Alerts Setup') //Price Variables Declaration close_ = close low_ = low high_ = high open_ = open bar_index_ = bar_index //Color Call Function fzonecolor(obcolor, _call) => c1 = color.r(obcolor) c2 = color.g(obcolor) c3 = color.b(obcolor) color.rgb(c1, c2, c3, _call) //Round Function round_f(x) => math.round(x / syminfo.mintick) * syminfo.mintick //Volume Spike Calculation hvs = ta.highest(volume, vslength) abs = volume * 100 / hvs * 4 / 5 smoothing = ta.ema(abs, 21) equal = abs - smoothing limit = ta.highest(equal, vslength) * multiplier cum = equal > 0 and equal >= limit beardir = close < open bulldir = close > open //Conditions bearvol = beardir and cum ? -1 : 0 bullvol = bulldir and cum ? 1 : 0 bearbccolor = bearvol ? highcolor : na bullbccolor = bullvol ? lowcolor : na //Boolean Conditions to Float var float bearvolprice = na if bearvol bearvolprice := high_ bearvolprice var float bullvolprice = na if bullvol bullvolprice := low_ bullvolprice //Plotting plotshape(bearvol, title='Bearish Volume Spike', style=shape.triangledown, location=location.abovebar, color=color.new(highcolor, 0), size=size.tiny) plotshape(bullvol, title='Bullish Volume Spike', style=shape.triangleup, location=location.belowbar, color=color.new(lowcolor, 0), size=size.tiny) barcolor(bearbccolor) barcolor(bullbccolor) if vsprice or vsvlength l=ta.crossunder(bearvol, 0) ? label.new(bar_index_, bearvolprice[1] + 0.01, vsprice and vsvlength ? str.tostring(round_f(bearvolprice)) + ' - ' + str.tostring(math.round(abs)) : vsprice ? str.tostring(round_f(bearvolprice)) : vsvlength ? str.tostring(math.round(abs)) : na, color=color.new(highcolor, 100), textcolor=highcolor, style=label.style_label_down, yloc=yloc.abovebar, size=size.small) : ta.crossover(bullvol, 0) ? label.new(bar_index_, bullvolprice[1] + 0.01, vsprice and vsvlength ? str.tostring(round_f(bullvolprice)) + ' - ' + str.tostring(math.round(abs)) : vsprice ? str.tostring(round_f(bullvolprice)) : vsvlength ? str.tostring(math.round(abs)) : na, color=color.new(lowcolor, 100), textcolor=lowcolor, style=label.style_label_up, yloc=yloc.belowbar, size=size.small) : na l if vsalerts and bearvol == 1 alert('Bearish Volume Spike Limit! At ' + str.tostring(bearvolprice), alert.freq_once_per_bar) if vsalerts and bullvol == 1 alert('Bullish Volume Spike Limit! At ' + str.tostring(bullvolprice), alert.freq_once_per_bar) //Retracement Lines Variables Declaration var int numberofline = linecount var float upperphzone = na var float upperplzone = na var float lowerphzone = na var float lowerplzone = na var line[] upperphzonearr = array.new_line(0, na) var line[] upperplzonearr = array.new_line(0, na) var line[] lowerphzonearr = array.new_line(0, na) var line[] lowerplzonearr = array.new_line(0, na) var line upperphzoneline = na var line upperplzoneline = na var line lowerphzoneline = na var line lowerplzoneline = na var bool[] upperzonetestedarr = array.new_bool(0, false) var bool[] lowerzonetestedarr = array.new_bool(0, false) var bool upperzonetested = false var bool lowerzonetested = false var bool nobool = true var bool showprice = true var color upperzonecolor = highcolor var color lowerzonecolor = lowcolor var label[] labelpharr = array.new_label(0, na) var label[] labelplarr = array.new_label(0, na) var label labelph = na var label labelpl = na //Lines Styles String f_linestyle(_style) => _style == 'Solid' ? line.style_solid : _style == 'Dotted' ? line.style_dotted : line.style_dashed //Top Retracement Lines Calculation if bearvol upperphzone := high_ upperplzone := close_ < open_ ? close_ : open_ upperplzoneline := layout == 'Zone' ? line.new(bar_index_, upperplzone, bar_index, upperplzone, width=linessize) : na upperphzoneline := nobool ? line.new(bar_index_, upperphzone, bar_index, upperphzone, width=linessize) : line.new(bar_index_, (upperphzone + upperplzone) / 2, bar_index, (upperphzone + upperplzone) / 2, width=linessize) labelph := showprice ? label.new(bar_index_, nobool ? upperphzone : (upperphzone + upperplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=upperzonecolor, style=label.style_none) : na if array.size(upperphzonearr) > numberofline line.delete(array.shift(upperphzonearr)) line.delete(array.shift(upperplzonearr)) array.shift(upperzonetestedarr) label.delete(array.shift(labelpharr)) array.push(upperphzonearr, upperphzoneline) array.push(upperplzonearr, upperplzoneline) array.push(upperzonetestedarr, extend ? true : false) array.push(labelpharr, labelph) if array.size(upperplzonearr) > 0 for i = 0 to array.size(upperplzonearr) - 1 by 1 line tempupperline = array.get(upperphzonearr, i) line templowerline = array.get(upperplzonearr, i) label linepricelabel = array.get(labelpharr, i) bool tested = array.get(upperzonetestedarr, i) line.set_style(tempupperline, f_linestyle(linestyle)) line.set_style(templowerline, f_linestyle(linestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), upperzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(tempupperline)))) label.set_text(linepricelabel, '                                              Top Retracement - ' + str.tostring(round_f(line.get_y1(tempupperline)))) label.set_x(linepricelabel, bar_index) crossed = high > line.get_y1(tempupperline) if crossed and not tested array.set(upperzonetestedarr, i, true) label.delete(linepricelabel) if crossalerts and crossed and not tested array.set(upperzonetestedarr, i, true) label.delete(linepricelabel) alert('Top Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(upperphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(upperplzonearr, i, templowerline) //Bottom Retracement Lines Calculation if bullvol lowerplzone := low_ lowerphzone := close_ < open_ ? open_ : close_ lowerphzoneline := layout == 'Zone' ? line.new(bar_index_, lowerphzone, bar_index, lowerphzone, width=linessize) : na lowerplzoneline := nobool ? line.new(bar_index_, lowerplzone, bar_index, lowerplzone, width=linessize) : line.new(bar_index_, (lowerphzone + lowerplzone) / 2, bar_index, (lowerphzone + lowerplzone) / 2, width=linessize) labelpl := showprice ? label.new(bar_index_, nobool ? lowerplzone : (lowerphzone + lowerplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=lowerzonecolor, style=label.style_none) : na if array.size(lowerphzonearr) > numberofline line.delete(array.shift(lowerphzonearr)) line.delete(array.shift(lowerplzonearr)) array.shift(lowerzonetestedarr) label.delete(array.shift(labelplarr)) array.push(lowerphzonearr, lowerphzoneline) array.push(lowerplzonearr, lowerplzoneline) array.push(lowerzonetestedarr, extend ? true : false) array.push(labelplarr, labelpl) if array.size(lowerplzonearr) > 0 for i = 0 to array.size(lowerplzonearr) - 1 by 1 line tempupperline = array.get(lowerphzonearr, i) line templowerline = array.get(lowerplzonearr, i) label linepricelabel = array.get(labelplarr, i) bool tested = array.get(lowerzonetestedarr, i) line.set_style(tempupperline, f_linestyle(linestyle)) line.set_style(templowerline, f_linestyle(linestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), lowerzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(templowerline)))) label.set_text(linepricelabel, '                                                   Bottom Retracement - ' + str.tostring(round_f(line.get_y1(templowerline)))) label.set_x(linepricelabel, bar_index) crossed = low < line.get_y1(templowerline) if crossed and not tested array.set(lowerzonetestedarr, i, true) label.delete(linepricelabel) if crossalerts and crossed and not tested array.set(lowerzonetestedarr, i, true) label.delete(linepricelabel) alert('Bottom Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(lowerphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(lowerplzonearr, i, templowerline)
RSI Supply / Demand Zones
https://www.tradingview.com/script/7SnBTXX3/
GioLucaas
https://www.tradingview.com/u/GioLucaas/
901
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/ // © GioLucaas //@version=5 indicator("RSI Zones", overlay=true) length = input(14, "Length") overbought = input(70, "Overbought Threshold") oversold = input(30, "Oversold Threshold") var maxA = 0.0 var minA = 0.0 var maxB = 0.0 var minB = 0.0 _rsi = ta.rsi(close, length) if (_rsi[1] >= overbought) if (_rsi[2] < overbought) maxA := high[1] minA := low[1] else if (high[1] > maxA[1]) maxA := high[1] else maxA := maxA[1] if (low[1] < minA) minA := low[1] else minA := minA[1] else maxA := maxA[1] minA := minA[1] if (_rsi[1] <= oversold) if (_rsi[2] > oversold) maxB := high[1] minB := low[1] else if (high[1] > maxB[1]) maxB := high[1] else maxB := maxB[1] if (low[1] < minB[1]) minB := low[1] else minB := minB[1] else maxB := maxB[1] minB := minB[1] color1 = maxA != maxA[1] ? na : #87f163 color2 = minA != minA[1] ? na : #6fc950 color3 = maxB != maxB[1] ? na : #f16387 color4 = minB != minB[1] ? na : #c9506f plot(maxA, title='Overbought Top', color=color1) plot(minA, title='Overbought Bottom', color=color2, style=plot.style_cross) plot(maxB, title='Oversold Top', color=color3, style=plot.style_cross) plot(minB, title='Oversold Bottom', color=color4)
Ichimoku Cloud Oscillator
https://www.tradingview.com/script/hBdXJvUm-Ichimoku-Cloud-Oscillator/
MAGICMARK
https://www.tradingview.com/u/MAGICMARK/
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/ // © MAGICMARK //@version=5 indicator(title="Ichimoku Cloud Oscillator", shorttitle="IC Oscillator", overlay=false) conversionPeriods = input.int(30, minval=1, title="Conversion Line Length") basePeriods = input.int(60, minval=1, title="Base Line Length") laggingSpan2Periods = input.int(120, minval=1, title="Leading Span B Length") displacement = input.int(60, minval=1, title="Displacement") donchian(len) => math.avg(ta.lowest(len), ta.highest(len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) highLine = math.max(leadLine1[displacement], leadLine2[displacement]) lowLine = math.min(leadLine1[displacement], leadLine2[displacement]) ICoscHIGH = close / highLine ICoscLOW = close / lowLine ICosc = ICoscLOW if (close < highLine) if (close > lowLine) ICosc := 1 else if (close <= lowLine) ICosc := ICoscLOW else if (close >= highLine) ICosc := ICoscHIGH p1 = plot(ICosc, color=color.blue, linewidth=3, title="Ichi Cloud Oscillator") p2 = plot(ICoscLOW, color=color.green, title="Higher Bound") p3 = plot(ICoscHIGH, color=color.red, title="Lower Bound")
TL BP/IP Levels
https://www.tradingview.com/script/r9H4A4ze-TL-BP-IP-Levels/
JaRoRu
https://www.tradingview.com/u/JaRoRu/
72
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/ // © JaRoRu //@version=5 indicator(title="TL BP/IP Levels", shorttitle="BP/IP", overlay=true) currsym = input.string( "US500", "Symbol") BP = input.int(4660, minval=1, title="BP") IP1 = input.int(4800, minval=0, title="IP 1") IP2 = input.int(4700, minval=0, title="IP 2") IP3 = input.int(4300, minval=0, title="IP 3") IP4 = input.int(4200, minval=0, title="IP 4") IP5 = input.int(4100, minval=0, title="IP 5") BL = input.int(3, minval=0, title="Plot # Bars to the left") BR = input.int(2, minval=0, title="Plot # Bars to the right") IM = input.int(30, minval=1, title="Intrday Line Length Multiplier") BP_col = input.color(color.blue, "BP Color") BP_line = input.string(title="BP Line Type", defval=line.style_solid, options=[line.style_solid, line.style_dotted, line.style_dashed]) IP_col = input.color(color.blue, "IP Color") IP_line = input.string(title="IP Line Type", defval=line.style_dotted, options=[line.style_solid, line.style_dotted, line.style_dashed]) if(timeframe.isintraday) BL *= IM BR *= IM/10 var line0 = line.new(last_bar_index-BL, BP, last_bar_index+BR, BP, color=BP_col, style=BP_line, width=4, extend=extend.none) var line1 = line.new(last_bar_index-BL, IP1, last_bar_index+BR, IP1, color=IP_col, style=IP_line, width=3, extend=extend.none) var line2 = line.copy(line1) line.set_xy1(line2, last_bar_index-BL, IP2) line.set_xy2(line2, last_bar_index+BR, IP2) var line3 = line.copy(line1) line.set_xy1(line3, last_bar_index-BL, IP3) line.set_xy2(line3, last_bar_index+BR, IP3) var line4 = line.copy(line1) line.set_xy1(line4, last_bar_index-BL, IP4) line.set_xy2(line4, last_bar_index+BR, IP4) var line5 = line.copy(line1) line.set_xy1(line5, last_bar_index-BL, IP5) line.set_xy2(line5, last_bar_index+BR, IP5) var PTable = table.new(position = position.bottom_center, columns = 6, rows = 1, bgcolor = color.gray, border_width = 1) table.cell(table_id = PTable, column = 0, row = 0, text_size=size.auto, text_color=color.white, text = "BP " + str.tostring(BP)) table.cell(table_id = PTable, column = 1, row = 0, text_size=size.auto, text_color=color.white, text = "IP1 " + str.tostring(IP1)) table.cell(table_id = PTable, column = 2, row = 0, text_size=size.auto, text_color=color.white, text = "IP2 " + str.tostring(IP2)) table.cell(table_id = PTable, column = 3, row = 0, text_size=size.auto, text_color=color.white, text = "IP3 " + str.tostring(IP3)) table.cell(table_id = PTable, column = 4, row = 0, text_size=size.auto, text_color=color.white, text = "IP4 " + str.tostring(IP4)) table.cell(table_id = PTable, column = 5, row = 0, text_size=size.auto, text_color=color.white, text = "IP5 " + str.tostring(IP5)) //Only show BP/IP Levels on specific ticker symbol if(currsym != syminfo.ticker) line.delete(line0) line.delete(line1) line.delete(line2) line.delete(line3) line.delete(line4) line.delete(line5) table.delete(PTable) if (IP3 == 0) line.delete(line3) line.delete(line4) line.delete(line5) else if(IP4 == 0) line.delete(line4) line.delete(line5) else if (IP5 == 0) line.delete(line5) //Automatic Alerts for close crossing BP and IP levels BPO = ta.crossover(close,BP) BPU = ta.crossunder(close,BP) IP1O = ta.crossover(close,IP1) IP1U = ta.crossunder(close,IP1) IP2O = ta.crossover(close,IP2) IP2U = ta.crossunder(close,IP2) IP3O = ta.crossover(close,IP3) IP3U = ta.crossunder(close,IP3) IP4O = ta.crossover(close,IP4) IP4U = ta.crossunder(close,IP4) IP5O = ta.crossover(close,IP5) IP5U = ta.crossunder(close,IP5) if(BPO) alert("US500 (" + str.tostring(close) + ") crossed over BP (" + str.tostring(BP) + ")", alert.freq_once_per_bar) else if(BPU) alert("US500 (" + str.tostring(close) + ") crossed under BP (" + str.tostring(BP) + ")", alert.freq_once_per_bar) if(IP1O) alert("US500 (" + str.tostring(close) + ") crossed over IP1 (" + str.tostring(IP1) + ")", alert.freq_once_per_bar) else if(IP1U) alert("US500 (" + str.tostring(close) + ") crossed under IP1 (" + str.tostring(IP1) + ")", alert.freq_once_per_bar) if(IP2O) alert("US500 (" + str.tostring(close) + ") crossed over IP2 (" + str.tostring(IP2) + ")", alert.freq_once_per_bar) else if(IP2U) alert("US500 (" + str.tostring(close) + ") crossed under IP2 (" + str.tostring(IP2) + ")", alert.freq_once_per_bar) if(IP3O) alert("US500 (" + str.tostring(close) + ") crossed over IP3 (" + str.tostring(IP3) + ")", alert.freq_once_per_bar) else if(IP3U) alert("US500 (" + str.tostring(close) + ") crossed under IP3 (" + str.tostring(IP3) + ")", alert.freq_once_per_bar) if(IP4O) alert("US500 (" + str.tostring(close) + ") crossed over IP4 (" + str.tostring(IP4) + ")", alert.freq_once_per_bar) else if(IP4U) alert("US500 (" + str.tostring(close) + ") crossed under IP4 (" + str.tostring(IP4) + ")", alert.freq_once_per_bar) if(IP5O) alert("US500 (" + str.tostring(close) + ") crossed over IP5 (" + str.tostring(IP5) + ")", alert.freq_once_per_bar) else if(IP5U) alert("US500 (" + str.tostring(close) + ") crossed under IP5 (" + str.tostring(IP5) + ")", alert.freq_once_per_bar) //Setup custom alerts for price crossovers alertcondition(BPO, title='BP Cross Over', message='BP Cross Over') alertcondition(BPU, title='BP Cross Under', message='BP Cross Under') alertcondition(IP1O, title='IP1 Cross Over', message='IP1 Cross Over') alertcondition(IP1U, title='IP1 Cross Under', message='IP1 Cross Under') alertcondition(IP2O, title='IP2 Cross Over', message='IP2 Cross Over') alertcondition(IP2U, title='IP2 Cross Under', message='IP2 Cross Under') alertcondition(IP3O, title='IP3 Cross Over', message='IP3 Cross Over') alertcondition(IP3U, title='IP3 Cross Under', message='IP3 Cross Under') alertcondition(IP4O, title='IP4 Cross Over', message='IP4 Cross Over') alertcondition(IP4U, title='IP4 Cross Under', message='IP4 Cross Under') alertcondition(IP5O, title='IP5 Cross Over', message='IP5 Cross Over') alertcondition(IP5U, title='IP5 Cross Under', message='IP5 Cross Under')
Modified Mannarino Market Risk Indicator
https://www.tradingview.com/script/9hdYLdm8-Modified-Mannarino-Market-Risk-Indicator/
TraderHalai
https://www.tradingview.com/u/TraderHalai/
70
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/ // © SunilHalai // Formula being used to calculate : //TVC*DXY*TVC:US10Y*ECONOMICS:USGD/(1.61*FRED:GDP*1000) //@version=5 indicator("Modified Mannarino Market Risk Indicator Percentile", format = format.percent, max_bars_back=3000) src = input(close, title="Source") lookback_period = input.int(2000, title="Lookback Period for Percentile", maxval=3000, minval=200) dxy = request.security("TVC:DXY","D", src) us10y = request.security("TVC:TNX", "D", src) debt = request.security("ECONOMICS:USGD", "D", src) gdp = request.security("FRED:GDPPOT", "D", src) debt_to_gdp = request.security("FRED:GFDEGDQ188S", "D", src) mmmri = (dxy * us10y * debt)/ (1.61 * gdp * 1000000000) h = ta.highest(mmmri, lookback_period) l = ta.lowest(mmmri, lookback_period) //Use this with the mmmri to plot a percentile of risk. percentile_mmmri = ((mmmri - l)/(h - l)) * 100 if(percentile_mmmri >= 100) percentile_mmmri := 100 risk_color = (percentile_mmmri < 25) ? color.green : (percentile_mmmri < 50) ? color.yellow : (percentile_mmmri < 75) ? color.orange : color.red plot(percentile_mmmri, color = risk_color)
VIX SPX & XJO
https://www.tradingview.com/script/TjOAZQmF-VIX-SPX-XJO/
mikey0888
https://www.tradingview.com/u/mikey0888/
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/ // © mikey0888 //@version=5 indicator('VIX SPX & XJO') index = 'CBOE:VIX' vix = request.security(index, timeframe.period, close) color signalColor = color.from_gradient(vix, 20, 30, color.new(color.blue, 0), color.new(color.red, 0)) vixPlot = plot(vix, "VIX SPX", signalColor, 1) hline(30, color=color.blue) index1 = 'ASX:XVI' vix1 = request.security(index1, timeframe.period, close) color signalColor1 = color.from_gradient(vix1, 10, 20, color.new(color.green, 0), color.new(color.red, 0)) vixPlot1 = plot(vix1, "VIX ASX", signalColor1, 1) hline(20, color=color.green)
Better Divergence On Any Indicator [DoctaBot]
https://www.tradingview.com/script/tbrsp75I-Better-Divergence-On-Any-Indicator-DoctaBot/
DoctaBot
https://www.tradingview.com/u/DoctaBot/
617
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/ // © DoctaBot //@version=5 indicator("Ultimate Divs On Any Indicator [DoctaBot]", format=format.price, overlay=true, max_lines_count = 500, max_bars_back = 100) //Inputs{ plotBull = input.bool(defval = true, title = 'Regular Bullish   ', group = 'Alert Options', inline = 'Divs1') plotBear = input.bool(defval = true, title = 'Regular Bearish', group = 'Alert Options', inline = 'Divs1') plotHiddenBull = input.bool(defval = true, title = 'Hidden Bullish   ', group = 'Alert Options', inline = 'Divs2') plotHiddenBear = input.bool(defval = true, title = 'Hidden Bearish', group = 'Alert Options', inline = 'Divs2') PotAlerts = input.bool(defval = true, title = 'Potential Divergences', group = 'Alert Options', inline = 'Divs3') plotDivLines = input.bool(defval = true, title = 'Plot Divergence Lines    ', group = 'Plot Options', inline = 'Plot1') plotDivLabels = input.bool(defval = true, title = 'Plot Divergence Labels', group = 'Plot Options', inline = 'Plot1') plotPotentials = input.bool(defval = true, title = 'Plot Potential Divergences', group = 'Plot Options', inline = 'Plot2') overlay_main = input(false, title = 'Plot on price', group = 'Plot Options', inline = 'Plot2', tooltip = 'rather than on indicator') osc = input.source(ohlc4, title = 'Indicator', group = 'Divergence Settings') rangeUpper = input.int(defval = 20, title = 'Max of Lookback Range', group = 'Divergence Settings') rangeLower = input.int(defval = 2, title = 'Min of Lookback Range', group = 'Divergence Settings', minval = 2) maxdivs = input.int(defval = 25, title = 'Max Divs to Show', group = 'Divergence Settings', minval = 1) OBOSFilt = input.string('Off', title = 'OB/OS Filt', group = 'Divergence Settings', options = ['Off', 'On', 'Strict'], tooltip = 'On will only show divs where currently OB/OS. Strict will require start and end of div line be OB/OS') OBLev = input.int(70, title = 'Overbought level', group = 'Divergence Settings', tooltip = 'Oversold = 100 - this') OSLev = 100 - OBLev lbR = 1 lbL = 1 bullColor = input.color(defval = color.new(color.green, 0), title = 'Reg Bull Color', group = 'Colors', inline = 'Colors1') bearColor = input.color(defval = color.new(color.red, 0), title = 'Reg Bear Color', group = 'Colors', inline = 'Colors1') hiddenBullColor = input.color(defval = color.new(color.green, 70), title = 'Hid Bull Color', group = 'Colors', inline = 'Colors2') hiddenBearColor = input.color(defval = color.new(color.red, 70), title = 'Hid Bear Color', group = 'Colors', inline = 'Colors2') textColor = color.new(color.white, 0) noneColor = color.new(color.white, 100) //} //Arrays{ //Line Arrays var URegBullDivLines = array.new_line() var UHidBullDivLines = array.new_line() var URegBearDivLines = array.new_line() var UHidBearDivLines = array.new_line() var RegBullDivLines = array.new_line() var HidBullDivLines = array.new_line() var RegBearDivLines = array.new_line() var HidBearDivLines = array.new_line() //Label Arrays var URegBullDivLabels = array.new_label() var UHidBullDivLabels = array.new_label() var URegBearDivLabels = array.new_label() var UHidBearDivLabels = array.new_label() var RegBullDivLabels = array.new_label() var HidBullDivLabels = array.new_label() var RegBearDivLabels = array.new_label() var HidBearDivLabels = array.new_label() //} //Load Pivots{ //Check Arrays are even to ensure Price and Bar values have been added properly f_checkPivArrays(float[] PriceArr, float[] OscArr, int[] BarsArr) => if array.size(PriceArr) != array.size(OscArr) or array.size(PriceArr) != array.size(BarsArr) or array.size(OscArr) != array.size(BarsArr) runtime.error('Array sizes are not equal!') //Load new Price, Osc, and Bar values into their respective arrays f_loadNewPivValues(float[] PriceArr, Price, float[] OscArr, Osc, int[] BarsArr, Bars) => f_checkPivArrays(PriceArr, OscArr, BarsArr) array.unshift(PriceArr, Price) array.unshift(OscArr, Osc) array.unshift(BarsArr, Bars) f_loadPivArrays() => phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true //Declare Pivot High Arrays var PricePHArr = array.new_float() var OscPHArr = array.new_float() var BarPHArr = array.new_int() //Declare Pivot Low Arrays var PricePLArr = array.new_float() var OscPLArr = array.new_float() var BarPLArr = array.new_int() //Declare Pivot Values PricePH = math.max(open[lbR], close[lbR]) //ta.highest(close, lbR + 2) PricePL = math.min(open[lbR], close[lbR]) //ta.lowest(close, lbR + 2) //Load Pivot High Values into Arrays and remove pivots outside range lookback if phFound and (OBOSFilt == 'Strict' ? osc[lbR] >= OBLev : true) f_loadNewPivValues(PricePHArr, PricePH, OscPHArr, osc[lbR], BarPHArr, bar_index - lbR) if bar_index - array.min(BarPHArr) > rangeUpper array.pop(PricePHArr) array.pop(OscPHArr) array.pop(BarPHArr) //Load Pivot Low Values into Arrays and remove pivots outside range lookback if plFound and (OBOSFilt == 'Strict' ? osc[lbR] <= OSLev : true) f_loadNewPivValues(PricePLArr, PricePL, OscPLArr, osc[lbR], BarPLArr, bar_index - lbR) if bar_index - array.min(BarPLArr) > rangeUpper array.pop(PricePLArr) array.pop(OscPLArr) array.pop(BarPLArr) [PricePH, PricePL, phFound, plFound, PricePHArr, OscPHArr, BarPHArr, PricePLArr, OscPLArr, BarPLArr] //} //Get Divergences{ f_getDivergence(_plotOn, _divType, _divDir, _conf, line[]_DivLineArr, label[]_DivLabelArr)=> [PricePH, PricePL, phFound, plFound, PricePHArr, OscPHArr, BarPHArr, PricePLArr, OscPLArr, BarPLArr] = f_loadPivArrays() _OscArr = _divDir == 'Bull' ? OscPLArr : OscPHArr _PriceArr = _divDir == 'Bull' ? PricePLArr : PricePHArr _BarArr = _divDir == 'Bull' ? BarPLArr : BarPHArr ConfLineCol = _divDir == 'Bull' ? _divType == 'Regular' ? bullColor : hiddenBullColor : _divType == 'Regular' ? bearColor : hiddenBearColor PotLineCol = plotPotentials ? _divDir == 'Bull' ? _divType == 'Regular' ? bullColor : hiddenBullColor : _divType == 'Regular' ? bearColor : hiddenBearColor : noneColor LineColor = plotDivLines ? _conf ? ConfLineCol : PotLineCol : noneColor LineStyle = _conf ? line.style_solid : line.style_dashed LabColor = plotDivLabels ? _conf ? _divDir == 'Bull' ? bullColor : bearColor : plotPotentials ? _divDir == 'Bull' ? hiddenBullColor : hiddenBearColor : noneColor : noneColor LabStyle = _divDir == 'Bull' ? label.style_label_up : label.style_label_down LabTextCol = plotDivLabels ? _conf ? textColor : plotPotentials ? textColor : noneColor : noneColor IntLBStart = _conf ? lbR + 1 : 1 var line newDivLine = na var label newDivLabel = na DivCount = 0 OscEnd = _conf ? osc[lbR] : osc PriceEnd = _conf ? _divDir == 'Bull' ? PricePL : PricePH : close BarEnd = _conf ? bar_index - lbR : bar_index LineEnd = overlay_main ? PriceEnd : OscEnd if array.size(_OscArr) > 0 for i = array.size(_OscArr) - 1 to 0 OscStart = array.get(_OscArr, i) PriceStart = array.get(_PriceArr, i) BarStart = array.get(_BarArr, i) LineStart = overlay_main ? PriceStart : OscStart oscH = OscEnd > OscStart oscL = OscEnd < OscStart PriceH = PriceEnd > PriceStart PriceL = PriceEnd < PriceStart DivLen = BarEnd - BarStart Divergence = (_conf ? _divDir == 'Bull' ? plFound : phFound : true) and (((_divType == 'Regular' and _divDir == 'Bull') or (_divType == 'Hidden' and _divDir == 'Bear')) ? (oscH and PriceL) : (oscL and PriceH)) and (OBOSFilt == 'On' ? _divDir == 'Bull' ? OscEnd <= OSLev : OscEnd >= OBLev : true) if DivLen >= rangeLower and Divergence and _plotOn NoIntersect = true OscSlope = (OscEnd - OscStart)/(BarEnd - BarStart) PriceSlope = (PriceEnd - PriceStart)/(BarEnd - BarStart) OscLine = OscEnd - OscSlope PriceLine = PriceEnd - PriceSlope for x = IntLBStart to DivLen - 1 if (_divDir == 'Bull' and (osc[x] < OscLine or nz(close[x]) < PriceLine)) or (_divDir == 'Bear' and (osc[x] > OscLine or nz(close[x]) > PriceLine)) NoIntersect := false break OscLine -= OscSlope PriceLine -= PriceSlope NoIntersect if NoIntersect newDivLine := line.new(BarStart, LineStart, BarEnd, LineEnd, xloc.bar_index, extend.none, LineColor, LineStyle, 1) array.push(_DivLineArr, newDivLine) //Add new osc line to end of array DivCount := DivCount + 1 DivCount if DivCount > 0 if array.size(_DivLabelArr) > 0 if BarEnd != label.get_x(array.get(_DivLabelArr, array.size(_DivLabelArr) - 1)) newDivLabel := label.new(BarEnd, LineEnd, _divType == 'Regular' ? 'R' : 'H', xloc.bar_index, yloc.price, LabColor, LabStyle, LabTextCol, size.small) array.push(_DivLabelArr, newDivLabel) else newDivLabel := label.new(BarEnd, LineEnd, _divType == 'Regular' ? 'R' : 'H', xloc.bar_index, yloc.price, LabColor, LabStyle, LabTextCol, size.small) array.push(_DivLabelArr, newDivLabel) DivCount PotRegBullDivCount = f_getDivergence(PotAlerts and plotBull, 'Regular', 'Bull', false, URegBullDivLines, URegBullDivLabels) PotRegBearDivCount = f_getDivergence(PotAlerts and plotBear, 'Regular', 'Bear', false, URegBearDivLines, URegBearDivLabels) PotHidBullDivCount = f_getDivergence(PotAlerts and plotHiddenBull, 'Hidden', 'Bull', false, UHidBullDivLines, UHidBullDivLabels) PotHidBearDivCount = f_getDivergence(PotAlerts and plotHiddenBear, 'Hidden', 'Bear', false, UHidBearDivLines, UHidBearDivLabels) RegBullDivCount = f_getDivergence(plotBull, 'Regular', 'Bull', true, RegBullDivLines, RegBullDivLabels) RegBearDivCount = f_getDivergence(plotBear, 'Regular', 'Bear', true, RegBearDivLines, RegBearDivLabels) HidBullDivCount = f_getDivergence(plotHiddenBull, 'Hidden', 'Bull', true, HidBullDivLines, HidBullDivLabels) HidBearDivCount = f_getDivergence(plotHiddenBear, 'Hidden', 'Bear', true, HidBearDivLines, HidBearDivLabels) NewPotRegBullDiv = PotRegBullDivCount > 0 NewPotRegBearDiv = PotRegBearDivCount > 0 NewPotHidBullDiv = PotHidBullDivCount > 0 NewPotHidBearDiv = PotHidBearDivCount > 0 NewRegBullDiv = RegBullDivCount > 0 NewRegBearDiv = RegBearDivCount > 0 NewHidBullDiv = HidBullDivCount > 0 NewHidBearDiv = HidBearDivCount > 0 //} //Purge Old Divergences{ //Old Potential Divs f_purgeOldUnconDivs(line[]_DivLineArr, label[]_DivLabelArr)=> if array.size(_DivLineArr) > 0 if line.get_x2(array.get(_DivLineArr, 0)) <= bar_index - lbR for i = array.size(_DivLineArr) - 1 to 0 line.delete(array.get(_DivLineArr, i)) array.clear(_DivLineArr) if array.size(_DivLabelArr) > 0 if label.get_x(array.get(_DivLabelArr, 0)) <= bar_index - lbR for i = array.size(_DivLabelArr) - 1 to 0 label.delete(array.get(_DivLabelArr, i)) array.clear(_DivLabelArr) var int LastBar = 0 RegBullDivDisp = plotBull ? array.size(RegBullDivLabels) : 0 RegBearDivDisp = plotBear ? array.size(RegBearDivLabels) : 0 HidBullDivDisp = plotHiddenBull ? array.size(HidBullDivLabels) : 0 HidBearDivDisp = plotHiddenBear ? array.size(HidBearDivLabels) : 0 ConfDivCount = RegBullDivDisp + RegBearDivDisp + HidBullDivDisp + HidBearDivDisp if ConfDivCount > maxdivs and array.size(label.all) > 0 LastBar := label.get_x(array.get(label.all, array.size(label.all) - maxdivs)) f_purgeOldConDivs(_LineArr, _LabelArr)=> if array.size(_LabelArr) > 0 if label.get_x(array.get(_LabelArr, 0)) < LastBar label.delete(array.shift(_LabelArr)) if array.size(_LineArr) > 0 if line.get_x2(array.get(_LineArr, 0)) < LastBar line.delete(array.shift(_LineArr)) f_purgeOldUnconDivs(URegBullDivLines, URegBullDivLabels) f_purgeOldUnconDivs(URegBearDivLines, URegBearDivLabels) f_purgeOldUnconDivs(UHidBullDivLines, UHidBullDivLabels) f_purgeOldUnconDivs(UHidBearDivLines, UHidBearDivLabels) f_purgeOldConDivs(RegBullDivLines, RegBullDivLabels) f_purgeOldConDivs(RegBearDivLines, RegBearDivLabels) f_purgeOldConDivs(HidBullDivLines, HidBullDivLabels) f_purgeOldConDivs(HidBearDivLines, HidBearDivLabels) //} //Alerts{ if NewRegBullDiv alert('Regular Bull Divergence x' + str.tostring(RegBullDivCount), alert.freq_once_per_bar_close ) if NewHidBullDiv alert('Hidden Bull Divergence x' + str.tostring(HidBullDivCount), alert.freq_once_per_bar_close ) if NewRegBearDiv alert('Regular Bear Divergence x' + str.tostring(RegBearDivCount), alert.freq_once_per_bar_close ) if NewHidBearDiv alert('Hidden Bear Divergence x' + str.tostring(HidBearDivCount), alert.freq_once_per_bar_close ) if NewPotRegBullDiv alert('Potential Regular Bull Divergence x' + str.tostring(PotRegBullDivCount), alert.freq_once_per_bar_close ) if NewPotHidBullDiv alert('Potential Hidden Bull Divergence x' + str.tostring(PotHidBullDivCount), alert.freq_once_per_bar_close ) if NewPotRegBearDiv alert('Potential Regular Bear Divergence x' + str.tostring(PotRegBearDivCount), alert.freq_once_per_bar_close ) if NewPotHidBearDiv alert('Potential Hidden Bear Divergence x' + str.tostring(PotHidBearDivCount), alert.freq_once_per_bar_close ) //}
Tenkan/Kijun Higher Time Frame
https://www.tradingview.com/script/D6CD78t7/
GiuseppeInzirillo
https://www.tradingview.com/u/GiuseppeInzirillo/
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/ // © GiuseppeInzirillo //@version=5 indicator("Tenkan/Kijun Higher Time Frame", shorttitle="Tenkan/Kijun HTF", overlay=true) // input declarations tenkan_len = input.int(9, title="Length") tenkan_timeframe = input.timeframe("60", "Higher Timeframe") tenkan_timeframe2 = input.timeframe("240", "Higher Timeframe2") tenkan_timeframe3 = input.timeframe("D", "Higher Timeframe3") tenkan_timeframe4 = input.timeframe("W", "Higher Timeframe4") tenkan_timeframe5 = input.timeframe("M", "Higher Timeframe5") kijun_len = input.int(26, title="Length") kijun_timeframe = input.timeframe("60", "Higher Timeframe") kijun_timeframe2 = input.timeframe("240", "Higher Timeframe2") kijun_timeframe3 = input.timeframe("D", "Higher Timeframe3") kijun_timeframe4 = input.timeframe("W", "Higher Timeframe4") kijun_timeframe5 = input.timeframe("M", "Higher Timeframe5") tenkan = math.avg(ta.highest(high,tenkan_len), ta.lowest(low, tenkan_len)) tenkan_high = request.security(syminfo.tickerid,tenkan_timeframe,tenkan) tenkan_high2 = request.security(syminfo.tickerid,tenkan_timeframe2,tenkan) tenkan_high3 = request.security(syminfo.tickerid,tenkan_timeframe3,tenkan) tenkan_high4 = request.security(syminfo.tickerid,tenkan_timeframe4,tenkan) tenkan_high5 = request.security(syminfo.tickerid,tenkan_timeframe5,tenkan) kijun = math.avg(ta.highest(high,kijun_len), ta.lowest(low, kijun_len)) kijun_high = request.security(syminfo.tickerid,kijun_timeframe,kijun) kijun_high2 = request.security(syminfo.tickerid,kijun_timeframe2,kijun) kijun_high3 = request.security(syminfo.tickerid,kijun_timeframe3,kijun) kijun_high4 = request.security(syminfo.tickerid,kijun_timeframe4,kijun) kijun_high5 = request.security(syminfo.tickerid,kijun_timeframe5,kijun) plot(tenkan_high, color=color.gray, title="Tenkan H1", linewidth=1) plot(tenkan_high2, color=color.orange, title="Tenkan H4", linewidth=2) plot(tenkan_high3, color=color.maroon, title="Tenkan D", linewidth=3) plot(tenkan_high4, color=color.olive, title="Tenkan W", linewidth=4) plot(tenkan_high5, color=color.purple, title="Tenkan M", linewidth=5) plot(kijun_high, color=color.gray, title="Kijun H1", linewidth=1) plot(kijun_high2, color=color.orange, title="Kijun H4", linewidth=2) plot(kijun_high3, color=color.maroon, title="Kijun D", linewidth=3) plot(kijun_high4, color=color.olive, title="Kijun W", linewidth=4) plot(kijun_high5, color=color.purple, title="Kijun M", linewidth=5)
Hull ZigZag
https://www.tradingview.com/script/xwjchX5W-Hull-ZigZag/
djsnowman06
https://www.tradingview.com/u/djsnowman06/
240
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/ // © djsnowman06 //@version=5 indicator("Hull ZigZag", overlay=true, max_bars_back=250) src = input.source(close, "Source") len = input.int(9, "Hull Length", minval=1) disp = input.bool(false, "Display Hull MA") tog = input.bool(true, "Extend Latest Trendline") out = ta.hma(src, len) pivot = ((out[1] <= out)and(out[1] < out[2])) or ((out[1] >= out)and(out[1] > out[2])) ZZ = pivot ? out[1] : na exTog = tog ? extend.right : extend.none var extend = line.new(x1=bar_index[10], y1=close[10], x2=bar_index, y2=close, color=color.gray, width=3) var extend2 = line.new(x1=bar_index[10], y1=close[10], x2=bar_index, y2=close, color=color.gray, width=1, extend=exTog, style=line.style_dashed ) var extend3 = line.new(x1=bar_index[10], y1=close[10], x2=bar_index, y2=close, color=color.gray, width=1, extend=exTog, style=line.style_dashed ) x1 = ta.barssince(pivot) + 1 col = out > out[1] ? #00FF00 : #FF0000 line.set_color(id=extend, color=col) line.set_xy1(id=extend, x=bar_index[x1], y=out[x1]) line.set_xy2(id=extend, x=bar_index, y=out) line.set_color(id=extend3, color=col) line.set_xy1(id=extend2, x=bar_index[x1], y=out[x1]) line.set_xy2(id=extend2, x=bar_index, y=out) line.set_xy1(id=extend3, x=bar_index[1], y=out[1]) line.set_xy2(id=extend3, x=bar_index, y=out) dEna = disp ? #0000FF : na plot(out, title="Hull Ma", color=dEna, display=display.all - display.price_scale) plot(ZZ, title="Zig Zag", color=color.gray, linewidth=3, offset=-1) //
Lankou Shad helper
https://www.tradingview.com/script/A9IQ9SLy-Lankou-Shad-helper/
lankou
https://www.tradingview.com/u/lankou/
293
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/ // © lankou //@version=5 indicator('Lankou Shad helper', overlay=true) input_price = input.price(0, title="price, 0 for AUTO mode") cur_price = close if (input_price != 0) cur_price := input_price //hline(price, title, color, linestyle, linewidth, editable) → hline //hline(price=cur_price, title="start calc", color=color.rgb(0, 0, 255), linestyle=hline.style_solid, linewidth=1) if (input_price != 0) var line _newLine = line.new(bar_index[1], cur_price, bar_index, cur_price, extend=extend.right) line.set_x2(_newLine, x=bar_index) line.set_style(id=_newLine, style=line.style_solid) line.set_width(id=_newLine, width=5) line.set_color(id=_newLine, color=color.rgb(50, 50, 255, 10)) plot(cur_price / 4, trackprice=true, offset=-9999, color=color.rgb(205, 50, 100), title="/4") plot(cur_price / 2, trackprice=true, offset=-9999, color=color.rgb(205, 50, 100), title="/2") plot(2 * cur_price, trackprice=true, offset=-9999, title="x2") plot(4 * cur_price, trackprice=true, offset=-9999, title="x4") plot(8 * cur_price, trackprice=true, offset=-9999, title="x8") //plot(16 * close, trackprice=true, offset=-9999, title="x16") if timeframe.ismonthly or timeframe.isdaily or timeframe.isweekly if barstate.islast and syminfo.basecurrency != "BTC" dt = time - time[1] label.new(time + 4*dt, cur_price / 2, xloc=xloc.bar_time, text="/2", color=color.rgb(205, 50, 100)) label.new(time + 12*dt, cur_price / 4, xloc=xloc.bar_time, text="/4", color=color.rgb(205, 50, 100)) label.new(time + 3*dt, 2 * cur_price, xloc=xloc.bar_time, text="x2") label.new(time + 3*dt, 4 * cur_price, xloc=xloc.bar_time, text="x4") //label.new(time + 3*dt, 8 * close, xloc=xloc.bar_time, text="x8") //label.new(time + 3*dt, 16 * close, xloc=xloc.bar_time, text="x16")
Resistance card
https://www.tradingview.com/script/J3fC5fi5-Resistance-card/
UsmanQ
https://www.tradingview.com/u/UsmanQ/
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/ // © UsmanQ //@version=5 indicator("Resistance card" , overlay = true) biastgf = input.string("High", title="Direction", options= ["High","Low"], tooltip="Select Direction from where to claculate") bias = biastgf == "High" ? "+" : biastgf == "Low" ? "-" : na Price = input.float(0, title= "1st Pivot") Price1 = input.float(0, title= "2nd Pivot") Price2 = input.float(0, title= "3rd Pivot") Price3 = input.float(0, title= "4th Pivot") // bias == "-" ? expr2 : expr3 hline(Price, color = color.black , linewidth = 2, linestyle =hline.style_solid) // first pivot levels hline(bias == "-" ? Price + (Price*0.5): Price - (Price*0.5), linestyle =hline.style_solid,title ="50%", color = color.red , linewidth = 2) hline(bias == "-" ? Price + (Price*0.75): Price - (Price*0.75) , linestyle =hline.style_dashed, title ="75%",color = color.red , linewidth = 2) hline(bias == "-" ? Price + (Price*1): Price - (Price*1), linestyle =hline.style_solid, title ="100%",color = color.red , linewidth = 3) hline(bias == "-" ? Price + (Price*2): Price - (Price*2), linestyle =hline.style_solid,title ="200%",color = color.red , linewidth = 2) hline(bias == "-" ? Price + (Price*3): Price - (Price*3), linestyle =hline.style_solid, title ="300%",color = color.red , linewidth = 2) hline(bias == "-" ? Price + (Price*4): Price - (Price*4), linestyle =hline.style_solid, title ="400%",color = color.red , linewidth = 2) //2nd pivot levels hline(bias == "-" ? Price1 + (Price1*0.25): Price1 - (Price1*0.25) , linestyle =hline.style_dashed,title ="Pivot 2 - 25%") hline(bias == "-" ? Price1 + (Price1*0.5): Price1 - (Price1*0.5), linestyle =hline.style_solid,title ="Pivot 2 - 50%", color = color.red , linewidth = 2) hline(bias == "-" ? Price1 + (Price1*0.75): Price1 - (Price1*0.75) , linestyle =hline.style_dashed, title ="Pivot 2 - 75%",color = color.red , linewidth = 2) hline(bias == "-" ? Price1 + (Price1*1): Price1 - (Price1*1), linestyle =hline.style_solid, title ="Pivot 2 - 100%",color = color.red , linewidth = 3) // hline(bias == "-" ? Price1 + (Price1*2): Price1 - (Price1*2), linestyle =hline.style_solid,title ="Pivot 2 - 200%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price1 + (Price1*3): Price1 - (Price1*3), linestyle =hline.style_solid, title ="Pivot 2 - 300%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price1 + (Price1*4): Price1 - (Price1*4), linestyle =hline.style_solid, title ="Pivot 2 - 400%",color = color.red , linewidth = 2) //3rd pivot levels hline(bias == "-" ? Price2 + (Price2*0.25): Price2 - (Price2*0.25) , linestyle =hline.style_dashed,title ="Pivot 3 - 25%") hline(bias == "-" ? Price2 + (Price2*0.5): Price2 - (Price2*0.5), linestyle =hline.style_solid,title ="Pivot 3 - 50%", color = color.red , linewidth = 2) hline(bias == "-" ? Price2 + (Price2*0.75): Price2 - (Price2*0.75) , linestyle =hline.style_dashed, title ="Pivot 3 - 75%",color = color.red , linewidth = 2) hline(bias == "-" ? Price2 + (Price2*1): Price2 - (Price2*1), linestyle =hline.style_solid, title ="Pivot 3 - 100%",color = color.red , linewidth = 3) // hline(bias == "-" ? Price2 + (Price2*2): Price2 - (Price2*2), linestyle =hline.style_solid,title ="Pivot 3 - 200%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price2 + (Price2*3): Price2 - (Price2*3), linestyle =hline.style_solid, title ="Pivot 3 - 300%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price2 + (Price2*4): Price2 - (Price2*4), linestyle =hline.style_solid, title ="Pivot 3 - 400%",color = color.red , linewidth = 2) //4th pivot levels hline(bias == "-" ? Price3 + (Price3*0.25): Price3 - (Price3*0.25) , linestyle =hline.style_dashed,title ="Pivot 4 - 25%") hline(bias == "-" ? Price3 + (Price3*0.5): Price3 - (Price3*0.5), linestyle =hline.style_solid,title ="Pivot 4 - 50%", color = color.red , linewidth = 2) hline(bias == "-" ? Price3 + (Price3*0.75): Price3 - (Price3*0.75) , linestyle =hline.style_dashed, title ="Pivot 4 - 75%",color = color.red , linewidth = 2) hline(bias == "-" ? Price3 + (Price3*1): Price3 - (Price3*1), linestyle =hline.style_solid, title ="Pivot 4 - 100%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price3 + (Price3*2): Price3 - (Price3*2), linestyle =hline.style_solid,title ="200%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price3 + (Price3*3): Price3 - (Price3*3), linestyle =hline.style_solid, title ="300%",color = color.red , linewidth = 2) // hline(bias == "-" ? Price3 + (Price3*4): Price3 - (Price3*4), linestyle =hline.style_solid, title ="400%",color = color.red , linewidth = 2) //sub divions of 1st pivot hline(bias == "-" ? Price + (Price*0.125): Price - (Price*0.125) , linestyle =hline.style_dashed,title ="12.5%") hline(bias == "-" ? Price + (Price*0.25): Price - (Price*0.25) , linestyle =hline.style_dashed,title ="25%") hline(bias == "-" ? Price + (Price*0.333): Price - (Price*0.333) , linestyle =hline.style_dashed,title ="33%") hline(bias == "-" ? Price + (Price*0.375): Price - (Price*0.375) , linestyle =hline.style_dashed,title ="37.5") hline(bias == "-" ? Price + (Price*1.25): Price - (Price*1.25), linestyle =hline.style_dashed,title ="125%") hline(bias == "-" ? Price + (Price*1.5): Price - (Price*1.5), linestyle =hline.style_dashed,title ="150%") hline(bias == "-" ? Price + (Price*1.75): Price - (Price*1.75), linestyle =hline.style_dashed,title ="175%") hline(bias == "-" ? Price + (Price*2.25): Price - (Price*2.25), linestyle =hline.style_dashed,title ="225%") hline(bias == "-" ? Price + (Price*2.5): Price - (Price*2.5), linestyle =hline.style_dashed,title ="250%") hline(bias == "-" ? Price + (Price*2.75): Price - (Price*2.75), linestyle =hline.style_dashed,title ="275%") hline(bias == "-" ? Price + (Price*3.25): Price - (Price*3.25), linestyle =hline.style_dashed,title ="325%") hline(bias == "-" ? Price + (Price*3.5): Price - (Price*3.5), linestyle =hline.style_dashed,title ="350%") hline(bias == "-" ? Price + (Price*3.75): Price - (Price*3.75), linestyle =hline.style_dashed,title ="375%") hline(bias == "-" ? Price + (Price*4): Price - (Price*4), linestyle =hline.style_dashed,title ="400%") plot(close ,transp = 100)
The Namib Flow
https://www.tradingview.com/script/QgRgxQ4R-The-Namib-Flow/
Marc_Thiart
https://www.tradingview.com/u/Marc_Thiart/
281
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/ // © greenmask9 //@version=4 study("The Namib Flow", overlay = true) src = input(close, title="RSI Source", group = "Global") //▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Hull Suite //INPUT modeSwitch = input("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"], group = "Hull Suite") length = input(60, title="Length(180-200 for floating S/R , 55 for swing entry)", group = "Hull Suite") lengthMult = input(6.0, title="Length multiplier (Used to view higher timeframes with straight band)", group = "Hull Suite") useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)", group = "Hull Suite") htf = input("240", title="Higher timeframe", type=input.resolution, group = "Hull Suite") switchColor = input(true, "Color Hull according to trend?", group = "Hull Suite") candleCol = input(false,title="Color candles based on Hull's Trend?", group = "Hull Suite") visualSwitch = input(true, title="Show as a Band?", group = "Hull Suite") thicknesSwitch = input(15, title="Line Thickness", group = "Hull Suite") transpSwitch = input(40, title="Band Transparency",step=5, group = "Hull Suite") //FUNCTIONS //HMA HMA(_src, _length) => wma(2 * wma(_src, _length / 2) - wma(_src, _length), round(sqrt(_length))) //EHMA EHMA(_src, _length) => ema(2 * ema(_src, _length / 2) - ema(_src, _length), round(sqrt(_length))) //THMA THMA(_src, _length) => wma(wma(_src,_length / 3) * 3 - wma(_src, _length / 2) - wma(_src, _length), _length) //SWITCH Mode(modeSwitch, src, len) => modeSwitch == "Hma" ? HMA(src, len) : modeSwitch == "Ehma" ? EHMA(src, len) : modeSwitch == "Thma" ? THMA(src, len/2) : na //OUT _hull = Mode(modeSwitch, src, int(length * lengthMult)) HULL = useHtf ? security(syminfo.ticker, htf, _hull) : _hull MHULL = HULL[0] SHULL = HULL[2] //COLOR hullColor = switchColor ? (HULL > HULL[2] ? #00ff00 : #ff0000) : #ff9800 Fi1 = plot(MHULL, title="MHULL", color=hullColor, linewidth=thicknesSwitch, transp=50) Fi2 = plot(visualSwitch ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch, transp=50) fill(Fi1, Fi2, title="Band Filler", color=hullColor, transp=transpSwitch) //▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ Follow Line Indicator BBperiod = input(defval = 6, title = "BB Period", type = input.integer, minval = 1, group = "Follow Line") BBdeviations = input(defval = 1.00, title = "BB Deviations", type = input.float, minval = 0.1, step=0.05, group = "Follow Line") UseATRfilter = input(defval = true, title = "ATR Filter", type = input.bool, group = "Follow Line") ATRperiod = input(defval = 5, title = "ATR Period", type = input.integer, minval = 1, group = "Follow Line") hl = input(defval = false, title = "Hide Labels", type = input.bool, group = "Follow Line") // BBUpper=sma (close,BBperiod)+stdev(close, BBperiod)*BBdeviations BBLower=sma (close,BBperiod)-stdev(close, BBperiod)*BBdeviations // TrendLine = 0.0 iTrend = 0.0 buy = 0.0 sell = 0.0 // BBSignal = close>BBUpper? 1 : close<BBLower? -1 : 0 // if BBSignal == 1 and UseATRfilter == 1 TrendLine:=low-atr(ATRperiod) if TrendLine<TrendLine[1] TrendLine:=TrendLine[1] if BBSignal == -1 and UseATRfilter == 1 TrendLine:=high+atr(ATRperiod) if TrendLine>TrendLine[1] TrendLine:=TrendLine[1] if BBSignal == 0 and UseATRfilter == 1 TrendLine:=TrendLine[1] // if BBSignal == 1 and UseATRfilter == 0 TrendLine:=low if TrendLine<TrendLine[1] TrendLine:=TrendLine[1] if BBSignal == -1 and UseATRfilter == 0 TrendLine:=high if TrendLine>TrendLine[1] TrendLine:=TrendLine[1] if BBSignal == 0 and UseATRfilter == 0 TrendLine:=TrendLine[1] // iTrend:=iTrend[1] if TrendLine>TrendLine[1] iTrend:=1 if TrendLine<TrendLine[1] iTrend:=-1 // buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na sell:=iTrend[1]==1 and iTrend==-1? 1 : na // plot(TrendLine, color=iTrend > 0?color.blue:color.red ,style=plot.style_line,linewidth=2,transp=0,title="Trend Line") plotshape(buy == 1 and hl == false? TrendLine-atr(8) :na, text='💣', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto) plotshape(sell == 1 and hl == false ?TrendLine+atr(8):na, text='🔨', style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, offset=0, transp=0,size=size.auto) //▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬ QQE Mod RSI_Period = input(6, title='RSI Length', group = "QQE Mod") SF = input(5, title='RSI Smoothing', group = "QQE Mod") QQE = input(3, title='Fast QQE Factor', group = "QQE Mod") ThreshHold = input(3, title="Thresh-hold", group = "QQE Mod") // // // Wilders_Period = RSI_Period * 2 - 1 Rsi = rsi(src, RSI_Period) RsiMa = ema(Rsi, SF) AtrRsi = abs(RsiMa[1] - RsiMa) MaAtrRsi = ema(AtrRsi, Wilders_Period) dar = ema(MaAtrRsi, Wilders_Period) * QQE longband = 0.0 shortband = 0.0 trend = 0 DeltaFastAtrRsi = dar RSIndex = RsiMa newshortband = RSIndex + DeltaFastAtrRsi newlongband = RSIndex - DeltaFastAtrRsi longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? max(longband[1], newlongband) : newlongband shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? min(shortband[1], newshortband) : newshortband cross_1 = cross(longband[1], RSIndex) trend := cross(RSIndex, shortband[1]) ? 1 : cross_1 ? -1 : nz(trend[1], 1) FastAtrRsiTL = trend == 1 ? longband : shortband //////////////////// q_length = input(50, minval=1, title="Bollinger Length", group = "QQE Mod") mult = input(0.35, minval=0.001, maxval=5, step=0.1, title="BB Multiplier", group = "QQE Mod") basis = sma(FastAtrRsiTL - 50, q_length) dev = mult * stdev(FastAtrRsiTL - 50, q_length) upper = basis + dev lower = basis - dev color_bar = RsiMa - 50 > upper ? #00c3ff : RsiMa - 50 < lower ? #ff0062 : color.gray // // Zero cross QQEzlong = 0 QQEzlong := nz(QQEzlong[1]) QQEzshort = 0 QQEzshort := nz(QQEzshort[1]) QQEzlong := RSIndex >= 50 ? QQEzlong + 1 : 0 QQEzshort := RSIndex < 50 ? QQEzshort + 1 : 0 // Zero = hline(0, color=color.white, linestyle=hline.style_dotted, linewidth=1) //////////////////////////////////////////////////////////////// RSI_Period2 = input(6, title='RSI Length', group = "QQE Mod") SF2 = input(5, title='RSI Smoothing', group = "QQE Mod") QQE2 = input(1.61, title='Fast QQE2 Factor', group = "QQE Mod") ThreshHold2 = input(3, title="Thresh-hold", group = "QQE Mod") src2 = input(close, title="RSI Source") // // Wilders_Period2 = RSI_Period2 * 2 - 1 Rsi2 = rsi(src2, RSI_Period2) RsiMa2 = ema(Rsi2, SF2) AtrRsi2 = abs(RsiMa2[1] - RsiMa2) MaAtrRsi2 = ema(AtrRsi2, Wilders_Period2) dar2 = ema(MaAtrRsi2, Wilders_Period2) * QQE2 longband2 = 0.0 shortband2 = 0.0 trend2 = 0 DeltaFastAtrRsi2 = dar2 RSIndex2 = RsiMa2 newshortband2 = RSIndex2 + DeltaFastAtrRsi2 newlongband2 = RSIndex2 - DeltaFastAtrRsi2 longband2 := RSIndex2[1] > longband2[1] and RSIndex2 > longband2[1] ? max(longband2[1], newlongband2) : newlongband2 shortband2 := RSIndex2[1] < shortband2[1] and RSIndex2 < shortband2[1] ? min(shortband2[1], newshortband2) : newshortband2 cross_2 = cross(longband2[1], RSIndex2) trend2 := cross(RSIndex2, shortband2[1]) ? 1 : cross_2 ? -1 : nz(trend2[1], 1) FastAtrRsi2TL = trend2 == 1 ? longband2 : shortband2 // // Zero cross QQE2zlong = 0 QQE2zlong := nz(QQE2zlong[1]) QQE2zshort = 0 QQE2zshort := nz(QQE2zshort[1]) QQE2zlong := RSIndex2 >= 50 ? QQE2zlong + 1 : 0 QQE2zshort := RSIndex2 < 50 ? QQE2zshort + 1 : 0 // Greenbar1 = RsiMa2 - 50 > ThreshHold2 Greenbar2 = RsiMa - 50 > upper Redbar1 = RsiMa2 - 50 < 0 - ThreshHold2 Redbar2 = RsiMa - 50 < lower // // Bar Color //▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬conditions hull_green = HULL > HULL[2] hull_red = HULL < HULL[2] follow_green = iTrend > 0 follow_red = not follow_green QQE_green = Greenbar1 and Greenbar2 == 1 QQE_red = Redbar1 and Redbar2 == 1 barcolor_green = close > open barcolor_red = close < open full_condition_long = hull_green and follow_green and QQE_green and barcolor_green full_condition_short = hull_red and follow_red and QQE_red and barcolor_red fcl = full_condition_long and not full_condition_long[1] fcs = full_condition_short and not full_condition_short[1] //filtering first three occurences varip long_counter = 0, varip short_counter = 0 if fcl short_counter := 0 if long_counter[1] == 0 long_counter := 1 if long_counter[1] == 1 long_counter := 2 if long_counter[1] == 2 long_counter := 3 if long_counter[1] == 3 long_counter := 4 if fcs long_counter := 0 if short_counter[1] == 0 short_counter := 1 if short_counter[1] == 1 short_counter := 2 if short_counter[1] == 2 short_counter := 3 if short_counter[1] == 3 short_counter := 4 //plotshape(long_counter < 4, location = location.bottom) plotshape(fcl and long_counter < 4, title = "Long", location = location.belowbar, size = size.small, color = color.yellow, style = shape.triangleup) plotshape(fcs and short_counter < 4, title = "Short", location = location.abovebar, size = size.small, color = color.yellow, style = shape.triangledown) alertcondition(fcl and long_counter < 4 , title = "Bullish Alert") alertcondition(fcs and short_counter < 4 , title = "Bearish Alert") alertcondition((fcl and long_counter < 4) or (fcs and short_counter < 4), title = "Any Alert")
Golden Swing Strategy
https://www.tradingview.com/script/iOufFkDE-Golden-Swing-Strategy/
in_pursuit
https://www.tradingview.com/u/in_pursuit/
27
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © in_pursuit //@version=5 indicator(title = "Golden Swing Strategy",shorttitle = "GSS", overlay=true) // RSI : Relative Strength Index // Arguments : source (series int/float) Series of values to process. // Argument : length (simple int) Number of bars (length). // Returns : Relative strength index. RSI = ta.rsi(source = close, length = 20) //Stochastic periodK = input.int(55, title="%K Length", minval=1) smoothK = input.int(34, title="%K Smoothing", minval=1) periodD = input.int(21, title="%D Smoothing", minval=1) k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) //supertrend // Argument : factor (series int/float) The multiplier by which the ATR will get multiplied. // Argument : atrPeriod (simple int) Length of ATR. // Returns : Tuple of two supertrend series: supertrend line and direction of trend. Possible values are 1 (up direction) and -1 (down direction). [supertrend, direction] = ta.supertrend(factor = 2, atrPeriod = 10) // Bollinger Bands. //Arguments // series (series int/float) Series of values to process. // length (series int) Number of bars (length). // mult (simple int/float) Standard deviation factor. // Returns : Bollinger Bands. [middle, upper, lower] = ta.bb(close, length = 20, mult = 2) // Arguments : length (simple int) Length (number of bars back). // Returns : Average true range. // atr = ta.atr(length = 5) // Check RSI >= 50 RSI_test_buy = RSI > 50 RSI_test_sell = RSI < 50 // Check Stochastic %K should be above %D stoch_test_buy = k > d stoch_test_sell = k < d // Day Low/high Should be below/above SuperTrend supertrend_low_test = low < supertrend supertrend_high_test = high > supertrend // Day close Should be above SuperTrend supertrend_close_test = close > supertrend // SuperTrend should remain green/red before & EOD supertrend_green_test = direction == -1 supertrend_red_test = direction == 1 // SuperTrend should be below Mid Bollinger supertrend_bb_test_buy = supertrend < middle supertrend_bb_test_sell = supertrend > middle //compute buy/sell result buy = RSI_test_buy and stoch_test_buy and supertrend_low_test and supertrend_green_test and supertrend_bb_test_buy sell = RSI_test_sell and stoch_test_sell and supertrend_high_test and supertrend_red_test and supertrend_bb_test_sell //plot plotshape(buy, style=shape.triangleup, location = location.abovebar, color = color.green, size = size.small) plotshape(sell, style=shape.triangledown, location = location.belowbar, color = color.red, size = size.small)
Display Case
https://www.tradingview.com/script/B0O1RKZs-Display-Case/
CubanEmissary
https://www.tradingview.com/u/CubanEmissary/
35
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © CubanEmissary //@version=5 indicator("Display Case", explicit_plot_zorder = true) //Target Data Source src = input(close, title="Select Data Source") //Select Indicator preset5 = input.string(title="Ind 5", defval="None", options=["Source", "RSI", "TSI", "Stochastic", "MFI", "RVSI", "ROC", "SMA", "HMA", "VWMA", "RMA", "EMA", "LSMA", "SMMA", "TMA", "WMA", "WILDMA", "None"]) preset4 = input.string(title="Ind 4", defval="None", options=["Source", "RSI", "TSI", "Stochastic", "MFI", "RVSI", "ROC", "SMA", "HMA", "VWMA", "RMA", "EMA", "LSMA", "SMMA", "TMA", "WMA", "WILDMA", "None"]) preset3 = input.string(title="Ind 3", defval="None", options=["Source", "RSI", "TSI", "Stochastic", "MFI", "RVSI", "ROC", "SMA", "HMA", "VWMA", "RMA", "EMA", "LSMA", "SMMA", "TMA", "WMA", "WILDMA", "None"]) preset2 = input.string(title="Ind 2", defval="None", options=["Source", "RSI", "TSI", "Stochastic", "MFI", "RVSI", "ROC", "SMA", "HMA", "VWMA", "RMA", "EMA", "LSMA", "SMMA", "TMA", "WMA", "WILDMA", "None"]) preset1 = input.string(title="Ind 1", defval="None", options=["Source", "RSI", "TSI", "Stochastic", "MFI", "RVSI", "ROC", "SMA", "HMA", "VWMA", "RMA", "EMA", "LSMA", "SMMA", "TMA", "WMA", "WILDMA", "None"]) //Indicator Colors ic5 = input.color(color.orange, "Ind 5 Color") ic4 = input.color(color.red, "Ind 4 Color") ic3 = input.color(color.lime, "Ind 3 Color") ic2 = input.color(color.fuchsia, "Ind 2 Color") ic1 = input.color(color.silver, "Ind 1 Color") //Indicator Candle Length len5 = input.int(2, "Ind 5 Candle Length") len4 = input.int(2, "Ind 4 Candle Length") len3 = input.int(2, "Ind 3 Candle Length") len2 = input.int(2, "Ind 2 Candle Length") len1 = input.int(2, "Ind 1 Candle Length") //Indicator Y-Adjust y5 = input.int(0, "Ind 5 Y-Adjust") y4 = input.int(0, "Ind 4 Y-Adjust") y3 = input.int(0, "Ind 3 Y-Adjust") y2 = input.int(0, "Ind 2 Y-Adjust") y1 = input.int(0, "Ind 1 Y-Adjust") //Partition Line Y-Adjust Values p3 = input(300, "Partition Line 3 Y-Adjust") p2 = input(200, "Partition Line 2 Y-Adjust") p1 = input(100, "Partition Line 1 Y-Adjust") //Partition Fill Colors pf3 = input.color(#1976d2, "Partition Fill 3") pf2 = input.color(#1976d2, "Partition Fill 2") pf1 = input.color(#1976d2, "Partition Fill 1") //Partition Line Colors pl3 = input.color(#fff176, "Partition Line 3") pl2 = input.color(#fff176, "Partition Line 2") pl1 = input.color(#fff176, "Partition Line 1") //Indicator Switch Functions float e5 = switch preset5 "Source" => src "RSI" => ta.rsi(src, len5) "TSI" => ta.tsi(src, len5, len5*2) "Stochastic" => ta.stoch(src, high, low, len5) "MFI" => ta.mfi(src, len5) "ROC" => ta.roc(src,len5) "RVSI" => ta.rsi(ta.ema(ta.cum((ta.change(src))*volume), len5), len5*2) "SMA" => ta.sma(src,len5) "HMA" => ta.hma(src,len5) "VWMA" => ta.vwma(src,len5) "RMA" => ta.rma(src,len5) "EMA" => ta.ema(src,len5) "LSMA" => ta.linreg(src,len5, 0) "TMA" => ta.sma(src,len5)/len5 "WMA" => ta.wma(src,len5) "WILDMA" => nz(src[1]) + (close-nz(src[1]))/len5 "None" => float(na) => float(na) float e4 = switch preset4 "Source" => src "RSI" => ta.rsi(src, len4) "TSI" => ta.tsi(src, len4, len4*2) "Stochastic" => ta.stoch(src, high, low, len4) "MFI" => ta.mfi(src, len4) "ROC" => ta.roc(src,len4) "RVSI" => ta.rsi(ta.ema(ta.cum((ta.change(src))*volume), len4), len4*2) "SMA" => ta.sma(src,len4) "HMA" => ta.hma(src,len4) "VWMA" => ta.vwma(src,len4) "RMA" => ta.rma(src,len4) "EMA" => ta.ema(src,len4) "LSMA" => ta.linreg(src,len4, 0) "TMA" => ta.sma(src,len4)/len4 "WMA" => ta.wma(src,len4) "WILDMA" => nz(src[1]) + (close-nz(src[1]))/len4 "None" => float(na) => float(na) float e3 = switch preset3 "Source" => src "RSI" => ta.rsi(src, len3) "TSI" => ta.tsi(src, len3, len3*2) "Stochastic" => ta.stoch(src, high, low, len3) "MFI" => ta.mfi(src, len3) "ROC" => ta.roc(src,len3) "RVSI" => ta.rsi(ta.ema(ta.cum((ta.change(src))*volume), len3), len3*2) "SMA" => ta.sma(src,len3) "HMA" => ta.hma(src,len3) "VWMA" => ta.vwma(src,len3) "RMA" => ta.rma(src,len3) "EMA" => ta.ema(src,len3) "LSMA" => ta.linreg(src,len3, 0) "TMA" => ta.sma(src,len3)/len3 "WMA" => ta.wma(src,len3) "WILDMA" => nz(src[1]) + (close-nz(src[1]))/len3 "None" => float(na) => float(na) float e2 = switch preset2 "Source" => src "RSI" => ta.rsi(src, len2) "TSI" => ta.tsi(src, len2, len2*2) "Stochastic" => ta.stoch(src, high, low, len2) "MFI" => ta.mfi(src, len2) "ROC" => ta.roc(src,len2) "RVSI" => ta.rsi(ta.ema(ta.cum((ta.change(src))*volume), len2), len2*2) "SMA" => ta.sma(src,len2) "HMA" => ta.hma(src,len2) "VWMA" => ta.vwma(src,len2) "RMA" => ta.rma(src,len2) "EMA" => ta.ema(src,len2) "LSMA" => ta.linreg(src,len2, 0) "TMA" => ta.sma(src,len2)/len2 "WMA" => ta.wma(src,len2) "WILDMA" => nz(src[1]) + (close-nz(src[1]))/len2 => float(na) float e1 = switch preset1 "Source" => src "RSI" => ta.rsi(src, len1) "TSI" => ta.tsi(src,len1,len1*2) "Stochastic" => ta.stoch(src, high, low, len1) "MFI" => ta.mfi(src,len1) "ROC" => ta.roc(src,len1) "RVSI" => ta.rsi(ta.ema(ta.cum((ta.change(src))*volume), len1), len1*2) "SMA" => ta.sma(src,len1) "HMA" => ta.hma(src,len1) "VWMA" => ta.vwma(src,len1) "RMA" => ta.rma(src,len1) "EMA" => ta.ema(src,len1) "LSMA" => ta.linreg(src,len1, 0) "TMA" => ta.sma(src,len1)/len1 "WMA" => ta.wma(src,len1) "WILDMA" => nz(src[1]) + (close-nz(src[1]))/len1 => float(na) //Floor Tile Reference Values top20 = 20 top19 = 19 top18 = 18 top17 = 17 top16 = 16 top15 = 15 top14 = 14 top13 = 13 top12 = 12 top11 = 11 top10 = 10 top9 = 9 top8 = 8 top7 = 7 top6 = 6 top5 = 5 top4 = 4 top3 = 3 top2 = 2 top1 = 1 top0 = 0 topn1 = -1 topn5 = -5 //Floor Tile Color Generator //Tilecolor 1 editable in sourcecode only //Tilecolor 2 must remain na to get checkboard effect color tilecolor1 = color.white color tilecolor2 = na if tilecolor1[45] == color.white tilecolor1 := na tilecolor2 := color.white else if tilecolor1[45] == na tilecolor1 := color.white tilecolor2 := na else na //Plots the Floor Tiles h20 = plot(top20, title="20", color=color.new(tilecolor1, 80), editable = false, linewidth=1, offset=10) h19 = plot(top19, title="20", color=color.new(#000000, 100), editable = false, offset=9) h18 = plot(top18, title="20", color=color.new(#000000, 100), editable = false, offset=8, linewidth = 4) h17 = plot(top17, title="20", color=color.new(#000000, 100), editable = false, offset=7, linewidth = 4) h16 = plot(top16, title="20", color=color.new(#000000, 100), editable = false, offset=6, linewidth = 4) h15 = plot(top15, title="20", color=color.new(#000000, 100), editable = false, offset=5, linewidth = 4) h14 = plot(top14, title="20", color=color.new(#000000, 100), editable = false, offset=4, linewidth = 4) h13 = plot(top13, title="20", color=color.new(#000000, 100), editable = false, offset=3, linewidth = 4) h12 = plot(top12, title="20", color=color.new(#000000, 100), editable = false, offset=2, linewidth = 4) h11 = plot(top11, title="20", color=color.new(#000000, 100), editable = false, offset=1, linewidth = 4) h10 = plot(top10, title="20", color=color.new(#000000, 100), editable = false, offset=0, linewidth = 4) h9 = plot(top9, title="20", color=color.new(#000000, 100), editable = false, offset=-1, linewidth = 4) h8 = plot(top8, title="20", color=color.new(#000000, 100), editable = false, offset=-2, linewidth = 4) h7 = plot(top7, title="20", color=color.new(#000000, 100), editable = false, offset=-3, linewidth = 4) h6 = plot(top6, title="20", color=color.new(#000000, 100), editable = false, offset=-4, linewidth = 4) h5 = plot(top5, title="20", color=color.new(#000000, 100), editable = false, offset=-5, linewidth = 4) h4 = plot(top4, title="20", color=color.new(#000000, 100), editable = false, offset=-6, linewidth = 4) h3 = plot(top3, title="20", color=color.new(#000000, 100), editable = false, offset=-7, linewidth = 4) h2 = plot(top2, title="20", color=color.new(#000000, 100), editable = false, offset=-8, linewidth = 4) h1 = plot(top1, title="20", color=color.new(#000000, 100), editable = false, offset=-9, linewidth = 4) h0 = plot(top0, title="20", color=color.new(tilecolor1, 80), editable = false, offset=-10, linewidth = 2) hn5 = plot(topn5, title="20", color=color.new(#ffffff, 75), editable = false, offset=-10, linewidth = 1) //Floor Tile Filling fill(h20, h19, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h19, h18, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h18, h17, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h17, h16, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h16, h15, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h15, h14, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h14, h13, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h13, h12, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h12, h11, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h11, h10, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h10, h9, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h9, h8, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h8, h7, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h7, h6, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h6, h5, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h5, h4, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h4, h3, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h3, h2, title="fill", color=color.new(tilecolor2, 65), editable=false) fill(h2, h1, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h1, h0, title="fill", color=color.new(tilecolor1, 65), editable=false) fill(h0, hn5, title="fill", color=color.new(tilecolor1, 65), editable=false) //Partition lines for fill() references k1 = plot(p1, title="Partition Line 1", color=pl1, linewidth=2, offset=10, editable=false) k2 = plot(p2, title="Partition Line 2", color=pl2, linewidth=2, offset=10, editable=false) k3 = plot(p3, title="Partition Line 3", color=pl3, linewidth=2, offset=10, editable=false) //Color Filling the Partitions //Edit in Settings fill(h20, k1, title="Partition Fill 1", color=color.new(pf1, 75), editable=false) fill(k1, k2, title="Partition FIll 2", color=color.new(pf2, 75), editable=false) fill(k2, k3, title="Partition Fill 3", color=color.new(pf3, 75), editable=false) //Plot Equations plot(e5+y5, title="Ind 5", color=ic5, linewidth=2) plot(e4+y4, title="Ind 4", color=ic4, linewidth=2) plot(e3+y3, title="Ind 3", color=ic3, linewidth=2) plot(e2+y2, title="Ind 2", color=ic2, linewidth=2) plot(e1+y1, title="Ind 1", color=ic1, linewidth=2) //Indicator Labels label1 = label.new(bar_index+5, e1+y1, text=string(preset1)+" "+str.tostring(math.round(e1)), style=label.style_label_left, textcolor=ic1, size=size.normal, color=color.rgb(0, 0, 0, 100), xloc=xloc.bar_index, yloc=yloc.price) label.delete(label1[1]) label2 = label.new(bar_index+5, e2+y2, text=string(preset2)+" "+str.tostring(math.round(e2)), style=label.style_label_left, textcolor=ic2, size=size.normal, color=color.rgb(0, 0, 0, 100), xloc=xloc.bar_index, yloc=yloc.price) label.delete(label2[1]) label3 = label.new(bar_index+5, e3+y3, text=string(preset3)+" "+str.tostring(math.round(e3)), style=label.style_label_left, textcolor=ic3, size=size.normal, color=color.rgb(0, 0, 0, 100), xloc=xloc.bar_index, yloc=yloc.price) label.delete(label3[1]) label4 = label.new(bar_index+5, e4+y4, text=string(preset4)+" "+str.tostring(math.round(e4)), style=label.style_label_left, textcolor=ic4, size=size.normal, color=color.rgb(0, 0, 0, 100), xloc=xloc.bar_index, yloc=yloc.price) label.delete(label4[1]) label5 = label.new(bar_index+10, e5+y5, text=string(preset5)+" "+str.tostring(math.round(e5)), style=label.style_label_left, textcolor=ic5, size=size.normal, color=color.rgb(0, 0, 0, 100), xloc=xloc.bar_index, yloc=yloc.price) label.delete(label5[1])
How To Count Decimals
https://www.tradingview.com/script/HUUmMKiS-How-To-Count-Decimals/
allanster
https://www.tradingview.com/u/allanster/
42
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © allanster //@version=5 indicator(title = "How To Count Decimals", shorttitle = 'Get Precision', overlay = true) // Custom f_nDecimals() function returns precision of decimal numbers of the following forms: // const, input, simple, and series of the following types: float, integer, and string. // Error checking is performed for valid numbers and invalid values return NaN. // Annotated and Compact versions of function shown below are equivalent. // NOTICE: There is currently an oddity when a float _value is loaded as an argument into a custom function // that contains internal str.tostring(_value) functions. The string of the float _value becomes truncated. // To prevent truncation of float _value load arguments with an additional str.tostring() function. // Example: instead of f_unction(_value) load as f_unction(str.tostring(_value)). This method may also be // applied to int and string argument types without affecting their result. Special thanks to Phince for // providing this loading method as a workaround! // === FUNCTION ANNOTATED VERSION === f_nDecimal5(_value) => // accepts float, integer, or string values decimals = int(na) // declare variable to hold count to5tring = str.tostring(_value) // convert _value to string validate = not na(str.tonumber(to5tring)) // check if this is a valid number if not validate // if number is invalidated decimals := int(na) // returns na else if validate // else if number is validated getRadix = str.pos(to5tring, ".") // get position of separator character "." if na(getRadix) // if separator not found decimals := 0 // there are no decimal characters else // else separator was found toSubstr = str.substring(to5tring, getRadix + 1) // create substring of decimal characters decimals := str.length(toSubstr) // returns number of decimal characters // === FUNCTION COMPACT VERSION === f_nDecimals(_in) => //_in: float, integer, string | out: n Decimals n = int(na), s = str.tostring(_in), p = str.pos(s, ".") n := na(str.tonumber(s)) ? int(na) : na(p) ? 0 : str.length(str.substring(s, p + 1)) // === EXAMPLE VALUES === float cnt0 = 0.1234567890123456 // form const type float int cnt1 = 12345678901234567 // form const type integer string cnt2 = '0.12345678901234567890' // form const type string string cnt3 = '123456789012345678901' // form const type string float inp0 = input(0.1234567890123456, 'Float') // form input type float int inp1 = input(123456789012, 'Integer') // form input type integer string inp2 = input('0.12345678901234567890', 'String') // form input type string string inp3 = input('123456789012345678901', 'String') // form input type string float smp0 = syminfo.mintick // form simple type float int smp1 = timeframe.multiplier // form simple type integer string smp2 = timeframe.period // form simple type string float ser0 = close > open ? cnt0 : cnt0 // form series type float int ser1 = close > open ? cnt1 : cnt1 // form series type integer string ser2 = close > open ? cnt2 : cnt2 // form series type string string ser3 = close > open ? cnt3 : cnt3 // form series type string // === EXAMPLE OUTPUT === str(int _value) => // apply string across table cells where loaded argument type is int to5tring = str.tostring(_value) str(float _value) => // apply string across table cells where loaded argument type is float to5tring = str.tostring(_value, '#.#########################') str(string _value) => // apply string across table cells where loaded argument type is string to5tring = _value C_(_str, _column, _row, _t) => // single cell of string _str of number _column of number _row of table _t table.cell(_t, _column, _row, _str, text_color = #ffffff, text_halign = text.align_center) R_(_t, _row, _strC0, _strC1, _strC2, _strC3, _strC4, _strC5) => // single row of table _t of number _row of string columns _strCn C_(_strC0, 0, _row, _t), C_(_strC1, 1, _row, _t), C_(_strC2, 2, _row, _t), C_(_strC3, 3, _row, _t), C_(_strC4, 4, _row, _t), C_(_strC5, 5, _row, _t) if barstate.islast var T = table.new(position.middle_center, 6, 16, bgcolor = color.new(#3f3f3f, 0), border_color = #bfbfbf, border_width = 1, frame_color = #7f7f7f, frame_width = 2) R_(T, 0, 'FORM TYPE', 'LOADED VALUE', 'LOADED DECIMALS', 'STRING RETURNS', 'f_nDecimal5(str.tostring(_value))', 'f_nDecimals(str.tostring(_value))') R_(T, 1, 'const float', '0.1234567890123456', '16', str(cnt0), str(f_nDecimal5(str(cnt0))), str(f_nDecimals(str(cnt0)))) R_(T, 2, 'const int', '12345678901234567', '0', str(cnt1), str(f_nDecimal5(str(cnt1))), str(f_nDecimals(str(cnt1)))) R_(T, 3, 'const strng', '0.12345678901234567890', '20', str(cnt2), str(f_nDecimal5(str(cnt2))), str(f_nDecimals(str(cnt2)))) R_(T, 4, 'const strng', '123456789012345678901', '0', str(cnt3), str(f_nDecimal5(str(cnt3))), str(f_nDecimals(str(cnt3)))) R_(T, 5, 'input float', '"' + str(inp0) + '"', '16', str(inp0), str(f_nDecimal5(str(inp0))), str(f_nDecimals(str(inp0)))) R_(T, 6, 'input int', '"' + str(inp1) + '"', '0', str(inp1), str(f_nDecimal5(str(inp1))), str(f_nDecimals(str(inp1)))) R_(T, 7, 'input strng', '"' + str(inp2) + '"', '20', str(inp2), str(f_nDecimal5(str(inp2))), str(f_nDecimals(str(inp2)))) R_(T, 8, 'input strng', '"' + str(inp3) + '"', '0', str(inp3), str(f_nDecimal5(str(inp3))), str(f_nDecimals(str(inp3)))) R_(T, 9, 'simple float', 'syminfo.mintick', '2', str(smp0), str(f_nDecimal5(str(smp0))), str(f_nDecimals(str(smp0)))) R_(T, 10, 'simple int', 'timeframe.multiplier', '0', str(smp1), str(f_nDecimal5(str(smp1))), str(f_nDecimals(str(smp1)))) R_(T, 11, 'simple strng', 'timeframe.period', '0', str(smp2), str(f_nDecimal5(str(smp2))), str(f_nDecimals(str(smp2)))) R_(T, 12, 'series float', '0.1234567890123456', '16', str(ser0), str(f_nDecimal5(str(ser0))), str(f_nDecimals(str(ser0)))) R_(T, 13, 'series int', '12345678901234567', '0', str(ser1), str(f_nDecimal5(str(ser1))), str(f_nDecimals(str(ser1)))) R_(T, 14, 'series strng', '0.12345678901234567890', '20', str(ser2), str(f_nDecimal5(str(ser2))), str(f_nDecimals(str(ser2)))) R_(T, 15, 'series strng', '123456789012345678901', '0', str(inp3), str(f_nDecimal5(str(ser3))), str(f_nDecimals(str(ser3))))
Historical Range (Using eStrategy library)
https://www.tradingview.com/script/Qls5uGCg-Historical-Range-Using-eStrategy-library/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
110
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator('Historical Range (Using eStrategy library)', overlay=false) import HeWhoMustNotBeNamed/historicalrange/1 as hr import HeWhoMustNotBeNamed/enhanced_ta/10 as eta import HeWhoMustNotBeNamed/eStrategy/4 as stg startYear = input.int(2010, maxval=2999, minval=0, title='Start Year', group='Inital Investment', tooltip='Year on which investment is started', confirm=true) initialDeposit = input.float(10000, "Deposit", minval=0, step=5000, group="Inital Investment", tooltip='Initial one time deposit to start with', confirm=true) recurringDepositFrequency = input.string("monthly", "Frequency", group="Recurring Investment", options=["monthly", "weekly"], tooltip="Periodic investment frequency", confirm=true) recurringDeposit = input.float(1000, "Deposit", step=1000, minval=0, group="Recurring Investment", tooltip="Periodic investment", confirm=true) buyPrice = input.source(open, "Buy Price", group="Buy and Hold") strategyInvestPercent = input.float(50, "Regular investiment Percent", group="Strategy", step=10) reducePercent = input.float(100, "Reduce Percent", group="Strategy", step=10) reloadPercent = input.float(100, "Reload Percent", group="Strategy", step=10) buyPriceStrategy = input.source(open, "Buy Price", group="Strategy") sellPriceStrategy = input.source(open, "Sell Price", group="Strategy") dividends = nz(request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, ignore_invalid_symbol=true)) [totalInvestment, buyAndHoldQty, bnhEquity] = stg.sip(startYear, initialDeposit, recurringDepositFrequency, recurringDeposit, buyPrice, dividends) [bEquityAth, bDrawdown, bMaxDrawdown] = stg.getEquityAthAndDrawdown(bnhEquity) base = input.string("oscillator", options=["band", "oscillator"], group="Strategy") buyAdjustment = input.int(15, step=5, minval=0, maxval=50, group="Strategy") sellAdjustment = input.int(30, step=5, minval=0, maxval =50, group="Strategy") bandType = input.string("dc", options=["bb", "kc", "dc"], group="Bands") type = (base == "band"? bandType : base) useTrueRange = input.bool(true, title="Use True Range (KC)", group="Bands", inline="b") useAlternateSource = input.bool(false, title="Use Alternate Source (DC)", group="Bands", inline="b") sticky = input.bool(false, title="Sticky", group="Bands", inline="b") masource = input.source(close, title="Source", group="Bands") matype = input.string("ema", title="Moving Average", group="Bands", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) malength = input.int(20, step=10, title="", group="Bands") multiplier = input.float(10, step=5, title="Multiplier", group="Bands") oscType = input.string("rsi", title="Oscillator Type", group="Oscillator", options=["cci", "cmo", "roc", "rsi", "stoch", "tsi", "wpr"]) oLength = input.int(9, step=5, title="Length", group="Oscillator") shortLength = input.int(9, title="Short Length (TSI)", group="Oscillator") longLength = input.int(26, title="Long Length (TSI)", group="Oscillator") method = input.string("highlow", title="Dynamic Overvought/Oversold Calculation method", group="Oscillator", options=["highlow", "sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) highlowlength = input.int(50, title="Length", group="Oscillator") useDynamicRange = input.bool(false, title="Dynamic Range", group="Oscillator", inline="b") osticky = input.bool(false, title="Sticky", group="Oscillator", inline="b") pmatype = input.string("sma", title="Type", group="Percentile MA", options=["sma", "ema", "hma", "rma", "wma", "vwma", "swma", "linreg", "median"]) pmalength = input.int(22, step=10, title="Length", group="Percentile MA") [source, index, pArray, percentile, median, max] = switch(type) "bb" => hr.bpercentb(masource, matype, malength, multiplier, sticky) "kc" => hr.kpercentk(masource, matype, malength, multiplier, useTrueRange, sticky) "dc" => hr.dpercentd(malength, useAlternateSource, masource, sticky) "oscillator" => hr.oscillator(oscType, oLength, shortLength, longLength, method = method, highlowLength=highlowlength, sticky=osticky, useDynamicRange=useDynamicRange) total = array.sum(pArray) var dateStart = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) dateEnd = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth) ma = eta.ma(percentile, pmatype, pmalength) ma2 = eta.ma(ma, pmatype, pmalength) longBias = median > 50 shortBias = median < 50 buySignal = percentile < median-buyAdjustment and ta.crossover(percentile, ma) sellSignal = percentile > median+sellAdjustment and ta.crossunder(percentile, ma) signal = buySignal? 1 : sellSignal ? -1 : 0 qtyPercent = buySignal? reloadPercent : sellSignal? reducePercent : 0 [_totalInvestment, totalQty, totalCash, totalEquity] = stg.customStrategy(startYear, initialDeposit, recurringDepositFrequency, recurringDeposit, buyPriceStrategy, sellPriceStrategy, strategyInvestPercent, strategyInvestPercent, signal, qtyPercent, dividends) [sEquityAth, sDrawdown, sMaxDrawdown] = stg.getEquityAthAndDrawdown(totalEquity) [currentCashPercent, avgCashPercent] = stg.getAverageCashPercent(totalCash, totalEquity) diffQty = totalQty - totalQty[1] // plotchar(diffQty>0?totalEquity:na, "Long", location.absolute, text='L') plotchar(diffQty>0 and signal == 1?totalEquity:na, title="Reload", char='🚀', location=location.absolute, color=color.green) plotchar(diffQty>0 and signal != 1?totalEquity:na, title="Invest", char='💵', location=location.absolute, color=color.green) plotchar(diffQty<0?totalEquity:na, title="Reduce", char='💰', location=location.absolute, color=color.red) plot(totalEquity, "Strategy", color=color.new(color.yellow, 80), style=plot.style_area) plot(bnhEquity, "Buy and Hold", color=color.new(color.green, 80), style=plot.style_area) plot(totalInvestment, "Investment", color=color.new(color.purple, 80), style=plot.style_area) dateRange = syminfo.ticker + ' From ' + str.tostring(startYear) var stats = table.new(position=position.middle_left, columns=3, rows=8, border_width=1) table.cell(stats, 0, 0, dateRange, bgcolor=color.navy, text_color=color.white) table.cell(stats, 2, 0, "Buy and Hold", bgcolor=color.teal, text_color=color.white) table.cell(stats, 1, 0, "Strategy", bgcolor=color.teal, text_color=color.white) table.cell(stats, 0, 1, "Equity", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 2, "Max Equity", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 3, "Drawdown", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 4, "Max Drawdown", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 5, "ROI", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 6, "Cash Holding(%)", bgcolor=color.maroon, text_color=color.white) table.cell(stats, 0, 7, "Average Cash Holding(%)", bgcolor=color.maroon, text_color=color.white) roiBnh = bnhEquity*100/totalInvestment roiStrategy = totalEquity*100/totalInvestment table.cell(stats, 2, 1, str.tostring(bnhEquity), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 2, 2, str.tostring(bEquityAth), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 2, 3, str.tostring(bDrawdown), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 2, 4, str.tostring(bMaxDrawdown), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 2, 5, str.tostring(roiBnh), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 1, str.tostring(totalEquity), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 2, str.tostring(sEquityAth), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 3, str.tostring(sDrawdown), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 4, str.tostring(sMaxDrawdown), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 5, str.tostring(roiStrategy), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 6, str.tostring(currentCashPercent), bgcolor=color.aqua, text_color=color.black) table.cell(stats, 1, 7, str.tostring(avgCashPercent), bgcolor=color.aqua, text_color=color.black)
S&P Sector Advance/Decline Weighted -Tom1trader
https://www.tradingview.com/script/pV8aPTZN-S-P-Sector-Advance-Decline-Weighted-Tom1trader/
Tom1trader
https://www.tradingview.com/u/Tom1trader/
479
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/ // © Tom1trader // Thanks to @MartinShkreli. The sector function, variables & "repaint" (approx lines 28 through 43 of this script) // are used directly from your script "Sectors" // RECOMMENDATION: Update the sector weightings -inputs are provided. They change as often as monthly and the // annual changes are certainly significant. // When updating weighting percentages use the decimal value. I.E. 29% is .29 ///// // All sectors advanced is line at +1 and declined at -1 // Line values between +/- 100 represent percentage of sector weight that advanced or declined // The weight (% S&P mkt cap) is added if advances or subtracted if declines // i.e infotech sector was 26% of S&P when I did this so .26 added/subtracted when advance/decline. // The columes aqua fuchsia are a 5 period Hull Moving Average [changed from ema] // Zero Cross of this histo/columns give pretty good signals for S&P. // Above/below zero track pretty well as price rising/falling. // The space between plus 0.5 and minus 0.5 is more neutral such that // when histo is between them price is rising or falling more slowly // or price is ranging when histo straddles back and forth + and -. // I colored the AD line also to emphasize the times it opposes the histo. // On 7/7/23 updated the sector weightings and changed the online source for the // Weightings to yahoo. Link: https://finance.yahoo.com/quote/SPY/holdings/ //@version=5 indicator("AD Line of S&P Sectors", "AD Sects", overlay=false) f_security(_symbol, _res, _src, _repaint) => request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1] res = timeframe.period re = input(title='Repaint', defval=true) energy = f_security('SP:SPN', res, close, re) // this group sector closes mat = f_security('SP:S5MATR', res, close, re) indu = f_security('SP:S5INDU', res, close, re) discr = f_security('SP:S5COND', res, close, re) staple = f_security('SP:S5CONS', res, close, re) hlth = f_security('SP:S5HLTH', res, close, re) fin = f_security('SP:SPF', res, close, re) infot = f_security('SP:S5INFT', res, close, re) tele = f_security('SP:S5TELS', res, close, re) util = f_security('SP:S5UTIL', res, close, re) real = f_security('SP:S5REAS', res, close, re) enec = energy-energy[1] // this group establish sector advance or decline matc = mat-mat[1] indc = indu-indu[1] disc = discr-discr[1] stac = staple-staple[1] hltc = hlth-hlth[1] finc = fin-fin[1] infc = infot-infot[1] telc = tele-tele[1] utic = util-util[1] reac = real-real[1] // calculate impact by Market Cap weighting of setocr // note that market caps change and when they do these following values could be updated // I intend to update them annually with free info from https://finance.yahoo.com/quote/SPY/holdings/ enep = input(.0417, title="Energy Wght [1%=.01") matp = input(.0218, title="Materials Wght [1%=.01]") indp = input(.0801, title="Indusrials Wght [1%=.01]") disp = input(.1031, title="Cons Disc (cyclical) Wght [1%=.01]") stap = input(.0683, title="Cons Staples (defensive) Wght [1%=.01]") hltp = input(.1377, title="Health Wght [1%=.01]") finp = input(.1201, title="Financials Wght [1%=.01]") infp = input(.2864, title="InfoTech Wght [1%=.01]") telp = input(.0875, title="Comms Svcs Wght [1%=.01]") utip = input(.0268, title="Utilities Wght [1%=.01]") reap = input(.0250, title="Real Estate Wght [1%=.01]") // this is each sector % of s&P times 500 for std ADL scale enet = enec==0 ? 0 : enec>0 ? enep : -enep matt = matc==0 ? 0 : matc>0 ? matp : -matp indt = indc==0 ? 0 : indc>0 ? indp : -indp dist = disc==0 ? 0 : disc>0 ? disp : -disp stat = stac==0 ? 0 : stac>0 ? stap : -stap hltt = hltc==0 ? 0 : hltc>0 ? hltp : -hltp fint = finc==0 ? 0 : finc>0 ? finp : -finp inft = infc==0 ? 0 : infc>0 ? infp : -infp telt = telc==0 ? 0 : telc>0 ? telp : -telp utit = utic==0 ? 0 : utic>0 ? utip : -utip reat = reac==0 ? 0 : reac>0 ? reap : -reap adls = enet+matt+indt+dist+stat+hltt+fint+inft+telt+utit+reat color adcol = adls >= adls[1] ? color.green : adls <= adls[1] ? color.red : color.blue plot(adls, "AD Line Sects", color.new(adcol, 30), linewidth=2) admlen = input(5, "adma len") adma = ta.hma(adls, admlen) color macol = adma>adma[1] ? color.aqua : adma<adma[1] ? color.fuchsia : color.gray // choice of factor to bring up visibility of the Hull MA histo mamult = input.float(1.4, title="Increase scale of Histo", minval=1, maxval=2, step=0.1) plot(adma, "adma", color.new(macol, 60), linewidth=2, style=plot.style_columns) hline(0, color=color.black, linewidth=2) hline(1, title="All Up-scaled-350") hline(-1, title="All Down-scxaled-350") // for the line, not the histo inside of these lines is more neutral as to direction change hline(.5, title="Upper of more neutral values") hline(-.5, title="Lower of more neutral values")
Support & Ressistance by @kaleboraciy [REUPLOAD]
https://www.tradingview.com/script/K75SZWV6-support-ressistance-by-kaleboraciy-reupload/
kaleboraciy
https://www.tradingview.com/u/kaleboraciy/
909
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/ // © kaleboraciy //@version=4 study("Support & Ressistance by @kaleboraciy", overlay = true, max_lines_count = 500, max_labels_count = 500) pivot_len = input(20, title = 'Pivot Points Length', type = input.integer) inacc = input(0.5, title = 'Inaccuracy', type = input.float, step = 0.1) / 100 * close width = input(10, title = 'Linewidth') width2 = input(2, title = 'Linewidth of broken line') show_broken = input(false, title = 'Сontinue broken lines?') start = input(timestamp("2021-01-01"), type = input.time, title = 'Start calculations from') time_cond = time >= start ph = pivothigh(high, pivot_len, pivot_len) pl = pivotlow(low, pivot_len, pivot_len) var lines_upper = array.new_line(1) var lines_lower = array.new_line(1) if array.size(lines_upper) > 500 array.shift(lines_upper) if array.size(lines_lower) > 500 array.shift(lines_lower) // deleting bad levels k = 0 for i = 0 to array.size(lines_upper) - 1 line_price = line.get_y2(array.get(lines_upper, i - k)) if high - inacc > line_price x1 = line.get_x1(array.get(lines_upper, i - k)) x2 = line.get_x2(array.get(lines_upper, i - k)) y1 = line.get_y1(array.get(lines_upper, i - k)) if x1 != x2 line.new(x1, y1, bar_index, y1, extend = extend.none, color = color.new(color.green, 50), width = width) line.set_x2(array.get(lines_upper, i - k), bar_index) alert("Green level at "+ tostring(y1) + " has broken!", freq = alert.freq_once_per_bar) if show_broken line.new(time_close[1], y1, time_close + 1, y1, extend = extend.right, color = color.new(color.green, 50), width = width2, xloc = xloc.bar_time) line.delete(array.get(lines_upper, i - k)) array.remove(lines_upper, i - k) k := k + 1 k := 0 for i = 0 to array.size(lines_lower) - 1 line_price = line.get_y2(array.get(lines_lower, i - k)) if low + inacc < line_price x1 = line.get_x1(array.get(lines_lower, i - k)) x2 = line.get_x2(array.get(lines_lower, i - k)) y1 = line.get_y1(array.get(lines_lower, i - k)) if x1 != x2 line.new(x1, y1, bar_index, y1, extend = extend.none, color = color.new(color.red, 50), width = width) line.set_x2(array.get(lines_lower, i - k), bar_index) alert("Red level at "+ tostring(y1) + " has broken!", freq = alert.freq_once_per_bar) if show_broken line.new(time_close[1], y1, time_close + 1, y1, extend = extend.right, color = color.new(color.red, 50), width = width2, xloc = xloc.bar_time) line.delete(array.get(lines_lower, i - k)) array.remove(lines_lower, i - k) k := k + 1 if ph and time_cond bool flag = false for i = 0 to array.size(lines_upper) - 1 line_price = line.get_y2(array.get(lines_upper, i)) if ph >= line_price - inacc and ph <= line_price + inacc flag := true line.set_color(array.get(lines_upper, i), color.new(color.green, 50)) line.set_x2(array.get(lines_upper, i), bar_index) if not flag array.push(lines_upper, line.new(bar_index[pivot_len], ph, bar_index[pivot_len], ph, color = na, extend = extend.right, width = width)) if pl and time_cond bool flag = false for i = 0 to array.size(lines_lower) - 1 line_price = line.get_y2(array.get(lines_lower, i)) if pl >= line_price - inacc and pl <= line_price + inacc flag := true line.set_color(array.get(lines_lower, i), color.new(color.red, 50)) line.set_x2(array.get(lines_lower, i), bar_index) if not flag array.push(lines_lower, line.new(bar_index[pivot_len], pl, bar_index[pivot_len], pl, color = na, extend = extend.right, width = width)) // plot(array.size(lines_upper)) // plot(ph) // plot(pl)
Liquidations by volume (spot/futures)
https://www.tradingview.com/script/EjxQftfJ-Liquidations-by-volume-spot-futures/
Thomas_Davison
https://www.tradingview.com/u/Thomas_Davison/
232
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/ // © Thomas_Davison //@version=5 indicator("Liquidations by volume") // uses the difference in volume between a spot market and a futures market to determine possible liquidations that might have taken place // the calculation is simple: histogram bar value = futures volume - spot volume // NOTES: - markets used should have the same volume equivalent i.e. volume for BTCUSDT should be measured in BTC for both spot and futures markets, some futures markets use contracts worth different amounts meaning values will differ greatly. // - negative values will been removed as they dont show relevant data to this indicator // - all values while calculated accurately, are given to interpretation, as not all of the volume difference seen on a futures market is due to liquidations. Traders making trades within a single candle time period will skew the data. longLiqCol = input.color(title="Long liquidations", defval = color.red) shortLiqCol = input.color(title="Short liquidations", defval = color.green) removeBelowMean = input.bool(title="Remove below average volume differences?", defval = true) timePeriodMean = input.int(title="bars used in mean calculation", defval = 100) assetFutures = input.symbol(title="Futures symbol", defval = "binance:btcusdtperp") plotFutures = input.bool(title="Plot futures market volume?", defval = false) futuresVolCol = input.color(title="futures volume", defval = color.blue) assetSpot = input.symbol(title="Spot symbol", defval = "binance:btcusdt") plotSpot = input.bool(title="Plot spot market volume?", defval = false) spotVolCol = input.color(title="spot volume", defval = color.yellow) spotVolume = request.security(assetSpot,timeframe.period,volume) futuresVolume = request.security(assetFutures,timeframe.period,volume) difference = futuresVolume - spotVolume direction = close > open ? shortLiqCol : longLiqCol differenceSum = math.sum(difference, timePeriodMean) differenceMean = differenceSum / timePeriodMean if removeBelowMean and difference < differenceMean or difference < 0 difference := 0 plot(difference, linewidth = 2, color = direction, style = plot.style_histogram) plot(plotSpot ? spotVolume : na, color=spotVolCol) plot(plotFutures ? futuresVolume: na, color=futuresVolCol)
Smoothed Heiken Ashi
https://www.tradingview.com/script/pjl3mIvc-Smoothed-Heiken-Ashi/
TheBacktestGuy
https://www.tradingview.com/u/TheBacktestGuy/
799
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/ // © wallneradam //@version=5 indicator("Smoothed Heiken Ashi", "SHA", overlay=true, timeframe="", timeframe_gaps=true) import wallneradam/TAExt/8 // // User inputs // ha_smooth_length = input.int(10, "Smooth Length", minval=1, group="Before HA") ha_smooth_ma_type = input.string('EMA', 'MA Type', options=['SMA', 'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "SWMA", "SMMA", "JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"], group="Before HA") ha_after_smooth_length = input.int(10, "After Smooth Length", minval=1, group="After HA") ha_after_smooth_ma_type = input.string('EMA', 'After MA Type', options=['SMA', 'EMA', 'WMA', "VWMA", "RMA", "DEMA", "TEMA", "ZLEMA", "HMA", "ALMA", "LSMA", "SWMA", "SMMA", "JMA", "DONCHIAN", "ATRWSMA", "ATRWEMA", "ATRWRMA", "ATRWWMA"], group="After HA") // // Calculation // [o, h, l, c] = TAExt.heiken_ashi(smooth_length=ha_smooth_length, smooth_ma_type=ha_smooth_ma_type, after_smooth_length=ha_after_smooth_length, after_smooth_ma_type=ha_after_smooth_ma_type) // // Plotting // plotcandle(o, h, l, c, title="Smoothed Heiken Ashi", color=o > c ? color.new(color.red, 60) : color.new(color.lime, 60), wickcolor=o > c ? color.new(color.red, 20) : color.new(color.lime, 20), bordercolor=o > c ? color.new(color.red, 10) : color.new(color.lime, 10))
World Markets Open/Close Background
https://www.tradingview.com/script/d7S43yxg-World-Markets-Open-Close-Background/
goofoffgoose
https://www.tradingview.com/u/goofoffgoose/
150
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © goofoffgoose // @version=5 indicator("World Markets", shorttitle="Wrd Mkts", overlay=true) t = timestamp("01 Jan 2022 00:00") // My intentions for this script is to use it and its varible value to plot the open, close, highs and lows in the specific times of a // session and to more easily visualize those sessions with color background. // ***Fixed the Timezone issue. The default timeframe of sessions should update to the users current timezone set on the platform. // Although times will still need to be adjusted for DST. // ***Cleaned up the code and menu layout to be more User/Coder friendly. // ***Added option to color background for a lookahead period in minutes. The default is false with lookahead set for 1 day (1380 mins) // with times set on the hourly chart. This code is however intended for a chart in minute(s). Manually input the time to change this. // Selecting "Future Sessions" can take a moment to load on the 1 min and under chart. // ****PLEASE NOTE*** "Future Sessions" is VERY picky on the 1 hour chart. Selected times HAVE TO BE at least 1 hour and sometimes even // ON THE HOUR. Change "Future Sessions" INPUT to 1379(mins) for an hourly chart otherwise it won't show the first selected session // It will take increments sometimes, and other times it just won't. Please don't ask me to fix this, belive me I have tried. // Indicator fills background on the chart for diffent markets around the world. // Times can be changed for each session to include the entire session or a specific time. // Sessions are default to be displayed on the 1 hour chart. All default times for each market are in CST. // Background color can be turned off or changed and this can just be used for source. // Market open and close inputs ///// US Markets///// USOpenSession = input.session(title="US Open", defval="0800-0845", tooltip="US(NYSE) Open", group="US Session") USCloseSession = input.session(title="US Close", defval="1445-1515", tooltip="US(NYSE) Close") Show_US_Session = input.bool(title="Show US Session?", defval=true) // show session ? // Colors USOpenColor = input.color(color.rgb(0,153,0,90), title="US Open", inline="UsSess color") USCloseColor = input.color(color.rgb(0,102,0,90), title="US Close", inline="UsSess color" ) ///// Asia Markets///// AsiaOpenSession = input.session(title="Asia Open", defval="1800-1930", tooltip="Open is for Multiple Markets: Tokyo(TSE), Hong Kong(HKEX) and Shanghai(SSX) Open", group="Asia Session") AsiaCloseSession = input.session(title="Asia Close", defval="0000-0200", tooltip="Close is for Multiple Markets: Tokyo(TSE), Hong Kong(HKEX) and Shanghai(SSX) Close") Show_Asia_Session = input.bool(title="Show Asia Session?", defval=true)// show session ? // Colors AsiaOpenColor = input.color(color.rgb(204,0,0,91), title="Asia Open", inline="AsiaSess Color") AsiaCloseColor = input.color(color.rgb(153,0,0,93), title="Asia Close", inline="AsiaSess Color" ) ///// India Markets///// IndiaOpenSession = input.session(title="India Open", defval="2230-2330", tooltip="India(NSE), (BSE), and Nifty Open", group="India Session") IndiaCloseSession = input.session(title="India Close", defval="0445-0515", tooltip="India(NSE), (BSE), and Nifty Close") Show_India_Session = input.bool(title="Show India Session?", defval=true)// show session ? // Colors IndiaOpenColor = input.color(color.rgb(204,102,0,90), title="India Open", inline="IndiaSess Color") IndiaCloseColor = input.color(color.rgb(204,102,0,92), title="India Close", inline="IndiaSess Color" ) ///// London Market///// LondonOpenSession = input.session(title="London Open", defval="0200-0300", tooltip="London(LSE) Open", group="London Session") LondonCloseSession = input.session(title="London Close", defval="1000-1100", tooltip="London(LSE) Close") Show_London_Session = input.bool(title="Show London Session?", defval=true)// show session ? // Colors LondonOpenColor = input.color(color.rgb(0,102,204,90), title="London Open", inline="LondonSess Color") LondonCloseColor = input.color(color.rgb(0,76,153,90), title="London Close", inline="LondonSess Color" ) // Returns true if the current bar falls within the given time session (:123456 Sunday - Friday) inSession(session, sessionTimeZone=syminfo.timezone) => na(time(timeframe.period, session + ":1234567")) == false // Conditions to print future sessions on chart Show_Future_Session = input.bool(false, title="Future Sessions", tooltip="This will show sessions into the future on the chart.") var print_fut = false var dont_print_fut = false if Show_Future_Session print_fut := true else dont_print_fut := true // Input for future session in minutes FutureSess = input(1380, title="Future Sessions", tooltip="Number of minutes in your chart. Default is for 23 Hours(1380 mins) for ETH charts including Globex sessions. Change to 1379 for hourly chart") // Background colors for each market session // New York BG print // Open bgcolor(inSession(USOpenSession) and Show_US_Session and dont_print_fut ? USOpenColor : na, editable=false) bgcolor(inSession(USOpenSession) and Show_US_Session and print_fut ? USOpenColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // Close bgcolor(inSession(USCloseSession) and Show_US_Session and dont_print_fut ? USCloseColor : na, editable=false) bgcolor (inSession(USCloseSession) and Show_US_Session and print_fut ? USCloseColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // Asia BG print // Open bgcolor(inSession(AsiaOpenSession) and Show_Asia_Session and dont_print_fut ? AsiaOpenColor : na, editable=false) bgcolor(inSession(AsiaOpenSession) and Show_Asia_Session and print_fut ? AsiaOpenColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // Close bgcolor(inSession(AsiaCloseSession) and Show_Asia_Session and dont_print_fut ? AsiaCloseColor : na, editable=false) bgcolor(inSession(AsiaCloseSession) and Show_Asia_Session and print_fut ? AsiaCloseColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // India BG print // Opem bgcolor(inSession(IndiaOpenSession) and Show_India_Session and dont_print_fut ? IndiaOpenColor : na, editable=false) bgcolor(inSession(IndiaOpenSession) and Show_India_Session and print_fut ? IndiaOpenColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // Close bgcolor(inSession(IndiaCloseSession) and Show_India_Session and dont_print_fut ? IndiaCloseColor : na, editable=false) bgcolor(inSession(IndiaCloseSession) and Show_India_Session and print_fut ? IndiaCloseColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // London BG print // Open bgcolor(inSession(LondonOpenSession) and Show_London_Session and dont_print_fut ? LondonOpenColor : na, editable=false) bgcolor(inSession(LondonOpenSession) and Show_London_Session and print_fut ? LondonOpenColor : na, offset=FutureSess /timeframe.multiplier, editable=false) // Close bgcolor(inSession(LondonCloseSession) and Show_London_Session and dont_print_fut ? LondonCloseColor : na, editable=false) bgcolor(inSession(LondonCloseSession) and Show_London_Session and print_fut? LondonCloseColor : na, offset=FutureSess/timeframe.multiplier, editable=false)
Price Difference At Expiration
https://www.tradingview.com/script/EXSP44YX-Price-Difference-At-Expiration/
dcgraham7
https://www.tradingview.com/u/dcgraham7/
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/ // © dcgraham7 //@version=5 indicator(title="Price Difference At Expiration", shorttitle="exp-diff") interval = input.int(10, "interval (days)") maxRange = input.float(200, "buffer") drawMonday = input.bool(true, "Monday") drawTuesday = input.bool(false, "Tuesday") drawWednesday = input.bool(true, "Wednesday") drawThursday = input.bool(false, "Thursday") drawFriday = input.bool(true, "Friday") day = dayofweek(time_close(timeframe.period)) // decide if we want to draw this bar bool shouldDraw = true if day == 2 and drawMonday == false shouldDraw := false else if day == 3 and drawTuesday == false shouldDraw := false else if day == 4 and drawWednesday == false shouldDraw := false else if day == 5 and drawThursday == false shouldDraw := false else if day == 6 and drawFriday == false shouldDraw := false dayLetter = if day == 2 "M" else if day == 3 "T" else if day == 4 "W" else if day == 5 "Th" else "F" change = shouldDraw ? close - close[interval] : 0 isOver = math.abs(change) >= maxRange barColor = isOver ? color.red : color.gray plot(change, color=barColor, style=plot.style_histogram, linewidth=4) if shouldDraw and isOver label.new(bar_index, na, dayLetter)
Kaufman's Adaptive Moving Average (KAMA) - Multi timeframe
https://www.tradingview.com/script/F1nza3ej-Kaufman-s-Adaptive-Moving-Average-KAMA-Multi-timeframe/
DojiEmoji
https://www.tradingview.com/u/DojiEmoji/
164
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/ // © DojiEmoji //@version=5 indicator(title="Kaufman's Adaptive Moving Average (KAMA)", shorttitle="KAMA", overlay=true, timeframe="", timeframe_gaps=false) var int period = input.int(10, title="Lookback period", minval=2) // Implementation of Kaufman's Efficiency Ratio ("ER"): // (Previous script: https://www.tradingview.com/script/j9hCD2lP-Kaufman-s-Efficiency-Ratio-Indicator/) // @function er(source, length) returns float efficiency ratio. er(src, len) => float total_abs_chng = 0 for i = 1 to len by 1 total_abs_chng += math.abs(src[i - 1] - src[i]) (src - src[len]) / total_abs_chng // Return: net change / total absolute change // Kaufman's Adaptive Moving Average ("KAMA") // (Source: Chapter 17, "Trading System and Methods - 6th edition" by Perry J. Kaufman) // { // KAMA_t = KAMA_t-1 + sc_t * (p_t - KAMA_t-1) // where: // p_t = current closing price // sc_t = smoothing constant, based on Kaufman's Eff. Ratio ("ER") // // where: sc_t = (ER_t x (_FAST - _SLOW) + _SLOW) ^2 // _FAST = 2 / (fast MA period + 1) // _SLOW = 2 / (slow MA period + 1) // Fast and slow periods are 2, and 30 (respectively) // } var float _FAST = 0.666666666666667 var float _SLOW = 0.0645161290322581 abs_er = math.abs(er(close, period)) sc_t = math.pow(abs_er * (_FAST-_SLOW) + _SLOW, 2) float KAMA_t = 0 KAMA_t := nz(KAMA_t[1],close[1]) + sc_t * (close-nz(KAMA_t[1],close[1])) //----------------------- // Experimental features //----------------------- var string GROUP_EXP = "Experimental" // Background colors to visualize levels of market noise (experimental) var bool bgcol_mode = input.bool(false, title="Fill background: Low / High Noise", group=GROUP_EXP, inline="ln0", tooltip="To visualize market noise. Thresholds (min.) can be adjusted below.") var color color_low = input.color(color.new(color.green, 90),title="Low level of market noise", group=GROUP_EXP, inline="ln1") var color color_high = input.color(color.new(color.red, 90),title="High level of market noise", group=GROUP_EXP, inline="ln1") var float thres_low = input.float(0.25, minval=0, maxval=0.5, step=0.01, title="Thresholds for Low / High Noise", inline="ln2", group=GROUP_EXP) var float thres_high = input.float(0.5, minval=0.5, maxval=1, step=0.01, title="/", inline="ln2", group=GROUP_EXP) bgcolor(bgcol_mode and abs_er < thres_low ? color_low : na) bgcolor(bgcol_mode and abs_er > thres_high ? color_high : na) // Smoothening var bool use_linreg = input.bool(false, title="Smooth KAMA:", inline="ln3", group=GROUP_EXP, tooltip="Using the least squares method over the same window of lookback.") //----------------------- // Plot //----------------------- kama_plot = use_linreg ? ta.linreg(KAMA_t, period, 0) : KAMA_t plot(kama_plot, title="KAMA")
Chikou Filter for Ichimoku Cloud
https://www.tradingview.com/script/7VzNeBva-Chikou-Filter-for-Ichimoku-Cloud/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
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/ // © MightyZinger //@version=5 indicator(title = "Chikou Filter for Ichimoku Cloud", shorttitle = 'MZ Chikou Filter', overlay = true) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///// Source Options ////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // ─── Different Sources Options List ───► [ string SRC_Tv = 'Use traditional TradingView Sources ' string SRC_Wc = '(high + low + (2 * close)) / 4' string SRC_Wo = 'close+high+low-2*open' string SRC_Wi = '(close+high+low) / 3' string SRC_Ex = 'close>open ? high : low' string SRC_Hc = 'Heikin Ashi Close' string src_grp = 'Source Parameters' // ●───────── Inputs ─────────● { diff_src = input.string(SRC_Wi, '→ Different Sources Options', options=[SRC_Tv, SRC_Wc, SRC_Wo, SRC_Wi, SRC_Ex, SRC_Hc], group=src_grp) i_sourceSetup = input.source(close, 'Source Setup', group=src_grp) uha_src = input.bool(true, title='Use Heikin Ashi Candles for Different Source Calculations', group=src_grp) i_Symmetrical = input.bool(true, 'Apply Symmetrically Weighted Moving Average at the price source (May Result Repainting)', group=src_grp) // Heikinashi Candles for calculations h_close = uha_src ? ohlc4 : close f_ha_open() => haopen = float(na) haopen := na(haopen[1]) ? (open + close) / 2 : (nz(haopen[1]) + nz(ohlc4[1])) / 2 haopen h_open = uha_src ? f_ha_open() : open h_high = high h_low = low // Get Source src_o = diff_src == SRC_Wc ? (h_high + h_low + 2 * h_close) / 4 : diff_src == SRC_Wo ? h_close + h_high + h_low - 2 * h_open : diff_src == SRC_Wi ? (h_close + h_high + h_low) / 3 : diff_src == SRC_Ex ? h_close > h_open ? h_high : h_low : diff_src == SRC_Hc ? ohlc4 : i_sourceSetup src_f = i_Symmetrical ? ta.swma(src_o) : src_o // Symmetrically Weighted Moving Average? string grp1 = 'Chikou Parameters' c_len = input.int(26, title='Chikou Period:', group=grp1) p_lb = input.int(50, title='Chikou Filter Percentage Lookback:', group=grp1, maxval = 90) ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// chikou_filter(src, len, perc, _high, _low, bull_col, bear_col, r_col)=> var _up = bool(na) var _dn = bool(na) var _re = bool(na) var color _clr = color.new(na, 0) var sig = int(na) lb_len = int(len*perc/100) // Percentage Candels of total length to be considered for filter _up := src > ta.highest(_high, lb_len)[lb_len] _dn := src < ta.lowest(_low, lb_len)[lb_len] _re := src < ta.highest(_high, lb_len)[lb_len] and src > ta.lowest(_low, lb_len)[lb_len] _clr := _up ? bull_col : _dn ? bear_col : r_col sig := _up ? 1 : _dn ? -1 : 0 // provides Bullish and Bearish condition in Integer format that can be used as signals [_clr, sig] ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// [c_col, _trend] = chikou_filter(src_f, c_len, p_lb, high, low, color.green, color.red, color.yellow) chikou_plot = plot(src_f, offset = -c_len+1 , color= c_col , title="Chikou-Span", linewidth=4) // Alerts if _trend == 1 and not _trend[1] == 1 alert('Buy : Chikou crossed resistance at ' + str.tostring(close), alert.freq_once_per_bar_close) if _trend == -1 and not _trend[1] == -1 alert('Sell : Chikou below support at ' + str.tostring(close), alert.freq_once_per_bar_close) ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
HiLo Screener
https://www.tradingview.com/script/J38214Ms-HiLo-Screener/
starbolt
https://www.tradingview.com/u/starbolt/
154
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © starbolt //@version=5 indicator('HiLo Screener', overlay=true) //Removes exchange name from ticker _remove_exchange(ticker) => res = ticker == '' ? na : array.get(str.split(ticker, ':'), 1) res //HiLo Activator function _hilo(len) => float hilo = na smax = ta.sma(high, len) smin = ta.sma(low, len) hilo := close > smax[1] ? 1 : close < smin[1] ? -1 : hilo[1] ghla = hilo == 1 and hilo[1] == - 1 ? 1 : hilo == -1 and hilo[1] == 1 ? -1 : 0 ghla //Inputs pos = input.string("Top Right", "Panel Position", ["Top Right", "Middle Right", "Bottom Right"]) timeframe = input.timeframe("D", "Default Timeframe") position = pos == "Bottom Right" ? position.bottom_right : pos == "Middle Right" ? position.middle_right : position.top_right t1 = input.symbol('BMFBOVESPA:VALE3', 'Ticker 1') t1len = input.int(20, 'Length 1', step=1, minval=1) t2 = input.symbol('', 'Ticker 2') t2len = input.int(20, 'Length 2', step=1, minval=1) t3 = input.symbol('', 'Ticker 3') t3len = input.int(20, 'Length 3', step=1, minval=1) t4 = input.symbol('', 'Ticker 4') t4len = input.int(20, 'Length 4', step=1, minval=1) t5 = input.symbol('', 'Ticker 5') t5len = input.int(20, 'Length 5', step=1, minval=1) t6 = input.symbol('', 'Ticker 6') t6len = input.int(20, 'Length 6', step=1, minval=1) t7 = input.symbol('', 'Ticker 7') t7len = input.int(20, 'Length 7', step=1, minval=1) t8 = input.symbol('', 'Ticker 8') t8len = input.int(20, 'Length 8', step=1, minval=1) t9 = input.symbol('', 'Ticker 9') t9len = input.int(20, 'Length 9', step=1, minval=1) t10 = input.symbol('', 'Ticker 10') t10len = input.int(20, 'Length 10', step=1, minval=1) t1name = _remove_exchange(t1) t2name = _remove_exchange(t2) t3name = _remove_exchange(t3) t4name = _remove_exchange(t4) t5name = _remove_exchange(t5) t6name = _remove_exchange(t6) t7name = _remove_exchange(t7) t8name = _remove_exchange(t8) t9name = _remove_exchange(t9) t10name = _remove_exchange(t10) h1 = t1 == '' ? 0 : request.security(t1, timeframe, _hilo(t1len)) h2 = t2 == '' ? 0 : request.security(t2, timeframe, _hilo(t2len)) h3 = t3 == '' ? 0 : request.security(t3, timeframe, _hilo(t3len)) h4 = t4 == '' ? 0 : request.security(t4, timeframe, _hilo(t4len)) h5 = t5 == '' ? 0 : request.security(t5, timeframe, _hilo(t5len)) h6 = t6 == '' ? 0 : request.security(t6, timeframe, _hilo(t6len)) h7 = t7 == '' ? 0 : request.security(t7, timeframe, _hilo(t7len)) h8 = t8 == '' ? 0 : request.security(t8, timeframe, _hilo(t8len)) h9 = t9 == '' ? 0 : request.security(t9, timeframe, _hilo(t9len)) h10 = t10 == '' ? 0 : request.security(t10, timeframe, _hilo(t10len)) ut1 = h1 == 1 ut2 = h2 == 1 ut3 = h3 == 1 ut4 = h4 == 1 ut5 = h5 == 1 ut6 = h6 == 1 ut7 = h7 == 1 ut8 = h8 == 1 ut9 = h9 == 1 ut10 = h10 == 1 dt1 = h1 == -1 dt2 = h2 == -1 dt3 = h3 == -1 dt4 = h4 == -1 dt5 = h5 == -1 dt6 = h6 == -1 dt7 = h7 == -1 dt8 = h8 == -1 dt9 = h9 == -1 dt10 = h10 == -1 var table perfTable = table.new(position, 1, 2, border_width = 3) up_label = "UP TREND \n\n" up_label := ut1 ? up_label + t1name + '\n' : up_label up_label := ut2 ? up_label + t2name + '\n' : up_label up_label := ut3 ? up_label + t3name + '\n' : up_label up_label := ut4 ? up_label + t4name + '\n' : up_label up_label := ut5 ? up_label + t5name + '\n' : up_label up_label := ut6 ? up_label + t6name + '\n' : up_label up_label := ut7 ? up_label + t7name + '\n' : up_label up_label := ut8 ? up_label + t8name + '\n' : up_label up_label := ut9 ? up_label + t9name + '\n' : up_label up_label := ut10 ? up_label + t10name + '\n' : up_label down_label = 'DOWN TREND \n\n' down_label := dt1 ? down_label + t1name + '\n' : down_label down_label := dt2 ? down_label + t2name + '\n' : down_label down_label := dt3 ? down_label + t3name + '\n' : down_label down_label := dt4 ? down_label + t4name + '\n' : down_label down_label := dt5 ? down_label + t5name + '\n' : down_label down_label := dt6 ? down_label + t6name + '\n' : down_label down_label := dt7 ? down_label + t7name + '\n' : down_label down_label := dt8 ? down_label + t8name + '\n' : down_label down_label := dt9 ? down_label + t9name + '\n' : down_label down_label := dt10 ? down_label + t10name + '\n' : down_label f_fillCell(_table, _column, _row, _value, _color) => _c_color = _color _transp = 80 _cellText = str.tostring(_value) table.cell(_table, _column, _row, _cellText, bgcolor = color.new(_c_color, _transp), text_color = _c_color, width = 10) f_fillCell(perfTable, 0, 0, up_label, #239B56) f_fillCell(perfTable, 0, 1, down_label, #E74C3C)
Elliot wave : Wave 3 finder
https://www.tradingview.com/script/TXP1Chk0-Elliot-wave-Wave-3-finder/
Qantar
https://www.tradingview.com/u/Qantar/
691
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/ // © Qantar //@version=4 study("3x finder",overlay=true,max_bars_back=5000) //eow=rectracment of end of wave x (eowx) var eow1=0.7, eow2=0.5, eow3=1.618, s=0 //find start of wave 1 N=bar_index+1, LV=lowest(low,N) LP=valuewhen(low==LV,bar_index,0) //mark end of wave 1 and 2 if N>LP HV=highest(high,N-LP) HP=valuewhen(high==HV,bar_index,0) R=HV-LV FP=HV-eow1*R BP=HV-eow2*R LV2V=lowest(low,N-HP) LV2P=valuewhen(low==LV2V,bar_index,0) EXP=LV2V+eow3*R if (LV2V<FP)and(LV2V>LV)and(LV2P>HP) //label.new(x=LP,y=LV,color=color.red,style=label.style_label_up,textcolor=color.white,text="0") if (high>=BP)and(N-1>LV2P)and(close>=BP) alert("wave 3 start") W0=label.new(x=LP,y=LV,color=color.red,style=label.style_label_up,textcolor=color.white,text="0") W1=label.new(x=HP,y=HV,color=color.green,textcolor=color.white,text="1") W2=label.new(x=LV2P,y=LV2V,color=color.orange,style=label.style_label_up,textcolor=color.white,text="2") label.delete(W0[1]) label.delete(W1[1]) label.delete(W2[1]) TP=LV2V+(1.618*R) SL=LV2V Line1=line.new(x1=HP,y1=TP,x2=N+100,y2=TP, color=color.green) Line2=line.new(x1=HP,y1=SL,x2=N+100,y2=SL, color=color.red) Label1=label.new(x=N+100,y=TP,color=color.green,textcolor=color.white,text="Target price = "+tostring(TP)) Label2=label.new(x=N+100,y=SL,color=color.orange,textcolor=color.white,text="Stop loss = "+tostring(SL)) line.delete(Line1[1]) line.delete(Line2[1]) label.delete(Label1[1]) label.delete(Label2[1]) if barstate.islast RRR=(TP-high)/(high-SL) label.new(x=N-1,y=high,color=color.blue,textcolor=color.white,text="buy \n Risk Reward Ratio = "+tostring(RRR)) fast=ema(close,14) slow=ema(close,26) crossover(fast,slow) barcolor(crossover(fast,slow)? color.blue: crossunder(fast,slow)? color.purple: fast>slow? color.green:color.red)
Bitcoin Golden Bottom Oscillator (MZ BTC Oscillator)
https://www.tradingview.com/script/98n44mYJ-Bitcoin-Golden-Bottom-Oscillator-MZ-BTC-Oscillator/
MightyZinger
https://www.tradingview.com/u/MightyZinger/
247
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/ // © MightyZinger //@version=5 indicator(title='Bitcoin Golden Bottom Oscillator (MZ BTC Oscillator)', shorttitle='MZ BTC Oscillator', overlay=false) src = request.security('INDEX:BTCUSD', '1D', close) length = input.int(title='Adaptive MA Length', defval=365) majLength = input.int(title='Major Length', defval=100) minLength = input.int(title='Minor Length', defval=50) rsiLen = input.int(14, minval=1,title="RSI Period") // Envelop Parameters atr_mult = input.float(20, title='Distance (Envelope) Multiplier', step=.1, group='ENVELOPE DISTANCE ZONE') env_atr = input.int(40, title='Envelope ATR Length', group='ENVELOPE DISTANCE ZONE') ama(src,length,minLength,majLength)=> minAlpha = 2 / (minLength + 1) majAlpha = 2 / (majLength + 1) hh = ta.highest(length + 1) ll = ta.lowest(length + 1) mult = hh - ll != 0 ? math.abs(2 * src - ll - hh) / (hh - ll) : 0 final = mult * (minAlpha - majAlpha) + majAlpha ma = 0.0 ma := nz(ma[1]) + math.pow(final, 2) * (src - nz(ma[1])) ma _low = request.security('INDEX:BTCUSD', '1D', low) _ama = request.security('INDEX:BTCUSD', '1D', ama(src,length,minLength,majLength)) madif = (_low - _ama) / src * 100 // AMA Delta deltaMA = ta.sma(math.abs(madif) , rsiLen) // RSI rsi = ta.rsi(math.abs(deltaMA), rsiLen) osc = request.security('INDEX:BTCUSD', '1D', ta.hma(math.abs(rsi), rsiLen)) band0 = hline(80, "Overbought", color=#787B86, linestyle=hline.style_dashed) band1 = hline(20, "Oversold", color=#787B86, linestyle=hline.style_dashed) band2 = hline(50, "Middle", color=#787B86, linestyle=hline.style_dashed) // Dynamic coloring function to detect trend b_col = color.from_gradient(osc, 0, 100, color.rgb(8,255,8), color.rgb(225,6,0)) plot(osc, "Osc", b_col , 4) // Enveloping AMA with ATR bands env_MA = _ama float dev = 0.0 dev := request.security('INDEX:BTCUSD', '1D', atr_mult * ta.atr(env_atr)) // Bands b1 = env_MA + 0.236 * dev t1 = env_MA + 0.764 * dev t2 = env_MA + dev bottom = madif < 20 local_b = _low < b1 and not bottom out = request.security('INDEX:BTCUSD', '1D', high) > t2 local_out = request.security('INDEX:BTCUSD', '1D', high) > t1 and not out bgcolor(bottom ? color.rgb(47, 249, 36, 60) : na) bgcolor(local_b ? color.rgb(83,176,174, 70) : na) bgcolor(out ? color.rgb(225,6,0, 60) : na) bgcolor(local_out ? color.rgb(219,62,121, 80) : na)
McDonald's Pattern [LuxAlgo]
https://www.tradingview.com/script/BbHc0nIt-McDonald-s-Pattern-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
2,444
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("McDonald's Pattern [LuxAlgo]",overlay=true,max_lines_count=500,max_bars_back=500) length = input(30) from_start = input(true,'Use First Bar As Vertex') css = input(#FFC72C,'Shape Color',group='Style') min_width = input(2,'Width',inline='b',group='Style') max_width = input(30,'',inline='b',group='Style') colored_area = input(true,'Area',inline='c',group='Style') css_dn = input(#DA291C,'',inline='c',group='Style') css_up = input(#0cb51a,'',inline='c',group='Style') show_score = input(true,"McDonald's Score") //---- os = 0 src = close n = bar_index var float valtop = na var float valbtm = na var tb = table.new(position.top_right,1,2) //------------------------------------------------------------------------------ var Y = array.new_float(0) var X = array.new_int(0) a = math.max(close,open) b = math.min(close,open) upper = ta.highest(a,length) lower = ta.lowest(b,length) os := a[length] > upper ? 0 : b[length] < lower ? 1 : os[1] btm = os == 1 and os[1] != 1 top = os == 0 and os[1] != 0 if top array.unshift(Y,a[length]) array.unshift(X,n-length) if btm array.unshift(Y,b[length]) array.unshift(X,n-length) //---- plotchar(top ? high[length] : na,"Top",'🍟',location.abovebar,offset=-length,size=size.tiny) plotchar(btm ? low[length] : na,"Bottom",'🍔',location.belowbar,offset=-length,size=size.tiny) //---- a_y = 0.,b_y = 0. c_y = 0.,d_y = 0. if barstate.islast dist_a = 0. dist_b = 0. for l in line.all line.delete(l) if from_start array.unshift(Y,close) array.unshift(X,n) max = array.max(array.slice(Y,0,5)) min = array.min(array.slice(Y,0,5)) val = array.get(Y,0) < array.get(Y,1) ? min : max //---- dist1 = array.get(X,0) - array.get(X,2) a_y := array.get(Y,2),b_y := array.get(Y,1) c_y := array.get(Y,1),d_y := array.get(Y,0) float y1 = na for i = 0 to dist1 k = i/dist1 y2 = a_y*math.pow(1 - k,3) + 3*b_y*math.pow(1 - k,2)*k + 3*c_y*(1 - k)*math.pow(k,2) + d_y*math.pow(k,3) dist_a += math.abs(y2 - val) r = (array.get(X,0) - array.get(X,1))/dist1 w = min_width + math.abs(i/dist1 - r)*(max_width-min_width) line.new(array.get(X,2)+i,y2,array.get(X,2)+i-1,y1,color=css,width=w) y1 := y2 //---- dist2 = array.get(X,2) - array.get(X,4) a_y := array.get(Y,4),b_y := array.get(Y,3) c_y := array.get(Y,3),d_y := array.get(Y,2) y1 := na for i = 0 to dist2 k = i/dist2 y2 = a_y*math.pow(1 - k,3) + 3*b_y*math.pow(1 - k,2)*k + 3*c_y*(1 - k)*math.pow(k,2) + d_y*math.pow(k,3) dist_b += math.abs(y2 - val) r = (array.get(X,3) - array.get(X,4))/dist2 w = min_width + math.abs(i/dist2 - r)*(max_width-min_width) line.new(array.get(X,4)+i,y2,array.get(X,4)+i-1,y1,color=css,width=w) y1 := y2 if colored_area area_css = array.get(Y,0) < array.get(Y,1) ? css_dn : css_up box.delete(box.new(array.get(X,4),max, array.get(X,0),min, border_color=na, bgcolor=color.new(area_css,80))[1]) if from_start array.shift(Y) array.shift(X) //---- a = dist_a/dist1 b = dist_b/dist2 score = (1 - math.abs(a/(a+b) - .5)*2)*100 if show_score table.cell(tb,0,0,"McDonald's Score",text_color=color.gray) table.cell(tb,0,1,str.tostring(score,'#.##')+'%',text_color=color.gray) // I'm lovin' it
One Year Return
https://www.tradingview.com/script/Q8eHL2Z8-One-Year-Return/
lucasschnare1
https://www.tradingview.com/u/lucasschnare1/
38
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/ // © lucasschnare1 //@version=4 study("One yr return") hi = input(false, "Average Return above 0") lo = input(false, "Average Return below 0") return1 = (((close - close[50]) / close[50] ) *100 ) color1 = return1 >= 0 ? color.blue : color.yellow plot(0, color = color1) re = cum(return1) / bar_index rere = bar_index count1 = return1 < 0 ? 1 : 0 count2 = return1 > 0 ? 1 : 0 total1 = cum(count1) total2 = cum(count2) lowavg = return1 < 0 ? return1 : 0 highavg = return1 > 0 ? return1 : 0 t1 = cum(lowavg) / total1 t2 = cum(highavg) / total2 color2 = color.new(color.green, transp = 100) color3 = color.new(color.red, transp = 100) y1 = plot(lo ? t1 : na, color = color3) y2 = plot(hi ? t2 : na, color = color2) fill(y1, y2, color = color.blue) plot(return1, color = color1)
Compound Indicator
https://www.tradingview.com/script/wPmDa7a1-Compound-Indicator/
pcooma
https://www.tradingview.com/u/pcooma/
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/ // © pcooma //@version=5 indicator("Compound Indicator", shorttitle="Compound Indicator", overlay=true, precision = 5) var show = input.string(title = "Show graph", options=['NONE','positive_signal','Volume Ocilator', 'Momentum Ocilator', 'Stochastic Indicator', 'RSI', 'MFI', 'RVI','BOP', 'SMA', 'EMA'], defval='NONE') hl_period = input.int(defval = 50,title = "look back period") //Values for calculation price_average_previous_bar = (open + close)/2 price_average_current_bar = (high+low)/2 volume_average = ta.sma(volume,100) var float positive_signal = 0 //Volume Change Ocillator var float cumVol = 0. var float short = 0.0 var float long = 1.0 cumVol += nz(volume) if barstate.islast and cumVol == 0 runtime.error("No volume is provided by the data vendor.") shortlen = input.int(5, minval=1, title = "Short Length of volume change ocillator", group = "Volume Change Ocillator") longlen = input.int(200, minval=1, title = "Long Length of volume change ocillator", group = "Volume Change Ocillator") cal_method_osc = input.string(title = "Calculation method of volume change ocillator is", options=['EMA', 'SMA'], defval='SMA', group = "Volume Change Ocillator") if cal_method_osc == 'SMA' short := ta.sma(volume, shortlen) long := ta.sma(volume, longlen) else if cal_method_osc == 'EMA' short := ta.ema(volume, shortlen) long := ta.ema(volume, longlen) osc = 100 * (short - long) / long osc_crossunder_100 = ta.crossunder(osc,100) osc_crossunder_200 = ta.crossunder(osc,200) osc_crossunder_300 = ta.crossunder(osc,300) osc_crossunder_400 = ta.crossunder(osc,400) osc_crossunder_500 = ta.crossunder(osc,500) osc_crossunder_600 = ta.crossunder(osc,600) osc_crossunder_700 = ta.crossunder(osc,700) osc_crossunder_800 = ta.crossunder(osc,800) osc_crossunder_900 = ta.crossunder(osc,900) osc_crossunder_1000 = ta.crossunder(osc,1000) osc_crossover_100 = ta.crossover(osc,100) osc_crossover_200 = ta.crossover(osc,200) osc_crossover_300 = ta.crossover(osc,300) osc_crossover_400 = ta.crossover(osc,400) osc_crossover_500 = ta.crossover(osc,500) osc_crossover_600 = ta.crossover(osc,600) osc_crossover_700 = ta.crossover(osc,700) osc_crossover_800 = ta.crossover(osc,800) osc_crossover_900 = ta.crossover(osc,900) osc_crossover_1000 = ta.crossover(osc,1000) if open < close if osc_crossover_100 positive_signal := positive_signal + 1 else if osc_crossunder_100 positive_signal := positive_signal - 1 else if osc_crossover_200 positive_signal := positive_signal + 1 else if osc_crossunder_200 positive_signal := positive_signal - 1 else if osc_crossover_300 positive_signal := positive_signal + 1 else if osc_crossunder_300 positive_signal := positive_signal - 1 else if osc_crossover_400 positive_signal := positive_signal + 1 else if osc_crossunder_400 positive_signal := positive_signal - 1 else if osc_crossover_500 positive_signal := positive_signal + 1 else if osc_crossunder_500 positive_signal := positive_signal - 1 else if osc_crossover_600 positive_signal := positive_signal + 1 else if osc_crossunder_600 positive_signal := positive_signal - 1 else if osc_crossover_700 positive_signal := positive_signal + 1 else if osc_crossunder_700 positive_signal := positive_signal - 1 else if osc_crossover_800 positive_signal := positive_signal + 1 else if osc_crossunder_800 positive_signal := positive_signal - 1 else if osc_crossover_900 positive_signal := positive_signal + 1 else if osc_crossunder_900 positive_signal := positive_signal - 1 else if osc_crossover_1000 positive_signal := positive_signal + 1 else if osc_crossunder_1000 positive_signal := positive_signal - 1 else if open > close if osc_crossover_100 positive_signal := positive_signal - 1 else if osc_crossunder_100 positive_signal := positive_signal + 1 else if osc_crossover_200 positive_signal := positive_signal - 1 else if osc_crossunder_200 positive_signal := positive_signal + 1 else if osc_crossover_300 positive_signal := positive_signal - 1 else if osc_crossunder_300 positive_signal := positive_signal + 1 else if osc_crossover_400 positive_signal := positive_signal - 1 else if osc_crossunder_400 positive_signal := positive_signal + 1 else if osc_crossover_500 positive_signal := positive_signal - 1 else if osc_crossunder_500 positive_signal := positive_signal + 1 else if osc_crossover_600 positive_signal := positive_signal - 1 else if osc_crossunder_600 positive_signal := positive_signal + 1 else if osc_crossover_700 positive_signal := positive_signal - 1 else if osc_crossunder_700 positive_signal := positive_signal + 1 else if osc_crossover_800 positive_signal := positive_signal - 1 else if osc_crossunder_800 positive_signal := positive_signal + 1 else if osc_crossover_900 positive_signal := positive_signal - 1 else if osc_crossunder_900 positive_signal := positive_signal + 1 else if osc_crossover_1000 positive_signal := positive_signal - 1 else if osc_crossunder_1000 positive_signal := positive_signal + 1 // Momemtum Ocillator src_mom_10 = input(close, title = "Source of MOM - 10", group = "Momentun Ocillator") lb_mom_10 = 10 momm_10 = ta.change(src_mom_10) f1_10(m_10) => m_10 >= 0.0 ? m_10 : 0.0 f2_10(m_10) => m_10 >= 0.0 ? 0.0 : -m_10 m1_10 = f1_10(momm_10) m2_10 = f2_10(momm_10) sm1_10 = math.sum(m1_10, lb_mom_10) sm2_10 = math.sum(m2_10, lb_mom_10) percent_10(nom_10, div_10) => 100 * nom_10 / div_10 chandeMO_10 = percent_10(sm1_10-sm2_10, sm1_10+sm2_10) src_mom_50 = input(close, title = "Source of MOM - 50", group = "Momentun Ocillator") lb_mom_50 = 50 momm_50 = ta.change(src_mom_50) f1_50(m_50) => m_50 >= 0.0 ? m_50 : 0.0 f2_50(m_50) => m_50 >= 0.0 ? 0.0 : -m_50 m1_50 = f1_50(momm_50) m2_50 = f2_50(momm_50) sm1_50 = math.sum(m1_50, lb_mom_50) sm2_50 = math.sum(m2_50, lb_mom_50) percent_50(nom_50, div_50) => 100 * nom_50 / div_50 chandeMO_50 = percent_50(sm1_50-sm2_50, sm1_50+sm2_50) src_mom_100 = input(close, title = "Source of MOM - 100", group = "Momentun Ocillator") lb_mom_100 = 100 momm_100 = ta.change(src_mom_100) f1_100(m_100) => m_100 >= 0.0 ? m_100 : 0.0 f2_100(m_100) => m_100 >= 0.0 ? 0.0 : -m_100 m1_100 = f1_100(momm_100) m2_100 = f2_100(momm_100) sm1_100 = math.sum(m1_100, lb_mom_100) sm2_100 = math.sum(m2_100, lb_mom_100) percent_100(nom_100, div_100) => 100 * nom_100 / div_100 chandeMO_100 = percent_100(sm1_100-sm2_100, sm1_100+sm2_100) src_mom_200 = input(close, title = "Source of MOM - 200", group = "Momentun Ocillator") lb_mom_200 = 200 momm_200 = ta.change(src_mom_200) f1_200(m_200) => m_200 >= 0.0 ? m_200 : 0.0 f2_200(m_200) => m_200 >= 0.0 ? 0.0 : -m_200 m1_200 = f1_200(momm_200) m2_200 = f2_200(momm_200) sm1_200 = math.sum(m1_200, lb_mom_200) sm2_200 = math.sum(m2_200, lb_mom_200) percent_200(nom_200, div_200) => 100 * nom_200 / div_200 chandeMO_200 = percent_200(sm1_200-sm2_200, sm1_200+sm2_200) //MOM graphs cross over and cross under each other mom_10_crossover_50 = ta.crossover(chandeMO_10,chandeMO_50) mom_10_crossover_100 = ta.crossover(chandeMO_10,chandeMO_100) mom_10_crossover_200 = ta.crossover(chandeMO_10,chandeMO_200) mom_50_crossover_100 = ta.crossover(chandeMO_50,chandeMO_100) mom_50_crossover_200 = ta.crossover(chandeMO_50,chandeMO_200) mom_100_crossover_200 = ta.crossover(chandeMO_100,chandeMO_200) mom_10_crossunder_50 = ta.crossunder(chandeMO_10,chandeMO_50) mom_10_crossunder_100 = ta.crossunder(chandeMO_10,chandeMO_100) mom_10_crossunder_200 = ta.crossunder(chandeMO_10,chandeMO_200) mom_50_crossunder_100 = ta.crossunder(chandeMO_50,chandeMO_100) mom_50_crossunder_200 = ta.crossunder(chandeMO_50,chandeMO_200) mom_100_crossunder_200 = ta.crossunder(chandeMO_100,chandeMO_200) if mom_10_crossover_50 or mom_10_crossover_100 or mom_10_crossover_200 or mom_50_crossover_100 or mom_50_crossover_200 or mom_100_crossover_200 positive_signal := positive_signal + 1 if mom_10_crossunder_50 or mom_10_crossunder_100 or mom_10_crossunder_200 or mom_50_crossunder_100 or mom_50_crossunder_200 or mom_100_crossunder_200 positive_signal := positive_signal - 1 //MOM cross over and cross under different values mom_10_crossover_val_10 = ta.crossover(chandeMO_10,10) mom_10_crossover_val_20 = ta.crossover(chandeMO_10,20) mom_10_crossover_val_30 = ta.crossover(chandeMO_10,30) mom_10_crossover_val_40 = ta.crossover(chandeMO_10,40) mom_10_crossover_val_50 = ta.crossover(chandeMO_10,50) mom_10_crossover_val_60 = ta.crossover(chandeMO_10,60) mom_10_crossover_val_70 = ta.crossover(chandeMO_10,70) mom_10_crossover_val_80 = ta.crossover(chandeMO_10,80) mom_10_crossover_val_90 = ta.crossover(chandeMO_10,90) mom_10_crossover_val_100 = ta.crossover(chandeMO_10,100) mom_10_crossunder_val_10 = ta.crossunder(chandeMO_10,10) mom_10_crossunder_val_20 = ta.crossunder(chandeMO_10,20) mom_10_crossunder_val_30 = ta.crossunder(chandeMO_10,30) mom_10_crossunder_val_40 = ta.crossunder(chandeMO_10,40) mom_10_crossunder_val_50 = ta.crossunder(chandeMO_10,50) mom_10_crossunder_val_60 = ta.crossunder(chandeMO_10,60) mom_10_crossunder_val_70 = ta.crossunder(chandeMO_10,70) mom_10_crossunder_val_80 = ta.crossunder(chandeMO_10,80) mom_10_crossunder_val_90 = ta.crossunder(chandeMO_10,90) mom_10_crossunder_val_100 = ta.crossunder(chandeMO_10,100) mom_50_crossover_val_10 = ta.crossover(chandeMO_50,4) mom_50_crossover_val_20 = ta.crossover(chandeMO_50,8) mom_50_crossover_val_30 = ta.crossover(chandeMO_50,12) mom_50_crossover_val_40 = ta.crossover(chandeMO_50,16) mom_50_crossover_val_50 = ta.crossover(chandeMO_50,20) mom_50_crossover_val_60 = ta.crossover(chandeMO_50,24) mom_50_crossover_val_70 = ta.crossover(chandeMO_50,28) mom_50_crossover_val_80 = ta.crossover(chandeMO_50,32) mom_50_crossover_val_90 = ta.crossover(chandeMO_50,36) mom_50_crossover_val_100 = ta.crossover(chandeMO_50,40) mom_50_crossunder_val_10 = ta.crossunder(chandeMO_50,-4) mom_50_crossunder_val_20 = ta.crossunder(chandeMO_50,-8) mom_50_crossunder_val_30 = ta.crossunder(chandeMO_50,-12) mom_50_crossunder_val_40 = ta.crossunder(chandeMO_50,-16) mom_50_crossunder_val_50 = ta.crossunder(chandeMO_50,-20) mom_50_crossunder_val_60 = ta.crossunder(chandeMO_50,-24) mom_50_crossunder_val_70 = ta.crossunder(chandeMO_50,-28) mom_50_crossunder_val_80 = ta.crossunder(chandeMO_50,-32) mom_50_crossunder_val_90 = ta.crossunder(chandeMO_50,-36) mom_50_crossunder_val_100 = ta.crossunder(chandeMO_50,-40) mom_100_crossover_val_10 = ta.crossover(chandeMO_100,3.5) mom_100_crossover_val_20 = ta.crossover(chandeMO_100,7.0) mom_100_crossover_val_30 = ta.crossover(chandeMO_100,10.5) mom_100_crossover_val_40 = ta.crossover(chandeMO_100,14.0) mom_100_crossover_val_50 = ta.crossover(chandeMO_100,17.5) mom_100_crossover_val_60 = ta.crossover(chandeMO_100,21.0) mom_100_crossover_val_70 = ta.crossover(chandeMO_100,24.5) mom_100_crossover_val_80 = ta.crossover(chandeMO_100,28.0) mom_100_crossover_val_90 = ta.crossover(chandeMO_100,31.5) mom_100_crossover_val_100 = ta.crossover(chandeMO_100,35) mom_100_crossunder_val_10 = ta.crossunder(chandeMO_100,-3.5) mom_100_crossunder_val_20 = ta.crossunder(chandeMO_100,-7) mom_100_crossunder_val_30 = ta.crossunder(chandeMO_100,-10.5) mom_100_crossunder_val_40 = ta.crossunder(chandeMO_100,-14) mom_100_crossunder_val_50 = ta.crossunder(chandeMO_100,-17.5) mom_100_crossunder_val_60 = ta.crossunder(chandeMO_100,-21) mom_100_crossunder_val_70 = ta.crossunder(chandeMO_100,-24.5) mom_100_crossunder_val_80 = ta.crossunder(chandeMO_100,-28) mom_100_crossunder_val_90 = ta.crossunder(chandeMO_100,-31.5) mom_100_crossunder_val_100 = ta.crossunder(chandeMO_100,-35) mom_200_crossover_val_10 = ta.crossover(chandeMO_200,2) mom_200_crossover_val_20 = ta.crossover(chandeMO_200,4) mom_200_crossover_val_30 = ta.crossover(chandeMO_200,6) mom_200_crossover_val_40 = ta.crossover(chandeMO_200,8) mom_200_crossover_val_50 = ta.crossover(chandeMO_200,10) mom_200_crossover_val_60 = ta.crossover(chandeMO_200,12) mom_200_crossover_val_70 = ta.crossover(chandeMO_200,14) mom_200_crossover_val_80 = ta.crossover(chandeMO_200,16) mom_200_crossover_val_90 = ta.crossover(chandeMO_200,18) mom_200_crossover_val_100 = ta.crossover(chandeMO_200,20) mom_200_crossunder_val_10 = ta.crossunder(chandeMO_200,-2) mom_200_crossunder_val_20 = ta.crossunder(chandeMO_200,-4) mom_200_crossunder_val_30 = ta.crossunder(chandeMO_200,-6) mom_200_crossunder_val_40 = ta.crossunder(chandeMO_200,-8) mom_200_crossunder_val_50 = ta.crossunder(chandeMO_200,-10) mom_200_crossunder_val_60 = ta.crossunder(chandeMO_200,-12) mom_200_crossunder_val_70 = ta.crossunder(chandeMO_200,-14) mom_200_crossunder_val_80 = ta.crossunder(chandeMO_200,-16) mom_200_crossunder_val_90 = ta.crossunder(chandeMO_200,-18) mom_200_crossunder_val_100 = ta.crossunder(chandeMO_200,-20) if mom_10_crossover_val_10 or mom_10_crossover_val_20 or mom_10_crossover_val_30 or mom_10_crossover_val_40 or mom_10_crossover_val_50 or mom_10_crossover_val_60 or mom_10_crossover_val_70 or mom_10_crossover_val_80 or mom_10_crossover_val_90 or mom_10_crossover_val_100 or mom_50_crossover_val_10 or mom_50_crossover_val_20 or mom_50_crossover_val_30 or mom_50_crossover_val_40 or mom_50_crossover_val_50 or mom_50_crossover_val_60 or mom_50_crossover_val_70 or mom_50_crossover_val_80 or mom_50_crossover_val_90 or mom_50_crossover_val_100 or mom_100_crossover_val_10 or mom_100_crossover_val_20 or mom_100_crossover_val_30 or mom_100_crossover_val_40 or mom_100_crossover_val_50 or mom_100_crossover_val_60 or mom_100_crossover_val_70 or mom_100_crossover_val_80 or mom_100_crossover_val_90 or mom_100_crossover_val_100 or mom_200_crossover_val_10 or mom_200_crossover_val_20 or mom_200_crossover_val_30 or mom_200_crossover_val_40 or mom_200_crossover_val_50 or mom_200_crossover_val_60 or mom_200_crossover_val_70 or mom_200_crossover_val_80 or mom_200_crossover_val_90 or mom_200_crossover_val_100 positive_signal := positive_signal + 1 if mom_10_crossunder_val_10 or mom_10_crossunder_val_20 or mom_10_crossunder_val_30 or mom_10_crossunder_val_40 or mom_10_crossunder_val_50 or mom_10_crossunder_val_60 or mom_10_crossunder_val_70 or mom_10_crossunder_val_80 or mom_10_crossunder_val_90 or mom_10_crossunder_val_100 or mom_50_crossunder_val_10 or mom_50_crossunder_val_20 or mom_50_crossunder_val_30 or mom_50_crossunder_val_40 or mom_50_crossunder_val_50 or mom_50_crossunder_val_60 or mom_50_crossunder_val_70 or mom_50_crossunder_val_80 or mom_50_crossunder_val_90 or mom_50_crossunder_val_100 or mom_100_crossunder_val_10 or mom_100_crossunder_val_20 or mom_100_crossunder_val_30 or mom_100_crossunder_val_40 or mom_100_crossunder_val_50 or mom_100_crossunder_val_60 or mom_100_crossunder_val_70 or mom_100_crossunder_val_80 or mom_100_crossunder_val_90 or mom_100_crossunder_val_100 or mom_200_crossunder_val_10 or mom_200_crossunder_val_20 or mom_200_crossunder_val_30 or mom_200_crossunder_val_40 or mom_200_crossunder_val_50 or mom_200_crossunder_val_60 or mom_200_crossunder_val_70 or mom_200_crossunder_val_80 or mom_200_crossunder_val_90 or mom_200_crossunder_val_100 positive_signal := positive_signal - 1 //Stochastic Indicator period_of_stoch_ind = input.string (title = "Look back period of stochastic indicator", options=['10', '50','100','200'], defval='100', group = "Stochastic Indicator") var int periodK = 0 var int smoothK = 0 var int periodD = 0 if period_of_stoch_ind == '10' periodK := 10 smoothK := 1 periodD := 3 else if period_of_stoch_ind == '50' periodK := 50 smoothK := 5 periodD := 5 else if period_of_stoch_ind == '100' periodK := 100 smoothK := 10 periodD := 10 else if period_of_stoch_ind == '200' periodK := 200 smoothK := 10 periodD := 10 k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) // Graphs crossover and cross under each other k_10 = ta.sma(ta.stoch(close, high, low, 10), 1) d_10 = ta.sma(k, 3) k_50 = ta.sma(ta.stoch(close, high, low, 50), 5) d_50 = ta.sma(k, 5) k_100 = ta.sma(ta.stoch(close, high, low, 100), 10) d_100 = ta.sma(k, 10) k_200 = ta.sma(ta.stoch(close, high, low, 200), 10) d_200 = ta.sma(k, 10) k_10_crossover_k_50 = ta.crossover(k_10,k_50) k_10_crossover_k_100 = ta.crossover(k_10,k_100) k_10_crossover_k_200 = ta.crossover(k_10,k_200) k_50_crossover_k_100 = ta.crossover(k_50,k_100) k_50_crossover_k_200 = ta.crossover(k_50,k_200) k_100_crossover_k_200 = ta.crossover(k_100,k_200) k_10_crossunder_k_50 = ta.crossunder(k_10,k_50) k_10_crossunder_k_100 = ta.crossunder(k_10,k_100) k_10_crossunder_k_200 = ta.crossunder(k_10,k_200) k_50_crossunder_k_100 = ta.crossunder(k_50,k_100) k_50_crossunder_k_200 = ta.crossunder(k_50,k_200) k_100_crossunder_k_200 = ta.crossunder(k_100,k_200) // Values cross over each other var bool stochastic_10_buy = false var bool stochastic_50_buy = false var bool stochastic_100_buy = false var bool stochastic_200_buy = false if k_10 >= d_10 stochastic_10_buy := true else stochastic_10_buy := false if k_50 >= d_50 stochastic_50_buy := true else stochastic_50_buy := false if k_100 >= d_100 stochastic_100_buy := true else stochastic_100_buy := false if k_200 >= d_200 stochastic_200_buy := true else stochastic_200_buy := false if k_10_crossover_k_50 or k_10_crossover_k_100 or k_10_crossover_k_200 or k_50_crossover_k_100 or k_50_crossover_k_200 or k_100_crossover_k_200 positive_signal := positive_signal + 1 if k_10_crossunder_k_50 or k_10_crossunder_k_100 or k_10_crossunder_k_200 or k_50_crossunder_k_100 or k_50_crossunder_k_200 or k_100_crossunder_k_200 positive_signal := positive_signal - 1 if stochastic_10_buy == true or stochastic_50_buy == true or stochastic_100_buy == true or stochastic_100_buy == true positive_signal := positive_signal + 1 if stochastic_10_buy == false or stochastic_50_buy == false or stochastic_100_buy == false or stochastic_100_buy == false positive_signal := positive_signal - 1 //Multi timeframe RSI src_rsi_10 = input(close, title = "Source of RSI - 10", group = "Relative Strength Index (RSI)", inline = "10") lb_rsi_10 = 10 rsi_10 = ta.rsi(src_rsi_10,lb_rsi_10) src_rsi_50 = input(close, title = "Source of RSI - 50", group = "Relative Strength Index (RSI)", inline = "50") lb_rsi_50 = 50 rsi_50 = ta.rsi(src_rsi_50,lb_rsi_50) src_rsi_100 = input(close, title = "Source of RSI - 100", group = "Relative Strength Index (RSI)", inline = "100") lb_rsi_100 = 100 rsi_100 = ta.rsi(src_rsi_100,lb_rsi_100) src_rsi_200 = input(close, title = "Source of RSI - 200", group = "Relative Strength Index (RSI)", inline = "200") lb_rsi_200 = 200 rsi_200 = ta.rsi(src_rsi_200,lb_rsi_200) //RSI Graphs cross eachother rsi_10_crossover_rsi_50 = ta.crossover(rsi_10,rsi_50) rsi_10_crossover_rsi_100 = ta.crossover(rsi_10,rsi_100) rsi_10_crossover_rsi_200 = ta.crossover(rsi_10,rsi_200) rsi_50_crossover_rsi_100 = ta.crossover(rsi_50,rsi_100) rsi_50_crossover_rsi_200 = ta.crossover(rsi_50,rsi_200) rsi_100_crossover_rsi_200 = ta.crossover(rsi_100,rsi_200) rsi_10_crossunder_rsi_50 = ta.crossunder(rsi_10,rsi_50) rsi_10_crossunder_rsi_100 = ta.crossunder(rsi_10,rsi_100) rsi_10_crossunder_rsi_200 = ta.crossunder(rsi_10,rsi_200) rsi_50_crossunder_rsi_100 = ta.crossunder(rsi_50,rsi_100) rsi_50_crossunder_rsi_200 = ta.crossunder(rsi_50,rsi_200) rsi_100_crossunder_rsi_200 = ta.crossunder(rsi_100,rsi_200) if rsi_10_crossover_rsi_50 or rsi_10_crossover_rsi_100 or rsi_10_crossover_rsi_200 or rsi_50_crossover_rsi_100 or rsi_50_crossover_rsi_200 or rsi_100_crossover_rsi_200 positive_signal := positive_signal + 1 if rsi_10_crossunder_rsi_50 or rsi_10_crossunder_rsi_100 or rsi_10_crossunder_rsi_200 or rsi_50_crossunder_rsi_100 or rsi_50_crossunder_rsi_200 or rsi_100_crossunder_rsi_200 positive_signal := positive_signal - 1 //RSI crossing different values rsi_10_crossover_val_0 = ta.cross(rsi_10,0) rsi_10_crossover_val_10 = ta.crossover(rsi_10,10) rsi_10_crossover_val_20 = ta.crossover(rsi_10,20) rsi_10_crossover_val_30 = ta.crossover(rsi_10,30) rsi_10_crossover_val_40 = ta.crossover(rsi_10,40) rsi_10_crossover_val_50 = ta.crossover(rsi_10,50) rsi_10_crossover_val_60 = ta.crossover(rsi_10,60) rsi_10_crossover_val_70 = ta.crossover(rsi_10,70) rsi_10_crossover_val_80 = ta.crossover(rsi_10,80) rsi_10_crossover_val_90 = ta.crossover(rsi_10,90) rsi_10_crossover_val_100 = ta.cross(rsi_10,100) rsi_10_crossunder_val_0 = ta.cross(rsi_10,0) rsi_10_crossunder_val_10 = ta.crossunder(rsi_10,10) rsi_10_crossunder_val_20 = ta.crossunder(rsi_10,20) rsi_10_crossunder_val_30 = ta.crossunder(rsi_10,30) rsi_10_crossunder_val_40 = ta.crossunder(rsi_10,40) rsi_10_crossunder_val_50 = ta.crossunder(rsi_10,50) rsi_10_crossunder_val_60 = ta.crossunder(rsi_10,60) rsi_10_crossunder_val_70 = ta.crossunder(rsi_10,70) rsi_10_crossunder_val_80 = ta.crossunder(rsi_10,80) rsi_10_crossunder_val_90 = ta.crossunder(rsi_10,90) rsi_10_crossunder_val_100 = ta.cross(rsi_10,100) if rsi_10_crossover_val_0 or rsi_10_crossover_val_10 or rsi_10_crossover_val_20 or rsi_10_crossover_val_30 or rsi_10_crossover_val_40 or rsi_10_crossover_val_50 or rsi_10_crossover_val_60 or rsi_10_crossover_val_70 or rsi_10_crossover_val_80 or rsi_10_crossover_val_90 or rsi_10_crossover_val_100 positive_signal := positive_signal + 1 if rsi_10_crossunder_val_0 or rsi_10_crossunder_val_10 or rsi_10_crossunder_val_20 or rsi_10_crossunder_val_30 or rsi_10_crossunder_val_40 or rsi_10_crossunder_val_50 or rsi_10_crossunder_val_60 or rsi_10_crossunder_val_70 or rsi_10_crossunder_val_80 or rsi_10_crossunder_val_90 or rsi_10_crossunder_val_100 positive_signal := positive_signal - 1 rsi_50_crossover_val_75 = ta.crossover(rsi_50,75) rsi_50_crossover_val_70 = ta.crossover(rsi_50,70) rsi_50_crossover_val_65 = ta.crossover(rsi_50,65) rsi_50_crossover_val_60 = ta.crossover(rsi_50,60) rsi_50_crossover_val_55 = ta.crossover(rsi_50,55) rsi_50_crossover_val_50 = ta.crossover(rsi_50,50) rsi_50_crossover_val_45 = ta.crossover(rsi_50,45) rsi_50_crossover_val_40 = ta.crossover(rsi_50,40) rsi_50_crossover_val_35 = ta.crossover(rsi_50,35) rsi_50_crossover_val_30 = ta.crossover(rsi_50,30) rsi_50_crossover_val_25 = ta.crossover(rsi_50,25) rsi_50_crossunder_val_75 = ta.crossunder(rsi_50,75) rsi_50_crossunder_val_70 = ta.crossunder(rsi_50,70) rsi_50_crossunder_val_65 = ta.crossunder(rsi_50,65) rsi_50_crossunder_val_60 = ta.crossunder(rsi_50,60) rsi_50_crossunder_val_55 = ta.crossunder(rsi_50,55) rsi_50_crossunder_val_50 = ta.crossunder(rsi_50,50) rsi_50_crossunder_val_45 = ta.crossunder(rsi_50,45) rsi_50_crossunder_val_40 = ta.crossunder(rsi_50,40) rsi_50_crossunder_val_35 = ta.crossunder(rsi_50,35) rsi_50_crossunder_val_30 = ta.crossunder(rsi_50,30) rsi_50_crossunder_val_25 = ta.crossunder(rsi_50,25) if rsi_50_crossover_val_75 or rsi_50_crossover_val_70 or rsi_50_crossover_val_65 or rsi_50_crossover_val_60 or rsi_50_crossover_val_55 or rsi_50_crossover_val_50 or rsi_50_crossover_val_45 or rsi_50_crossover_val_40 or rsi_50_crossover_val_35 or rsi_50_crossover_val_30 or rsi_50_crossover_val_25 positive_signal := positive_signal + 1 if rsi_50_crossunder_val_75 or rsi_50_crossunder_val_70 or rsi_50_crossunder_val_65 or rsi_50_crossunder_val_60 or rsi_50_crossunder_val_55 or rsi_50_crossunder_val_50 or rsi_50_crossunder_val_45 or rsi_50_crossunder_val_40 or rsi_50_crossunder_val_35 or rsi_50_crossunder_val_30 or rsi_50_crossunder_val_25 positive_signal := positive_signal - 1 rsi_100_crossover_val_65 = ta.crossover(rsi_100,65) rsi_100_crossover_val_62 = ta.crossover(rsi_100,62) rsi_100_crossover_val_59 = ta.crossover(rsi_100,59) rsi_100_crossover_val_56 = ta.crossover(rsi_100,56) rsi_100_crossover_val_53 = ta.crossover(rsi_100,53) rsi_100_crossover_val_50 = ta.crossover(rsi_100,50) rsi_100_crossover_val_47 = ta.crossover(rsi_100,47) rsi_100_crossover_val_44 = ta.crossover(rsi_100,44) rsi_100_crossover_val_41 = ta.crossover(rsi_100,41) rsi_100_crossover_val_38 = ta.crossover(rsi_100,38) rsi_100_crossover_val_35 = ta.crossover(rsi_100,35) rsi_100_crossunder_val_65 = ta.crossunder(rsi_100,65) rsi_100_crossunder_val_62 = ta.crossunder(rsi_100,62) rsi_100_crossunder_val_59 = ta.crossunder(rsi_100,59) rsi_100_crossunder_val_56 = ta.crossunder(rsi_100,56) rsi_100_crossunder_val_53 = ta.crossunder(rsi_100,53) rsi_100_crossunder_val_50 = ta.crossunder(rsi_100,50) rsi_100_crossunder_val_47 = ta.crossunder(rsi_100,47) rsi_100_crossunder_val_44 = ta.crossunder(rsi_100,44) rsi_100_crossunder_val_41 = ta.crossunder(rsi_100,41) rsi_100_crossunder_val_38 = ta.crossunder(rsi_100,38) rsi_100_crossunder_val_35 = ta.crossunder(rsi_100,35) if rsi_100_crossover_val_65 or rsi_100_crossover_val_62 or rsi_100_crossover_val_59 or rsi_100_crossover_val_56 or rsi_100_crossover_val_53 or rsi_100_crossover_val_50 or rsi_100_crossover_val_47 or rsi_100_crossover_val_44 or rsi_100_crossover_val_41 or rsi_100_crossover_val_38 or rsi_100_crossover_val_35 positive_signal := positive_signal + 1 if rsi_100_crossunder_val_65 or rsi_100_crossunder_val_62 or rsi_100_crossunder_val_59 or rsi_100_crossunder_val_56 or rsi_100_crossunder_val_53 or rsi_100_crossunder_val_50 or rsi_100_crossunder_val_47 or rsi_100_crossunder_val_44 or rsi_100_crossunder_val_41 or rsi_100_crossunder_val_38 or rsi_100_crossunder_val_35 positive_signal := positive_signal - 1 rsi_200_crossover_val_60 = ta.crossover(rsi_200,60) rsi_200_crossover_val_58 = ta.crossover(rsi_200,58) rsi_200_crossover_val_56 = ta.crossover(rsi_200,56) rsi_200_crossover_val_54 = ta.crossover(rsi_200,54) rsi_200_crossover_val_52 = ta.crossover(rsi_200,52) rsi_200_crossover_val_50 = ta.crossover(rsi_200,50) rsi_200_crossover_val_48 = ta.crossover(rsi_200,48) rsi_200_crossover_val_46 = ta.crossover(rsi_200,46) rsi_200_crossover_val_44 = ta.crossover(rsi_200,44) rsi_200_crossover_val_42 = ta.crossover(rsi_200,42) rsi_200_crossover_val_40 = ta.crossover(rsi_200,40) rsi_200_crossunder_val_60 = ta.crossunder(rsi_200,60) rsi_200_crossunder_val_58 = ta.crossunder(rsi_200,58) rsi_200_crossunder_val_56 = ta.crossunder(rsi_200,56) rsi_200_crossunder_val_54 = ta.crossunder(rsi_200,54) rsi_200_crossunder_val_52 = ta.crossunder(rsi_200,52) rsi_200_crossunder_val_50 = ta.crossunder(rsi_200,50) rsi_200_crossunder_val_48 = ta.crossunder(rsi_200,48) rsi_200_crossunder_val_46 = ta.crossunder(rsi_200,46) rsi_200_crossunder_val_44 = ta.crossunder(rsi_200,44) rsi_200_crossunder_val_42 = ta.crossunder(rsi_200,42) rsi_200_crossunder_val_40 = ta.crossunder(rsi_200,40) if rsi_200_crossover_val_60 or rsi_200_crossover_val_58 or rsi_200_crossover_val_56 or rsi_200_crossover_val_54 or rsi_200_crossover_val_52 or rsi_200_crossover_val_50 or rsi_200_crossover_val_48 or rsi_200_crossover_val_46 or rsi_200_crossover_val_44 or rsi_200_crossover_val_42 or rsi_200_crossover_val_40 positive_signal := positive_signal + 1 if rsi_200_crossunder_val_60 or rsi_200_crossunder_val_58 or rsi_200_crossunder_val_56 or rsi_200_crossunder_val_54 or rsi_200_crossunder_val_52 or rsi_200_crossunder_val_50 or rsi_200_crossunder_val_48 or rsi_200_crossunder_val_46 or rsi_200_crossunder_val_44 or rsi_200_crossunder_val_42 or rsi_200_crossunder_val_40 positive_signal := positive_signal - 1 //Multi timeframe money flow index (MFI) src_mfi_10 = input(close, title = "Source of MFI - 10", group = "Money Flow Index (MFI)", inline = "10") lb_mfi_10 = 10 mfi_10 = ta.mfi(src_mfi_10,lb_mfi_10) src_mfi_50 = input(close, title = "Source of MFI - 50", group = "Money Flow Index (MFI)", inline = "50") lb_mfi_50 = 50 mfi_50 = ta.mfi(src_mfi_50,lb_mfi_50) src_mfi_100 = input(close, title = "Source of MFI - 100", group = "Money Flow Index (MFI)", inline = "100") lb_mfi_100 = 100 mfi_100 = ta.mfi(src_mfi_100,lb_mfi_100) src_mfi_200 = input(close, title = "Source of MFI - 200", group = "Money Flow Index (MFI)", inline = "200") lb_mfi_200 = 200 mfi_200 = ta.mfi(src_mfi_200,lb_mfi_200) //MFI Crossing over and under each other mfi_10_crossover_mfi_50 = ta.crossover(mfi_10,mfi_50) mfi_10_crossover_mfi_100 = ta.crossover(mfi_10,mfi_100) mfi_10_crossover_mfi_200 = ta.crossover(mfi_10,mfi_200) mfi_50_crossover_mfi_100 = ta.crossover(mfi_50,mfi_100) mfi_50_crossover_mfi_200 = ta.crossover(mfi_50,mfi_200) mfi_100_crossover_mfi_200 = ta.crossover(mfi_100,mfi_200) mfi_10_crossunder_mfi_50 = ta.crossunder(mfi_10,mfi_50) mfi_10_crossunder_mfi_100 = ta.crossunder(mfi_10,mfi_100) mfi_10_crossunder_mfi_200 = ta.crossunder(mfi_10,mfi_200) mfi_50_crossunder_mfi_100 = ta.crossunder(mfi_50,mfi_100) mfi_50_crossunder_mfi_200 = ta.crossunder(mfi_50,mfi_200) mfi_100_crossunder_mfi_200 = ta.crossunder(mfi_100,mfi_200) if mfi_10_crossover_mfi_50 or mfi_10_crossover_mfi_100 or mfi_10_crossover_mfi_200 or mfi_50_crossover_mfi_100 or mfi_50_crossover_mfi_200 or mfi_100_crossover_mfi_200 positive_signal := positive_signal + 1 if mfi_10_crossunder_mfi_50 or mfi_10_crossunder_mfi_100 or mfi_10_crossunder_mfi_200 or mfi_50_crossunder_mfi_100 or mfi_50_crossunder_mfi_200 or mfi_100_crossunder_mfi_200 positive_signal := positive_signal - 1 //Valued cross over & under mfi_10_crossover_val_0 = ta.cross(mfi_10,0) mfi_10_crossover_val_10 = ta.crossover(mfi_10,10) mfi_10_crossover_val_20 = ta.crossover(mfi_10,20) mfi_10_crossover_val_30 = ta.crossover(mfi_10,30) mfi_10_crossover_val_40 = ta.crossover(mfi_10,40) mfi_10_crossover_val_50 = ta.crossover(mfi_10,50) mfi_10_crossover_val_60 = ta.crossover(mfi_10,60) mfi_10_crossover_val_70 = ta.crossover(mfi_10,70) mfi_10_crossover_val_80 = ta.crossover(mfi_10,80) mfi_10_crossover_val_90 = ta.crossover(mfi_10,90) mfi_10_crossover_val_100 = ta.cross(mfi_10,100) mfi_10_crossunder_val_0 = ta.cross(mfi_10,0) mfi_10_crossunder_val_10 = ta.crossunder(mfi_10,10) mfi_10_crossunder_val_20 = ta.crossunder(mfi_10,20) mfi_10_crossunder_val_30 = ta.crossunder(mfi_10,30) mfi_10_crossunder_val_40 = ta.crossunder(mfi_10,40) mfi_10_crossunder_val_50 = ta.crossunder(mfi_10,50) mfi_10_crossunder_val_60 = ta.crossunder(mfi_10,60) mfi_10_crossunder_val_70 = ta.crossunder(mfi_10,70) mfi_10_crossunder_val_80 = ta.crossunder(mfi_10,80) mfi_10_crossunder_val_90 = ta.crossunder(mfi_10,90) mfi_10_crossunder_val_100 = ta.cross(mfi_10,100) if mfi_10_crossover_val_0 or mfi_10_crossover_val_10 or mfi_10_crossover_val_20 or mfi_10_crossover_val_30 or mfi_10_crossover_val_40 or mfi_10_crossover_val_50 or mfi_10_crossover_val_60 or mfi_10_crossover_val_70 or mfi_10_crossover_val_80 or mfi_10_crossover_val_90 or mfi_10_crossover_val_100 positive_signal := positive_signal + 1 if mfi_10_crossunder_val_0 or mfi_10_crossunder_val_10 or mfi_10_crossunder_val_20 or mfi_10_crossunder_val_30 or mfi_10_crossunder_val_40 or mfi_10_crossunder_val_50 or mfi_10_crossunder_val_60 or mfi_10_crossunder_val_70 or mfi_10_crossunder_val_80 or mfi_10_crossunder_val_90 or mfi_10_crossunder_val_100 positive_signal := positive_signal - 1 mfi_50_crossover_val_90 = ta.crossover(mfi_50,90) mfi_50_crossover_val_82 = ta.crossover(mfi_50,82) mfi_50_crossover_val_74 = ta.crossover(mfi_50,74) mfi_50_crossover_val_66 = ta.crossover(mfi_50,66) mfi_50_crossover_val_58 = ta.crossover(mfi_50,58) mfi_50_crossover_val_50 = ta.crossover(mfi_50,50) mfi_50_crossover_val_42 = ta.crossover(mfi_50,42) mfi_50_crossover_val_34 = ta.crossover(mfi_50,34) mfi_50_crossover_val_26 = ta.crossover(mfi_50,26) mfi_50_crossover_val_18 = ta.crossover(mfi_50,18) mfi_50_crossover_val_10 = ta.crossover(mfi_50,10) mfi_50_crossunder_val_90 = ta.crossunder(mfi_50,90) mfi_50_crossunder_val_82 = ta.crossunder(mfi_50,82) mfi_50_crossunder_val_74 = ta.crossunder(mfi_50,74) mfi_50_crossunder_val_66 = ta.crossunder(mfi_50,66) mfi_50_crossunder_val_58 = ta.crossunder(mfi_50,58) mfi_50_crossunder_val_50 = ta.crossunder(mfi_50,50) mfi_50_crossunder_val_42 = ta.crossunder(mfi_50,42) mfi_50_crossunder_val_34 = ta.crossunder(mfi_50,34) mfi_50_crossunder_val_26 = ta.crossunder(mfi_50,26) mfi_50_crossunder_val_18 = ta.crossunder(mfi_50,18) mfi_50_crossunder_val_10 = ta.crossunder(mfi_50,10) if mfi_50_crossover_val_90 or mfi_50_crossover_val_82 or mfi_50_crossover_val_74 or mfi_50_crossover_val_66 or mfi_50_crossover_val_58 or mfi_50_crossover_val_50 or mfi_50_crossover_val_42 or mfi_50_crossover_val_34 or mfi_50_crossover_val_26 or mfi_50_crossover_val_18 or mfi_50_crossover_val_10 positive_signal := positive_signal + 1 if mfi_50_crossunder_val_90 or mfi_50_crossunder_val_82 or mfi_50_crossunder_val_74 or mfi_50_crossunder_val_66 or mfi_50_crossunder_val_58 or mfi_50_crossunder_val_50 or mfi_50_crossunder_val_42 or mfi_50_crossunder_val_34 or mfi_50_crossunder_val_26 or mfi_50_crossunder_val_18 or mfi_50_crossunder_val_10 positive_signal := positive_signal - 1 mfi_100_crossover_val_85 = ta.crossover(mfi_100,85) mfi_100_crossover_val_78 = ta.crossover(mfi_100,78) mfi_100_crossover_val_71 = ta.crossover(mfi_100,71) mfi_100_crossover_val_64 = ta.crossover(mfi_100,64) mfi_100_crossover_val_57 = ta.crossover(mfi_100,57) mfi_100_crossover_val_50 = ta.crossover(mfi_100,50) mfi_100_crossover_val_43 = ta.crossover(mfi_100,43) mfi_100_crossover_val_36 = ta.crossover(mfi_100,36) mfi_100_crossover_val_29 = ta.crossover(mfi_100,29) mfi_100_crossover_val_22 = ta.crossover(mfi_100,22) mfi_100_crossover_val_15 = ta.crossover(mfi_100,15) mfi_100_crossunder_val_85 = ta.crossunder(mfi_100,85) mfi_100_crossunder_val_78 = ta.crossunder(mfi_100,78) mfi_100_crossunder_val_71 = ta.crossunder(mfi_100,71) mfi_100_crossunder_val_64 = ta.crossunder(mfi_100,64) mfi_100_crossunder_val_57 = ta.crossunder(mfi_100,57) mfi_100_crossunder_val_50 = ta.crossunder(mfi_100,50) mfi_100_crossunder_val_43 = ta.crossunder(mfi_100,43) mfi_100_crossunder_val_36 = ta.crossunder(mfi_100,36) mfi_100_crossunder_val_29 = ta.crossunder(mfi_100,29) mfi_100_crossunder_val_22 = ta.crossunder(mfi_100,22) mfi_100_crossunder_val_15 = ta.crossunder(mfi_100,15) if mfi_100_crossover_val_85 or mfi_100_crossover_val_78 or mfi_100_crossover_val_71 or mfi_100_crossover_val_64 or mfi_100_crossover_val_57 or mfi_100_crossover_val_50 or mfi_100_crossover_val_43 or mfi_100_crossover_val_36 or mfi_100_crossover_val_29 or mfi_100_crossover_val_22 or mfi_100_crossover_val_15 positive_signal := positive_signal + 1 if mfi_100_crossunder_val_85 or mfi_100_crossunder_val_78 or mfi_100_crossunder_val_71 or mfi_100_crossunder_val_64 or mfi_100_crossunder_val_57 or mfi_100_crossunder_val_50 or mfi_100_crossunder_val_43 or mfi_100_crossunder_val_36 or mfi_100_crossunder_val_29 or mfi_100_crossunder_val_22 or mfi_100_crossunder_val_15 positive_signal := positive_signal - 1 mfi_200_crossover_val_80 = ta.crossover(mfi_200,80) mfi_200_crossover_val_74 = ta.crossover(mfi_200,74) mfi_200_crossover_val_68 = ta.crossover(mfi_200,68) mfi_200_crossover_val_62 = ta.crossover(mfi_200,62) mfi_200_crossover_val_56 = ta.crossover(mfi_200,56) mfi_200_crossover_val_50 = ta.crossover(mfi_200,50) mfi_200_crossover_val_44 = ta.crossover(mfi_200,44) mfi_200_crossover_val_38 = ta.crossover(mfi_200,38) mfi_200_crossover_val_32 = ta.crossover(mfi_200,32) mfi_200_crossover_val_26 = ta.crossover(mfi_200,26) mfi_200_crossover_val_20 = ta.crossover(mfi_200,20) mfi_200_crossunder_val_80 = ta.crossunder(mfi_200,80) mfi_200_crossunder_val_74 = ta.crossunder(mfi_200,74) mfi_200_crossunder_val_68 = ta.crossunder(mfi_200,68) mfi_200_crossunder_val_62 = ta.crossunder(mfi_200,62) mfi_200_crossunder_val_56 = ta.crossunder(mfi_200,56) mfi_200_crossunder_val_50 = ta.crossunder(mfi_200,50) mfi_200_crossunder_val_44 = ta.crossunder(mfi_200,44) mfi_200_crossunder_val_38 = ta.crossunder(mfi_200,38) mfi_200_crossunder_val_32 = ta.crossunder(mfi_200,32) mfi_200_crossunder_val_26 = ta.crossunder(mfi_200,26) mfi_200_crossunder_val_20 = ta.crossunder(mfi_200,20) if mfi_200_crossover_val_80 or mfi_200_crossover_val_74 or mfi_200_crossover_val_68 or mfi_200_crossover_val_62 or mfi_200_crossover_val_56 or mfi_200_crossover_val_50 or mfi_200_crossover_val_44 or mfi_200_crossover_val_38 or mfi_200_crossover_val_32 or mfi_200_crossover_val_26 or mfi_200_crossover_val_20 positive_signal := positive_signal + 1 if mfi_200_crossunder_val_80 or mfi_200_crossunder_val_74 or mfi_200_crossunder_val_68 or mfi_200_crossunder_val_62 or mfi_200_crossunder_val_56 or mfi_200_crossunder_val_50 or mfi_200_crossunder_val_44 or mfi_200_crossunder_val_38 or mfi_200_crossunder_val_32 or mfi_200_crossunder_val_26 or mfi_200_crossunder_val_20 positive_signal := positive_signal - 1 //Multi timeframe relative volatility index (RVI) src_rvi_10 = input(close,title = "Source of RVI-10 is", group = "Revative Volatility Index (RVI)", inline = '10') lb_rvi_10 = 10 cal_method_rvi_10 = input.string(title = "& calculation method is", options=['EMA', 'SMA'], defval='EMA', group = "Revative Volatility Index (RVI)", inline = '10') stddev_rvi_10 = ta.stdev(src_rvi_10, lb_rvi_10) var float upper_rvi_10 = 0 var float lower_rvi_10 = 0 if cal_method_rvi_10 == "EMA" upper_rvi_10 := ta.ema(ta.change(src_rvi_10) <= 0 ? 0 : stddev_rvi_10, lb_rvi_10) lower_rvi_10 := ta.ema(ta.change(src_rvi_10) > 0 ? 0 : stddev_rvi_10, lb_rvi_10) else if cal_method_rvi_10 == "SMA" upper_rvi_10 := ta.sma(ta.change(src_rvi_10) <= 0 ? 0 : stddev_rvi_10, lb_rvi_10) lower_rvi_10 := ta.sma(ta.change(src_rvi_10) > 0 ? 0 : stddev_rvi_10, lb_rvi_10) rvi_10 = upper_rvi_10 / (upper_rvi_10 + lower_rvi_10) * 100 src_rvi_50 = input(close,title = "Source of RVI-50 is", group = "Revative Volatility Index (RVI)", inline = '50') lb_rvi_50 = 50 cal_method_rvi_50 = input.string(title = "& calculation method is", options=['EMA', 'SMA'], defval='EMA', group = "Revative Volatility Index (RVI)", inline = '50') stddev_rvi_50 = ta.stdev(src_rvi_50, lb_rvi_50) var float upper_rvi_50 = 0 var float lower_rvi_50 = 0 if cal_method_rvi_50 == "EMA" upper_rvi_50 := ta.ema(ta.change(src_rvi_50) <= 0 ? 0 : stddev_rvi_50, lb_rvi_50) lower_rvi_50 := ta.ema(ta.change(src_rvi_50) > 0 ? 0 : stddev_rvi_50, lb_rvi_50) else if cal_method_rvi_50 == "SMA" upper_rvi_50 := ta.sma(ta.change(src_rvi_50) <= 0 ? 0 : stddev_rvi_50, lb_rvi_50) lower_rvi_50 := ta.sma(ta.change(src_rvi_50) > 0 ? 0 : stddev_rvi_50, lb_rvi_50) rvi_50 = upper_rvi_50 / (upper_rvi_50 + lower_rvi_50) * 100 src_rvi_100 = input(close,title = "Source of RVI-100 is", group = "Revative Volatility Index (RVI)", inline = '100') lb_rvi_100 = 100 cal_method_rvi_100 = input.string(title = "& calculation method is", options=['EMA', 'SMA'], defval='EMA', group = "Revative Volatility Index (RVI)", inline = '100') stddev_rvi_100 = ta.stdev(src_rvi_100, lb_rvi_100) var float upper_rvi_100 = 0 var float lower_rvi_100 = 0 if cal_method_rvi_100 == "EMA" upper_rvi_100 := ta.ema(ta.change(src_rvi_100) <= 0 ? 0 : stddev_rvi_100, lb_rvi_100) lower_rvi_100 := ta.ema(ta.change(src_rvi_100) > 0 ? 0 : stddev_rvi_100, lb_rvi_100) else if cal_method_rvi_100 == "SMA" upper_rvi_100 := ta.sma(ta.change(src_rvi_100) <= 0 ? 0 : stddev_rvi_100, lb_rvi_100) lower_rvi_100 := ta.sma(ta.change(src_rvi_100) > 0 ? 0 : stddev_rvi_100, lb_rvi_100) rvi_100 = upper_rvi_100 / (upper_rvi_100 + lower_rvi_100) * 100 src_rvi_200 = input(close,title = "Source of RVI-200 is", group = "Revative Volatility Index (RVI)", inline = '200') lb_rvi_200 = 200 cal_method_rvi_200 = input.string(title = "& calculation method is", options=['EMA', 'SMA'], defval='EMA', group = "Revative Volatility Index (RVI)", inline = '200') stddev_rvi_200 = ta.stdev(src_rvi_200, lb_rvi_200) var float upper_rvi_200 = 0 var float lower_rvi_200 = 0 if cal_method_rvi_200 == "EMA" upper_rvi_200 := ta.ema(ta.change(src_rvi_200) <= 0 ? 0 : stddev_rvi_200, lb_rvi_200) lower_rvi_200 := ta.ema(ta.change(src_rvi_200) > 0 ? 0 : stddev_rvi_200, lb_rvi_200) else if cal_method_rvi_200 == "SMA" upper_rvi_200 := ta.sma(ta.change(src_rvi_200) <= 0 ? 0 : stddev_rvi_200, lb_rvi_200) lower_rvi_200 := ta.sma(ta.change(src_rvi_200) > 0 ? 0 : stddev_rvi_200, lb_rvi_200) rvi_200 = upper_rvi_200 / (upper_rvi_200 + lower_rvi_200) * 100 //RVI Crossing over and under each other rvi_10_crossover_rvi_50 = ta.crossover(rvi_10,rvi_50) rvi_10_crossover_rvi_100 = ta.crossover(rvi_10,rvi_100) rvi_10_crossover_rvi_200 = ta.crossover(rvi_10,rvi_200) rvi_50_crossover_rvi_100 = ta.crossover(rvi_50,rvi_100) rvi_50_crossover_rvi_200 = ta.crossover(rvi_50,rvi_200) rvi_100_crossover_rvi_200 = ta.crossover(rvi_100,rvi_200) rvi_10_crossunder_rvi_50 = ta.crossunder(rvi_10,rvi_50) rvi_10_crossunder_rvi_100 = ta.crossunder(rvi_10,rvi_100) rvi_10_crossunder_rvi_200 = ta.crossunder(rvi_10,rvi_200) rvi_50_crossunder_rvi_100 = ta.crossunder(rvi_50,rvi_100) rvi_50_crossunder_rvi_200 = ta.crossunder(rvi_50,rvi_200) rvi_100_crossunder_rvi_200 = ta.crossunder(rvi_100,rvi_200) if rvi_10_crossover_rvi_50 or rvi_10_crossover_rvi_100 or rvi_10_crossover_rvi_200 or rvi_50_crossover_rvi_100 or rvi_50_crossover_rvi_200 or rvi_100_crossover_rvi_200 positive_signal := positive_signal + 1 if rvi_10_crossunder_rvi_50 or rvi_10_crossunder_rvi_100 or rvi_10_crossunder_rvi_200 or rvi_50_crossunder_rvi_100 or rvi_50_crossunder_rvi_200 or rvi_100_crossunder_rvi_200 positive_signal := positive_signal - 1 //RVI crossing different values rvi_10_crossover_val_0 = ta.cross(rvi_10,0) rvi_10_crossover_val_10 = ta.crossover(rvi_10,10) rvi_10_crossover_val_20 = ta.crossover(rvi_10,20) rvi_10_crossover_val_30 = ta.crossover(rvi_10,30) rvi_10_crossover_val_40 = ta.crossover(rvi_10,40) rvi_10_crossover_val_50 = ta.crossover(rvi_10,50) rvi_10_crossover_val_60 = ta.crossover(rvi_10,60) rvi_10_crossover_val_70 = ta.crossover(rvi_10,70) rvi_10_crossover_val_80 = ta.crossover(rvi_10,80) rvi_10_crossover_val_90 = ta.crossover(rvi_10,90) rvi_10_crossover_val_100 = ta.cross(rvi_10,100) rvi_10_crossunder_val_0 = ta.cross(rvi_10,0) rvi_10_crossunder_val_10 = ta.crossunder(rvi_10,10) rvi_10_crossunder_val_20 = ta.crossunder(rvi_10,20) rvi_10_crossunder_val_30 = ta.crossunder(rvi_10,30) rvi_10_crossunder_val_40 = ta.crossunder(rvi_10,40) rvi_10_crossunder_val_50 = ta.crossunder(rvi_10,50) rvi_10_crossunder_val_60 = ta.crossunder(rvi_10,60) rvi_10_crossunder_val_70 = ta.crossunder(rvi_10,70) rvi_10_crossunder_val_80 = ta.crossunder(rvi_10,80) rvi_10_crossunder_val_90 = ta.crossunder(rvi_10,90) rvi_10_crossunder_val_100 = ta.cross(rvi_10,100) if rvi_10_crossover_val_0 or rvi_10_crossover_val_10 or rvi_10_crossover_val_20 or rvi_10_crossover_val_30 or rvi_10_crossover_val_40 or rvi_10_crossover_val_50 or rvi_10_crossover_val_60 or rvi_10_crossover_val_70 or rvi_10_crossover_val_80 or rvi_10_crossover_val_90 or rvi_10_crossover_val_100 positive_signal := positive_signal + 1 if rvi_10_crossunder_val_0 or rvi_10_crossunder_val_10 or rvi_10_crossunder_val_20 or rvi_10_crossunder_val_30 or rvi_10_crossunder_val_40 or rvi_10_crossunder_val_50 or rvi_10_crossunder_val_60 or rvi_10_crossunder_val_70 or rvi_10_crossunder_val_80 or rvi_10_crossunder_val_90 or rvi_10_crossunder_val_100 positive_signal := positive_signal - 1 rvi_50_crossover_val_75 = ta.crossover(rvi_50,75) rvi_50_crossover_val_70 = ta.crossover(rvi_50,70) rvi_50_crossover_val_65 = ta.crossover(rvi_50,65) rvi_50_crossover_val_60 = ta.crossover(rvi_50,60) rvi_50_crossover_val_55 = ta.crossover(rvi_50,55) rvi_50_crossover_val_50 = ta.crossover(rvi_50,50) rvi_50_crossover_val_45 = ta.crossover(rvi_50,45) rvi_50_crossover_val_40 = ta.crossover(rvi_50,40) rvi_50_crossover_val_35 = ta.crossover(rvi_50,35) rvi_50_crossover_val_30 = ta.crossover(rvi_50,30) rvi_50_crossover_val_25 = ta.crossover(rvi_50,25) rvi_50_crossunder_val_75 = ta.crossunder(rvi_50,75) rvi_50_crossunder_val_70 = ta.crossunder(rvi_50,70) rvi_50_crossunder_val_65 = ta.crossunder(rvi_50,65) rvi_50_crossunder_val_60 = ta.crossunder(rvi_50,60) rvi_50_crossunder_val_55 = ta.crossunder(rvi_50,55) rvi_50_crossunder_val_50 = ta.crossunder(rvi_50,50) rvi_50_crossunder_val_45 = ta.crossunder(rvi_50,45) rvi_50_crossunder_val_40 = ta.crossunder(rvi_50,40) rvi_50_crossunder_val_35 = ta.crossunder(rvi_50,35) rvi_50_crossunder_val_30 = ta.crossunder(rvi_50,30) rvi_50_crossunder_val_25 = ta.crossunder(rvi_50,25) if rvi_50_crossover_val_75 or rvi_50_crossover_val_70 or rvi_50_crossover_val_65 or rvi_50_crossover_val_60 or rvi_50_crossover_val_55 or rvi_50_crossover_val_50 or rvi_50_crossover_val_45 or rvi_50_crossover_val_40 or rvi_50_crossover_val_35 or rvi_50_crossover_val_30 or rvi_50_crossover_val_25 positive_signal := positive_signal + 1 if rvi_50_crossunder_val_75 or rvi_50_crossunder_val_70 or rvi_50_crossunder_val_65 or rvi_50_crossunder_val_60 or rvi_50_crossunder_val_55 or rvi_50_crossunder_val_50 or rvi_50_crossunder_val_45 or rvi_50_crossunder_val_40 or rvi_50_crossunder_val_35 or rvi_50_crossunder_val_30 or rvi_50_crossunder_val_25 positive_signal := positive_signal - 1 rvi_100_crossover_val_70 = ta.crossover(rvi_100,70) rvi_100_crossover_val_66 = ta.crossover(rvi_100,66) rvi_100_crossover_val_62 = ta.crossover(rvi_100,62) rvi_100_crossover_val_58 = ta.crossover(rvi_100,58) rvi_100_crossover_val_54 = ta.crossover(rvi_100,54) rvi_100_crossover_val_50 = ta.crossover(rvi_100,50) rvi_100_crossover_val_46 = ta.crossover(rvi_100,46) rvi_100_crossover_val_42 = ta.crossover(rvi_100,42) rvi_100_crossover_val_38 = ta.crossover(rvi_100,38) rvi_100_crossover_val_34 = ta.crossover(rvi_100,34) rvi_100_crossover_val_30 = ta.crossover(rvi_100,30) rvi_100_crossunder_val_70 = ta.crossunder(rvi_100,70) rvi_100_crossunder_val_66 = ta.crossunder(rvi_100,66) rvi_100_crossunder_val_62 = ta.crossunder(rvi_100,62) rvi_100_crossunder_val_58 = ta.crossunder(rvi_100,58) rvi_100_crossunder_val_54 = ta.crossunder(rvi_100,54) rvi_100_crossunder_val_50 = ta.crossunder(rvi_100,50) rvi_100_crossunder_val_46 = ta.crossunder(rvi_100,46) rvi_100_crossunder_val_42 = ta.crossunder(rvi_100,42) rvi_100_crossunder_val_38 = ta.crossunder(rvi_100,38) rvi_100_crossunder_val_34 = ta.crossunder(rvi_100,34) rvi_100_crossunder_val_30 = ta.crossunder(rvi_100,30) if rvi_100_crossover_val_70 or rvi_100_crossover_val_66 or rvi_100_crossover_val_62 or rvi_100_crossover_val_58 or rvi_100_crossover_val_54 or rvi_100_crossover_val_50 or rvi_100_crossover_val_46 or rvi_100_crossover_val_42 or rvi_100_crossover_val_38 or rvi_100_crossover_val_34 or rvi_100_crossover_val_30 positive_signal := positive_signal + 1 if rvi_100_crossunder_val_70 or rvi_100_crossunder_val_66 or rvi_100_crossunder_val_62 or rvi_100_crossunder_val_58 or rvi_100_crossunder_val_54 or rvi_100_crossunder_val_50 or rvi_100_crossunder_val_46 or rvi_100_crossunder_val_42 or rvi_100_crossunder_val_38 or rvi_100_crossunder_val_34 or rvi_100_crossunder_val_30 positive_signal := positive_signal - 1 rvi_200_crossover_val_65 = ta.crossover(rvi_200,65) rvi_200_crossover_val_62 = ta.crossover(rvi_200,62) rvi_200_crossover_val_59 = ta.crossover(rvi_200,59) rvi_200_crossover_val_56 = ta.crossover(rvi_200,56) rvi_200_crossover_val_53 = ta.crossover(rvi_200,53) rvi_200_crossover_val_50 = ta.crossover(rvi_200,50) rvi_200_crossover_val_47 = ta.crossover(rvi_200,47) rvi_200_crossover_val_44 = ta.crossover(rvi_200,44) rvi_200_crossover_val_41 = ta.crossover(rvi_200,41) rvi_200_crossover_val_38 = ta.crossover(rvi_200,38) rvi_200_crossover_val_35 = ta.crossover(rvi_200,35) rvi_200_crossunder_val_65 = ta.crossunder(rvi_200,65) rvi_200_crossunder_val_62 = ta.crossunder(rvi_200,62) rvi_200_crossunder_val_59 = ta.crossunder(rvi_200,59) rvi_200_crossunder_val_56 = ta.crossunder(rvi_200,56) rvi_200_crossunder_val_53 = ta.crossunder(rvi_200,53) rvi_200_crossunder_val_50 = ta.crossunder(rvi_200,50) rvi_200_crossunder_val_47 = ta.crossunder(rvi_200,47) rvi_200_crossunder_val_44 = ta.crossunder(rvi_200,44) rvi_200_crossunder_val_41 = ta.crossunder(rvi_200,41) rvi_200_crossunder_val_38 = ta.crossunder(rvi_200,38) rvi_200_crossunder_val_35 = ta.crossunder(rvi_200,35) if rvi_200_crossover_val_65 or rvi_200_crossover_val_62 or rvi_200_crossover_val_59 or rvi_200_crossover_val_56 or rvi_200_crossover_val_53 or rvi_200_crossover_val_50 or rvi_200_crossover_val_47 or rvi_200_crossover_val_44 or rvi_200_crossover_val_41 or rvi_200_crossover_val_38 or rvi_200_crossover_val_35 positive_signal := positive_signal + 1 if rvi_200_crossunder_val_65 or rvi_200_crossunder_val_62 or rvi_200_crossunder_val_59 or rvi_200_crossunder_val_56 or rvi_200_crossunder_val_53 or rvi_200_crossunder_val_50 or rvi_200_crossunder_val_47 or rvi_200_crossunder_val_44 or rvi_200_crossunder_val_41 or rvi_200_crossunder_val_38 or rvi_200_crossunder_val_35 positive_signal := positive_signal - 1 //Balance of power bop = ((((close - open) / (high - low))*100)+50) cal_method_bop_10 = input.string(title = "BOP-10 cal method is", options=['EMA', 'SMA'], defval='EMA', group = "Balance of Power (BOP)") cal_method_bop_50 = input.string(title = "BOP-50 cal method is", options=['EMA', 'SMA'], defval='EMA', group = "Balance of Power (BOP)") cal_method_bop_100 = input.string(title = "BOP-100 cal method is", options=['EMA', 'SMA'], defval='EMA', group = "Balance of Power (BOP)") cal_method_bop_200 = input.string(title = "BOP-200 cal method is", options=['EMA', 'SMA'], defval='EMA', group = "Balance of Power (BOP)") var float bop_10 = 0 var float bop_50 = 0 var float bop_100 = 0 var float bop_200 = 0 if cal_method_bop_10 == "SMA" bop_10 := ta.sma(bop,10) else if cal_method_bop_10 == "EMA" bop_10 := ta.ema(bop,10) if cal_method_bop_50 == "SMA" bop_50 := ta.sma(bop,50) else if cal_method_bop_50 == "EMA" bop_50 := ta.ema(bop,50) if cal_method_bop_100 == "SMA" bop_100 := ta.sma(bop,100) else if cal_method_bop_100 == "EMA" bop_100 := ta.ema(bop,100) if cal_method_bop_200 == "SMA" bop_200 := ta.sma(bop,200) else if cal_method_bop_200 == "EMA" bop_200 := ta.ema(bop,200) //BOP Crossing over and under each other bop_10_crossover_bop_50 = ta.crossover(bop_10,bop_50) bop_10_crossover_bop_100 = ta.crossover(bop_10,bop_100) bop_10_crossover_bop_200 = ta.crossover(bop_10,bop_200) bop_50_crossover_bop_100 = ta.crossover(bop_50,bop_100) bop_50_crossover_bop_200 = ta.crossover(bop_50,bop_200) bop_100_crossover_bop_200 = ta.crossover(bop_100,bop_200) bop_10_crossunder_bop_50 = ta.crossunder(bop_10,bop_50) bop_10_crossunder_bop_100 = ta.crossunder(bop_10,bop_100) bop_10_crossunder_bop_200 = ta.crossunder(bop_10,bop_200) bop_50_crossunder_bop_100 = ta.crossunder(bop_50,bop_100) bop_50_crossunder_bop_200 = ta.crossunder(bop_50,bop_200) bop_100_crossunder_bop_200 = ta.crossunder(bop_100,bop_200) if bop_10_crossover_bop_50 or bop_10_crossover_bop_100 or bop_10_crossover_bop_200 or bop_50_crossover_bop_100 or bop_50_crossover_bop_200 or bop_100_crossover_bop_200 positive_signal := positive_signal + 1 if bop_10_crossunder_bop_50 or bop_10_crossunder_bop_100 or bop_10_crossunder_bop_200 or bop_50_crossunder_bop_100 or bop_50_crossunder_bop_200 or bop_100_crossunder_bop_200 positive_signal := positive_signal - 1 //BOP crossing different values bop_10_crossover_val_0 = ta.cross(bop_10,0) bop_10_crossover_val_10 = ta.crossover(bop_10,10) bop_10_crossover_val_20 = ta.crossover(bop_10,20) bop_10_crossover_val_30 = ta.crossover(bop_10,30) bop_10_crossover_val_40 = ta.crossover(bop_10,40) bop_10_crossover_val_50 = ta.crossover(bop_10,50) bop_10_crossover_val_60 = ta.crossover(bop_10,60) bop_10_crossover_val_70 = ta.crossover(bop_10,70) bop_10_crossover_val_80 = ta.crossover(bop_10,80) bop_10_crossover_val_90 = ta.crossover(bop_10,90) bop_10_crossover_val_100 = ta.cross(bop_10,100) bop_10_crossunder_val_0 = ta.cross(bop_10,0) bop_10_crossunder_val_10 = ta.crossunder(bop_10,10) bop_10_crossunder_val_20 = ta.crossunder(bop_10,20) bop_10_crossunder_val_30 = ta.crossunder(bop_10,30) bop_10_crossunder_val_40 = ta.crossunder(bop_10,40) bop_10_crossunder_val_50 = ta.crossunder(bop_10,50) bop_10_crossunder_val_60 = ta.crossunder(bop_10,60) bop_10_crossunder_val_70 = ta.crossunder(bop_10,70) bop_10_crossunder_val_80 = ta.crossunder(bop_10,80) bop_10_crossunder_val_90 = ta.crossunder(bop_10,90) bop_10_crossunder_val_100 = ta.cross(bop_10,100) if bop_10_crossover_val_0 or bop_10_crossover_val_10 or bop_10_crossover_val_20 or bop_10_crossover_val_30 or bop_10_crossover_val_40 or bop_10_crossover_val_50 or bop_10_crossover_val_60 or bop_10_crossover_val_70 or bop_10_crossover_val_80 or bop_10_crossover_val_90 or bop_10_crossover_val_100 positive_signal := positive_signal + 1 if bop_10_crossunder_val_0 or bop_10_crossunder_val_10 or bop_10_crossunder_val_20 or bop_10_crossunder_val_30 or bop_10_crossunder_val_40 or bop_10_crossunder_val_50 or bop_10_crossunder_val_60 or bop_10_crossunder_val_70 or bop_10_crossunder_val_80 or bop_10_crossunder_val_90 or bop_10_crossunder_val_100 positive_signal := positive_signal - 1 bop_50_crossover_val_80 = ta.crossover(bop_50,80) bop_50_crossover_val_74 = ta.crossover(bop_50,74) bop_50_crossover_val_68 = ta.crossover(bop_50,68) bop_50_crossover_val_62 = ta.crossover(bop_50,62) bop_50_crossover_val_56 = ta.crossover(bop_50,56) bop_50_crossover_val_50 = ta.crossover(bop_50,50) bop_50_crossover_val_44 = ta.crossover(bop_50,44) bop_50_crossover_val_38 = ta.crossover(bop_50,38) bop_50_crossover_val_32 = ta.crossover(bop_50,32) bop_50_crossover_val_26 = ta.crossover(bop_50,26) bop_50_crossover_val_20 = ta.crossover(bop_50,20) bop_50_crossunder_val_80 = ta.crossunder(bop_50,80) bop_50_crossunder_val_74 = ta.crossunder(bop_50,74) bop_50_crossunder_val_68 = ta.crossunder(bop_50,68) bop_50_crossunder_val_62 = ta.crossunder(bop_50,62) bop_50_crossunder_val_56 = ta.crossunder(bop_50,56) bop_50_crossunder_val_50 = ta.crossunder(bop_50,50) bop_50_crossunder_val_44 = ta.crossunder(bop_50,44) bop_50_crossunder_val_38 = ta.crossunder(bop_50,38) bop_50_crossunder_val_32 = ta.crossunder(bop_50,32) bop_50_crossunder_val_26 = ta.crossunder(bop_50,26) bop_50_crossunder_val_20 = ta.crossunder(bop_50,20) if bop_50_crossover_val_80 or bop_50_crossover_val_74 or bop_50_crossover_val_68 or bop_50_crossover_val_62 or bop_50_crossover_val_56 or bop_50_crossover_val_50 or bop_50_crossover_val_44 or bop_50_crossover_val_38 or bop_50_crossover_val_32 or bop_50_crossover_val_26 or bop_50_crossover_val_20 positive_signal := positive_signal + 1 if bop_50_crossunder_val_80 or bop_50_crossunder_val_74 or bop_50_crossunder_val_68 or bop_50_crossunder_val_62 or bop_50_crossunder_val_56 or bop_50_crossunder_val_50 or bop_50_crossunder_val_44 or bop_50_crossunder_val_38 or bop_50_crossunder_val_32 or bop_50_crossunder_val_26 or bop_50_crossunder_val_20 positive_signal := positive_signal - 1 bop_100_crossover_val_75 = ta.crossover(bop_100,75) bop_100_crossover_val_70 = ta.crossover(bop_100,70) bop_100_crossover_val_65 = ta.crossover(bop_100,65) bop_100_crossover_val_60 = ta.crossover(bop_100,60) bop_100_crossover_val_55 = ta.crossover(bop_100,55) bop_100_crossover_val_50 = ta.crossover(bop_100,50) bop_100_crossover_val_45 = ta.crossover(bop_100,45) bop_100_crossover_val_40 = ta.crossover(bop_100,40) bop_100_crossover_val_35 = ta.crossover(bop_100,35) bop_100_crossover_val_30 = ta.crossover(bop_100,30) bop_100_crossover_val_25 = ta.crossover(bop_100,25) bop_100_crossunder_val_75 = ta.crossunder(bop_100,75) bop_100_crossunder_val_70 = ta.crossunder(bop_100,70) bop_100_crossunder_val_65 = ta.crossunder(bop_100,65) bop_100_crossunder_val_60 = ta.crossunder(bop_100,60) bop_100_crossunder_val_55 = ta.crossunder(bop_100,55) bop_100_crossunder_val_50 = ta.crossunder(bop_100,50) bop_100_crossunder_val_45 = ta.crossunder(bop_100,45) bop_100_crossunder_val_40 = ta.crossunder(bop_100,40) bop_100_crossunder_val_35 = ta.crossunder(bop_100,35) bop_100_crossunder_val_30 = ta.crossunder(bop_100,30) bop_100_crossunder_val_25 = ta.crossunder(bop_100,25) if bop_100_crossover_val_75 or bop_100_crossover_val_70 or bop_100_crossover_val_65 or bop_100_crossover_val_60 or bop_100_crossover_val_55 or bop_100_crossover_val_50 or bop_100_crossover_val_45 or bop_100_crossover_val_40 or bop_100_crossover_val_35 or bop_100_crossover_val_30 or bop_100_crossover_val_25 positive_signal := positive_signal + 1 if bop_100_crossunder_val_75 or bop_100_crossunder_val_70 or bop_100_crossunder_val_65 or bop_100_crossunder_val_60 or bop_100_crossunder_val_55 or bop_100_crossunder_val_50 or bop_100_crossunder_val_45 or bop_100_crossunder_val_40 or bop_100_crossunder_val_35 or bop_100_crossunder_val_30 or bop_100_crossunder_val_25 positive_signal := positive_signal - 1 bop_200_crossover_val_70 = ta.crossover(bop_200,70) bop_200_crossover_val_66 = ta.crossover(bop_200,66) bop_200_crossover_val_62 = ta.crossover(bop_200,62) bop_200_crossover_val_58 = ta.crossover(bop_200,58) bop_200_crossover_val_54 = ta.crossover(bop_200,54) bop_200_crossover_val_50 = ta.crossover(bop_200,50) bop_200_crossover_val_46 = ta.crossover(bop_200,46) bop_200_crossover_val_42 = ta.crossover(bop_200,42) bop_200_crossover_val_38 = ta.crossover(bop_200,38) bop_200_crossover_val_34 = ta.crossover(bop_200,34) bop_200_crossover_val_30 = ta.crossover(bop_200,30) bop_200_crossunder_val_70 = ta.crossunder(bop_200,70) bop_200_crossunder_val_66 = ta.crossunder(bop_200,66) bop_200_crossunder_val_62 = ta.crossunder(bop_200,62) bop_200_crossunder_val_58 = ta.crossunder(bop_200,58) bop_200_crossunder_val_54 = ta.crossunder(bop_200,54) bop_200_crossunder_val_50 = ta.crossunder(bop_200,50) bop_200_crossunder_val_46 = ta.crossunder(bop_200,46) bop_200_crossunder_val_42 = ta.crossunder(bop_200,42) bop_200_crossunder_val_38 = ta.crossunder(bop_200,38) bop_200_crossunder_val_34 = ta.crossunder(bop_200,34) bop_200_crossunder_val_30 = ta.crossunder(bop_200,30) if bop_200_crossover_val_70 or bop_200_crossover_val_66 or bop_200_crossover_val_62 or bop_200_crossover_val_58 or bop_200_crossover_val_54 or bop_200_crossover_val_50 or bop_200_crossover_val_46 or bop_200_crossover_val_42 or bop_200_crossover_val_38 or bop_200_crossover_val_34 or bop_200_crossover_val_30 positive_signal := positive_signal + 1 if bop_200_crossunder_val_70 or bop_200_crossunder_val_66 or bop_200_crossunder_val_62 or bop_200_crossunder_val_58 or bop_200_crossunder_val_54 or bop_200_crossunder_val_50 or bop_200_crossunder_val_46 or bop_200_crossunder_val_42 or bop_200_crossunder_val_38 or bop_200_crossunder_val_34 or bop_200_crossunder_val_30 positive_signal := positive_signal - 1 //Simple moving average (SMA) src_sma_10= input(close,title = "Source of SMA-10 is", group = "Simple moving average (SMA)") sma_10 = ta.sma(src_sma_10,10) src_sma_50= input(close,title = "Source of SMA-50 is", group = "Simple moving average (SMA)") sma_50 = ta.sma(src_sma_50,50) src_sma_100= input(close,title = "Source of SMA-100 is", group = "Simple moving average (SMA)") sma_100 = ta.sma(src_sma_100,100) src_sma_200= input(close,title = "Source of SMA-200 is", group = "Simple moving average (SMA)") sma_200 = ta.sma(src_sma_200,200) //SMA Crossing over and under each other sma_10_crossover_sma_50 = ta.crossover(sma_10,sma_50) sma_10_crossover_sma_100 = ta.crossover(sma_10,sma_100) sma_10_crossover_sma_200 = ta.crossover(sma_10,sma_200) sma_50_crossover_sma_100 = ta.crossover(sma_50,sma_100) sma_50_crossover_sma_200 = ta.crossover(sma_50,sma_200) sma_100_crossover_sma_200 = ta.crossover(sma_100,sma_200) sma_10_crossunder_sma_50 = ta.crossunder(sma_10,sma_50) sma_10_crossunder_sma_100 = ta.crossunder(sma_10,sma_100) sma_10_crossunder_sma_200 = ta.crossunder(sma_10,sma_200) sma_50_crossunder_sma_100 = ta.crossunder(sma_50,sma_100) sma_50_crossunder_sma_200 = ta.crossunder(sma_50,sma_200) sma_100_crossunder_sma_200 = ta.crossunder(sma_100,sma_200) if sma_10_crossover_sma_50 or sma_10_crossover_sma_100 or sma_10_crossover_sma_200 or sma_50_crossover_sma_100 or sma_50_crossover_sma_200 or sma_100_crossover_sma_200 positive_signal := positive_signal + 1 if sma_10_crossunder_sma_50 or sma_10_crossunder_sma_100 or sma_10_crossunder_sma_200 or sma_50_crossunder_sma_100 or sma_50_crossunder_sma_200 or sma_100_crossunder_sma_200 positive_signal := positive_signal - 1 //Exponential Moving average (EMA) src_ema_10= input(close,title = "Source of EMA-10 is", group = "Exponential Moving average (EMA)") ema_10 = ta.ema(src_ema_10,10) src_ema_50= input(close,title = "Source of EMA-50 is", group = "Exponential Moving average (EMA)") ema_50 = ta.ema(src_ema_50,50) src_ema_100= input(close,title = "Source of EMA-100 is", group = "Exponential Moving average (EMA)") ema_100 = ta.ema(src_ema_100,100) src_ema_200= input(close,title = "Source of EMA-200 is", group = "Exponential Moving average (EMA)") ema_200 = ta.ema(src_ema_200,200) //EMA Crossing over and under each other ema_10_crossover_ema_50 = ta.crossover(ema_10,ema_50) ema_10_crossover_ema_100 = ta.crossover(ema_10,ema_100) ema_10_crossover_ema_200 = ta.crossover(ema_10,ema_200) ema_50_crossover_ema_100 = ta.crossover(ema_50,ema_100) ema_50_crossover_ema_200 = ta.crossover(ema_50,ema_200) ema_100_crossover_ema_200 = ta.crossover(ema_100,ema_200) ema_10_crossunder_ema_50 = ta.crossunder(ema_10,ema_50) ema_10_crossunder_ema_100 = ta.crossunder(ema_10,ema_100) ema_10_crossunder_ema_200 = ta.crossunder(ema_10,ema_200) ema_50_crossunder_ema_100 = ta.crossunder(ema_50,ema_100) ema_50_crossunder_ema_200 = ta.crossunder(ema_50,ema_200) ema_100_crossunder_ema_200 = ta.crossunder(ema_100,ema_200) if ema_10_crossover_ema_50 or ema_10_crossover_ema_100 or ema_10_crossover_ema_200 or ema_50_crossover_ema_100 or ema_50_crossover_ema_200 or ema_100_crossover_ema_200 positive_signal := positive_signal + 1 if ema_10_crossunder_ema_50 or ema_10_crossunder_ema_100 or ema_10_crossunder_ema_200 or ema_50_crossunder_ema_100 or ema_50_crossunder_ema_200 or ema_100_crossunder_ema_200 positive_signal := positive_signal - 1 //SAR indicator start = input(0.02, title = "SAR Start value", group = "SAR") increment = input(0.02, title = "SAR Incremental value", group = "SAR") maximum = input(0.2, title = "SAR Max Value", group = "SAR") out = ta.sar(start, increment, maximum) if out <= close positive_signal := positive_signal + 1 if out > close positive_signal := positive_signal - 1 //SUper trend atrPeriod = input(10, "ATR Length", group = "Super Trend") factor = input.float(3.0, "Factor", step = 0.01, group = "Super Trend") [supertrend, direction] = ta.supertrend(factor, atrPeriod) if direction < 0 positive_signal := positive_signal + 1 else positive_signal := positive_signal - 1 //End of calculations for positive signal price_indicator_corelation = ta.correlation(positive_signal, close, hl_period) signal_average = ta.sma(positive_signal/100,hl_period) signal_high = ta.highest(positive_signal/100,hl_period) signal_low = ta.lowest(positive_signal/100,hl_period) var float co_variance_positive_signal_and_signal_high_high = 0 var float co_variance_positive_signal_and_signal_low_high = 0 a = array.new_float(0) b = array.new_float(0) c = array.new_float(0) e = array.new_float(0) f = array.new_float(0) for i = 0 to 10 array.push(a, positive_signal[i]) array.push(b, ((close+open)/2)[i]) array.push(c, signal_high[i]) array.push(e, signal_low[i]) co_variance_price_and_positive_signal = math.round(array.covariance(a, b)/100, 2) co_variance_price_and_positive_signal_high = ta.highest(co_variance_price_and_positive_signal,5) co_variance_positive_signal_and_signal_high = math.round(array.covariance(a, c), 5) co_variance_positive_signal_and_signal_low = math.round(array.covariance(a, e), 5) highest_val_co_variance_positive_signal_and_signal_high = ta.highest(co_variance_positive_signal_and_signal_high,5) lowest_val_co_variance_positive_signal_and_signal_high = ta.lowest(co_variance_positive_signal_and_signal_high,5) highest_val_co_variance_positive_signal_and_signal_low = ta.highest(co_variance_positive_signal_and_signal_low,5) lowest_val_co_variance_positive_signal_and_signal_low = ta.lowest(co_variance_positive_signal_and_signal_low,5) if co_variance_positive_signal_and_signal_high > 0 co_variance_positive_signal_and_signal_high_high := highest_val_co_variance_positive_signal_and_signal_high else if co_variance_positive_signal_and_signal_high <= 0 co_variance_positive_signal_and_signal_high_high := lowest_val_co_variance_positive_signal_and_signal_high if co_variance_positive_signal_and_signal_low > 0 co_variance_positive_signal_and_signal_low_high := highest_val_co_variance_positive_signal_and_signal_low if co_variance_positive_signal_and_signal_low <= 0 co_variance_positive_signal_and_signal_low_high := lowest_val_co_variance_positive_signal_and_signal_low //signal generation price_rising = ta.rising(ta.sma(close,9),5) price_falling = ta.falling(ta.sma(close,9),5) var bool point_one = false var bool point_two = false var bool point_three = false var bool point_four = false var bool point_five = false var bool point_six = false if co_variance_price_and_positive_signal[1] == co_variance_price_and_positive_signal_high[1] and co_variance_price_and_positive_signal < co_variance_price_and_positive_signal_high and co_variance_price_and_positive_signal >= 1 and price_falling point_one := true else point_one := false if co_variance_price_and_positive_signal[1] == co_variance_price_and_positive_signal_high[1] and co_variance_price_and_positive_signal < co_variance_price_and_positive_signal_high and co_variance_price_and_positive_signal >= 1 and price_rising point_two := true else point_two := false if co_variance_positive_signal_and_signal_high[1] == co_variance_positive_signal_and_signal_high_high[1] and co_variance_positive_signal_and_signal_high < co_variance_positive_signal_and_signal_high_high and co_variance_positive_signal_and_signal_high >= 1 and price_rising point_three := true else point_three := false if co_variance_positive_signal_and_signal_high[1] == co_variance_positive_signal_and_signal_high_high[1] and co_variance_positive_signal_and_signal_high > co_variance_positive_signal_and_signal_high_high and co_variance_positive_signal_and_signal_high <= -0.5 and price_rising point_four := true else point_four := false if co_variance_positive_signal_and_signal_low[1] == co_variance_positive_signal_and_signal_low_high[1] and co_variance_positive_signal_and_signal_low < co_variance_positive_signal_and_signal_low_high and co_variance_positive_signal_and_signal_low >= 1 and price_falling point_five := true else point_five := false if co_variance_positive_signal_and_signal_low[1] == co_variance_positive_signal_and_signal_low_high[1] and co_variance_positive_signal_and_signal_low > co_variance_positive_signal_and_signal_low_high and co_variance_positive_signal_and_signal_low <= -0.5 and price_falling point_six := true else point_six := false //Graphs //MOM plot(show == "Momentum Ocilator" ? chandeMO_10:na, color=color.new(color.green,50), title = "MOM-10") plot(show == "Momentum Ocilator" ? chandeMO_50:na, color=color.yellow, title = "MOM-50") plot(show == "Momentum Ocilator" ? chandeMO_100:na, color=color.orange, title = "MOM-100") plot(show == "Momentum Ocilator" ? chandeMO_200:na, color=color.red, title = "MOM-200") plot(show == "Momentum Ocilator" ? 80:na, color=color.new(color.white,50), title = "80") plot(show == "Momentum Ocilator" ? 40:na, color=color.new(color.white,50), title = "40") plot(show == "Momentum Ocilator" ? 00:na, color=color.new(color.white,50), title = "00") plot(show == "Momentum Ocilator" ? -40:na, color=color.new(color.white,50), title = "-40") plot(show == "Momentum Ocilator" ? -80:na, color=color.new(color.white,50), title = "-80") //Volume change plot(show == "Volume Ocilator" ? osc:na, color=#2962FF, title = "Volume Ocillator") plot(show == "Volume Ocilator" ? 100:na, color=color.new(color.white,50), title = "100") plot(show == "Volume Ocilator" ? 300:na, color=color.new(color.white,50), title = "300") plot(show == "Volume Ocilator" ? 500:na, color=color.new(color.white,50), title = "500") plot(show == "Volume Ocilator" ? 0:na, color=color.new(color.white,50), title = "0") //RSI plot(show == "RSI" ? rsi_10:na, color=color.new(color.green,50), title = "RSI-10") plot(show == "RSI" ? rsi_50:na, color=color.yellow, title = "RSI-50") plot(show == "RSI" ? rsi_100:na, color=color.orange, title = "RSI-100") plot(show == "RSI" ? rsi_200:na, color=color.red, title = "RSI-200") //MFI plot(show == "MFI" ? mfi_10:na, color=color.new(color.green,50), title = "MFI-10") plot(show == "MFI" ? mfi_50:na, color=color.yellow, title = "MFI-50") plot(show == "MFI" ? mfi_100:na, color=color.orange, title = "MFI-100") plot(show == "MFI" ? mfi_200:na, color=color.red, title = "MFI-200") //RVI plot(show == "RVI" ? rvi_10:na, color=color.new(color.green,50), title = "RVI-10") plot(show == "RVI" ? rvi_50:na, color=color.yellow, title = "RVI-50") plot(show == "RVI" ? rvi_100:na, color=color.orange, title = "RVI-100") plot(show == "RVI" ? rvi_200:na, color=color.red, title = "RVI-200") //BOP plot(show == "BOP" ? bop_10:na, color=color.new(color.green,50), title = "BOP-10") plot(show == "BOP" ? bop_50:na, color=color.yellow, title = "BOP-50") plot(show == "BOP" ? bop_100:na, color=color.orange, title = "BOP-100") plot(show == "BOP" ? bop_200:na, color=color.red, title = "BOP-200") //SMA plot(show == "SMA" ? sma_10:na, color=color.new(color.green,50), title = "SMA-10") plot(show == "SMA" ? sma_50:na, color=color.yellow, title = "SMA-50") plot(show == "SMA" ? sma_100:na, color=color.orange, title = "SMA-100") plot(show == "SMA" ? sma_200:na, color=color.red, title = "SMA-200") //EMA plot(show == "EMA" ? ema_10:na, color=color.new(color.green,50), title = "EMA-10") plot(show == "EMA" ? ema_50:na, color=color.yellow, title = "EMA-50") plot(show == "EMA" ? ema_100:na, color=color.orange, title = "EMA-100") plot(show == "EMA" ? ema_200:na, color=color.red, title = "EMA-200") plot(show == "RSI" or show == "MFI" or show == "RVI" or show == "BOP" ? 60:na, color=color.new(color.white,50), title = "60") plot(show == "RSI" or show == "MFI" or show == "RVI" or show == "BOP" ? 50:na, color=color.new(color.white,50), title = "50") plot(show == "RSI" or show == "MFI" or show == "RVI" or show == "BOP" ? 40:na, color=color.new(color.white,50), title = "40") //Stochastic Indicator plot(show == 'Stochastic Indicator'? k:na, color=#2962FF, title="%K") plot(show == 'Stochastic Indicator'? d:na, color=#FF6D00, title="%D") plot(show == "positive_signal" ? positive_signal/100 : na, title = "positive_signal") plot(show == "positive_signal" ? (co_variance_price_and_positive_signal):na, title = "CV between Price & Signal", color = color.orange) plot(show == "positive_signal" ? (co_variance_positive_signal_and_signal_high):na, title = "CV between High values & Signal", color = color.white) plot(show == "positive_signal" ? (co_variance_positive_signal_and_signal_low):na, title = "CV between Low values & Signal", color = color.green) //Shapes plotshape(point_one == true, style = shape.arrowdown, color = color.orange, location = location.abovebar, size = size.large, text = "1") plotshape(point_two == true, style = shape.arrowdown, color = color.red, location = location.abovebar, size = size.large, text = "2") plotshape(point_three == true, style = shape.arrowdown, color = color.white, location = location.abovebar, size = size.large, text = "3") plotshape(point_four == true, style = shape.arrowdown, color = color.silver, location = location.abovebar, size = size.large, text = "4") plotshape(point_five == true, style = shape.arrowdown, color = color.green, location = location.abovebar, size = size.large, text = "5") plotshape(point_six == true, style = shape.arrowdown, color = color.olive, location = location.abovebar, size = size.large, text = "6")
MTF MA Reference Levels - SamX
https://www.tradingview.com/script/oB1O6sMx-MTF-MA-Reference-Levels-SamX/
SamAccountX
https://www.tradingview.com/u/SamAccountX/
150
study
5
MPL-2.0
// This source code provided free and open-source as defined by the terms of the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/) // with the following additional requirements: // // 1. Citations for sources and references must be maintained and updated when appropriate // 2. Links to strategy references included in indicator tooptips and/or alerts should be retained to give credit to the original source // while also providing a freely available source of information on proper use and interpretation // // Author: SamAccountX // // The intent of this indicator is to provide a way to easily reference the same moving average across multiple timeframes without the clutter // of multiple moving averate lines being printed on the chart (which can also lead to potential difficulty in easily distinguishing which line // represent what timeframe). // // Note: While I usually prefer to structure my code by a more "standard" flow of Inputs -> Function Definitiona -> Functional Code, // I opted to take a slightly different approach in this indicator to break out the individual moving average timeframe and color // inputs along with their actual calculations and plot code, as this makes scaling out (adding additional timeframes) a lot easier. // //@version=5 indicator(title="MTF MA Reference Levels - SamX", shorttitle="MTF MAs", overlay=true) // //       BEGIN inputs       // // Global settings g_Global = "Global Settings" maType = input.string(title="Moving Average Calculation", defval="Exponential", group=g_Global, tooltip='Select the moving average calculation method to use. This ' + 'same calculation method will be used for ALL selected timeframes!', options=["Simple", "Exponential", "Weighted", "Volume-Weigehted", "Smoothed", "RMA", "Linear", "Hull", "ALMA", "Double EMA", "Triple EMA"]) maLength = input.int(title="Moving Average Length", defval=144, minval=2, maxval=500, step=1, group=g_Global, tooltip='Select the moving average length to use. This ' + 'same length will be used for ALL selected timeframes!') maSource = input.source(title="Moving Average Price Source", defval=close, group=g_Global, tooltip='Select the moving average price source to use. This ' + 'same price source will be used for ALL selected timeframes!') allowRepainting = input.bool(title="Allow Real-Time Updates", defval=true, group=g_Global, tooltip='If selected (enabled), moving average calculations on the current bar ' + 'will update as new price data comes in, which may alter the line level and/or displayed Moving Average value (also known as "repainting"). This ' + 'same setting will be used for ALL selected timeframes!') lineOffset = input.int(title="Line offset", group=g_Global, defval=20, minval=0, maxval=100, step=1, tooltip='This setting controls the left offest (number candles to the ' + 'left of the current/latest candle) for the MA lines. A value of 0 will start the line on the current candle.') showLabel = input.bool(title='Show MA Line Labels', defval=true, group=g_Global, tooltip='If selected, labels will be placed on the MA lines. \n\n' + 'The label position/direction will be based on the current MA value compared to the value on the previous candle. If the current MA value is greater than the ' + 'previous one, it will be a down-label (printed above the MA line with the carat pointing down), and as an up-label if the current MA vale us greater than the ' + 'previous one') labelOffset = input.int(title="Label offset", group=g_Global, defval=40, minval=0, maxval=100, step=1, tooltip='This setting controls the right offest (number candles to the ' + 'right of the current/latest candle) for labels. A value of 0 will print the label on the current candle.') additionalabelOffset = input.int(title="Additional Label offset", group=g_Global, defval=10, minval=0, maxval=100, step=1, tooltip='This setting controls an additional right offest for ' + 'subesequent labels (number candles to the right of the previous TF label). A value of 0 will print the labels in the same location on the X (time) axis, which might result ' + 'in label overlap.') labelAsPeriod = input.bool(title='Show TF in Label', defval=false, group=g_Global, tooltip='The default label text is the actual current MA value rounded to the nearest tick of the ' + 'current chart. If this option is selected, the label text will instead be replaced with the timeframe reference period String representation. \n\n' + 'See: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Timeframes.html#timeframe-string-specifications') //       END inputs       //       BEGIN Function Definitions       // // DEMA dema(src, len) => de1 = ta.ema(src, len) de2 = ta.ema(de1, len) dema = 2 * de1 - de2 // TEMA tema(src, len) => te1 = ta.ema(src, len) te2 = ta.ema(te1, len) te3 = ta.ema(te2, len) tema = 3 * (te1 - te2) + te3 // Function to calculate smoothed moving average... smoothedMovingAvg(src, len) => smma = 0.0 // TV will complain about the use of the ta.sma function use inside a function saying that it should be called on each calculation, // but since we're only using it once to set the initial value for the smoothed MA (when the previous smma value is NaN - Not a Number) // and using the previous smma value for each subsequent iteration, this can be safely ignored smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len smma // MA calculation ma(source, length, type) => switch type "Simple" => ta.sma(source, length) "Exponential" => ta.ema(source, length) "Weighted" => ta.wma(source, length) "Volume-Weigehted" => ta.vwma(source, length) "Smoothed" => smoothedMovingAvg(source, length) "RMA" => ta.rma(source, length) "Linear" => ta.linreg(source, length, 0) "Hull" => ta.hma(source, length) "ALMA" => ta.alma(source, length, 0.85, 6) "Double EMA" => dema(source, length) "Triple EMA" => tema(source, length) // //       END Function Definitions       // // //       Functional code start       // // TODO: Get EMA values for up to 5 higher timeframes and plot short-lenght lines extending fully to the right, // with a label indicating the MA timeframe and (optionally) MA value. // // Bonus points: ability to have these printed in an on-chart table... // // Explicitly define our ticker to help ensure that we're always getting ACTUAL price instead of relying on the input // ticker info and input vars (as they tend to inherit the type from what's displayed on the current chart) realPriceTicker = ticker.new(prefix=syminfo.prefix, ticker=syminfo.ticker) // Tracking var to assist in scale/offset of labels labelPrintCounter = 0 //       BEGIN MTF Code sections       // // TF #1 (intended as chart) // g_tf1 = 'Timeframe #1' showTF1 = input.bool(title='', defval=true, group=g_tf1, inline='t1_1') tf1Timeframe = input.timeframe(title='Timeframe:', defval='', group=g_tf1, inline='t1_1') tf1LineColor = input.color(title='Line/Label:', defval=color.rgb(255, 255, 255, 0), group=g_tf1, inline='t1_2') tf1LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(0, 0, 0, 0), group=g_tf1, inline='t1_2') tf1MA = request.security(symbol=realPriceTicker, timeframe=tf1Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if (showTF1) tf1MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf1MA : tf1MA[1], y2=allowRepainting ? tf1MA : tf1MA[1], extend=extend.right, style=line.style_dashed, color=tf1LineColor) line.delete(tf1MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf1Timeframe) == 0 ? timeframe.period : tf1Timeframe) : allowRepainting ? str.tostring(tf1MA, format.mintick) : str.tostring(tf1MA[1], format.mintick) labelStyleUp = allowRepainting ? tf1MA > tf1MA[1] ? true : false : tf1MA[1] > tf1MA[2] ? true : false tlLabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf1MALabel = label.new(x=(bar_index + tlLabelOffset), y=allowRepainting ? tf1MA : tf1MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf1LineColor, textcolor=tf1LabelTextColor) label.delete(tf1MALabel[1]) labelPrintCounter := labelPrintCounter + 1 // TF #2 (intended as 1 TF higher) // g_tf2 = 'Timeframe #2' showTF2 = input.bool(title='', defval=true, group=g_tf2, inline='t1_1') tf2Timeframe = input.timeframe(title='Timeframe:', defval='5', group=g_tf2, inline='t1_1') tf2LineColor = input.color(title='Line/Label:', defval=color.rgb(255, 255, 0, 0), group=g_tf2, inline='t1_2') tf2LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(0, 0, 0, 0), group=g_tf2, inline='t1_2') tf2MA = request.security(symbol=realPriceTicker, timeframe=tf2Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if (showTF2) tf2MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf2MA : tf2MA[1], y2=allowRepainting ? tf2MA : tf2MA[1], extend=extend.right, style=line.style_dashed, color=tf2LineColor) line.delete(tf2MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf2Timeframe) == 0 ? timeframe.period : tf2Timeframe) : allowRepainting ? str.tostring(tf2MA, format.mintick) : str.tostring(tf2MA[1], format.mintick) labelStyleUp = allowRepainting ? tf2MA > tf2MA[1] ? true : false : tf2MA[1] > tf2MA[2] ? true : false t2LabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf2MALabel = label.new(x=(bar_index + t2LabelOffset), y=allowRepainting ? tf2MA : tf2MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf2LineColor, textcolor=tf2LabelTextColor) label.delete(tf2MALabel[1]) labelPrintCounter := labelPrintCounter + 1 // TF #3 (intended as 2 TF higher) // g_tf3 = 'Timeframe #3' showTF3 = input.bool(title='', defval=true, group=g_tf3, inline='t1_1') tf3Timeframe = input.timeframe(title='Timeframe:', defval='15', group=g_tf3, inline='t1_1') tf3LineColor = input.color(title='Line/Label:', defval=color.rgb(0, 255, 255, 0), group=g_tf3, inline='t1_2') tf3LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(0, 0, 0, 0), group=g_tf3, inline='t1_2') tf3MA = request.security(symbol=realPriceTicker, timeframe=tf3Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if (showTF3) tf3MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf3MA : tf3MA[1], y2=allowRepainting ? tf3MA : tf3MA[1], extend=extend.right, style=line.style_dashed, color=tf3LineColor) line.delete(tf3MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf3Timeframe) == 0 ? timeframe.period : tf3Timeframe) : allowRepainting ? str.tostring(tf3MA, format.mintick) : str.tostring(tf3MA[1], format.mintick) labelStyleUp = allowRepainting ? tf3MA > tf3MA[1] ? true : false : tf3MA[1] > tf3MA[2] ? true : false t3LabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf3MALabel = label.new(x=(bar_index + t3LabelOffset), y=allowRepainting ? tf3MA : tf3MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf3LineColor, textcolor=tf3LabelTextColor) label.delete(tf3MALabel[1]) labelPrintCounter := labelPrintCounter + 1 // TF #4 (intended as 3 TF higher) // g_tf4 = 'Timeframe #4' showTF4 = input.bool(title='', defval=true, group=g_tf4, inline='t1_1') tf4Timeframe = input.timeframe(title='Timeframe:', defval='60', group=g_tf4, inline='t1_1') tf4LineColor = input.color(title='Line/Label:', defval=color.rgb(255, 0, 255, 0), group=g_tf4, inline='t1_2') tf4LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(255, 255, 180, 0), group=g_tf4, inline='t1_2') tf4MA = request.security(symbol=realPriceTicker, timeframe=tf4Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if(showTF4) tf4MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf4MA : tf4MA[1], y2=allowRepainting ? tf4MA : tf4MA[1], extend=extend.right, style=line.style_dashed, color=tf4LineColor) line.delete(tf4MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf4Timeframe) == 0 ? timeframe.period : tf4Timeframe) : allowRepainting ? str.tostring(tf4MA, format.mintick) : str.tostring(tf4MA[1], format.mintick) labelStyleUp = allowRepainting ? tf4MA > tf4MA[1] ? true : false : tf4MA[1] > tf4MA[2] ? true : false t4LabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf4MALabel = label.new(x=(bar_index + t4LabelOffset), y=allowRepainting ? tf4MA : tf4MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf4LineColor, textcolor=tf4LabelTextColor) label.delete(tf4MALabel[1]) labelPrintCounter := labelPrintCounter + 1 // TF #5 (intended as 4 TF higher) // g_tf5 = 'Timeframe #5' showTF5 = input.bool(title='', defval=true, group=g_tf5, inline='t1_1') tf5Timeframe = input.timeframe(title='Timeframe:', defval='120', group=g_tf5, inline='t1_1') tf5LineColor = input.color(title='Line/Label:', defval=color.rgb(175, 175, 175, 0), group=g_tf5, inline='t1_2') tf5LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(0, 0, 0, 0), group=g_tf5, inline='t1_2') tf5MA = request.security(symbol=realPriceTicker, timeframe=tf5Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if(showTF5) tf5MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf5MA : tf5MA[1], y2=allowRepainting ? tf5MA : tf5MA[1], extend=extend.right, style=line.style_dashed, color=tf5LineColor) line.delete(tf5MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf5Timeframe) == 0 ? timeframe.period : tf5Timeframe) : allowRepainting ? str.tostring(tf5MA, format.mintick) : str.tostring(tf5MA[1], format.mintick) labelStyleUp = allowRepainting ? tf5MA > tf5MA[1] ? true : false : tf5MA[1] > tf5MA[2] ? true : false t5LabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf5MALabel = label.new(x=(bar_index + t5LabelOffset), y=allowRepainting ? tf5MA : tf5MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf5LineColor, textcolor=tf5LabelTextColor) label.delete(tf5MALabel[1]) labelPrintCounter := labelPrintCounter + 1 // TF #6 (intended as 5 TF higher) // g_tf6 = 'Timeframe #6' showTF6 = input.bool(title='', defval=true, group=g_tf6, inline='t1_1') tf6Timeframe = input.timeframe(title='Timeframe:', defval='240', group=g_tf6, inline='t1_1') tf6LineColor = input.color(title='Line/Label:', defval=color.rgb(170, 120, 250, 0), group=g_tf6, inline='t1_2') tf6LabelTextColor = input.color(title='      Label Text:', defval=color.rgb(0, 0, 0, 0), group=g_tf6, inline='t1_2') tf6MA = request.security(symbol=realPriceTicker, timeframe=tf6Timeframe, expression=ma(maSource, maLength, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) if (showTF6) tf6MALine = line.new(x1=bar_index[lineOffset], x2=bar_index + 1, y1=allowRepainting ? tf6MA : tf6MA[1], y2=allowRepainting ? tf6MA : tf6MA[1], extend=extend.right, style=line.style_dashed, color=tf6LineColor) line.delete(tf6MALine[1]) if (showLabel) labelText = labelAsPeriod ? str.tostring(str.length(tf6Timeframe) == 0 ? timeframe.period : tf6Timeframe) : allowRepainting ? str.tostring(tf6MA, format.mintick) : str.tostring(tf6MA[1], format.mintick) labelStyleUp = allowRepainting ? tf6MA > tf6MA[1] ? true : false : tf6MA[1] > tf6MA[2] ? true : false t6LabelOffset = (additionalabelOffset * labelPrintCounter) + labelOffset tf6MALabel = label.new(x=(bar_index + t6LabelOffset), y=allowRepainting ? tf6MA : tf6MA[1], style=labelStyleUp ? label.style_label_up : label.style_label_down, text=labelText, color=tf6LineColor, textcolor=tf6LabelTextColor) label.delete(tf6MALabel[1]) labelPrintCounter := labelPrintCounter + 1
Lençol (Bedsheet)
https://www.tradingview.com/script/WOl7Rw8h-Len%C3%A7ol-Bedsheet/
jacobfabris
https://www.tradingview.com/u/jacobfabris/
16
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/ // © jacobfabris //@version=4 study("Lençol",overlay = true) T = input(defval=305,minval=4) spot = close G1 = 0.0 G2= 0.0 G3= 0.0 G4= 0.0 G5= 0.0 G6= 0.0 G7= 0.0 G8= 0.0 G9= 0.0 G10= 0.0 G11= 0.0 G12= 0.0 G13= 0.0 G14= 0.0 G15 = 0.0 G16 = 0.0 G1 := spot*17.9436/T + nz(G1[1])*(1-17.9436/T) G2 := spot*15.2841/T + nz(G2[1])*(1-15.2841/T) G3 := spot*13.0000/T + nz(G3[1])*(1-13.0000/T) G4 := spot*11.0893/T + nz(G4[1])*(1-11.0893/T) G5 := spot*09.4457/T + nz(G5[1])*(1-09.4457/T) G6 := spot*08.0458/T + nz(G6[1])*(1-08.0458/T) G7 := spot*06.8533/T + nz(G7[1])*(1-06.8533/T) G8 := spot*05.8376/T + nz(G8[1])*(1-05.8376/T) G9 := spot*04.9724/T + nz(G9[1])*(1-04.9724/T) G10 := spot*04.2360/T + nz(G10[1])*(1-04.2360/T) G11 := spot*03.6077/T + nz(G11[1])*(1-03.6077/T) G12 := spot*03.0730/T + nz(G12[1])*(1-03.0730/T) G13 := spot*02.6175/T + nz(G13[1])*(1-02.6175/T) G14 := spot*02.2296/T + nz(G14[1])*(1-02.2296/T) G15 := spot*01.9000/T + nz(G15[1])*(1-01.9000/T) G16 := spot*01.6180/T + nz(G16[1])*(1-01.6180/T) cor1 = G1 > G1[1] ? color.lime : color.yellow cor2 = G2 > G2[1] ? color.teal : color.orange cor3 = G3 > G3[1] ? color.teal : color.orange cor4 = G4 > G4[1] ? color.teal : color.orange cor5 = G5 > G5[1] ? color.teal : color.orange cor6 = G6 > G6[1] ? color.teal : color.orange cor7 = G7 > G7[1] ? color.teal : color.orange cor8 = G8 > G8[1] ? color.teal : color.orange cor9 = G9 > G9[1] ? color.teal : color.orange cor10 = G10 > G10[1] ? color.white : color.silver cor11 = G10 > G11[1] ? color.teal : color.orange cor12 = G12 > G12[1] ? color.teal : color.orange cor13 = G13 > G13[1] ? color.teal : color.orange cor14 = G14 > G14[1] ? color.teal : color.orange cor15 = G15 > G15[1] ? color.teal : color.orange cor16 = G16 > G16[1] ? color.yellow : color.red plot(G1,color=cor1,linewidth=2) plot(G2,color=cor2) plot(G3,color=cor3) plot(G4,color=cor4) plot(G5,color=cor5) plot(G6,color=cor6) plot(G7,color=cor7) plot(G8,color=cor8) plot(G9,color=cor9) plot(G10,color=cor10,linewidth=2) plot(G11,color=cor11) plot(G12,color=cor12) plot(G13,color=cor13) plot(G14,color=cor14) plot(G15,color=cor15) plot(G16,color=cor16,linewidth=2)
Income Ratio
https://www.tradingview.com/script/ZLOiZykR-Income-Ratio/
morzor61
https://www.tradingview.com/u/morzor61/
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/ // © morzor61 //@version=5 indicator("Income Ratio", format=format.volume) // Revenue & Gross Profit data01 = 'Total revenue' // 'TOTAL_REVENUE' data02 = ' Cost of goods' // 'COST_OF_GOODS' data03 = '  Deprecation and amortization' // 'DEP_AMORT_EXP_INCOME_S' data04 = '  Other COGS' // 'COST_OF_GOODS_EXCL_DEP_AMORT' data05 = 'Gross profit' // 'GROSS_PROFIT' // Total Operating Income / Expense ------------------------------------------------ data06 = 'Operating expenses (excl. COGS)' // 'OPERATING_EXPENSES' data07 = '  Selling/general/admin expenses, total' // 'SELL_GEN_ADMIN_EXP_TOTAL' data08 = '    Selling/general/admin expenses, other' // 'SELL_GEN_ADMIN_EXP_OTHER' data09 = '    Research & development' // 'RESEARCH_AND_DEV' data10 = '  Other operating expenses, total' // 'OTHER_OPER_EXPENSE_TOTAL' data11 = 'Operating income' // 'OPER_INCOME' // Non-Operating Income / Expense ---------------------------------------------- data12 = 'Non-operating interest income' // 'NON_OPER_INTEREST_INCOME' data13 = '  Interest expense, net of interest capitalized' // 'NON_OPER_INTEREST_EXP' data14 = '    Interest expense on debt' // 'INTEREST_EXPENSE_ON_DEBT' data15 = '    Interest capitalized' // 'INTEREST_CAPITALIZED' data16 = '  Non-operating income, excl. interest expenses' // 'NON_OPER_INCOME' data17 = '    Non-operating income, total' // 'TOTAL_NON_OPER_INCOME' data18 = '    Pretax equity in earnings' // 'PRETAX_EQUITY_IN_EARNINGS' data19 = '    Miscellaneous non-operating expense' // 'OTHER_INCOME' data20 = '  Unusual income/expense' // 'UNUSUAL_EXPENSE_INC' data21 = 'Pretax income' // 'PRETAX_INCOME' data22 = '  Equity in earnings' // 'EQUITY_IN_EARNINGS' data23 = '  Taxes' // 'INCOME_TAX' data24 = '  Non-controlling/minority interest' // 'MINORITY_INTEREST_EXP' data25 = 'After tax other income/expense' // 'AFTER_TAX_OTHER_INCOME' data26 = 'Net income before discontinued operations' // 'NET_INCOME_BEF_DISC_OPER' data27 = '  Discontinued operations' // 'DISCONTINUED_OPERATIONS' data28 = 'Net income' // 'NET_INCOME' data29 = '  Dilution adjustment' // 'DILUTION_ADJUSTMENT' data30 = '  Preferred dividends' // 'PREFERRED_DIVIDENDS' data31 = '  Diluted net income available to common stockholders' // 'DILUTED_NET_INCOME' data32 = 'Basic EPS' // 'EARNINGS_PER_SHARE_BASIC' data33 = 'Diluted EPS' // 'EARNINGS_PER_SHARE_DILUTED' data34 = 'Average basic shares outstanding' // 'BASIC_SHARES_OUTSTANDING' data35 = 'Diluted shares outstanding' // 'DILUTED_SHARES_OUTSTANDING' data36 = 'EBITDA' // 'EBITDA' data37 = 'EBIT' // 'EBIT' data38 = 'Total operating expenses' // 'TOTAL_OPER_EXPENSE' data39 = 'Total Share' data_type = input.string('Percent',title ='Data', options=['Percent','Value, M'] ) per = input.string('FY', options=['FQ', 'FY','TTM']) f_fin(_id, _period)=> request.financial(syminfo.tickerid, _id, _period, gaps=barmerge.gaps_off, ignore_invalid_symbol=true) item_01 = f_fin( 'TOTAL_REVENUE' , per) item_02 = f_fin( 'COST_OF_GOODS' , per) item_03 = f_fin( 'DEP_AMORT_EXP_INCOME_S' , per) // item_04 = f_fin( 'COST_OF_GOODS_EXCL_DEP_AMOR' , per) item_05 = f_fin( 'GROSS_PROFIT' , per) item_06 = f_fin( 'OPERATING_EXPENSES' , per) // item_07 = f_fin( 'SELL_GEN_ADMIN_EXP_TOTAL' , per) // item_08 = f_fin( 'SELL_GEN_ADMIN_EXP_OTHER' , per) // item_09 = f_fin( 'RESEARCH_AND_DEV' , per) // item_10 = f_fin( 'OTHER_OPER_EXPENSE_TOTAL' , per) item_11 = f_fin( 'OPER_INCOME' , per) // item_12 = f_fin( 'NON_OPER_INTEREST_INCOME' , per) // item_13 = f_fin( 'NON_OPER_INTEREST_EXP' , per) // item_14 = f_fin( 'INTEREST_EXPENSE_ON_DEBT' , per) // item_15 = f_fin( 'INTEREST_CAPITALIZED' , per) // item_16 = f_fin( 'NON_OPER_INCOME' , per) // item_17 = f_fin( 'TOTAL_NON_OPER_INCOME' , per) // item_18 = f_fin( 'PRETAX_EQUITY_IN_EARNINGS' , per) // item_19 = f_fin( 'OTHER_INCOME' , per) // item_20 = f_fin( 'UNUSUAL_EXPENSE_INC' , per) // item_21 = f_fin( 'PRETAX_INCOME' , per) // item_22 = f_fin( 'EQUITY_IN_EARNINGS' , per) item_23 = f_fin( 'INCOME_TAX' , per) // item_24 = f_fin( 'MINORITY_INTEREST_EXP' , per) // item_25 = f_fin( 'AFTER_TAX_OTHER_INCOME' , per) // item_26 = f_fin( 'NET_INCOME_BEF_DISC_OPER' , per) // item_27 = f_fin( 'DISCONTINUED_OPERATIONS' , per) item_28 = f_fin( 'NET_INCOME' , per) // item_29 = f_fin( 'DILUTION_ADJUSTMENT' , per) // item_30 = f_fin( 'PREFERRED_DIVIDENDS' , per) // item_31 = f_fin( 'DILUTED_NET_INCOME' , per) // item_32 = f_fin( 'EARNINGS_PER_SHARE_BASIC' , per) // item_33 = f_fin( 'EARNINGS_PER_SHARE_DILUTED' , per) // item_34 = f_fin( 'BASIC_SHARES_OUTSTANDING' , per) // item_35 = f_fin( 'DILUTED_SHARES_OUTSTANDING' , per) // item_36 = f_fin( 'EBITDA' , per) // item_37 = f_fin( 'EBIT' , per) // item_38 = f_fin( 'TOTAL_OPER_EXPENSE' , per) // item_39 = f_fin( 'TOTAL_SHARES_OUTSTANDING' , per) f_ratio(_item, _type)=> percent = _type == 'Percent' ? _item/item_01*100 : _item/1000000 per_01 = f_ratio(item_01, data_type) per_02 = f_ratio(item_02, data_type) per_03 = f_ratio(item_03, data_type) per_05 = f_ratio(item_05, data_type) per_06 = f_ratio(item_06, data_type) per_11 = f_ratio(item_11, data_type) per_23 = f_ratio(item_23, data_type) per_28 = f_ratio(item_28, data_type) // plot(per_01) plot(per_01, 'Revenue') plot(per_03, 'Deprecation and amortization', style=plot.style_area, color=color.purple) plot(per_02, 'COGS', style=plot.style_area, color=color.new(color.orange, 50)) plot(per_11, 'Operating Income', color=color.navy) plot(per_06, 'Operating Expense', color=color.red, linewidth=2) plot(per_06+per_23, 'Income Tax', color=color.lime) plot(per_05, 'Gross Profit', style=plot.style_area, color=color.new(color.green,50), linewidth=3) plot(per_28, 'Net Income', style=plot.style_circles, color=color.black, linewidth=3, join=true) if barstate.islast // label.new(bar_index+2, per_01, style=label.style_label_left, text='Revenue:'+str.tostring(per_01, '#,##0.0')) label.new(bar_index+2, per_02, style=label.style_label_left, text='COGS:'+ str.tostring(per_02, '#,##0.0'), color= color.new(color.orange,50)) label.new(bar_index+2, per_03, style=label.style_label_left, text='Dep/Amor:'+ str.tostring(per_03, '#,##0.0'), color = color.new(color.purple, 50)) label.new(bar_index+2, per_06, style=label.style_label_left, text='Operating expense:'+str.tostring(per_06, '#,##0.0'), color = color.new(color.red, 50)) label.new(bar_index+2, per_06+per_23, style=label.style_label_left, text='Income Tax:'+ str.tostring(per_23, '#,##0.0'), color=color.new(color.lime,50)) label.new(bar_index+2, per_05, style=label.style_label_left, text='Gross Profit:'+ str.tostring(per_05, '#,##0.0'), color = color.new(color.green, 50)) label.new(bar_index+2, per_28, style=label.style_label_left, text='Net Income:'+ str.tostring(per_28, '#,##0.0')) label.new(bar_index+2, per_11, style=label.style_label_left, text='Operating Income:'+ str.tostring(per_11, '#,##0.0'), color = color.new(color.navy, 50))
Next-Gen Engulfing Retracement
https://www.tradingview.com/script/syiWX03E-Next-Gen-Engulfing-Retracement/
RickSimpson
https://www.tradingview.com/u/RickSimpson/
647
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/ // © RickSimpson //@version=5 indicator('Next-Gen Engulfing Retracement', 'Next-Gen Engulfing Retracement', overlay=true, max_bars_back=500, max_lines_count=500, max_labels_count=500) ///////////////////////////////////// // Next-Gen Engulfing Retracement // ///////////////////////////////////// //Groups Setup groupcolor = "COLOR SETUP" groupretracement = "RETRACEMENT LINES SETTINGS" groupengulfing = "ENGULFING SETTINGS" groupalert = "ALERTS SETUP" //Customization Inputs bearishengulfingcolor = input.color(color.red, 'Bearish Engulfing Color', group=groupcolor) bullishengulfingcolor = input.color(color.green, 'Bullish engulfing Color', group=groupcolor) //Inputs showstrong = input.bool(true, 'Show Strong Engulfing Retracements?', group=groupretracement) show = input.bool(true, 'Show Engulfing Retracements?', group=groupretracement) maxlines = input.int(10, 'Maximum Lines', minval=1, maxval=500, group=groupretracement, inline='lines') layout = input.string('Wick', 'Lines Type', options=['Wick', 'Zone'], group=groupretracement, inline='lines') linessize = input.int(1, 'Lines Width     ', minval=1, maxval=3, group=groupretracement, inline='lines style') linestyle = input.string('Dotted', 'Lines Style', options=['Solid', 'Dotted', 'Dashed'], group=groupretracement, inline='lines style') extend = input.bool(false, 'Extend Lines?', group=groupretracement, inline='lines style') showengulfing = input.bool(true, 'Strong Engulfing Labels?', group=groupengulfing) showallengulfing = input.bool(false, 'Engulfing Labels?', group=groupengulfing) engulfingalerts = input.bool(true, 'Enable Engulfing Candles Alerts?', group=groupalert) crossingalerts = input.bool(true, 'Enable Retracement Lines Crossing Alerts?', group=groupalert) //Price Variables Declaration open_ = open high_ = high low_ = low close_ = close bar_index_ = bar_index //Color Call Function fzonecolor(obcolor, _call) => c1 = color.r(obcolor) c2 = color.g(obcolor) c3 = color.b(obcolor) color.rgb(c1, c2, c3, _call) //Round Function round_f(x) => math.round(x / syminfo.mintick) * syminfo.mintick //Truncated Percentile Function percent_1(x, y) => z = x * 100 / y z //Lines Styles String Function f_linestyle(_style) => _style == 'Solid' ? line.style_solid : _style == 'Dotted' ? line.style_dotted : line.style_dashed //Directions Variables Declaration beardir = close < open bulldir = close > open //Body Candle Size Calculation body = math.abs(close - open) //Momentum Calculation math = math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1])) //Average True Range Built-in Function atr = ta.atr(100) //Engulfment Size Calculation bodysizetop = atr * 1.1 bodysizebottom = atr / 3 smallbodysizetop = atr / 3 smallbodysizebottom = atr / 8 //Engulfment Conditions bodyengulfing = body > bodysizebottom and body < bodysizetop smallbodyengulfing = body > smallbodysizebottom and body < smallbodysizetop //Engulfing Calculation bearengulfing = (smallbodyengulfing[1] or bodyengulfing[1]) and bulldir[1] and beardir and open[1] > close bullengulfing = (smallbodyengulfing[1] or bodyengulfing[1]) and beardir[1] and bulldir and close > open[1] //Boolean Conditions to Float var float bearengulfingprice = na if bearengulfing bearengulfingprice := high bearengulfingprice var float bullengulfingprice = na if bullengulfing bullengulfingprice := low bullengulfingprice if showallengulfing l = ta.change(bearengulfingprice) ? label.new(bar_index_, bearengulfingprice[1] + 0.01, str.tostring(round_f(bearengulfingprice)), color=color.new(bearishengulfingcolor, 100), textcolor=bearishengulfingcolor, style=label.style_label_down, yloc=yloc.abovebar, size=size.small) : ta.change(bullengulfingprice) ? label.new(bar_index_, bullengulfingprice[1] - 0.01, str.tostring(round_f(bullengulfingprice)), color=color.new(bullishengulfingcolor, 100), textcolor=bullishengulfingcolor, style=label.style_label_up, yloc=yloc.belowbar, size=size.small) : na l //Strong Engulfing Calculation strongbearengulfing = beardir[2] and bullengulfing[1] and bearengulfing strongbullengulfing = bulldir[2] and bearengulfing[1] and bullengulfing //Boolean Conditions to Float var float strongbearengulfingprice = na if strongbearengulfing strongbearengulfingprice := high strongbearengulfingprice var float strongbullengulfingprice = na if strongbullengulfing strongbullengulfingprice := low strongbullengulfingprice if showengulfing l = ta.change(strongbearengulfingprice) ? label.new(bar_index_, strongbearengulfingprice[1] + 0.01, str.tostring(round_f(strongbearengulfingprice)), color=color.new(bearishengulfingcolor, 100), textcolor=bearishengulfingcolor, style=label.style_label_down, yloc=yloc.abovebar, size=size.small) : ta.change(strongbullengulfingprice) ? label.new(bar_index_, strongbullengulfingprice[1] - 0.01, str.tostring(round_f(strongbullengulfingprice)), color=color.new(bullishengulfingcolor, 100), textcolor=bullishengulfingcolor, style=label.style_label_up, yloc=yloc.belowbar, size=size.small) : na l //Plotting plotshape(strongbearengulfing, title='Strong Bearish Engulfing', text=' ', color=bearishengulfingcolor, style=shape.triangledown, location=location.abovebar, size=size.small) barcolor(beardir[2] and bullengulfing[1] and bearengulfing ? bearishengulfingcolor : na) plotshape(strongbullengulfing, title='Strong Bullish Engulfing', text=' ', color=bullishengulfingcolor, style=shape.triangleup, location=location.belowbar, size=size.small) barcolor(bulldir[2] and bearengulfing[1] and bullengulfing ? bullishengulfingcolor : na) plotshape(showallengulfing ? bearengulfing : na, title= "Bearish Engulfing", color=bearishengulfingcolor, text=' ', textcolor=bearishengulfingcolor, style=shape.arrowdown, location=location.abovebar, size=size.tiny) plotshape(showallengulfing ? bullengulfing : na, title= "Bullish Engulfing", color=bullishengulfingcolor, text=' ', textcolor=bullishengulfingcolor, style=shape.arrowup, location=location.belowbar, size=size.tiny) //Alerts if engulfingalerts and strongbearengulfing == 1 alert('Strong Bearish Engulfing Detected! At ' + str.tostring(strongbearengulfingprice), alert.freq_once_per_bar) if engulfingalerts and strongbullengulfing == 1 alert('Strong Bullish Engulfing Detected! At ' + str.tostring(strongbullengulfingprice), alert.freq_once_per_bar) if engulfingalerts and bearengulfing == 1 alert('Bearish Engulfing Detected! At ' + str.tostring(bearengulfingprice), alert.freq_once_per_bar) if engulfingalerts and bullengulfing == 1 alert('Bullish Engulfing Detected! At ' + str.tostring(bullengulfingprice), alert.freq_once_per_bar) //Retracement Lines Variables Declaration var int numberofline = maxlines var float upperphzone = na var float upperplzone = na var float lowerphzone = na var float lowerplzone = na var line[] upperphzonearr = array.new_line(0, na) var line[] upperplzonearr = array.new_line(0, na) var line[] lowerphzonearr = array.new_line(0, na) var line[] lowerplzonearr = array.new_line(0, na) var line upperphzoneline = na var line upperplzoneline = na var line lowerphzoneline = na var line lowerplzoneline = na var bool[] upperzonetestedarr = array.new_bool(0, false) var bool[] lowerzonetestedarr = array.new_bool(0, false) var bool upperzonetested = false var bool lowerzonetested = false var bool nobool = true var bool showprice = true var color upperzonecolor = bearishengulfingcolor var color lowerzonecolor = bullishengulfingcolor var label[] labelpharr = array.new_label(0, na) var label[] labelplarr = array.new_label(0, na) var label labelph = na var label labelpl = na var int numberofline2 = maxlines var float upperphzone2 = na var float upperplzone2 = na var float lowerphzone2 = na var float lowerplzone2 = na var line[] upperphzonearr2 = array.new_line(0, na) var line[] upperplzonearr2 = array.new_line(0, na) var line[] lowerphzonearr2 = array.new_line(0, na) var line[] lowerplzonearr2 = array.new_line(0, na) var line upperphzoneline2 = na var line upperplzoneline2 = na var line lowerphzoneline2 = na var line lowerplzoneline2 = na var bool[] upperzonetestedarr2 = array.new_bool(0, false) var bool[] lowerzonetestedarr2 = array.new_bool(0, false) var bool upperzonetested2 = false var bool lowerzonetested2 = false var bool nobool2 = true var color upperzonecolor2 = bearishengulfingcolor var color lowerzonecolor2 = bullishengulfingcolor var string stronglinestyle = 'Solid' var label[] labelpharr2 = array.new_label(0, na) var label[] labelplarr2 = array.new_label(0, na) var label labelph2 = na var label labelpl2 = na //Strong Bearish Engulfing Retracement Lines Calculation if showstrong and strongbearengulfing upperphzone := high_ upperplzone := close_ < open_ ? close_ : open_ upperplzoneline := layout == 'Zone' ? line.new(bar_index_, upperplzone, bar_index, upperplzone, width=linessize) : na upperphzoneline := nobool ? line.new(bar_index_, upperphzone, bar_index, upperphzone, width=linessize) : line.new(bar_index_, (upperphzone + upperplzone) / 2, bar_index, (upperphzone + upperplzone) / 2, width=linessize) labelph := showprice ? label.new(bar_index_, nobool ? upperphzone : (upperphzone + upperplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=upperzonecolor, style=label.style_none) : na if array.size(upperphzonearr) > numberofline line.delete(array.shift(upperphzonearr)) line.delete(array.shift(upperplzonearr)) array.shift(upperzonetestedarr) label.delete(array.shift(labelpharr)) array.push(upperphzonearr, upperphzoneline) array.push(upperplzonearr, upperplzoneline) array.push(upperzonetestedarr, extend ? true : false) array.push(labelpharr, labelph) if array.size(upperplzonearr) > 0 for i = 0 to array.size(upperplzonearr) - 1 by 1 line tempupperline = array.get(upperphzonearr, i) line templowerline = array.get(upperplzonearr, i) label linepricelabel = array.get(labelpharr, i) bool tested = array.get(upperzonetestedarr, i) line.set_style(tempupperline, f_linestyle(stronglinestyle)) line.set_style(templowerline, f_linestyle(stronglinestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), fzonecolor(upperzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(upperzonecolor, 00), upperzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(tempupperline)))) label.set_text(linepricelabel, '                                                    Bearish Engulfing - ' + str.tostring(round_f(line.get_y1(tempupperline)))) label.set_x(linepricelabel, bar_index) crossed = high > line.get_y1(tempupperline) if crossed and not tested array.set(upperzonetestedarr, i, true) label.delete(linepricelabel) if crossingalerts and crossed and not tested array.set(upperzonetestedarr, i, true) label.delete(linepricelabel) alert('Strong Bearish Engulfing Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(upperphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(upperplzonearr, i, templowerline) //Strong Bullish Engulfing Retracement Lines Calculation if showstrong and strongbullengulfing lowerplzone := low_ lowerphzone := close_ < open_ ? open_ : close_ lowerphzoneline := layout == 'Zone' ? line.new(bar_index_, lowerphzone, bar_index, lowerphzone, width=linessize) : na lowerplzoneline := nobool ? line.new(bar_index_, lowerplzone, bar_index, lowerplzone, width=linessize) : line.new(bar_index_, (lowerphzone + lowerplzone) / 2, bar_index, (lowerphzone + lowerplzone) / 2, width=linessize) labelpl := showprice ? label.new(bar_index_, nobool ? lowerplzone : (lowerphzone + lowerplzone) / 2, text=str.tostring(bar_index - bar_index_), textcolor=lowerzonecolor, style=label.style_none) : na if array.size(lowerphzonearr) > numberofline line.delete(array.shift(lowerphzonearr)) line.delete(array.shift(lowerplzonearr)) array.shift(lowerzonetestedarr) label.delete(array.shift(labelplarr)) array.push(lowerphzonearr, lowerphzoneline) array.push(lowerplzonearr, lowerplzoneline) array.push(lowerzonetestedarr, extend ? true : false) array.push(labelplarr, labelpl) if array.size(lowerplzonearr) > 0 for i = 0 to array.size(lowerplzonearr) - 1 by 1 line tempupperline = array.get(lowerphzonearr, i) line templowerline = array.get(lowerplzonearr, i) label linepricelabel = array.get(labelplarr, i) bool tested = array.get(lowerzonetestedarr, i) line.set_style(tempupperline, f_linestyle(stronglinestyle)) line.set_style(templowerline, f_linestyle(stronglinestyle)) line.set_color(tempupperline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) line.set_color(templowerline, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), fzonecolor(lowerzonecolor, 00))) label.set_textcolor(linepricelabel, color.from_gradient(i, 1, numberofline, fzonecolor(lowerzonecolor, 00), lowerzonecolor)) label.set_text(linepricelabel, str.tostring(round_f(line.get_y1(templowerline)))) label.set_text(linepricelabel, '                                                   Bullish Engulfing - ' + str.tostring(round_f(line.get_y1(templowerline)))) label.set_x(linepricelabel, bar_index) crossed = low < line.get_y1(templowerline) if crossed and not tested array.set(lowerzonetestedarr, i, true) label.delete(linepricelabel) if crossingalerts and crossed and not tested array.set(lowerzonetestedarr, i, true) label.delete(linepricelabel) alert('Strong Bullish Engulfing Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested : not tested line.set_x2(tempupperline, bar_index) array.set(lowerphzonearr, i, tempupperline) line.set_x2(templowerline, bar_index) array.set(lowerplzonearr, i, templowerline) //Bearish Engulfing Retracement Lines Calculation if show and bearengulfing upperphzone2 := high_ upperplzone2 := close_ < open_ ? close_ : open_ upperplzoneline2 := layout == 'Zone' ? line.new(bar_index_, upperplzone2, bar_index, upperplzone2, width=linessize) : na upperphzoneline2 := nobool ? line.new(bar_index_, upperphzone2, bar_index, upperphzone2, width=linessize) : line.new(bar_index_, (upperphzone2 + upperplzone2) / 2, bar_index, (upperphzone2 + upperplzone2) / 2, width=linessize) labelph2 := showprice ? label.new(bar_index_, nobool ? upperphzone2 : (upperphzone2 + upperplzone2) / 2, text=str.tostring(bar_index - bar_index_), textcolor=upperzonecolor2, style=label.style_none) : na if array.size(upperphzonearr2) > numberofline2 line.delete(array.shift(upperphzonearr2)) line.delete(array.shift(upperplzonearr2)) array.shift(upperzonetestedarr2) label.delete(array.shift(labelpharr2)) array.push(upperphzonearr2, upperphzoneline2) array.push(upperplzonearr2, upperplzoneline2) array.push(upperzonetestedarr2, extend ? true : false) array.push(labelpharr2, labelph2) if array.size(upperplzonearr2) > 0 for i = 0 to array.size(upperplzonearr2) - 1 by 1 line tempupperline2 = array.get(upperphzonearr2, i) line templowerline2 = array.get(upperplzonearr2, i) label linepricelabel2 = array.get(labelpharr2, i) bool tested2 = array.get(upperzonetestedarr2, i) line.set_style(tempupperline2, f_linestyle(linestyle)) line.set_style(templowerline2, f_linestyle(linestyle)) line.set_color(tempupperline2, color.from_gradient(i, 1, numberofline2, fzonecolor(upperzonecolor2, 00), fzonecolor(upperzonecolor2, 00))) line.set_color(templowerline2, color.from_gradient(i, 1, numberofline2, fzonecolor(upperzonecolor2, 00), fzonecolor(upperzonecolor2, 00))) label.set_textcolor(linepricelabel2, color.from_gradient(i, 1, numberofline2, fzonecolor(upperzonecolor2, 00), upperzonecolor2)) label.set_text(linepricelabel2, str.tostring(round_f(line.get_y1(tempupperline2)))) label.set_text(linepricelabel2, '                                                    Bearish Engulfing - ' + str.tostring(round_f(line.get_y1(tempupperline2)))) label.set_x(linepricelabel2, bar_index) crossed = high > line.get_y1(tempupperline2) if crossed and not tested2 array.set(upperzonetestedarr2, i, true) label.delete(linepricelabel2) if crossingalerts and crossed and not tested2 array.set(upperzonetestedarr2, i, true) label.delete(linepricelabel2) alert('Bearish Engulfing Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested2 : not tested2 line.set_x2(tempupperline2, bar_index) array.set(upperphzonearr2, i, tempupperline2) line.set_x2(templowerline2, bar_index) array.set(upperplzonearr2, i, templowerline2) //Bullish Engulfing Retracement Lines Calculation if show and bullengulfing lowerplzone2 := low_ lowerphzone2 := close_ < open_ ? open_ : close_ lowerphzoneline2 := layout == 'Zone' ? line.new(bar_index_, lowerphzone2, bar_index, lowerphzone2, width=linessize) : na lowerplzoneline2 := nobool ? line.new(bar_index_, lowerplzone2, bar_index, lowerplzone2, width=linessize) : line.new(bar_index_, (lowerphzone2 + lowerplzone2) / 2, bar_index, (lowerphzone2 + lowerplzone2) / 2, width=linessize) labelpl2 := showprice ? label.new(bar_index_, nobool ? lowerplzone2 : (lowerphzone2 + lowerplzone2) / 2, text=str.tostring(bar_index - bar_index_), textcolor=lowerzonecolor2, style=label.style_none) : na if array.size(lowerphzonearr2) > numberofline2 line.delete(array.shift(lowerphzonearr2)) line.delete(array.shift(lowerplzonearr2)) array.shift(lowerzonetestedarr2) label.delete(array.shift(labelplarr2)) array.push(lowerphzonearr2, lowerphzoneline2) array.push(lowerplzonearr2, lowerplzoneline2) array.push(lowerzonetestedarr2, extend ? true : false) array.push(labelplarr2, labelpl2) if array.size(lowerplzonearr2) > 0 for i = 0 to array.size(lowerplzonearr2) - 1 by 1 line tempupperline2 = array.get(lowerphzonearr2, i) line templowerline2 = array.get(lowerplzonearr2, i) label linepricelabel2 = array.get(labelplarr2, i) bool tested2 = array.get(lowerzonetestedarr2, i) line.set_style(tempupperline2, f_linestyle(linestyle)) line.set_style(templowerline2, f_linestyle(linestyle)) line.set_color(tempupperline2, color.from_gradient(i, 1, numberofline2, fzonecolor(lowerzonecolor2, 00), fzonecolor(lowerzonecolor2, 00))) line.set_color(templowerline2, color.from_gradient(i, 1, numberofline2, fzonecolor(lowerzonecolor2, 00), fzonecolor(lowerzonecolor2, 00))) label.set_textcolor(linepricelabel2, color.from_gradient(i, 1, numberofline2, fzonecolor(lowerzonecolor2, 00), lowerzonecolor2)) label.set_text(linepricelabel2, str.tostring(round_f(line.get_y1(templowerline2)))) label.set_text(linepricelabel2, '                                                   Bullish Engulfing - ' + str.tostring(round_f(line.get_y1(templowerline2)))) label.set_x(linepricelabel2, bar_index) crossed = low < line.get_y1(templowerline2) if crossed and not tested2 array.set(lowerzonetestedarr2, i, true) label.delete(linepricelabel2) if crossingalerts and crossed and not tested2 array.set(lowerzonetestedarr2, i, true) label.delete(linepricelabel2) alert('Bullish Engulfing Line Has Been Crossed! At ' + str.tostring(close), alert.freq_once_per_bar) else if extend ? tested2 : not tested2 line.set_x2(tempupperline2, bar_index) array.set(lowerphzonearr2, i, tempupperline2) line.set_x2(templowerline2, bar_index) array.set(lowerplzonearr2, i, templowerline2)
Multiple HMA
https://www.tradingview.com/script/6vwtRUhB-Multiple-HMA/
goofoffgoose
https://www.tradingview.com/u/goofoffgoose/
11
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © goofoffgoose // Original Indicator Script for calculation and color change Hull Ma written and published by huyfibo // I found his version preferable and superior due to the method of mathematics used to get the Hull Ma // This indicator was written for a study to replace multiple SMA's with Hull MAs to compare accuracy as the Hull has much less lag // Default values are as such so that the user can have 5 min values displayed on a 1 min chart, as well as the equiv of 200 on the 30 min for the 2 and 4 hour. // This is a simply a matter of convenience for the study and can be unchecked to be hidden. // Coded colors and lengths are to visually discern comparable values. Both 1 and 5 min timeframes are the same color, but 1 min timeframe value has larger linewidth //@version=5 // Hull MA 0 Original script by huyfibo indicator("Multi HMA",overlay = true ) src = input(defval=close, title="Source") n=input(title="Hull MA Period", defval=14) n2ma=2*ta.wma(close,math.round(n/2)) nma=ta.wma(close,n) diff=n2ma-nma sqn=math.round(math.sqrt(n)) n2ma1=2*ta.wma(close[1],math.round(n/2)) nma1=ta.wma(close[1],n) diff1=n2ma1-nma1 sqn1=math.round(math.sqrt(n)) n1=ta.wma(diff,sqn) n2=ta.wma(diff1,sqn) c=n1>n2? color.green : color.red hma=plot(n1, "Hull MA 14", color=c, linewidth=3) // Hull 1 n_h1=input(title="Hull MA Period", defval=25) n2ma_h1=2*ta.wma(close,math.round(n_h1/2)) nma_h1=ta.wma(close,n_h1) diff_h1=n2ma_h1-nma_h1 sqn_h1=math.round(math.sqrt(n_h1)) n2ma1_h1=2*ta.wma(close[1],math.round(n_h1/2)) nma1_h1=ta.wma(close[1],n_h1) diff1_h1=n2ma1_h1-nma1_h1 sqn1_h1=math.round(math.sqrt(n_h1)) n1_h1=ta.wma(diff_h1,sqn_h1) n2_h1=ta.wma(diff1_h1,sqn_h1) c_h1=n1_h1>n2_h1? color.fuchsia : color.purple hma_h1=plot(n1_h1, "Hull MA 25", color=c_h1, linewidth=3) // Hull 2 n_h2=input(title="Hull MA Period", defval=50) n2ma_h2=2*ta.wma(close,math.round(n_h2/2)) nma_h2=ta.wma(close,n_h2) diff_h2=n2ma_h2-nma_h2 sqn_h2=math.round(math.sqrt(n_h2)) n2ma1_h2=2*ta.wma(close[1],math.round(n_h2/2)) nma1_h2=ta.wma(close[1],n_h2) diff1_h2=n2ma1_h2-nma1_h2 sqn1_h2=math.round(math.sqrt(n_h2)) n1_h2=ta.wma(diff_h2,sqn_h2) n2_h2=ta.wma(diff1_h2,sqn_h2) c_h2=n1_h2>n2_h2? color.blue : color.navy hma_h2=plot(n1_h2, "Hull MA 50", color=c_h2, linewidth=3) // Hull 3 n_h3=input(title="Hull MA Period", defval=70) n2ma_h3=2*ta.wma(close,math.round(n_h3/2)) nma_h3=ta.wma(close,n_h3) diff_h3=n2ma_h3-nma_h3 sqn_h3=math.round(math.sqrt(n_h3)) n2ma1_h3=2*ta.wma(close[1],math.round(n_h3/2)) nma1_h3=ta.wma(close[1],n_h3) diff1_h3=n2ma1_h3-nma1_h3 sqn1_h3=math.round(math.sqrt(n_h3)) n1_h3=ta.wma(diff_h3,sqn_h3) n2_h3=ta.wma(diff1_h3,sqn_h3) c_h3=n1_h3>n2_h3? color.green : color.red hma_h3=plot(n1_h3, "Hull MA 70", color=c_h3) // Hull 4 n_h4=input(title="Hull MA Period", defval=100) n2ma_h4=2*ta.wma(close,math.round(n_h4/2)) nma_h4=ta.wma(close,n_h4) diff_h4=n2ma_h4-nma_h4 sqn_h4=math.round(math.sqrt(n_h4)) n2ma1_h4=2*ta.wma(close[1],math.round(n_h4/2)) nma1_h4=ta.wma(close[1],n_h4) diff1_h4=n2ma1_h4-nma1_h4 sqn1_h4=math.round(math.sqrt(n_h4)) n1_h4=ta.wma(diff_h4,sqn_h4) n2_h4=ta.wma(diff1_h4,sqn_h4) c_h4=n1_h4>n2_h4? color.aqua : color.teal hma_h4=plot(n1_h4, "Hull MA 100", color=c_h4, linewidth=3) // Hull 5 n_h5=input(title="Hull MA Period", defval=125) n2ma_h5=2*ta.wma(close,math.round(n_h5/2)) nma_h5=ta.wma(close,n_h5) diff_h5=n2ma_h5-nma_h5 sqn_h5=math.round(math.sqrt(n_h5)) n2ma1_h5=2*ta.wma(close[1],math.round(n_h5/2)) nma1_h5=ta.wma(close[1],n_h5) diff1_h5=n2ma1_h5-nma1_h5 sqn1_h5=math.round(math.sqrt(n_h5)) n1_h5=ta.wma(diff_h5,sqn_h5) n2_h5=ta.wma(diff1_h5,sqn_h5) c_h5=n1_h5>n2_h5? color.fuchsia : color.purple hma_h5=plot(n1_h5, "Hull MA 125", color=c_h5) // Hull 6 n_h6=input(title="Hull MA Period", defval=200) n2ma_h6=2*ta.wma(close,math.round(n_h6/2)) nma_h6=ta.wma(close,n_h6) diff_h6=n2ma_h6-nma_h6 sqn_h6=math.round(math.sqrt(n_h6)) n2ma1_h6=2*ta.wma(close[1],math.round(n_h6/2)) nma1_h6=ta.wma(close[1],n_h6) diff1_h6=n2ma1_h6-nma1_h6 sqn1_h6=math.round(math.sqrt(n_h6)) n1_h6=ta.wma(diff_h6,sqn_h6) n2_h6=ta.wma(diff1_h6,sqn_h6) c_h6=n1_h6>n2_h6? color.yellow : color.orange hma_h6=plot(n1_h6, "Hull MA 200", color=c_h6, linewidth=3) // Hull 7 n_h7=input(title="Hull MA Period", defval=250) n2ma_h7=2*ta.wma(close,math.round(n_h7/2)) nma_h7=ta.wma(close,n_h7) diff_h7=n2ma_h7-nma_h7 sqn_h7=math.round(math.sqrt(n_h7)) n2ma1_h7=2*ta.wma(close[1],math.round(n_h7/2)) nma1_h7=ta.wma(close[1],n_h7) diff1_h7=n2ma1_h7-nma1_h7 sqn1_h7=math.round(math.sqrt(n_h7)) n1_h7=ta.wma(diff_h7,sqn_h7) n2_h7=ta.wma(diff1_h7,sqn_h7) c_h7=n1_h7>n2_h7? color.blue : color.navy hma_h7=plot(n1_h7, "Hull MA 250", color=c_h7) // Hull 8 n_h8=input(title="Hull MA Period", defval=500) n2ma_h8=2*ta.wma(close,math.round(n_h8/2)) nma_h8=ta.wma(close,n_h8) diff_h8=n2ma_h8-nma_h8 sqn_h8=math.round(math.sqrt(n_h8)) n2ma1_h8=2*ta.wma(close[1],math.round(n_h8/2)) nma1_h8=ta.wma(close[1],n_h8) diff1_h8=n2ma1_h8-nma1_h8 sqn1_h8=math.round(math.sqrt(n_h8)) n1_h8=ta.wma(diff_h8,sqn_h8) n2_h8=ta.wma(diff1_h8,sqn_h8) c_h8=n1_h8>n2_h8? color.aqua : color.teal hma_h8=plot(n1_h8, "Hull MA 500", color=c_h8) // Hull 9 n_h9=input(title="Hull MA Period", defval=1000) n2ma_h9=2*ta.wma(close,math.round(n_h9/2)) nma_h9=ta.wma(close,n_h9) diff_h9=n2ma_h9-nma_h9 sqn_h9=math.round(math.sqrt(n_h9)) n2ma1_h9=2*ta.wma(close[1],math.round(n_h9/2)) nma1_h9=ta.wma(close[1],n_h9) diff1_h9=n2ma1_h9-nma1_h9 sqn1_h9=math.round(math.sqrt(n_h9)) n1_h9=ta.wma(diff_h9,sqn_h9) n2_h9=ta.wma(diff1_h9,sqn_h9) c_h9=n1_h9>n2_h9? color.yellow : color.orange hma_h9=plot(n1_h9, "Hull MA 1000", color=c_h9) // Hull 10 n_h10=input(title="Hull MA Period", defval=400) n2ma_h10=2*ta.wma(close,math.round(n_h10/2)) nma_h10=ta.wma(close,n_h10) diff_h10=n2ma_h10-nma_h10 sqn_h10=math.round(math.sqrt(n_h10)) n2ma1_h10=2*ta.wma(close[1],math.round(n_h10/2)) nma1_h10=ta.wma(close[1],n_h10) diff1_h10=n2ma1_h10-nma1_h10 sqn1_h10=math.round(math.sqrt(n_h10)) n1_h10=ta.wma(diff_h10,sqn_h10) n2_h10=ta.wma(diff1_h10,sqn_h10) c_h10=n1_h10>n2_h10? color.yellow : color.orange hma_h10=plot(n1_h10, "Hull MA 400", color=c_h10) // Hull 11 n_h11=input(title="Hull MA Period", defval=800) n2ma_h11=2*ta.wma(close,math.round(n_h11/2)) nma_h11=ta.wma(close,n_h11) diff_h11=n2ma_h11-nma_h11 sqn_h11=math.round(math.sqrt(n_h11)) n2ma1_h11=2*ta.wma(close[1],math.round(n_h11/2)) nma1_h11=ta.wma(close[1],n_h11) diff1_h11=n2ma1_h11-nma1_h11 sqn1_h11=math.round(math.sqrt(n_h11)) n1_h11=ta.wma(diff_h11,sqn_h11) n2_h11=ta.wma(diff1_h11,sqn_h11) c_h11=n1_h11>n2_h11? color.yellow : color.orange hma_h11=plot(n1_h11, "Hull MA 800", color=c_h11)
KAMIKAMI EMA RIBBON
https://www.tradingview.com/script/yDPpkodP-KAMIKAMI-EMA-RIBBON/
cryptofilio
https://www.tradingview.com/u/cryptofilio/
73
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/ //@ CryptoFilio 2021-2022 //@version=5 indicator('CF - KAMIKAMI EMA RIBBON', overlay=true, timeframe="", timeframe_gaps=false) //************************** Inputs ****************************// turnonfill1 = input.bool(true, title="Turn on colored fill between EMA1 and EMA 2?") turnonfill2 = input.bool(true, title="Turn on colored fill between EMA2 and EMA 3?") turnonfill3 = input.bool(true, title="Turn on colored fill between EMA1 and EMA 3?") lenemaS = input.int (21, minval = 3 , title='Short EMA Length') srcemaS = input (close, title = 'Short EMA Source') outS = ta.ema (srcemaS, lenemaS) lenemaM = input.int (50, minval = 5 , title='Medium EMA Length') srcemaM = input (close, title = 'Medium EMA Source') outM = ta.ema (srcemaM, lenemaM) lenemaL = input.int(200, minval = 8 , title='Long EMA Length') srcemaL = input (close, title = 'Long EMA Source') outL = ta.ema (srcemaL, lenemaL) //EMA EMAS = outS EMAM = outM EMAL = outL EMAS_color = EMAS > close ? #EE4B2B : #AFE1AF EMAM_color = EMAM > close ? #AA4A44 : #5F9EA0 EMAL_color = EMAL > close ? #880808 : #097969 lowaboveEMAS = low > EMAS lowaboveEMAM = low > EMAM lowaboveEMAL = low > EMAL lowbelowEMAS = low < EMAS lowbelowEMAM = low < EMAM lowbelowEMAL = low < EMAL highaboveEMAS = high > EMAS highaboveEMAM = high > EMAM highaboveEMAL = high > EMAL highbelowEMAS = high < EMAS highbelowEMAM = high < EMAM highbelowEMAL = high < EMAL BullBounceS = lowaboveEMAS [1] and lowbelowEMAS and close > EMAS // and close > open BearBounceS = highbelowEMAS[1] and highaboveEMAS and close < EMAS //and close < open BullBounceM = lowaboveEMAM [1] and lowbelowEMAM and close > EMAM // and close > open BearBounceM = highbelowEMAM[1] and highaboveEMAM and close < EMAM //and close < open BullBounceL = lowaboveEMAL [1] and lowbelowEMAL and close > EMAL // and close > open BearBounceL = highbelowEMAL[1] and highaboveEMAL and close < EMAL //and close < open plots = plot(EMAS, title='The EMA Short', color = EMAS_color, linewidth=2) plotm = plot(EMAM, title='The EMA Medium', color = EMAM_color, linewidth=2) plotl = plot(EMAL, title='The EMA Long', color = EMAL_color, linewidth=2) fill(plots,plotm, color = turnonfill1 ? color.new(EMAL_color, 30):color.new(EMAL_color, 100) ) fill(plotm,plotl, color = turnonfill2 ? color.new(EMAL_color, 30):color.new(EMAL_color, 100) ) fill(plots,plotl, color = turnonfill3 ? color.new(EMAL_color, 30):color.new(EMAL_color, 100) ) plotshape(BullBounceS, color = color.green, style=shape.arrowup , size=size.small, location=location.belowbar, editable=false) plotshape(BearBounceS, color = color.red, style=shape.arrowdown, size=size.small, location=location.abovebar, editable=false) plotshape(ta.crossover(EMAS,EMAM), color =color.new (color.green, 30), style=shape.diamond, size=size.small, location=location.bottom, editable=false) plotshape(ta.crossunder(EMAS,EMAM), color=color.new (color.red, 30), style=shape.diamond, size=size.small, location=location.bottom, editable=false) plotshape(ta.crossover(EMAM,EMAL), color =color.new (color.green, 50), style=shape.diamond, size=size.small, location=location.bottom, editable=false) plotshape(ta.crossunder(EMAM,EMAL), color=color.new (color.red, 50),style=shape.diamond, size=size.small, location=location.bottom, editable=false) plotshape(ta.crossover(EMAS,EMAL), color =color.new (color.green, 70), style=shape.diamond, size=size.small, location=location.bottom, editable=false) plotshape(ta.crossunder(EMAS,EMAL), color=color.new (color.red, 70), style=shape.diamond, size=size.small, location=location.bottom, editable=false) //BUY = (BullBounce or out50 > ohlc4) and ohlc4 > out //SELL = (BearBounce or out50 < ohlc4) and ohlc4 < out
Fusion: Pivot Angles and Thresholds
https://www.tradingview.com/script/7fNK2F3H-Fusion-Pivot-Angles-and-Thresholds/
Koalems
https://www.tradingview.com/u/Koalems/
90
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/ // © Koalems // @version=5 maxBarsBack = 4999 maxLabels = 500 indicator( title='Fusion: Pivot Angles and Thresholds', shorttitle='Fusion: Angles', max_bars_back = maxBarsBack, max_labels_count = 500, overlay = true) deg2RadConst = math.pi / 180 rad2DegConst = 180 / math.pi // *************************************************************************************************** // // // INPUTS // // // *************************************************************************************************** inputSeparator = '---------------------------------------------------------------------------------------------' inputDummy = false // *************************************************************************************************** // 5100 Strategy: Exit on reverse trend // *************************************************************************************************** Group5100 = '5100 Strategy: Exit on reverse trend - SHOW' stgyReverseTrendShowAngles = input(true, group=Group5100, title='Angle within threshold') stgyReverseTrendShowSource = input(true, group=Group5100, title='Source') stgyReverseTrendShowDebug = input(false, group=Group5100, title='Debug info') stgyReverseTrendShowDebugLimit = input(true, group=Group5100, title='  Limit') Group5110 = '5110 Strategy: Exit on reverse trend - RULES' tooltipThma = 'TEHMA, the "T" = the "tripple" in the Tripple Expotential Moving Average. I.e., TEHMA is even more weighted to the most recent price moves than the EHMA.' tooltipAngle = 'The smaller the angle the sharper the pivot so we are looking for angles smaller than our threshold.' stgyReverseTrendAngleThresholdHigh = input.float(70, group=Group5110, minval=0, maxval=180, step=0.1, title='Angle °', tooltip=tooltipAngle) * deg2RadConst stgyReverseTrendAngleThresholdLow = input.float(70, group=Group5110, minval=0, maxval=180, step=0.1, title='Angle °', tooltip=tooltipAngle) * deg2RadConst Group5120 = '5120 Strategy: Exit on reverse trend - SETTINGS' stgyReverseTrendSource = input.source(hl2, group=Group5120, title='Source') stgyReverseTrendModeSwitch = input.string('HMA', group=Group5120, inline='sRTAPM', title='MA variation', options=['EMA', 'EHMA', 'HMA', 'LINREG', 'RMA', 'SMA', 'SWMA', 'TEHMA', 'VWMA', 'WMA'], tooltip=tooltipThma) stgyReverseTrendLength = input.int(2, group=Group5120, minval=1, inline='sRTAPM', title='Length') stgyReverseTrendAnglePHighLeft = input.int(1, group=Group5120, minval=1, inline='sRTAPH1', title='Pivot high: Left') stgyReverseTrendAnglePHighRight = input.int(1, group=Group5120, minval=1, inline='sRTAPH1', title='Right') stgyReverseTrendAnglePLowLeft = input.int(1, group=Group5120, minval=1, inline='sRTAPH2', title='Pivot Low: Left') stgyReverseTrendAnglePLowRight = input.int(1, group=Group5120, minval=1, inline='sRTAPH2', title='Right') // *************************************************************************************************** // FUNCTIONS // *************************************************************************************************** // https://alanhull.com/hull-moving-average // Hull Moving Average (HMA) formula // Integer(SquareRoot(Period)) WMA [2 x Integer(Period/2) WMA(Price) - Period WMA(Price)] // THMA is even more weighted to shorter timeframes than the EMA. The 'T' is for Tripple and is like a Tripple EMA // so TEHMA would be more correct. HMA (_src, _length) => ta.wma(2 * ta.wma(_src, _length / 2) - ta.wma(_src, _length ), math.round(math.sqrt(_length))) EHMA(_src, _length) => ta.ema(2 * ta.ema(_src, _length / 2) - ta.ema(_src, _length ), math.round(math.sqrt(_length))) THMA(_src, _length) => ta.wma(3 * ta.wma(_src, _length / 3) - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length) HullMode(mode, src, len) => float ma = switch mode 'HMA' => HMA (src, len) 'EHMA' => EHMA(src, len) 'TEHMA' => THMA(src, len / 2) => runtime.error("No matching Hull MA type found.") float(na) MaTypes(mode, src, len) => float ma = switch mode 'EMA' => ta.ema(src, len) 'EHMA' => HullMode(mode, src, len) 'HMA' => HullMode(mode, src, len) 'LINREG' => ta.linreg(src, len, 0) 'RMA' => ta.rma(src, len) 'SMA' => ta.sma(src, len) "SWMA" => ta.swma(src) 'TEHMA' => HullMode(mode, src, len) "VWMA" => ta.vwma(src, len) 'WMA' => ta.wma(src, len) => runtime.error("No matching MA type found.") float(na) ma // *************************************************************************************************** // MAIN // *************************************************************************************************** AngleFromXY(x1, y1, x2, y2, x3, y3) => numerator = y2 * (x1 - x3) + y1 * (x3 - x1) + y3 * (x2 - x1) demoninator = (x2 - x1) * (x1 - x3) + (y2 - y1) * (y1 - y3) angle = math.atan(math.abs(numerator / demoninator)) debugStr = str.format('\nRadians: {0, number, #,##0.0000}', angle) + str.format('\nDegrees: {0, number, #,##0.0000}', angle * rad2DegConst) [angle, debugStr] AngleFromPivot(src, leftLen, rightLen, pivot) => x1 = rightLen x2 = rightLen + leftLen x3 = 0 y1 = src[x1] y2 = src[x2] y3 = src[x3] float angle = na debugStr = '' if not na(pivot) [angle2, debugStr2] = AngleFromXY(x1, y1, x2, y2, x3, y3) angle := angle2 debugStr := debugStr2 [angle, debugStr] sRevTrend = stgyReverseTrendLength == 1 ? stgyReverseTrendSource : MaTypes(stgyReverseTrendModeSwitch, stgyReverseTrendSource, int(stgyReverseTrendLength)) sRTPivotHigh = ta.pivothigh(sRevTrend, stgyReverseTrendAnglePHighLeft, stgyReverseTrendAnglePHighRight) sRTPivotLow = ta.pivotlow( sRevTrend, stgyReverseTrendAnglePLowLeft, stgyReverseTrendAnglePLowRight) [sRTPivotHighAngle, debugStrHigh] = AngleFromPivot(sRevTrend, stgyReverseTrendAnglePHighLeft, stgyReverseTrendAnglePHighRight, sRTPivotHigh) [sRTPivotLowAngle, debugStrLow] = AngleFromPivot(sRevTrend, stgyReverseTrendAnglePLowLeft, stgyReverseTrendAnglePLowRight, sRTPivotLow) // Remember: The smaller the angle the sharper the pivot so we // are looking for angles smaller than our threshold. sRTPivotHighAngleTriggered = sRTPivotHighAngle <= stgyReverseTrendAngleThresholdHigh sRTPivotLowAngleTriggered = sRTPivotLowAngle <= stgyReverseTrendAngleThresholdLow // *************************************************************************************************** // DEBUG // *************************************************************************************************** if stgyReverseTrendShowDebug and not na(sRTPivotHigh or sRTPivotLow) and (str.length(debugStrHigh) > 0 or str.length(debugStrLow) > 0) and (sRTPivotHighAngleTriggered or sRTPivotLowAngleTriggered or not stgyReverseTrendShowDebugLimit) t = str.format('Low threshold: {0, number, #,##0.00}', stgyReverseTrendAngleThresholdLow * rad2DegConst) + debugStrLow + '\n\n' + str.format('High threshold: {0, number, #,##0.00}', stgyReverseTrendAngleThresholdHigh * rad2DegConst) + debugStrHigh label.new( x = bar_index - (sRTPivotHigh ? stgyReverseTrendAnglePHighRight : stgyReverseTrendAnglePLowRight), y = sRevTrend, text = t, color = color.new(color.black, 50), style = label.style_label_down, textcolor = color.white, size = size.normal, textalign = text.align_left) // *************************************************************************************************** // ALERTS // *************************************************************************************************** if sRTPivotHighAngleTriggered msg = "Fusion: Angles" + "\nHigh pivot sharpe angle" + str.format('\nAngle: {0, number, #,##0.00}', sRTPivotHighAngle * rad2DegConst) + str.format('\nHigh threshold: {0, number, #,##0.00}', stgyReverseTrendAngleThresholdHigh * rad2DegConst) alert(msg, alert.freq_once_per_bar) if sRTPivotLowAngleTriggered msg = "Fusion: Angles" + "\nLow pivot sharpe angle" + str.format('\nAngle: {0, number, #,##0.00}', sRTPivotLowAngle * rad2DegConst) + str.format('\nLow threshold: {0, number, #,##0.00}', stgyReverseTrendAngleThresholdLow * rad2DegConst) alert(msg, alert.freq_once_per_bar) // *************************************************************************************************** // SHOW // *************************************************************************************************** stgyRevTrendHighColor = color.new(color.red, 20) stgyRevTrendLowColor = color.new(color.green, 20) plotshape( stgyReverseTrendShowAngles ? sRTPivotHighAngleTriggered : na, style = shape.arrowdown, location = location.abovebar, color = stgyRevTrendHighColor, offset = -stgyReverseTrendAnglePHighRight, size = size.small, title = 'Angles: High pivot') plotshape( stgyReverseTrendShowAngles ? sRTPivotLowAngleTriggered : na, style = shape.arrowup, location = location.belowbar, color = stgyRevTrendLowColor, offset = -stgyReverseTrendAnglePLowRight, size = size.small, title = 'Angles: Low pivot') sRevTrendColor = sRevTrend[1] > sRevTrend ? stgyRevTrendHighColor : sRevTrend[1] < sRevTrend ? stgyRevTrendLowColor : color.new(color.gray, 20) plot(stgyReverseTrendShowSource or stgyReverseTrendShowDebug ? sRevTrend : na, color=sRevTrendColor , linewidth=2, title='Angles: Source')
ETH vs BTC 200W SMA Overextension
https://www.tradingview.com/script/PDNC2ZYc-ETH-vs-BTC-200W-SMA-Overextension/
panpanXBT
https://www.tradingview.com/u/panpanXBT/
11
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/ // © gjfsdrtytru //@version=4 study("ETH vs BTC 200W SMA Overextension", "ETH/BTC 200W MA OX", overlay=false, resolution="D", max_bars_back=5000) cycleLen = 1400 getMaLen = bar_index < cycleLen ? bar_index + 1 : cycleLen ethSRC = security("BITSTAMP:ETHUSD","D",close) ethSMA = sma(ethSRC,getMaLen) ethOX = ethSRC/ethSMA btcSRC = security("BITSTAMP:BTCUSD","D",close) btcSMA = sma(btcSRC,getMaLen) btcOX = btcSRC/btcSMA OX = ethOX-btcOX hotzone = OX-OX[20] guideMid = color.new(color.black,50) guideTop = color.new(color.purple,50) guideLow = color.new(color.purple,50) EQ = hline(0,"Equilibrium",guideMid,linestyle=hline.style_dashed) OB = hline(2,"ETH More Overextended",guideTop,linestyle=hline.style_dashed) OS = hline(-2,"BTC More Overextended",guideTop,linestyle=hline.style_dashed) fill(OB,OS,color.purple,90) plot(hotzone,color=color.purple) BGcolour = hotzone > 2 ? color.new(color.red,90) : na bgcolor(BGcolour, title="ETH Bubble")
Shade COVID Period
https://www.tradingview.com/script/aKDEvvgG-Shade-COVID-Period/
TheOmegaTrader
https://www.tradingview.com/u/TheOmegaTrader/
2
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/ // © TheOmegaTrader //@version=4 study("Shade COVID Period",overlay=true) fromHour = input(7) toHour = input(10) weekdaysOnly = input(true) useVline = input(false) dayIsOk = not weekdaysOnly or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday) FromYear = input(title="From Year", type=input.integer, defval=2019, minval=1800) FromMonth = input(title="From Month", type=input.integer, defval=09, minval=1, maxval=12) FromDay = input(title="From Day", type=input.integer, defval=03, minval=1, maxval=31) ToYear = input(title="To Year", type=input.integer, defval=2020, minval=1800) ToMonth = input(title="To Month", type=input.integer, defval=03, minval=1, maxval=12) ToDay = input(title="To Day", type=input.integer, defval=31, minval=1, maxval=31) t1 = timestamp( FromYear, FromMonth,FromDay, fromHour, 00, 00) t2 = timestamp( ToYear, ToMonth, ToDay, toHour, 00, 00) ShadeColour = input(title="Color", type=input.color, defval=color.silver) timeIsOk = (time >= t1) and (time <= t2) bgcolor( not useVline and timeIsOk and dayIsOk ? ShadeColour : color.rgb(0, 0, 0, transp = 75))//modified this due to: https://quantnomad.com/faq-the-transp-argument-will-be-deprecated-soon-how-to-fix-it/ if useVline and timeIsOk and dayIsOk line.new(bar_index, low * .9999, bar_index, high * 1.0001, xloc.bar_index, extend.both, #FF8000ff, line.style_solid, 1)
Multi-Timeframe Squeeze Pro/DIM/Momentum/MA
https://www.tradingview.com/script/cDnX3SAE-Multi-Timeframe-Squeeze-Pro-DIM-Momentum-MA/
timmy1986
https://www.tradingview.com/u/timmy1986/
166
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/ // © Timmy1986 inspired by Beardy_Fred //@version=5 indicator("Multi-Timeframe Squeeze Pro/DIM/Momentum/MA", shorttitle="MTF SQZ/DMI/MA/MOM", overlay=true) show_mom = input.bool(false, "Show Momentum",group = "General",inline="Visibility-1") show_sq = input.bool(true, "Show squeeze",group = "General",inline="Visibility-1") show_10X = input.bool(true, "Show 10x",group = "General",inline="Visibility-2") show_ma = input.bool(true, "Show Stack MA",group = "General",inline="Visibility-2") //Timeframes tf_1 = input.timeframe(title="Res-1",defval="60",group = "Resolution",inline="Resolution-1") tf_2 = input.timeframe(title="Res-2",defval="240",group = "Resolution",inline="Resolution-1") tf_3 = input.timeframe(title="Res-3",defval="D",group = "Resolution",inline="Resolution-1") tf_4 = input.timeframe(title="Res-4",defval="2D",group = "Resolution",inline="Resolution-2") tf_5 = input.timeframe(title="Res-5",defval="3D",group = "Resolution",inline="Resolution-2") tf_6 = input.timeframe(title="Res-6",defval="4D",group = "Resolution",inline="Resolution-2") tf_7 = input.timeframe(title="Res-7",defval="W",group = "Resolution",inline="Resolution-3") tf_8 = input.timeframe(title="Res-8",defval="M",group = "Resolution",inline="Resolution-3") tableYposInput = input.string("top", "Panel position", options = ["top", "middle", "bottom"],group = "Table Settings",inline="Table-1") tableXposInput = input.string("right", "", options = ["left", "center", "right"],group = "Table Settings",inline="Table-1") TC = input.color(color.new(color.white, 0), "Table Text Color",group = "Table Settings",inline="Table-2") TS = input.string(size.small, "Table Text Size", options = [size.tiny, size.small, size.normal, size.large],group = "Table Settings",inline="Table-2") length = input.int(20, "TTM Squeeze Length",group="Squeeze Settings") //BOLLINGER BANDS BB_mult = input.float(2.0, "Bollinger Band STD Multiplier",group="Squeeze Settings") BB_basis = ta.sma(close, length) dev = BB_mult * ta.stdev(close, length) BB_upper = BB_basis + dev BB_lower = BB_basis - dev //KELTNER CHANNELS KC_mult_high = input.float(1.0, "Keltner Channel #1",group="Squeeze Settings") KC_mult_mid = input.float(1.5, "Keltner Channel #2",group="Squeeze Settings") KC_mult_low = input.float(2.0, "Keltner Channel #3",group="Squeeze Settings") KC_basis = ta.sma(close, length) devKC = ta.sma(ta.tr, length) KC_upper_high = KC_basis + devKC * KC_mult_high KC_lower_high = KC_basis - devKC * KC_mult_high KC_upper_mid = KC_basis + devKC * KC_mult_mid KC_lower_mid = KC_basis - devKC * KC_mult_mid KC_upper_low = KC_basis + devKC * KC_mult_low KC_lower_low = KC_basis - devKC * KC_mult_low //SQUEEZE CONDITIONS NoSqz = BB_lower < KC_lower_low or BB_upper > KC_upper_low //NO SQUEEZE: GREEN LowSqz = BB_lower >= KC_lower_low or BB_upper <= KC_upper_low //LOW COMPRESSION: BLACK MidSqz = BB_lower >= KC_lower_mid or BB_upper <= KC_upper_mid //MID COMPRESSION: RED HighSqz = BB_lower >= KC_lower_high or BB_upper <= KC_upper_high //HIGH COMPRESSION: ORANGE //MOMENTUM OSCILLATOR mom = ta.linreg(close - math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length)), length, 0) //MOMENTUM HISTOGRAM COLOR mom_up1_col = input.color(color.new(color.aqua, 0), title = "+ive Rising Momentum", group = "Squeeze Histogram Color",inline="Color-1") mom_up2_col = input.color(color.new(#2962ff, 0), title = "+ive Falling Momentum", group = "Squeeze Histogram Color",inline="Color-1") mom_down1_col = input.color(color.new(color.red, 0), title = "-ive Rising Momentum", group = "Squeeze Histogram Color",inline="Color-2") mom_down2_col = input.color(color.new(color.yellow, 0), title = "-ive Falling Momentum", group = "Squeeze Histogram Color",inline="Color-2") iff_1 = mom > nz(mom[1]) ? mom_up1_col : mom_up2_col iff_2 = mom < nz(mom[1]) ? mom_down1_col : mom_down2_col mom_color = mom > 0 ? iff_1 : iff_2 //SQUEEZE DOTS COLOR NoSqz_Col = input.color(color.new(color.green, 0), title = "No Squeeze", group = "Squeeze Dot Color",inline="Color-3") LowSqz_Col = input.color(color.new(color.black, 0), title = "Low Compression", group = "Squeeze Dot Color",inline="Color-3") MidSqz_Col = input.color(color.new(color.red, 0), title = "Medium Compression", group = "Squeeze Dot Color",inline="Color-4") HighSqz_Col = input.color(color.new(color.orange, 0), title = "High Compression", group = "Squeeze Dot Color",inline="Color-4") sq_color = HighSqz ? HighSqz_Col : MidSqz ? MidSqz_Col : LowSqz ? LowSqz_Col : NoSqz_Col //DI computation len = input.int(14, "Directional Length",group="10X Settings") ADX_T = input.int(20, "ADX Length",group="10X Settings") //DMI CALCULATIONS - Tradingview Built-In DMI Indicator 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), len) //10X CALCULATIONS D_Up = (plus > minus) and (adx > ADX_T) D_Down = (minus > plus) and (adx > ADX_T) Neutral = (adx < ADX_T) D_Up_Color = input.color(color.new(color.green, 0), title = "Uptrend",group="10X Colors",inline="Color-5") D_Down_Color = input.color(color.new(color.red, 0), title = "Downtrend",group="10X Colors",inline="Color-5") Neutral_Color = input.color(color.new(color.yellow, 0), title = "Neutral",group="10X Colors",inline="Color-5") MTF10_Color = Neutral ? Neutral_Color : D_Up ? D_Up_Color : D_Down ? D_Down_Color : na //Get the stacked EM // length option //Code from © dvinales len1 = input.int(title="MA-1", defval=8, minval=1,group="Stack MA Lengths",inline="stack-2") len2 = input.int(title="MA-2", defval=21, minval=1,group="Stack MA Lengths",inline="stack-2") len3 = input.int(title="MA-3", defval=34, minval=1,group="Stack MA Lengths",inline="stack-2") len4 = input.int(title="MA-4", defval=55, minval=0,group="Stack MA Lengths",inline="stack-2") len5 = input.int(title="MA-5", defval=89, minval=0,group="Stack MA Lengths",inline="stack-2") source = input.source(title="Source", defval=close,group="Stack MA",inline="stack-1") mafn = input.string(title="Moving Average", defval="EMA", options=["SMA", "EMA", "DEMA"],group="Stack MA",inline="stack-1") D_Stack_Color = input.color(color.new(color.green, 0), title = "Stacked +",group="Stack MA Colors",inline="Color-6") D_ReverseStack_Color = input.color(color.new(color.red, 0), title = "Stacked -",group="Stack MA Colors",inline="Color-6") D_UnStacked_Color = input.color(color.new(color.yellow, 0), title = "Unstacked",group="Stack MA Colors",inline="Color-6") fnMA(series, length) => if (mafn == "EMA") ta.ema(series, length) else if (mafn == "SMA") ta.sma(series, length) else if (length > 0) emaValue = ta.ema(series, length) 2 * emaValue - ta.ema(emaValue, length) else na ma1 = fnMA(source, len1) ma2 = fnMA(source, len2) ma3 = fnMA(source, len3) ma4 = len4 > 0 ? fnMA(source, len4) : na ma5 = len5 > 0 ? fnMA(source, len5) : na //get whether the MA are stacked is_uptrend = ma1 > ma2 and ma2 > ma3 and (ma3 > ma4 or len4 == 0) and (ma4 > ma5 or len4 == 0 or len5 == 0) is_downtrend = (ma5 > ma4 or len4 == 0 or len5 == 0) and (ma4 > ma3 or len4 == 0) and ma3 > ma2 and ma2 > ma1 stacked_ma_color = is_uptrend ? D_Stack_Color : (is_downtrend ? D_ReverseStack_Color : D_UnStacked_Color) // —————————— PineCoders MTF Selection Framework functions // ————— Converts current "timeframe.multiplier" plus the TF into minutes of type float. f_resInMinutes() => _resInMinutes = timeframe.multiplier * ( timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na) // ————— Returns resolution of _resolution period in minutes. f_tfResInMinutes(_res) => // _res: resolution of any TF (in "timeframe.period" string format). request.security(syminfo.tickerid, _res, f_resInMinutes()) //Array to store the original timeframes string[] timeframes_arr = array.from(tf_1,tf_2,tf_3,tf_4,tf_5,tf_6,tf_7,tf_8) //Array with timeframe in minutes for comparaison purposes float[] timeframes_arr_mn = array.from(f_tfResInMinutes(tf_1),f_tfResInMinutes(tf_2),f_tfResInMinutes(tf_3),f_tfResInMinutes(tf_4),f_tfResInMinutes(tf_5),f_tfResInMinutes(tf_6),f_tfResInMinutes(tf_7),f_tfResInMinutes(tf_8)) //MULTI TIMEFRAME HISTOGRAM COLOR [HC_1] = request.security(syminfo.tickerid, tf_1, [mom_color]) [HC_2] = request.security(syminfo.tickerid, tf_2, [mom_color]) [HC_3] = request.security(syminfo.tickerid, tf_3 , [mom_color]) [HC_4] = request.security(syminfo.tickerid, tf_4 , [mom_color]) [HC_5] = request.security(syminfo.tickerid, tf_5 , [mom_color]) [HC_6] = request.security(syminfo.tickerid, tf_6 , [mom_color]) [HC_7] = request.security(syminfo.tickerid, tf_7 , [mom_color]) [HC_8] = request.security(syminfo.tickerid, tf_8 , [mom_color]) //since i cannot dynamically use security request using a table index same way as the timeframe to build the table color[] color_hc = array.from(HC_1,HC_2,HC_3,HC_4,HC_5,HC_6,HC_7,HC_8) //MULTI TIMEFRAME SQUEEZE COLOR [SC_1] = request.security(syminfo.tickerid, tf_1, [sq_color]) [SC_2] = request.security(syminfo.tickerid, tf_2, [sq_color]) [SC_3] = request.security(syminfo.tickerid, tf_3 , [sq_color]) [SC_4] = request.security(syminfo.tickerid, tf_4 , [sq_color]) [SC_5] = request.security(syminfo.tickerid, tf_5 , [sq_color]) [SC_6] = request.security(syminfo.tickerid, tf_6 , [sq_color]) [SC_7] = request.security(syminfo.tickerid, tf_7 , [sq_color]) [SC_8] = request.security(syminfo.tickerid, tf_8 , [sq_color]) color[] color_sc = array.from(SC_1,SC_2,SC_3,SC_4,SC_5,SC_6,SC_7,SC_8) //MULTI TIMEFRAME DMI [MTF10_1] = request.security(syminfo.tickerid, tf_1, [MTF10_Color]) [MTF10_2] = request.security(syminfo.tickerid, tf_2, [MTF10_Color]) [MTF10_3] = request.security(syminfo.tickerid, tf_3, [MTF10_Color]) [MTF10_4] = request.security(syminfo.tickerid, tf_4 , [MTF10_Color]) [MTF10_5] = request.security(syminfo.tickerid, tf_5 , [MTF10_Color]) [MTF10_6] = request.security(syminfo.tickerid, tf_6 , [MTF10_Color]) [MTF10_7] = request.security(syminfo.tickerid, tf_7, [MTF10_Color]) [MTF10_8] = request.security(syminfo.tickerid, tf_8, [MTF10_Color]) color[] color_mft10 = array.from(MTF10_1,MTF10_2,MTF10_3,MTF10_4,MTF10_5,MTF10_6,MTF10_7,MTF10_8) //MUTLTI TIMEFRAME STACK MA [SM_1] = request.security(syminfo.tickerid, tf_1, [stacked_ma_color]) [SM_2] = request.security(syminfo.tickerid, tf_2, [stacked_ma_color]) [SM_3] = request.security(syminfo.tickerid, tf_3, [stacked_ma_color]) [SM_4] = request.security(syminfo.tickerid, tf_4 , [stacked_ma_color]) [SM_5] = request.security(syminfo.tickerid, tf_5 , [stacked_ma_color]) [SM_6] = request.security(syminfo.tickerid, tf_6 , [stacked_ma_color]) [SM_7] = request.security(syminfo.tickerid, tf_7, [stacked_ma_color]) [SM_8] = request.security(syminfo.tickerid, tf_8, [stacked_ma_color]) color[] color_sm = array.from(SM_1,SM_2,SM_3,SM_4,SM_5,SM_6,SM_7,SM_8) //use table length to get the number of column var table TTM = table.new(tableYposInput + "_" + tableXposInput, 9, 4, border_width = 1) //create header table.cell(TTM, 0, 0, "MOM", text_color = color.new(color.white, 0), bgcolor = color.new(color.gray, 0), text_size = TS) table.cell(TTM, 0, 1, "SQZ", text_color = color.new(color.white, 0), bgcolor = color.new(color.gray, 0), text_size = TS) table.cell(TTM, 0, 2, "10X", text_color = color.new(color.white, 0), bgcolor = color.new(color.gray, 0), text_size = TS) table.cell(TTM, 0, 3, str.tostring("STK "+mafn), text_color = color.new(color.white, 0), bgcolor = color.new(color.gray, 0), text_size = TS) i = 0 //resolution in min float res = f_resInMinutes() //use loop because of the array //create the table //Execute the loop only on the last candle (otherwise the loop execute on each candle causing an error) if barstate.islastconfirmedhistory while i < array.size(timeframes_arr) //cannot use this code because the security call require an simple string // while an array.get return a string serie. I cannot cast this. Otherwise will have done dynamic security call... // [HC] = request.security(syminfo.tickerid, res, [mom_color]) if res <= array.get(timeframes_arr_mn,i) table.cell(TTM, i+1, 0, array.get(timeframes_arr,i), text_color = TC, bgcolor = array.get(color_hc,i), text_size = TS) table.cell(TTM, i+1, 1, array.get(timeframes_arr,i), text_color = TC, bgcolor = array.get(color_sc,i), text_size = TS) table.cell(TTM, i+1, 2, array.get(timeframes_arr,i), text_color = TC, bgcolor = array.get(color_mft10,i), text_size = TS) table.cell(TTM, i+1, 3, array.get(timeframes_arr,i), text_color = TC, bgcolor = array.get(color_sm,i), text_size = TS) i+=1 //Stacked MA if not show_ma table.clear(TTM,0,3,8,3) if not show_mom table.clear(TTM,0,0,8,0) if not show_sq table.clear(TTM,0,1,8,1) if not show_10X table.clear(TTM,0,2,8,2)
Federal Funds Rate and Overnight Bank Fund Rate
https://www.tradingview.com/script/DZ9TdTQQ-Federal-Funds-Rate-and-Overnight-Bank-Fund-Rate/
MrDevDevy
https://www.tradingview.com/u/MrDevDevy/
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/ // © MrDevDevy //@version=5 indicator("Federal Funds Rate and Overnight Bank Fund Rate") OverNightColor = input.color(defval=color.red, title="Over Night Color") UpperboundColor = input.color(defval=color.blue, title="Upper Bound Color") LowerboundColor = input.color(defval=color.blue, title="Upper Bound Color") FedRateColor = input.color(defval=color.yellow, title="Fed Funds Rate Color") OverNightRate = request.security("OBFR", "D", close) Upperbound = request.security("DFEDTARU", "D", close) LowerBound = request.security("DFEDTARL", "D", close) FedFundsRate = request.security("FEDFUNDS", "D", close) plot(OverNightRate, color=OverNightColor) plot(Upperbound, color=UpperboundColor) plot(LowerBound, color =LowerboundColor) plot(FedFundsRate, color=FedRateColor)
Buy / Sell indicator light version [Crypto_BCT]
https://www.tradingview.com/script/vm0cJCjV-buy-sell-indicator-light-version-crypto-bct/
Crypto_BitCoinTrader
https://www.tradingview.com/u/Crypto_BitCoinTrader/
540
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/ // © Crypto_BitCoinTrader //@version=5 indicator(title = "Buy / Sell indicator light version [Crypto_BCT]", shorttitle = "Low / High [Crypto_BCT]", overlay=true, max_labels_count = 500) rsi_on = input.bool(false, "+ RSI") l_bar = input.int(150, "(BUY) Lowest Bar", minval=1) rsi_low_value = input.int(27, "(BUY) RSI value <") sell_on = input.bool(true, "+ SELL") h_bar = input.int(150, "(SELL) Highest Bar", minval=1) rsi_high_value = input.int(73, "(SELL) RSI value >") rsi = ta.rsi(close, 14) lowclosebar = ta.lowestbars(close, l_bar) highclosebar = ta.highestbars(close, h_bar) color labelbuy = color(color.green) color labelsell = color(color.red) buy_condition = lowclosebar == 0 and rsi_on == false buy_condition_rsi = lowclosebar == 0 and rsi_on == true and rsi < rsi_low_value sell_condition = highclosebar == 0 and rsi_on == false and sell_on sell_condition_rsi = highclosebar == 0 and rsi_on == true and rsi > rsi_high_value and sell_on if buy_condition label.new(bar_index, low, yloc = yloc.belowbar, color=labelbuy, style=label.style_triangleup, size=size.tiny) if buy_condition_rsi label.new(bar_index, low, yloc = yloc.belowbar, color=labelbuy, style=label.style_triangleup, size=size.tiny) if sell_condition label.new(bar_index, low, yloc = yloc.abovebar, color=labelsell, style=label.style_triangledown, size=size.tiny) if sell_condition_rsi label.new(bar_index, low, yloc = yloc.abovebar, color=labelsell, style=label.style_triangledown, size=size.tiny) alertcondition(buy_condition or buy_condition_rsi, title="Low Price Detected", message="Low Price Detected") alertcondition(sell_condition or sell_condition_rsi, title="High Price Detected", message="High Price Detected")
StableCoin MC vs Total MC by Crypto5Max
https://www.tradingview.com/script/v1YKO1wD-StableCoin-MC-vs-Total-MC-by-Crypto5Max/
FiveMillionMax
https://www.tradingview.com/u/FiveMillionMax/
344
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/ // © 5millionM //@version=5 indicator('StableCoin MC vs Total MC by Crypto5Max ', overlay=false) usdt = request.security('CRYPTOCAP:USDT', timeframe.period, close) usdc = request.security('CRYPTOCAP:USDC', timeframe.period, close) ust = request.security('CRYPTOCAP:UST', timeframe.period, close) dai = request.security('CRYPTOCAP:DAI', timeframe.period, close) total_mc = request.security('CRYPTOCAP:TOTAL', timeframe.period, close) plot((usdt + usdc + ust + dai) / total_mc)
Distance from EMA Levels
https://www.tradingview.com/script/xmiveefJ-Distance-from-EMA-Levels/
mrbongiolo
https://www.tradingview.com/u/mrbongiolo/
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/ // © mrbongiolo //@version=5 indicator("Distance from EMA Levels", "EMA Distance Levels", overlay = true) // Inputs i_ema_timeframe = input.timeframe("5", "Timeframe", group = "EMA") i_ema_source = input.source(close, "Source", group = "EMA") i_ema_period = input.int(12, "Period", group = "EMA") i_level_one_distance = input.int(5, "Distance %", group = "Level 1") i_level_two_distance = input.int(2, "Distance %", group = "Level 2") i_level_three_distance = input.int(-2, "Distance %", group = "Level 3") i_level_four_distance = input.int(-5, "Distance %", group = "Level 4") // Levels _ema = ta.ema(i_ema_source, i_ema_period) ema = request.security(syminfo.tickerid, i_ema_timeframe, _ema) level_one = ema * (i_level_one_distance / 100 + 1) level_two = ema * (i_level_two_distance / 100 + 1) level_three = ema * (i_level_three_distance / 100 + 1) level_four = ema * (i_level_four_distance / 100 + 1) // Plotting plot(ema, "EMA", #ffffff, linewidth = 2) plot(level_one, "Level 1", #388e3c) plot(level_two, "Level 2", #81c784) plot(level_three, "Level 3", #f06292) plot(level_four, "Level 4", #c2185b)
Modified Mannarino Market Risk Indicator
https://www.tradingview.com/script/oOCi0ZZ5-Modified-Mannarino-Market-Risk-Indicator/
HARRYDAN2
https://www.tradingview.com/u/HARRYDAN2/
122
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/ // © HARRYDAN2 //@version=5 indicator(title='Modified Mannarino Market Risk Indicator', shorttitle='MMMRI', overlay=false, scale=scale.right, format=format.price) var table risk = table.new(position=position.top_right, columns=1, rows=1) lowRisk = input(title='Low Risk', defval=80) moderateRisk = input(title='Moderate Risk', defval=140) highRisk = input(title='High Risk', defval=180) extremeRisk = input(title='Extreme Risk', defval=220) tardMode = input(title=' Tard Mode', defval=260) somethingsawry = input(title='Somethings Awry', defval=300) buyputs = input(title='Buy Puts or Calls, RIsk is a Double Edged Sword', defval=350) getstock = input(title = 'Request Stock Certificate', defval = 400) systemerror = input(title = 'System Error Imminent', defval = 500) maLength = input(title="SMA Length", defval=50) hideSma = input.bool(title="Hide SMA", defval=false) highlight(mmri) => col = color.green if mmri > lowRisk and mmri < moderateRisk col := color.yellow col if mmri >= moderateRisk and mmri < highRisk col := color.orange col if mmri >= highRisk and mmri < extremeRisk col := color.red col if mmri >= extremeRisk and mmri < tardMode col := color.white col if mmri >= tardMode and mmri < somethingsawry col := color.blue col if mmri >= somethingsawry and mmri < buyputs col := color.purple col if mmri >= buyputs and mmri < getstock col := color.rgb(12, 211, 151) col if mmri >= getstock and mmri < systemerror col := color.rgb(95, 50, 255) col if mmri > systemerror col := color.rgb(255, 109, 52) col riskLevel(mmri) => text_1 = 'Low Risk' if mmri > lowRisk and mmri < moderateRisk text_1 := 'Moderate Risk' text_1 if mmri >= moderateRisk and mmri < highRisk text_1 := 'High Risk' text_1 if mmri >= highRisk text_1 := 'Extreme Risk' text_1 if mmri >= extremeRisk text_1 := 'Tard Mode' text_1 if mmri >= tardMode text_1 := 'Somethings Awry' text_1 if mmri >= somethingsawry text_1 := 'Buy Puts or Calls, RIsk is a Double Edged Sword' text_1 if mmri >= buyputs text_1 := 'Request Stock Certificate' text_1 if mmri >= getstock text_1 := 'System Error Imminent' text_1 text_1 dollarSymbol = input.symbol(title='Dollar Symbol', defval='dxy') yieldSymbol = input.symbol(title='Yield Symbol', defval='tnx') mmriConstant = input(title='Divisor', defval=1.61) debtgdpConstant = input(title='Multiplier', defval=1.356) dxy = request.security(symbol=dollarSymbol, timeframe='', expression=close) yield = request.security(symbol=yieldSymbol, timeframe='', expression=close) mmmri = ((dxy * yield)/(mmriConstant)) * (debtgdpConstant) table.set_bgcolor(risk, highlight(mmmri)) table.cell(risk, 0, 0, str.tostring(riskLevel(mmmri))) plot(series=mmmri, title="MMRI", trackprice=false, color=highlight(mmmri)) plot(series=hideSma ? na : ta.sma(mmmri, maLength), title="SMA", color=color.new(color.blue, 50))
Failed Auction
https://www.tradingview.com/script/ItsORxlP-Failed-Auction/
geneclash
https://www.tradingview.com/u/geneclash/
532
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/ // © geneclash //@version=5 indicator("Failed Auction",overlay=true,max_lines_count=500) //INPUTS hideLine = input.bool(false,title="Hide Successful Auctions") actLines = input.bool(true,title="Lines:",inline="l1") lineClr = input.color(color.new(color.black,80),title="",inline="l1") lineStyle = input.string("Solid",options=["Solid","Dotted","Dashed"],inline='l1',title="") lineWidth = input.int(1,title="",inline="l1") StyleToEnum(s) => if s == 'Solid' line.style_solid else if s == 'Dotted' line.style_dotted else line.style_dashed //CALCS var float lineValue = na var line lineOne = na var arrLineBarIndex = array.new_float(0) GreenBar = close > open FailedAuctionCond = (high == high[1] and GreenBar==false and GreenBar[1]) or (low == low[1] and GreenBar and GreenBar[1]==false) if FailedAuctionCond lineValue := GreenBar ? low : high if actLines lineOne := line.new(bar_index,lineValue,bar_index+1,lineValue,color=lineClr,extend=extend.right,style=StyleToEnum(lineStyle),width=lineWidth) array.push(arrLineBarIndex,bar_index) alert(message="Failed Auction!",freq=alert.freq_once_per_bar_close) //PLOTS activeLines = line.all if array.size(activeLines) > 0 for i = 0 to array.size(activeLines) - 1 controlValue = line.get_y1(array.get(activeLines, i)) barIndex = line.get_x1(array.get(activeLines, i)) bIndex = array.indexof(arrLineBarIndex, barIndex) if ((open > controlValue and low < controlValue) or (open < controlValue and high > controlValue)) and bIndex != -1 if hideLine line.delete(array.get(activeLines, i)) else line.set_extend(array.get(activeLines, i),extend.none) line.set_x2(array.get(activeLines, i),bar_index) array.remove(arrLineBarIndex,bIndex) alert(message="Successful Auction!",freq=alert.freq_once_per_bar_close) plotshape(FailedAuctionCond and GreenBar,style=shape.square,location=location.belowbar,color=#ff03d9) plotshape(FailedAuctionCond and GreenBar==false,style=shape.square,location=location.abovebar,color=#ff03d9)
CHOPORSI
https://www.tradingview.com/script/c8z5yVek/
charthussars
https://www.tradingview.com/u/charthussars/
66
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/ // © hussarya //@version=5 indicator(title="Hussarya CHOPORSI v5.0", shorttitle="CHOPORSI v5.0 ", format=format.price, precision=2, timeframe="", timeframe_gaps=true) // CHOP ORYGINAL length = input.int(14, title="CHOP Length",group="CHOP Settings", minval=1) ci = 100 * math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) - ta.lowest(length))) / math.log10(length) offset = input.int(0, "Offset", minval = -500, maxval = 500) // RSI ORYGINAL rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) // DMI ORYGINAL lensig = input.int(14, title="ADX Smoothing",group="DMI Settings", minval=1, maxval=50) len = input.int(14, minval=1, title="DI Length") up1 = ta.change(high) down1 = -ta.change(low) plusDM = na(up1) ? na : (up1 > down1 and up1 > 0 ? up1 : 0) minusDM = na(down) ? na : (down1 > up1 and down1 > 0 ? down1 : 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) // STOCH RSI ORYGINAL smoothK = input.int(3, "K", group="STOCH Settings", minval=1) smoothD = input.int(3, "D", minval=1) lengthRSI = input.int(14, "RSI Length", minval=1) lengthStoch = input.int(14, "Stochastic Length", minval=1) src = input(close, title="RSI Source") rsi1 = ta.rsi(src, lengthRSI) k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) d = ta.sma(k, smoothD) // RSI nowy tym z MA ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "HMA" => ta.hma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) maTypeInput = input.string("HMA", title="MA Type", options=["SMA", "EMA", "HMA", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(8, title="MA Length", group="MA Settings") rsiMA = ma(rsi, maLengthInput, maTypeInput) buy = rsiMA*2-30 cs = (ci + k)/2 rs = (rsi + k)/2 price = ( rs + cs)-40 sell = (minus +adx )*2 -50 top_band = input.float(105,"Top Band", minval = 0, maxval = 120, group="BANDS Settings") bottom_band = input.float(15,"Bottom Band", minval = 0, maxval = 120, group = "BANDS Settings") //a= plot(line_a) poziom_rsi_buy =24 poziom_rsi_sell= 65 rsi2 = rsi -5 // RYSOWANIE SYGNAŁÓW //Lines plot(price, "CHOP RSI Price action" , color= color.blue) plot(sell, title="Sell power", color=color.red) plot(buy, "Buy Powwer", color= color.green) //Bands plot(top_band, "Top Band", color=color.red) plot(bottom_band, "Bottom Band", color= color.green) // cross plot(ta.crossover(buy, sell) ? buy : na, "Cross up",color=color.green, style = plot.style_cross, linewidth = 3) plot(ta.crossunder( buy, sell ) ? buy : na,"Cross down", color=#FF0000, style = plot.style_cross, linewidth = 3) // Alarmy pricetop = ta.crossover(price,top_band) pricelow = ta.crossunder(price,bottom_band) selltop = ta.crossover(sell,top_band) selllow = ta.crossunder(sell,bottom_band) perfectsell = if pricetop and selllow true else false perfectbuy = if selltop and pricelow true else false alertcondition(pricelow,"Buy ready?","Price cross under lower band") alertcondition(pricetop,"Sell ready?","Price cross over top band") alertcondition(perfectbuy,"Optimal buy condition?","Oversold condition") alertcondition(perfectsell,"optimal sell condition?","Overbought condition")
Modified morning and evening stars
https://www.tradingview.com/script/8oMtRZ0R-Modified-morning-and-evening-stars/
iitiantradingsage
https://www.tradingview.com/u/iitiantradingsage/
259
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/ // © tradeswithashish //@version=5 indicator(title="Modified morning and evening stars", shorttitle="Trend reversal patterns ", overlay=true) volMA=ta.sma(volume, 20) avgbarsize=ta.sma(math.abs(open-close), 20) //BULL PERCENTAGE bullper=(close-low)*100/(high-low) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // MORNING STAR (BULLISH PATTERN) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ br3=bullper[2]<40 and math.abs(open[2]-close[2])/(high[2]-low[2])>0.5 //healthy bearish candle dj2= low[1]<low[2] and math.abs(open[1]-close[1])/(high[1]-low[1])<0.3 and high[1]<high[2] // rejection and doji situation bl1=bullper>60 and volume>volMA and close>math.avg(low[2], high[2]) and volume>volume[1] and volume>volume[2] // Healthy bullish closing above past two bars mrgstar=br3 and dj2 and bl1 plotshape (mrgstar, title="True Morning Star", style=shape.labelup, location=location.belowbar, color=color.green, text="MgStar", textcolor=color.white, size=size.small) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // EVENING STAR (BEARISH PATTERN) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bl3=bullper[2]>60 and math.abs(open[2]-close[2])/(high[2]-low[2])>0.5 //healthy bullish djb=low[1]>low[2] and math.abs(open[1]-close[1])/(high[1]-low[1])<0.3 and high[1]>high[2] //doji and rejection br1=bullper<40 and volume>volMA and close<math.avg(low[2], high[2]) and volume>volume[1] and volume>volume[2] // Healthy bearish closing above past two bars evgstar=bl3 and djb and br1 plotshape (evgstar, title="True Evening Star", style=shape.labeldown, location=location.abovebar, color=color.red, text="EvStar", textcolor=color.white, size=size.small)
SAR+RSI+EMAs Signals
https://www.tradingview.com/script/i0cexae3-SAR-RSI-EMAs-Signals/
AliSignals
https://www.tradingview.com/u/AliSignals/
374
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/ // © AliSignals //@version=5 indicator('SAR+RSI+EMAs AliSignals', overlay=true) fast = input(7) slow = input(21) rsiL = input(14) boolVariable = input(title='use high&low instead of close for fast EMA', defval=false) filter = input(title='use MATD as a filter', defval=true) RSIOL = input.float(defval = 30, minval=0.1 ,maxval=99.9, title= " RSI oversold level") sar = ta.sar(0.02, 0.02, 0.2) // make EMAfast an easier one. srch = if boolVariable == true high else close srcl = if boolVariable == true low else close emashorthigh = ta.ema(srch, fast) emashortlow = ta.ema(srcl, fast) emashort = ta.ema(close, fast) emalong = ta.ema(close, slow) rsi = ta.rsi(close, rsiL) buy1 = if ta.crossover(rsi, 50) or ta.crossover(rsi, RSIOL) 1 else na sell1 = if ta.crossunder(rsi, 50) or ta.crossunder(rsi, 100-RSIOL) 1 else na buy = if buy1 == 1 and emashorthigh > emalong and close > emashort and close > sar 1 else na sell = if sell1 == 1 and emashortlow < emalong and close < emashort and close < sar 1 else na // adding MATD filter //declaring function to use different types of MA maf(source, length, type) => type == 'SMA' ? ta.sma(source, length) : type == 'EMA' ? ta.ema(source, length) : type == 'SMMA (RMA)' ? ta.rma(source, length) : type == 'WMA' ? ta.wma(source, length) : type == 'VWMA' ? ta.vwma(source, length) : na // inputs Malength = input(100, title = "MA Length") src = input(close, title = "MA Source") type = input.string( 'WMA', title='MA type', inline='MA Type', options=['SMA', 'EMA', 'SMMA (RMA)', 'WMA', 'VWMA', 'linreg']) Madistancelength = input(20, title = "Distance Length") srcdistance = input(hl2, title = "Distance Source") smoothing = input(20, title = "smooothing") // running fuction ma = maf(src, Malength, type) // calculating distance distance = srcdistance - ma // Average of distances smadistance = ta.sma(distance, Madistancelength) // MATD and smoothing of it MATD = srcdistance - smadistance Smoothed = ta.sma(MATD, smoothing) max = math.max(Smoothed,ma) min = math.min(Smoothed,ma) B = if close > max and buy == 1 1 else na S = if close < min and sell == 1 1 else na b = if filter == true B else buy s = if filter == true S else sell plotshape(b, title='Buy', style=shape.labelup, location=location.belowbar, size=size.normal, text='Buy', textcolor=color.new(color.white, 0), color=color.new(color.green, 0)) plotshape(s, title='Sell', style=shape.labeldown, location=location.abovebar, size=size.normal, text='Sell', textcolor=color.new(color.white, 0), color=color.new(color.red, 0)) plot(sar, title= "sar") plot(emalong, title= "emalong",color=color.new(color.red, 0))
Overbought & Oversold Tracker
https://www.tradingview.com/script/LhIo0wYR-Overbought-Oversold-Tracker/
taufan_ganas
https://www.tradingview.com/u/taufan_ganas/
160
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/ // © taufan_ganas //@version=5 indicator("OBS Tracker", overlay = true) //Stochastic grp_1 = 'STOCHASTIC SETTINGS' periodK = input.int(14, title='K', minval=1, group = grp_1) periodD = input.int(3, title='D', minval=1, group = grp_1) smoothK = input.int(3, title='Smooth', minval=1, group = grp_1) k = ta.sma(ta.stoch(close, high, low, periodK), smoothK) d = ta.sma(k, periodD) Oversoldlevel = input.int(25, title = 'k Line Value for Oversold', minval = 0, maxval = 100, group = grp_1) Overboughtlevel = input.int(75, title = 'k Line Value for Overbought', minval = 0, maxval = 100, group = grp_1) //Condition Support Line supportT0 = ta.crossover(d, k) and k >= Overboughtlevel ? low : ta.crossover(k, d) and k <= Overboughtlevel ? low : na linecolor = ta.crossover(d, k) and k >= Overboughtlevel ? color.red : ta.crossover(k, d) and k <= Oversoldlevel ? color.blue : na if(supportT0) supportT0_line = line.new(bar_index, low, bar_index[1], low, color = linecolor, style=line.style_dashed, extend = extend.left, width=1) line.delete(supportT0_line[1]) grp_2 = 'OTHER SETTINGS' //Breakout Support bearBO = ta.valuewhen(supportT0,low,0) bar = ta.crossover(bearBO,close) ? color.red: na barcolor(color = bar, title='Support Broken', show_last=input(title='Last Candles Done - Show Red Candle', defval=5, group = grp_2)) plotshape(supportT0, size = size.tiny, style = shape.triangleup, location = location.belowbar, color = linecolor, show_last=input(title='Last Candles Done - Show Triangle', defval=5, group = grp_2))
GMC Trend Filter
https://www.tradingview.com/script/pZ6UDAkq-GMC-Trend-Filter/
zubbihawk
https://www.tradingview.com/u/zubbihawk/
185
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 study("GMC Trend Ribbon", precision = 0) dlen = input(defval = 20, title = "Ribbon Period", minval = 10) dchannel(len)=> float hh = highest(len) float ll = lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) dchannelalt(len, maintrend)=> float hh = highest(len) float ll = lowest(len) int trend = 0 trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1]) maintrend == 1 ? trend == 1 ? #00FF00ff : #00FF009f : maintrend == -1 ? trend == -1 ? #FF0000ff : #FF00009f : na maintrend = dchannel(dlen) plot( 5, color = dchannelalt(dlen - 0, maintrend), style = plot.style_columns, histbase= 0) plot(10, color = dchannelalt(dlen - 1, maintrend), style = plot.style_columns, histbase= 5) plot(15, color = dchannelalt(dlen - 2, maintrend), style = plot.style_columns, histbase=10) plot(20, color = dchannelalt(dlen - 3, maintrend), style = plot.style_columns, histbase=15) plot(25, color = dchannelalt(dlen - 4, maintrend), style = plot.style_columns, histbase=20) plot(30, color = dchannelalt(dlen - 5, maintrend), style = plot.style_columns, histbase=25) plot(35, color = dchannelalt(dlen - 6, maintrend), style = plot.style_columns, histbase=30) plot(40, color = dchannelalt(dlen - 7, maintrend), style = plot.style_columns, histbase=35) plot(45, color = dchannelalt(dlen - 8, maintrend), style = plot.style_columns, histbase=40) plot(50, color = dchannelalt(dlen - 9, maintrend), style = plot.style_columns, histbase=45)
Super scalp
https://www.tradingview.com/script/whwec7IG-Super-scalp/
Wolfgang_Grimmer
https://www.tradingview.com/u/Wolfgang_Grimmer/
202
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/ // © Wolfgang_Grimmer //@version=5 indicator("Super scalp",overlay=true) atrPeriod = input(10, 'ATR Length') // 2. Change the ATR length/period (optional) factor = input.float(1.5, 'Factor') // 3. Change the ATR factor/multiplier (optional) riskvalue = input.int(1, 'Risk Value', tooltip='The volume executed will be based on your EA Settings on your MT4/5') // 4. Change the risk value (optional) [supertrend, direction] = ta.supertrend(factor, atrPeriod) bodyMiddle = plot((open + close) / 2, display=display.none) upTrend = plot(direction < 0 ? supertrend : na, 'Up Trend', color=color.new(color.green, 0), style=plot.style_linebr) downTrend = plot(direction < 0 ? na : supertrend, 'Down Trend', color=color.new(color.red, 0), style=plot.style_linebr) fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false) vwapval = ta.vwap(close) MA9 = ta.ema(close, 9) fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false) plotshape(ta.change(direction) < 0 and close>MA9 and close>vwapval, style=shape.labelup, location=location.belowbar, color=color.new(#009900, 0), size=size.large, text='Scalp \n Buy', textcolor=color.new(color.white, 0)) plotshape(ta.change(direction) > 0 and close<MA9 and close<vwapval, style=shape.labeldown, location=location.abovebar, color=color.new(#CC0000, 0), size=size.large, text='Scalp \n Sell', textcolor=color.new(color.white, 0)) plot(vwapval, color=color.black, title="vwapval") plot(MA9, color=color.orange, title="sma20")
Price Clouds Oscillator (PCO)
https://www.tradingview.com/script/H7k2xiDA-Price-Clouds-Oscillator-PCO/
peacefulLizard50262
https://www.tradingview.com/u/peacefulLizard50262/
91
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © peacefulLizard50262 //@version=5 indicator("PCO","PCO", false, precision=3, explicit_plot_zorder = true) //FUNCTIONS //{ //Derivative //© tbiktag diff(src, N) => //{ float derivative = 0.0 if N == 2 derivative := (src - src[2]) / 2 derivative else if N == 3 derivative := (src + src[1] - src[2] - src[3]) / 4 derivative else if N == 4 derivative := (src + 2 * src[1] - 2 * src[3] - src[4]) / 8 derivative else if N == 5 derivative := (src + 3 * src[1] + 2 * src[2] - 2 * src[3] - 3 * src[4] - src[5]) / 16 derivative //} //EMA Function (Fk) ema(src, len) => //{ alpha = 2 / (len + 1) sum = 0.0 sum := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1]) //} //Tripple 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 //} //Normalization Function norm(src, min, max, bool pass = true) => //{ //src is an input.source //min is an input.float //max is an input.float //offset is an input.float //scale is an input.int //pass bypasses the normalization function num = src - min den = max - min norm = num / den out = pass == true ? (norm - 0.5) * 2 : src //} //Full Standard Deviation Function stdev(src, avg, float dev, int len, bool pol) => //{ //src is an input.source //source of the avg //avg is the global series average //dev is an input.float //len is an input.int //use the global length //pol is an input.bool //this changes the polarity //true is positive stdev = dev * ta.stdev(src, len) out = pol == true ? avg + stdev : avg - stdev //} //Band Lines Function band_line(src, int len, int globallen, float dev, float globaldev, string avginput, string globalinput, bool pol, bool pos, bool preset, string presetinput, bool global, bool smooth, int smoothlen) => //{ //src is an input.source //should be high for the top band for instance //len is an input.int //band length //globallen is an input.int //input for the global lenght //dev is an input.float //the stdev for the line //globaldev is an input.float //this is the input for the global dev //avginput is an input.string //"SMA", "EMA", "TMA" //globalinput is an input.string //"SMA", "EMA", "TMA" //pol is an inputbool //polarity of the stdev //True is Positive //False is Negitive //pos is an input.bool //set this flag to determine its position in the band //true is top while false is bottom //preset is an input.bool //if true it will use the preset values //presetinput is an input.string //"Fast", "Slow", "Super Slow" //global is an input.bool //toggle globals //smooth is an input.bool //turn smoothing on and off //smoothlen is an input.int //smoothing length pstlen = switch presetinput "Fast" => int(10) "Slow" => int(48) "Super Slow" => int(200) pstdev = switch presetinput "Fast" => pos == true ? float(0.75) : float(0) "Slow" => pos == true ? float(2) : float(1) "Super Slow" => pos == true ? float(2) : float(1) pstavg = switch presetinput "Fast" => string("SMA") "Slow" => string("SMA") "Super Slow" => string("SMA") intlen = preset == true ? pstlen : global == true ? globallen : len intdev = preset == true ? pstdev : global == true ? globaldev : dev average = switch global == true ? globalinput : preset == true ? pstavg : avginput "SMA" => ta.sma(src, intlen) "EMA" => ema(src, intlen) "TMA" => tma(src, intlen) //stdev(src, avg, float dev, int len, bool pol) out = stdev(src, average, intdev, intlen, pol) outsmooth = smooth == true ? ta.sma(out, smoothlen) : out //} //Signal Lines Function signal(src, len, preset, presetinput, spd, smooth, smoothlen) => //{ //src is an input.source //float //should be hl2 //len is an input.int //length //preset is an input.bool //if true it will use the preset values //presetinput is an input.string //"Fast", "Slow", "Super Slow" //spd is an input.bool //TRUE is FAST line FALSE is SLOW line //smooth is an input.bool //turn smoothing on and off //smoothlen is an input.int //smoothing length pstlen = switch presetinput "Fast" => spd == true ? int(7) : int(14) "Slow" => spd == true ? int(14) : int(26) "Super Slow" => spd == true ? int(50) : int(100) out = tma(src, preset == true ? pstlen : len) outsmooth = smooth == true ? ta.sma(out, smoothlen) : out //} //Band Width Function width(upper, lower, top, bot) => //{ //upper is the series for the top of the band //lower is the series for the bottom of the band //avg is the mean dev = upper - lower hl = top - bot out = math.avg(dev, hl) //} //} //CONSTANTS //{ //color //} //INPUTS //{ //presets//{ flag_preset = input.bool(true, "Enable Presets", "This enables the presets found in the preset dropdown.", group = 'Presets', inline = "set") preset_string = input.string("Slow", "                   ", ["Fast", "Slow", "Super Slow"], "Select a Preset", group = "Presets", inline = "set")//} //normalize //{ flag_normalize = input.bool(false, "Normalize", "Enable Normalization", group = "Features")//} flag_candle = input.bool(false, "Candle View", group = "Features") flag_can_col = input.bool(false, "Candle Color", "When this is enabled it will color the candles on ma cross. When it is dissabled it will color on open close.", group = "Features") //cross color cross_enable = input.bool(false, "Color Cross", "Enable this to highlite MACD crosses.", "cross", "Features") ////////////////////////////////////// cross_up = input.color(color.new(color.blue , 50), "", inline = "cross", group = "Features") cross_down = input.color(color.new(color.orange , 50), "", inline = "cross", group = "Features") cross_high = input.color(color.new(color.green , 80), "", inline = "cross", group = "Features") cross_low = input.color(color.new(color.red , 80), "", inline = "cross", group = "Features") //width //{ width_enable = input.bool(false, "Bandwidth ", "Enable this when normalizing to see bandwidth", group = "Features", inline = "width") width_low_color = input.color(color.new(#311b92, 100), "", group = "Features", inline = "width") width_high_color = input.color(color.new(#311b92, 0), "", group = "Features", inline = "width") width_len = input.int(500, "", tooltip = "Bandwidth Normalization Lookback Period", group = "Features", inline = "width") //} //smoothing //{ flag_smoothing = input.bool(false, "Smoothing", "Toggle Signal Smoothing", group = "Features", inline = "smoothing") signal_smoothing = input.int(3, "                         ", 1, 10, 1, "Set the level of smoothing", group = "Features", inline = "smoothing")//} //histogram //{ flag_histogram = input.bool(true, "", "Enable Histogram.", group = "Features", inline = "hist") histogram_diff = input.bool(false, "Delta MACD", "Change the histogram color to the delta.", group = "Features")//////////////////// delta_back = input.int(20, "Delta Lookback", 1, 3000, group = "Features") histogram_input = input.string("MACD", "Histogram Toggle               ", ["MACD","Derivative"], group = "Features", inline = "hist") derivative_input = input.string("Fast", "Derivative      ", ["Fast","Slow"], group = "Features", inline = "derivative") N = input.int(title='', tooltip = "Select the input for the Derivative. Bandwidth from 2 - 5", defval=4, minval=2, maxval=5, group = "Features", inline = "derivative")//} //global //{ flag_global = input.bool(true, "Global Control Switch", "Toggle Global Control", group = "Global Controls") global_avg_input = input.string("SMA", "Global MA Type", ["SMA","EMA", "TMA"], group = "Global Controls") global_len = input.int(10, "Global Band Length", 1, 9999, 1, tooltip = "Set the Global Band Lenth.", group = "Global Controls") global_dev_top = input.float(0.75, "Global Band Stdev Top", -10, 10, 0.05, "Set the Global Band Stdev.", group = "Global Controls") global_dev_bot = input.float(0, "Global Band Stdev Mid", -10, 10, 0.05, "Set the Global Mid Band Stdev.", group = "Global Controls") //} //signals//{ signal_fast_len = input.int(7, "Signal Fast Line Length", 1, 9999, 1, "Set the period of the moving average associated with the Signal Fast Line.", group = "Signal Lines") signal_slow_len = input.int(14, "Signal Slow Line Length", 1, 9999, 1, "Set the period of the moving average associated with the Signal Slow Line Length.", group = "Signal Lines") //} //band //top of the high band//{ band_high_top_avg_input = input.string("SMA", "Top of High Band MA Type", ["SMA","EMA","TMA"], "Select the Moving Average type", group = "Top High Band" ) band_high_top_len = input.int(10, "Top of High Band Length", 1, 9999, 1, "Top of High Band MA Length", group = "Top High Band") band_high_top_dev = input.float(0.75, "Top of the High Band Stdev", -10, 10, 0.05, "Set the Top of the High Band Standard Deviation", group = "Top High Band") //} //mid of the high band//{ band_high_bot_avg_input = input.string("SMA", "Bottom of High Band MA Type", ["SMA","EMA","TMA"], "Select the Moving Average type", group = "Bottom High Band" ) band_high_bot_len = input.int(10, "Bottom of High Band Length", 1, 9999, 1, "Set the Bottom of High Band MA Length", group = "Bottom High Band") band_high_bot_dev = input.float(0, "Bottom of the High Band Stdev", -10, 10, 0.05, "Set the Bottom of the High Band Standard Deviation", group = "Bottom High Band") //} //mid of low band//{ band_low_top_avg_input = input.string("SMA", "Top of Low Band MA Type", ["SMA","EMA","TMA"], "Select the Moving Average type", group = "Top Low Band" ) band_low_top_len = input.int(10, "Top of Low Band Length", 1, 9999, 1, "Top of Low Band MA Length", group = "Top Low Band") band_low_top_dev = input.float(0.75, "Top of the Low Band Stdev", -10, 10, 0.05, "Set the Top of the Low Band Standard Deviation", group = "Top Low Band") //} //bottom of the low band //{ band_low_bot_avg_input = input.string("SMA", "Bottom of Low Band MA Type", ["SMA","EMA","TMA"], "Select the Moving Average type", group = "Bottom Low Band" ) band_low_bot_len = input.int(10, "Bottom of Low Band Length", 1, 9999, 1, "Set the Bottom of Low Band MA Length", group = "Bottom Low Band") band_low_bot_dev = input.float(0, "Bottom of the Low Band Stdev", -10, 10, 0.05, "Set the Bottom of the Low Band Standard Deviation", group = "Bottom Low Band") //} colour_fast = input.color(color.new(color.blue, 0), "Signal Fast Line Color", group = "Color") colour_slow = input.color(color.new(color.orange, 0), "Signal Slow Line Color", group = "Color") colour_band_top = input.color(color.new(color.green, 50), "High Band Color", group = "Color") colour_band_mid_top = input.color(color.new(color.green, 100), "High Mid Band Color", group = "Color") colour_cloud_top = input.color(color.new(color.green, 80), "High Cloud Color", group = "Color") colour_band_bot = input.color(color.new(color.red, 50), "Low Band Color", group = "Color") colour_band_mid_bot = input.color(color.new(color.red, 100), "Low Mid Band Color", group = "Color") colour_cloud_bot = input.color(color.new(color.red, 80), "Low Cloud Color", group = "Color") colour_center = input.color(color.new(color.gray, 100), "Center Line Color", group = "Color") colour_candle_up = input.color(color.new(#26a69a, 8), "Candle Bullish Color", group = "Color") colour_candle_down = input.color(color.new(#ef5350, 8), "Candle Bearish Color", group = "Color") col_grow_above = input.color(color.new(#26A69A, 50), "MACD Grow Above Color", group = "Color") col_fall_above = input.color(color.new(#B2DFDB, 50), "MACD Fall Above Color", group = "Color") col_grow_below = input.color(color.new(#FFCDD2, 50), "MACD Grow Below Color", group = "Color") col_fall_below = input.color(color.new(#FF5252, 50), "MACD Fall Below Color", group = "Color" )//} //MAIN //{ //signals raw //{ //signal(_src, _len, _preset, _preset_input, _spd, _smooth, _smooth_len) raw_signal_fast = signal(hl2, signal_fast_len, flag_preset, preset_string, true, flag_smoothing, signal_smoothing) raw_signal_slow = signal(hl2, signal_slow_len, flag_preset, preset_string, false, flag_smoothing, signal_smoothing) //} //bands raw //{ //band_line(_src, _len, _global_len, _dev, _global_dev, _avg_input, _global_input, _pol, _pos, _preset, _preset_input, _global, _smooth, _smooth_len) raw_band_high_top = band_line(high, band_high_top_len, global_len, band_high_top_dev, global_dev_top, band_high_top_avg_input, global_avg_input, true, true, flag_preset, preset_string, flag_global, flag_smoothing, signal_smoothing) raw_band_high_bot = band_line(high, band_high_bot_len, global_len, band_high_bot_dev, global_dev_bot, band_high_bot_avg_input, global_avg_input, true, false, flag_preset, preset_string, flag_global, flag_smoothing, signal_smoothing) raw_band_low_top = band_line(low, band_low_top_len, global_len, band_low_top_dev, global_dev_top, band_low_top_avg_input, global_avg_input, false, true, flag_preset, preset_string, flag_global, flag_smoothing, signal_smoothing) raw_band_low_bot = band_line(low, band_low_bot_len, global_len, band_low_bot_dev, global_dev_bot, band_low_bot_avg_input, global_avg_input, false, false, flag_preset, preset_string, flag_global, flag_smoothing, signal_smoothing) //} //mean calculation //{ mean = math.avg(raw_band_high_bot, raw_band_high_top, raw_band_low_bot, raw_band_low_top) //} //signals centered //{ cen_signal_fast = raw_signal_fast - mean cen_signal_slow = raw_signal_slow - mean //} //bands centered //{ cen_band_high_top = raw_band_high_top - mean cen_band_high_bot = raw_band_high_bot - mean cen_band_low_top = raw_band_low_top - mean cen_band_low_bot = raw_band_low_bot - mean open_fast = norm(signal(open , signal_fast_len, flag_preset, preset_string, true, flag_smoothing, signal_smoothing) - mean, cen_band_low_top, cen_band_high_top, flag_normalize) high_fast = norm(signal(high , signal_fast_len, flag_preset, preset_string, true, flag_smoothing, signal_smoothing) - mean, cen_band_low_top, cen_band_high_top, flag_normalize) low_fast = norm(signal(low , signal_fast_len, flag_preset, preset_string, true, flag_smoothing, signal_smoothing) - mean, cen_band_low_top, cen_band_high_top, flag_normalize) close_fast = norm(signal(close , signal_fast_len, flag_preset, preset_string, true, flag_smoothing, signal_smoothing) - mean, cen_band_low_top, cen_band_high_top, flag_normalize) //} //normalized signal //{ //norm(_src, _min, _max, _offset, _scale, _pass) Signal_Fast = norm(cen_signal_fast, cen_band_low_top, cen_band_high_top, flag_normalize) Signal_Slow = norm(cen_signal_slow, cen_band_low_top, cen_band_high_top, flag_normalize) //} //darivative input source //{ derivative_src = derivative_input == "Fast" ? Signal_Fast : Signal_Slow //} //normalized bands //{ Band_High_Top = norm(cen_band_high_top, cen_band_low_top, cen_band_high_top, flag_normalize) Band_High_Bot = norm(cen_band_high_bot, cen_band_low_top, cen_band_high_top, flag_normalize) Band_Low_Top = norm(cen_band_low_top, cen_band_low_top, cen_band_high_top, flag_normalize) Band_Low_Bot = norm(cen_band_low_bot, cen_band_low_top, cen_band_high_top, flag_normalize) //} //MACD //{ MACD = flag_histogram == true ? Signal_Fast - Signal_Slow : na macd_color = (MACD>=0 ? (MACD[1] < MACD ? col_grow_above : col_fall_above) : (MACD[1] < MACD ? col_grow_below : col_fall_below)) //} //derivitive //{ Derivative = flag_histogram == true ? diff(derivative_src, N) : na derivative_color = (Derivative>=0 ? (Derivative[1] < Derivative ? col_grow_above : col_fall_above) : (Derivative[1] < Derivative ? col_grow_below : col_fall_below)) //} //Histogram //{ histogram_color = histogram_input == "MACD" ? macd_color : derivative_color Histogram = histogram_input == "MACD" ? MACD : Derivative //} //Band Width //{ //TODO: Pack into function width_dev = width(cen_band_high_top, cen_band_low_top, cen_band_high_bot, cen_band_low_bot) width_high = ta.highest(width_dev, width_len) width_low = ta.lowest(width_dev, width_len) width_norm = (norm(width_dev, width_low, width_high) / 2) + 0.5 wide = width_enable == true ? color.from_gradient(width_norm, 0, 1, width_low_color, width_high_color) : na up = ta.crossover(Signal_Fast, Signal_Slow) //////////////////////////////// down = ta.crossunder(Signal_Fast, Signal_Slow) high_out = ta.cross(Signal_Fast, Band_High_Top) low_out = ta.cross(Signal_Fast, Band_Low_Top) color cross = na color cross_2 = na cross_2 := not low_out and not high_out ? na : high_out ? cross_high : low_out ? cross_low : na cross := not up and not down ? na : up ? cross_up : down ? cross_down : na Histogram_Delta = ((Histogram - Histogram[2])/2 - ta.lowest((Histogram - Histogram[2])/2, delta_back)) / (ta.highest((Histogram - Histogram[2])/2, delta_back) - ta.lowest((Histogram - Histogram[2])/2, delta_back)) delta_col = color.from_gradient(Histogram_Delta, 0, 1, col_fall_below, col_grow_above) //} //} //PLOT and FIll //{ //high top Plot_Band_High_Top = plot(Band_High_Top, "Top of High Band", colour_band_top) //high mid Plot_Band_High_Bot = plot(Band_High_Bot, "Bottom of High Band", colour_band_mid_top) //low mid Plot_Band_Low_Top = plot(Band_Low_Top, "Top of Low Band", colour_band_bot) Plot_Band_Low_Bot = plot(Band_Low_Bot, "Bottom of Low Band", colour_band_mid_bot) //top fill(Plot_Band_High_Top, Plot_Band_High_Bot, colour_cloud_top, "High Cloud") //bot fill(Plot_Band_Low_Top, Plot_Band_Low_Bot, colour_cloud_bot, "Low Cloud") //width fill(Plot_Band_High_Bot, Plot_Band_Low_Bot, wide) //histogram plot(Histogram, title="Histogram", style = plot.style_columns, color = histogram_diff ? delta_col : histogram_color) //band lines //center line Plot_center = plot(0, "Center Line", colour_center, style=plot.style_line) //fast line Plot_Fast = plot(flag_candle ? na : Signal_Fast, "Signal Fast Line", colour_fast) //slow line Plot_Slow = plot(flag_candle ? na : Signal_Slow, "Signal Slow Line", colour_slow) //} candle_color = flag_candle ? not flag_can_col ? open_fast < close_fast ? colour_candle_up : colour_candle_down : Signal_Fast > Signal_Slow ? colour_candle_up : colour_candle_down : na plotcandle(open_fast, high_fast, low_fast, close_fast, "Candles", candle_color, candle_color, true, bordercolor = candle_color) fill(Plot_Band_High_Bot, Plot_Band_Low_Bot, cross_enable ? cross : na) fill(Plot_Band_High_Bot, Plot_Band_Low_Bot, cross_enable ? cross_2 : na) signal_cross_under_bottom = ta.crossunder(Signal_Fast, Band_Low_Bot) signal_cross_over_bottom = ta.crossover(Signal_Fast, Band_Low_Bot) signal_cross_over_top = ta.crossover(Signal_Fast, Band_High_Bot) signal_cross_under_top = ta.crossunder(Signal_Fast, Band_High_Bot) signal_cross_bullish = ta.crossover(Signal_Fast, Signal_Slow) signal_cross_bearish = ta.crossunder(Signal_Fast, Signal_Slow) signal_cross_bullish_under = ta.crossover(Signal_Fast, Signal_Slow) and (Signal_Fast <= Band_Low_Bot) signal_cross_bearish_over = ta.crossunder(Signal_Fast, Signal_Slow) and (Signal_Fast >= Band_High_Top) alertcondition(signal_cross_under_bottom , "Signal Cross Under Bottom") alertcondition(signal_cross_over_bottom , "Signal Cross Over Bottom") alertcondition(signal_cross_over_top , "Signal Cross Over Top") alertcondition(signal_cross_under_top , "Signal Cross Under Top") alertcondition(signal_cross_bullish , "Signal Fast Cross Over Signal Slow") alertcondition(signal_cross_bearish , "Signal Fast Cross Under Signal Slow") alertcondition(signal_cross_bullish_under ,"Signal Fast Cross Over Signal Slow Outside of Range" ) alertcondition(signal_cross_bearish_over , "Signal Fast Cross Under Signal Slow Outside of Range")
HersG High Low Bar Charts Layout
https://www.tradingview.com/script/BNGCBnOO-HersG-High-Low-Bar-Charts-Layout/
HerschelleGirnari
https://www.tradingview.com/u/HerschelleGirnari/
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/ // © HerschelleGirnari //@version=5 indicator(title ="HersG High Low Bar Charts Layout", shorttitle = "HersG HL Bars", overlay = true) plot(open, title = "Open", color = color.new(color.red, 25), style = plot.style_circles, linewidth = 3) plot(close, title = "Close", color = color.new(color.green, 25), style = plot.style_circles, linewidth = 3) Highx = plot(high, title = "High", color = color.teal, linewidth = 3, style = plot.style_stepline) Lowx = plot(low, title = "Low", color = color.teal, linewidth = 3, style = plot.style_stepline) fill(Highx, Lowx, color = color.new(color.teal, 85), title = "Bars")
[HELPER] Table Color For Pairing Black And White
https://www.tradingview.com/script/hhq7hzOw-HELPER-Table-Color-For-Pairing-Black-And-White/
RozaniGhani-RG
https://www.tradingview.com/u/RozaniGhani-RG/
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/ // © RozaniGhani-RG //@version=5 indicator('[HELPER] Table Color For Pairing Black And White', shorttitle = 'TCFPAB') // 0. Inputs // 1. Variables and arrays // 2. Custom functions // 3. Plot // 4. Construct // 0. Inputs { T1 = 'Small font size recommended for mobile app or multiple layout' i_b_col = input.bool(false, 'Invert Color') i_s_Y = input.string('middle', 'Table Position', inline = '1', options = ['top', 'middle', 'bottom']) i_s_X = input.string('center', '', inline = '1', options = ['left', 'center', 'right']) i_s_font = input.string('normal', 'Font size', tooltip = T1, options = ['tiny', 'small', 'normal', 'large', 'huge']) // } // 1. Variables and arrays { var colorTable = table.new(i_s_Y + '_' + i_s_X, 3, 16, border_width = 1) var label_color = array.new_label(16) // 0 1 2 3 4 5 6 7 8 9 arr_black = array.from( color.aqua, color.lime, color.orange, color.silver, color.white, color.yellow) arr_white = array.from(color.black, color.blue, color.fuchsia, color.green, color.maroon, color.navy, color.olive, color.purple, color.red, color.teal) // 1 2 3 4 5 6 7 8 9 10 11 str_col = array.from( 'aqua', 'black', 'blue', 'fuchsia', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple', 'red', 'silver', 'teal', 'white', 'yellow') arr_col = array.from(color.aqua, color.black, color.blue, color.fuchsia, color.green, color.lime, color.maroon, color.navy, color.olive, color.orange, color.purple, color.red, color.silver, color.teal, color.white, color.yellow) // } // 2. Custom functions { // 2.1 Plot p_col(int _index) => array.get(arr_col, _index) // 2.2 Cell table _bgcolor(int _index) => color col = switch i_b_col true => array.includes(arr_black, array.get(arr_col, _index)) ? color.black : array.includes(arr_white, array.get(arr_col, _index)) ? color.white : na false => array.get(arr_col, _index) _color(int _index) => color col = switch i_b_col true => array.get(arr_col, _index) false => array.includes(arr_black, array.get(arr_col, _index)) ? color.black : array.includes(arr_white, array.get(arr_col, _index)) ? color.white : na str(int _index) => array.includes(arr_black, array.get(arr_col, _index)) ? 'color.black' : array.includes(arr_white, array.get(arr_col, _index)) ? 'color.white' : '' f_cell(int _column, int _row, string _text) => table.cell(colorTable, _column, _row, _text, text_color = _color(_row), text_size = i_s_font, bgcolor = _bgcolor(_row)) f_row(int _row) => f_cell(0, _row, str.tostring(_row)) f_cell(1, _row, array.get(str_col, _row)) f_cell(2, _row, str(_row)) // 2.3 Label f_label(int _index) => array.set(label_color, _index, label.new(bar_index, -_index, array.get(str_col, _index), color = _bgcolor(_index), style = label.style_label_left, size = i_s_font, textcolor = _color(_index)) ) // } // 3. Plot { plot( 0, 'aqua', p_col(0)) plot( -1, 'black', p_col(1)) plot( -2, 'blue', p_col(2)) plot( -3, 'fuchsia', p_col(3)) plot( -4, 'green', p_col(4)) plot( -5, 'lime', p_col(5)) plot( -6, 'maroon', p_col(6)) plot( -7, 'navy', p_col(7)) plot( -8, 'olive', p_col(8)) plot( -9, 'orange', p_col(9)) plot(-10, 'purple', p_col(10)) plot(-11, 'red', p_col(11)) plot(-12, 'silver', p_col(12)) plot(-13, 'teal', p_col(13)) plot(-14, 'white', p_col(14)) plot(-15, 'yellow', p_col(15)) // } // 4. Construct { if barstate.islast for x = 0 to 15 f_row(x) f_label(x) // }
Right Way Oscillator
https://www.tradingview.com/script/smOjCyaw-right-way-oscillator/
diemock
https://www.tradingview.com/u/diemock/
44
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/ // © diemock //@version=4 study("Right Way Oscillator") Theme = input(title="  Theme", options=["Standard", "Classic", "Lemon", "Silver Surfer", "Watermelon", "Ethereal"], defval="Watermelon") color1 = color.new(#26a69a, 75) color2 = color.new(#ef5350, 75) color3 = color.new(#43ff43, 75) color4 = color.new(#ff0d0d, 75) color5 = color.new(#ffff00, 75) color6 = color.new(#00ff00, 75) color7 = color.new(color.silver, 50) color8 = color.new(#353535, 50) color9 = color.new(#24e828, 75) color10 = color.new(#ff357e, 75) color11 = color.new(color.teal, 75) color12 = color.new(color.purple, 75) c1 = Theme == "Standard" ? color1 : Theme == "Classic" ? color3 : Theme == "Lemon" ? color5 : Theme == "Silver Surfer" ? color7 : Theme == "Watermelon" ? color9 : Theme == "Ethereal" ? color11 : na c2 = Theme == "Standard" ? color2 : Theme == "Classic" ? color4 : Theme == "Lemon" ? color6 : Theme == "Silver Surfer" ? color8 : Theme == "Watermelon" ? color10 : Theme == "Ethereal" ? color12 : na //------------VSLRT---------------- vslrt_src = input(defval = close, title = "Source") len2 = 50 len1 = 20 // get short/long-term regression slope slope_price = linreg(vslrt_src, len1, 0) - linreg(vslrt_src, len1, 1) slope_price_lt = linreg(vslrt_src, len2, 0) - linreg(vslrt_src, len2, 1) // get size of top/bottom/body of the candle tw = high - max(open, close) bw = min(open, close) - low body = abs(close - open) //Calculate Buy/Sell Volume _rate(cond) => ret = 0.5 * (tw + bw + (cond ? 2 * body : 0)) / (tw + bw + body) ret := na(ret) ? 0.5 : ret ret // Calculate Regression Slope for Buy/Sell Volumes _get_trend(len)=> deltaup = volume * _rate(open <= close) deltadown = volume * _rate(open > close) slope_volume_up = linreg(deltaup, len, 0) - linreg(deltaup, len, 1) slope_volume_down = linreg(deltadown, len, 0) - linreg(deltadown, len, 1) [slope_volume_up, slope_volume_down] [slope_volume_up, slope_volume_down] = _get_trend(len1) // get buy/sell volume regression slopes for long term period [slope_volume_up_lt, slope_volume_down_lt] = _get_trend(len2) // coloring col_VSLRT_lt = slope_price_lt > 0 ? slope_volume_up_lt > 0 ? slope_volume_up_lt > slope_volume_down_lt ? color.aqua : #006ec5 : #024478 : slope_price_lt < 0 ? slope_volume_down_lt > 0 ? slope_volume_up_lt < slope_volume_down_lt ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_VSLRT_lt = slope_price_lt > 0 ? slope_volume_up_lt > 0 ? slope_volume_up_lt > slope_volume_down_lt ? 1 : 0.5 : 0.25 : slope_price_lt < 0 ? slope_volume_down_lt > 0 ? slope_volume_up_lt < slope_volume_down_lt ? -1 : -0.5 : -0.25 : 0 // coloring col_VSLRT = slope_price > 0 ? slope_volume_up > 0 ? slope_volume_up > slope_volume_down ? color.aqua : #006ec5 : #024478 : slope_price < 0 ? slope_volume_down > 0 ? slope_volume_up < slope_volume_down ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_VSLRT = slope_price > 0 ? slope_volume_up > 0 ? slope_volume_up > slope_volume_down ? 1 : 0.5 : 0.25 : slope_price < 0 ? slope_volume_down > 0 ? slope_volume_up < slope_volume_down ? -1 : -0.5 : -0.25 : 0 //------------VSLRT END---------------- //------------ATR---------------- Periods = input(title="ATR Period", type=input.integer, defval=10) Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=1.0) Periods1 = input(title="ATR Period", type=input.integer, defval=12) Multiplier1 = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) Periods2 = input(title="ATR Period", type=input.integer, defval=11) Multiplier2 = input(title="ATR Multiplier", type=input.float, step=0.1, defval=2.0) src = input(hl2, title="Source") changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true) make_super(Periods, src, Multiplier, changeATR) => atr2 = sma(tr, Periods) atr= changeATR ? atr(Periods) : atr2 up=src-(Multiplier*atr) up1 = nz(up[1],up) up := close[1] > up1 ? max(up,up1) : up dn=src+(Multiplier*atr) dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend changeCond = trend != trend[1] [trend, trend[1], up, dn] [trend, trend1, up, dn] = make_super(Periods, src, Multiplier, changeATR) [trend_1, trend1_1, up_1, dn_1] = make_super(Periods1, src, Multiplier1, changeATR) [trend_2, trend1_2, up_2, dn_2] = make_super(Periods2, src, Multiplier2, changeATR) buySignal = trend == 1 and trend1 == -1 sellSignal = trend == -1 and trend1 == 1 buySignal_1 = trend_1 == 1 and trend1_1 == -1 sellSignal_1 = trend_1 == -1 and trend1_1 == 1 buySignal_2 = trend_2 == 1 and trend1_2 == -1 sellSignal_2 = trend_2 == -1 and trend1_2 == 1 count_up = 0 count_down = 0 if trend == 1 count_up :=count_up + 1 else count_down :=count_down + 1 if trend_1 == 1 count_up :=count_up + 1 else count_down :=count_down + 1 if trend_2 == 1 count_up :=count_up + 1 else count_down :=count_down + 1 // coloring col_ATR = count_up > count_down ? count_up > 2 ? color.aqua : #006ec5 : count_down > 1 ? count_down > 2 ? #fa3939 : #CE7A00 : color.gray weight_ATR = count_up > count_down ? count_up > 2 ? 1 : 0.5 : count_down > 1 ? count_down > 2 ? -1 : -0.5 : 0 //------------ATR END---------------- //------------------WT--------------- // PARAMETERS { // WaveTrend wtShow = true wtBuyShow = true wtGoldShow = true wtSellShow = true wtDivShow = true vwapShow = true wtChannelLen = 9 wtAverageLen = 12 wtMASource = hlc3 wtMALen = 3 // WaveTrend Overbought & Oversold lines obLevel = 53 obLevel2 = 60 obLevel3 = 100 osLevel = -53 osLevel2 = -60 osLevel3 = -75 // Divergence WT wtShowDiv = true wtShowHiddenDiv = false showHiddenDiv_nl = true wtDivOBLevel = 45 wtDivOSLevel = -65 // Divergence extra range wtDivOBLevel_addshow = true wtDivOBLevel_add = 15 wtDivOSLevel_add = -40 // RSI+MFI rsiMFIShow = true rsiMFIperiod = 60 rsiMFIMultiplier = 150 rsiMFIPosY = 2.5 // RSI rsiShow = false rsiSRC = close rsiLen = 14 rsiOversold = 30 rsiOverbought = 60 // Divergence RSI rsiShowDiv = false rsiShowHiddenDiv = false rsiDivOBLevel = 60 rsiDivOSLevel = 30 // RSI Stochastic stochShow = true stochUseLog = true stochAvg = false stochSRC = close stochLen = 14 stochRsiLen = 14 stochKSmooth = 3 stochDSmooth = 3 // Divergence stoch stochShowDiv = false stochShowHiddenDiv = false // Schaff Trend Cycle tcLine = false tcSRC = close tclength = 10 tcfastLength = 23 tcslowLength = 50 tcfactor = 0.5 // Sommi Flag sommiFlagShow = false sommiShowVwap = false sommiVwapTF = 720 sommiVwapBearLevel = 0 sommiVwapBullLevel = 0 soomiFlagWTBearLevel = 0 soomiFlagWTBullLevel = 0 soomiRSIMFIBearLevel = 0 soomiRSIMFIBullLevel =0 // Sommi Diamond sommiDiamondShow = false sommiHTCRes = '60' sommiHTCRes2 = '240' soomiDiamondWTBearLevel = 0 soomiDiamondWTBullLevel = 0 // macd Colors macdWTColorsShow = false macdWTColorsTF = '240' darkMode = input(false, title = 'Dark mode', type = input.bool) // Colors colorRed = #ff0000 colorPurple = #e600e6 colorGreen = #3fff00 colorOrange = #e2a400 colorYellow = #ffe500 colorWhite = #ffffff colorPink = #ff00f0 colorBluelight = #31c0ff colorBlue = #3142ff colorWT1 = #90caf9 colorWT2 = #0d47a1 colorWT2_ = #131722 colormacdWT1a = #4caf58 colormacdWT1b = #af4c4c colormacdWT1c = #7ee57e colormacdWT1d = #ff3535 colormacdWT2a = #305630 colormacdWT2b = #310101 colormacdWT2c = #132213 colormacdWT2d = #770000 // } PARAMETERS // FUNCTIONS { // RSI+MFI f_rsimfi(_period, _multiplier, _tf) => security(syminfo.tickerid, _tf, sma(((close - open) / (high - low)) * _multiplier, _period) - rsiMFIPosY) // WaveTrend f_wavetrend(src, chlen, avg, malen, tf) => tfsrc = security(syminfo.tickerid, tf, src) esa = ema(tfsrc, chlen) de = ema(abs(tfsrc - esa), chlen) ci = (tfsrc - esa) / (0.015 * de) wt1 = security(syminfo.tickerid, tf, ema(ci, avg)) wt2 = security(syminfo.tickerid, tf, sma(wt1, malen)) wtVwap = wt1 - wt2 wtOversold = wt2 <= osLevel wtOverbought = wt2 >= obLevel wtCross = cross(wt1, wt2) wtCrossUp = wt2 - wt1 <= 0 wtCrossDown = wt2 - wt1 >= 0 wtCrosslast = cross(wt1[2], wt2[2]) wtCrossUplast = wt2[2] - wt1[2] <= 0 wtCrossDownlast = wt2[2] - wt1[2] >= 0 [wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCrosslast, wtCrossUplast, wtCrossDownlast, wtVwap] // } FUNCTIONS // CALCULATE INDICATORS { // RSI + MFI Area rsiMFI = f_rsimfi(rsiMFIperiod, rsiMFIMultiplier, timeframe.period) mfiMAperiod = input(8, "mfi MA period") mfiMA = sma(rsiMFI, mfiMAperiod) //rsiMFIColor = rsiMFI > 0 ? #3ee145 : #ff3d2e // coloring col_MFI = rsiMFI > 0 ?rsiMFI > mfiMA ? rsiMFI > rsiMFI[1] ? color.aqua : #006ec5 : #024478 : rsiMFI < 0 ? rsiMFI < mfiMA ? rsiMFI < rsiMFI[1] ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_MFI = rsiMFI > 0 ?rsiMFI > mfiMA ? rsiMFI > rsiMFI[1] ? 1 : 0.5 : 0.25 : rsiMFI < 0 ? rsiMFI < mfiMA ? rsiMFI < rsiMFI[1] ? -1 : -0.5 : -0.25 : 0 // Calculates WaveTrend [wt1, wt2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown, wtCross_last, wtCrossUp_last, wtCrossDown_last, wtVwap] = f_wavetrend(wtMASource, wtChannelLen, wtAverageLen, wtMALen, timeframe.period) // Small Circles WT Cross signalColor = wt2 - wt1 > 0 ? color.red : color.lime // Buy signal. buySignal_wt = wtCross and wtCrossUp and wtOversold buySignalSmall_wt = wtCross and wtCrossUp and wt2 > 0 and not wtOversold // Sell signal sellSignal_wt = wtCross and wtCrossDown and wtOverbought sellSignalSmall_wt = wtCross and wtCrossDown and wt2 < 0 and not wtOverbought // coloring col_WT = wt1 > wt2 ? wt2 < 0 ? wtOversold ? color.aqua : #006ec5 : #024478 : wt1 < wt2 ? wt2 > 0 ? wtOverbought ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_WT = wt1 > wt2 ? wt2 < 0 ? wtOversold ? 1 : 0.5 : 0.25 : wt1 < wt2 ? wt2 > 0 ? wtOverbought ? -1 : -0.5 : -0.25 : 0 //------------------WT END--------------- //--------------AK TREND + MOM-------------- input1 = 3, input2 = 8 , fastmaa = ema(close,input1) fastmab = ema(close,input2) bspread = (fastmaa-fastmab)*1.001 adline = 0 m = bspread > 0 ? color.aqua : color.red //MOM lenmom = input(10, minval=1, title="Length Momentum") srcMOM = input(close, title="Source") mom = srcMOM - srcMOM[lenmom] // coloring col_MOM = mom > 0 ? bspread > 0 ? color.aqua : #006ec5 : mom < 0 ? bspread < 0 ? #fa3939 : #CE7A00 : color.gray weight_MOM = mom > 0 ? bspread > 0 ? 1 : 0.5 : mom < 0 ? bspread < 0 ? -1 : -0.5 : 0 //--------------AK TREND + MOM DIV END-------------- //--------------ADX DI-------------- len = input(14) th = input(10) th2 = input(30) th3 = input(20) th4 = input(100) TrueRange = max(max(high-low, abs(high-nz(close[1]))), abs(low-nz(close[1]))) DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? max(high-nz(high[1]), 0): 0 DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? max(nz(low[1])-low, 0): 0 SmoothedTrueRange = 0.0 SmoothedTrueRange := nz(SmoothedTrueRange[1]) - (nz(SmoothedTrueRange[1])/len) + TrueRange SmoothedDirectionalMovementPlus = 0.0 SmoothedDirectionalMovementPlus := nz(SmoothedDirectionalMovementPlus[1]) - (nz(SmoothedDirectionalMovementPlus[1])/len) + DirectionalMovementPlus SmoothedDirectionalMovementMinus = 0.0 SmoothedDirectionalMovementMinus := nz(SmoothedDirectionalMovementMinus[1]) - (nz(SmoothedDirectionalMovementMinus[1])/len) + DirectionalMovementMinus DIPlus = SmoothedDirectionalMovementPlus / SmoothedTrueRange * 100 DIMinus = SmoothedDirectionalMovementMinus / SmoothedTrueRange * 100 DX = abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100 ADX = sma(DX, len) trendStrong = ADX >= 20 and ADX <=30 trendReversal = ADX >= 35 diLong = DIMinus > 30 and not trendStrong diShort = DIPlus > 30 and not trendStrong //plusPlot = plot(DIPlus, color=color.green, title="DI+") //minusPlot = plot(DIMinus, color=color.red, title="DI-") //plot(ADX, color=color.white, title="ADX") //hline(th, color=color.gray, linewidth = 1) //hline(th2, color=color.gray, linewidth = 2) //hline(th3, color=color.gray, linewidth = 2, linestyle = hline.style_solid) //bgcolor(diLong ? trendReversal ? color.green: color.aqua : diShort ? trendReversal ? color.red : color.orange : na, transp = 80) //bgcolor(cross(DIPlus,DIMinus)?color.gray:na, transp=80) //plotchar(crossover(DIPlus,DIMinus), char='▲', location=location.bottom, color=color.green) //plotchar(crossunder(DIPlus,DIMinus), char='▼', location=location.top, color=color.red) // coloring col_ADX = DIPlus > DIMinus ? ADX > 20 ? ADX > 30 and DIPlus > DIPlus[1] ? color.aqua : #006ec5 : #024478 : DIPlus < DIMinus ? ADX > 20 ? ADX > 30 and DIMinus > DIMinus[1] ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_ADX = DIPlus > DIMinus ? ADX > 20 ? ADX > 30 and DIPlus > DIPlus[1] ? 1 : 0.5 : 0.25 : DIPlus < DIMinus ? ADX > 20 ? ADX > 30 and DIMinus > DIMinus[1] ? -1 : -0.5 : -0.25 : 0 //--------------ADX DI END-------------- //---------------keltner-------------- keltsrc = input(close, type=input.source) separatorAverage = input(false, title="⎻⎻⎻ MA Base Setting ⎻⎻⎻") movingAverageLength = input(34, minval=1, title="MA length") movingAverageType = input("EMA", title="MA", options=["SMA", "EMA", "WMA", "DEMA", "TEMA", "TRIMA", "KAMA", "MAMA", "T3"], type=input.string) separatorKC = input(false, title="⎻⎻⎻ CHANNELS ⎻⎻⎻") atrMultiplier = input(2.5, minval=0, type = input.float, title="ATR Multiplier") atrType = input("EMA", title="ATR Smoothing MA", options=["SMA", "EMA", "WMA", "DEMA", "TEMA", "TRIMA", "KAMA", "MAMA", "T3"], type=input.string) atrLength = input(88, minval=1, title="ATR Smoothing Length") kc_usePer = input(defval = false, title = "Different Time-Period ?") kc_res = input("15", type=input.resolution, title = "Time-Period") kama(keltsrc, len)=> xvnoise = abs(keltsrc - keltsrc[1]) nfastend = 0.666 nslowend = 0.0645 nsignal = abs(keltsrc - keltsrc[len]) nnoise = sum(xvnoise, len) nefratio = iff(nnoise != 0, nsignal / nnoise, 0) nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2) nAMA = 0.0 nAMA := nz(nAMA[1]) + nsmooth * (keltsrc - nz(nAMA[1])) mama(keltsrc, len)=> fl=0.5 sl=0.05 pi = 3.1415926 sp = (4*keltsrc + 3*keltsrc[1] + 2*keltsrc[2] + keltsrc[3]) / 10.0 p = 0.0 i2 = 0.0 q2 = 0.0 dt = (.0962*sp + .5769*nz(sp[2]) - .5769*nz(sp[4])- .0962*nz(sp[6]))*(.075*nz(p[1]) + .54) q1 = (.0962*dt + .5769*nz(dt[2]) - .5769*nz(dt[4])- .0962*nz(dt[6]))*(.075*nz(p[1]) + .54) i1 = nz(dt[3]) jI = (.0962*i1 + .5769*nz(i1[2]) - .5769*nz(i1[4])- .0962*nz(i1[6]))*(.075*nz(p[1]) + .54) jq = (.0962*q1 + .5769*nz(q1[2]) - .5769*nz(q1[4])- .0962*nz(q1[6]))*(.075*nz(p[1]) + .54) i2_ = i1 - jq q2_ = q1 + jI i2 := .2*i2_ + .8*nz(i2[1]) q2 := .2*q2_ + .8*nz(q2[1]) re_ = i2*nz(i2[1]) + q2*nz(q2[1]) im_ = i2*nz(q2[1]) - q2*nz(i2[1]) re = 0.0 im = 0.0 re := .2*re_ + .8*nz(re[1]) im := .2*im_ + .8*nz(im[1]) p1 = iff(im!=0 and re!=0, 2*pi/atan(im/re), nz(p[1])) p2 = iff(p1 > 1.5*nz(p1[1]), 1.5*nz(p1[1]), iff(p1 < 0.67*nz(p1[1]), 0.67*nz(p1[1]), p1)) p3 = iff(p2<6, 6, iff (p2 > 50, 50, p2)) p := .2*p3 + .8*nz(p3[1]) spp = 0.0 spp := .33*p + .67*nz(spp[1]) phase = 180/pi * atan(q1 / i1) dphase_ = nz(phase[1]) - phase dphase = iff(dphase_< 1, 1, dphase_) alpha_ = fl / dphase alpha = iff(alpha_ < sl, sl, iff(alpha_ > fl, fl, alpha_)) mama = 0.0 mama := alpha*keltsrc + (1 - alpha)*nz(mama[1]) t3(keltsrc, len)=> xe1_1 = ema(keltsrc, len) xe2_1 = ema(xe1_1, len) xe3_1 = ema(xe2_1, len) xe4_1 = ema(xe3_1, len) xe5_1 = ema(xe4_1, len) xe6_1 = ema(xe5_1, len) b_1 = 0.7 c1_1 = -b_1*b_1*b_1 c2_1 = 3*b_1*b_1+3*b_1*b_1*b_1 c3_1 = -6*b_1*b_1-3*b_1-3*b_1*b_1*b_1 c4_1 = 1+3*b_1+b_1*b_1*b_1+3*b_1*b_1 nT3Average_1 = c1_1 * xe6_1 + c2_1 * xe5_1 + c3_1 * xe4_1 + c4_1 * xe3_1 variant(type, keltsrc, len) => v1 = sma(keltsrc, len) // Simple v2 = ema(keltsrc, len) // Exponential v3 = 2 * v2 - ema(v2, len) // Double Exponential v4 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential v5 = wma(keltsrc, len) // Weighted v6 = sma(sma(keltsrc, ceil(len / 2)), floor(len / 2) + 1) // TRIMA v7 = kama(keltsrc, len) // KAMA v8 = mama(keltsrc, len) // MAMA v9 = t3(keltsrc, len) // T3 type=="EMA"?v2 : type=="DEMA"?v3 : type=="TEMA"?v4 : type=="WMA"?v5 : type=="TRIMA"?v6 : type=="KAMA"?v7 : type=="MAMA"?v8 : type=="T3"?v9 : v1 //MA Base Calculation KeltnerChannelMid = variant(movingAverageType, keltsrc, movingAverageLength) KeltnerChannelRange = variant(atrType, tr , atrLength) KeltnerChannelBottom = KeltnerChannelMid - KeltnerChannelRange * atrMultiplier KeltnerChannelTop = KeltnerChannelMid + KeltnerChannelRange * atrMultiplier resKeltnerChannelMid = kc_usePer ? security(syminfo.tickerid, kc_res, KeltnerChannelMid) : KeltnerChannelMid resKeltnerChannelRange = kc_usePer ? security(syminfo.tickerid, kc_res, KeltnerChannelRange) : KeltnerChannelRange resKeltnerChannelBottom = kc_usePer ? security(syminfo.tickerid, kc_res, KeltnerChannelBottom) : KeltnerChannelBottom resKeltnerChannelTop = kc_usePer ? security(syminfo.tickerid, kc_res, KeltnerChannelTop) : KeltnerChannelTop //---------------keltner end-------------- //--------------RSI BANDS------------------- rsi_obLevel = input(70, title="RSI Overbought") rsi_osLevel = input(30, title="RSI Oversold") length = input(14, title="RSI Length") rsi_src=close ep = 2 * length - 1 auc = ema( max( rsi_src - rsi_src[1], 0 ), ep ) adc = ema( max( rsi_src[1] - rsi_src, 0 ), ep ) x1 = (length - 1) * ( adc * rsi_obLevel / (100-rsi_obLevel) - auc) ub = iff( x1 >= 0, rsi_src + x1, rsi_src + x1 * (100-rsi_obLevel)/rsi_obLevel ) x2 = (length - 1) * ( adc * rsi_osLevel / (100-rsi_osLevel) - auc) lb = iff( x2 >= 0, rsi_src + x2, rsi_src + x2 * (100-rsi_osLevel)/rsi_osLevel ) ub:=(ub + resKeltnerChannelTop) /2 lb:=(lb + resKeltnerChannelBottom) /2 //--------------RSI BANDS END------------------- // ------------------------------------- // -------------- VWAP ---------------- // ------------------------------------- fib1 = input(title="Fibo extension 1", type=input.float, defval=1.618) fib2 = input(title="Fibo extension 2", type=input.float, defval=2.618) reso = input(title="Resolution VWAP", type=input.resolution, defval="W") dev = input(title="Deviation value min.", type=input.integer, defval=150) t = time(reso) debut = na(t[1]) or t > t[1] addsource = hlc3 * volume addvol = volume addsource := debut ? addsource : addsource + addsource[1] addvol := debut ? addvol : addvol + addvol[1] VWAP = addsource / addvol sn = 0.0 sn := debut ? sn : sn[1] + volume * (hlc3 - VWAP[1]) * (hlc3 - VWAP) sd = sqrt(sn / addvol) Fibp2 = VWAP + fib2 * sd Fibp1 = VWAP + fib1 * sd Fibm1 = VWAP - fib1 * sd Fibm2 = VWAP - fib2 * sd // ------------------------------------- // -------------- Plots ---------------- // ------------------------------------- //plot((VWAP + avg(ub, lb))/2, title="VWAP", color=col2, linewidth = 3) vwap_res = (VWAP + avg(ub, lb))/2 // ------------------------------------- // -------------- VWAP END-------------- // ------------------------------------- //--------------OBV M-------------- //Settings maInput = input(title="❓ OBV-M MA Type (ENA is default - the rest experimental)", defval="EMA", options=["EMA", "SMA", "VWMA", "WMA"]) PeriodsDiv = input(7, "OVBM MA Length") signalLengthobv = input(10, "OBV-M Signal Length") yes1 = input(title="Enable Bar Color by Trade?", type=input.bool, defval=true) //MA selector - Something I added getMA(src, length) => ma = 0.0 if maInput == "EMA" ma := ema(src, length) if maInput == "SMA" ma := sma(src, length) if maInput == "VWMA" ma := vwma(src, length) if maInput == "WMA" ma := wma(src, length) ma //OBV-M Formula OBVM = getMA(obv, PeriodsDiv) signalobv = getMA(OBVM, signalLengthobv) //Signal Conditions long = crossover(OBVM, signalobv) short = crossunder(OBVM, signalobv) // coloring col_OBV = barssince(long) > barssince(short) ? close < vwap_res ? #fa3939 : #CE7A00 : barssince(long) <= barssince(short) ? close > vwap_res ? color.aqua : #006ec5 : color.gray weight_OBV = barssince(long) < barssince(short) ? close > vwap_res ? 1 : 0.5 : barssince(long) > barssince(short) ? close < vwap_res ? -1 : -0.5 : 0 //--------------OBV M END-------------- //--MFIww PART clo=close valueMFIWW = high-low tt = input(4, minval=1, title="tt->sma(Volume,tt)"), lenmfi = input(14, minval=1,title="len-->MFI(close,len)"), ksmes = input(false, title="level 0 or 50") smes=ksmes ? 0 : 50 // MFI upper = sum(volume * (change(clo) <= 0 ? 0 : valueMFIWW), lenmfi) lower = sum(volume * (change(clo) >= 0 ? 0 : valueMFIWW), lenmfi) mf = rsi(upper, lower)-smes voll=sma(volume,tt) dmf=mf[0]-mf[1] dvol=voll[0]-voll[1] //col=dmf>0 and dvol>0 ? color.lime : dmf>0 and dvol<0 ? color.green : dmf<0 and dvol>0 ? color.red : dmf<0 and dvol<0 ? color.orange : color.yellow // coloring col_MFIWW = dmf>0 ? dvol>0 ? color.aqua : #006ec5 : dmf<0 ? dvol<0 ? #fa3939 : #CE7A00 : color.gray weight_MFIWW = dmf>0 ? dvol>0 ? 1 : 0.5 : dmf<0 ? dvol>0 ? -1 : -0.5 : 0 //----MFIww PART END //------------MACD------------- sourceMACD = close useCurrentRes = input(true, title="Use Current Chart Resolution?") resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="60") res = useCurrentRes ? timeframe.period : resCustom fastLengthMACD = input(12, minval=1), slowLengthMACD=input(26,minval=1) signalLengthMACD=input(9,minval=1) fastMA = ema(sourceMACD, fastLengthMACD) slowMA = ema(sourceMACD, slowLengthMACD) macd_ = fastMA - slowMA signalMACD = sma(macd_, signalLengthMACD) histMACD = macd_ - signalMACD outHist = security(syminfo.tickerid, res, histMACD) //histA_IsUp = outHist > outHist[1] and outHist > 0 //histA_IsDown = outHist < outHist[1] and outHist > 0 //histB_IsDown = outHist < outHist[1] and outHist <= 0 //histB_IsUp = outHist > outHist[1] and outHist <= 0 //plot_color = histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon : gray // coloring col_MACD = outHist > 0 ? outHist > outHist[1] ? color.aqua : #006ec5 : outHist <= 0 ? outHist < outHist[1] ? #fa3939 : #CE7A00 : color.gray weight_MACD = outHist > 0 ? outHist > outHist[1] ? 1 : -0.5 : outHist <= 0 ? outHist < outHist[1] ? -1 : 0.5 : 0 //plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=histogram, linewidth=4) //------------MACD END------------- //-----------AO------------------ // -Calculations ════════════════════════════════════════════════════════════════════════════════ // f_logmap(_s, _r, _l) => _r * _s / highest(_l) * (1 - _s / highest(_l)) f_map(_s, _r, _v) => mapeq = f_logmap(_s, _r, 13) lmap = mapeq for i = 0 to 29 array.push(_v,lmap) lmap := _r * abs(mapeq[i]) * (1 - mapeq[i]) lmap r = sma(hl2, 5) / sma(hl2, 34) - 1 var v = array.new_float(0) val = f_map(close, r, v) array.remove(v, 0) aStDev = sign(array.avg(v)) * array.stdev(v) //plot(aStDev, "Standard Deviation of Array's Elements", aStDev > 0 ? aStDev > aStDev[1] ? color.lime : color.navy : aStDev < 0 ? aStDev < aStDev[1] ? color.red:color.yellow : color.gray, 2, style = plot.style_histogram) array.clear(v) col_AO = aStDev > 0 ? aStDev > aStDev[1] ? color.aqua : #006ec5 : aStDev <= 0 ? aStDev < aStDev[1] ? #fa3939 : #CE7A00 : color.gray weight_AO = aStDev > 0 ? aStDev > aStDev[1] ? 1 : -0.5 : aStDev <= 0 ? aStDev < aStDev[1] ? -1 : 0.5 : 0 //------------AO END-------------- //----------CHOP EXPLODE----------- srcCHOP = close, lenCHOP = input(14, minval=1, title="Length") upCHOP = rma(max(change(srcCHOP), 0), lenCHOP) downCHOP = rma(-min(change(srcCHOP), 0), lenCHOP) rsiCHOP = downCHOP == 0 ? 100 : upCHOP == 0 ? 0 : 100 - (100 / (1 + upCHOP / downCHOP)) // coloring col_CHOP = close[1] < close ? rsiCHOP > 55 ? rsiCHOP > 60 ? color.aqua : #006ec5 : #024478 : close[1] > close ? rsiCHOP < 45 ? rsiCHOP < 40 ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_CHOP = close[1] < close ? rsiCHOP > 55 ? rsiCHOP > 60 ? 1 : 0.5 : 0.25 : close[1] > close ? rsiCHOP < 45 ? rsiCHOP < 40 ? -1 : -0.5 : -0.25 : 0 //--------CHOP EXPLODE END---------- //--------AROON---------- lengthAROON = input(14, minval=1) upperAROON = 100 * (highestbars(high, lengthAROON+1) + lengthAROON)/lengthAROON lowerAROON = 100 * (lowestbars(low, lengthAROON+1) + lengthAROON)/lengthAROON oscillatorAROON = upperAROON - lowerAROON // coloring col_AROON = oscillatorAROON > 0 ? upperAROON > 50 ? upperAROON > upperAROON[1] and lowerAROON[1] >= lowerAROON ? color.aqua : #006ec5 : #024478 : oscillatorAROON < 0 ? lowerAROON > 50 ? lowerAROON > lowerAROON[1] and upperAROON[1] >= upperAROON ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_AROON = oscillatorAROON > 0 ? upperAROON > 50 ? upperAROON > upperAROON[1] and lowerAROON[1] >= lowerAROON ? 1 : 0.5 : 0.25 : oscillatorAROON < 0 ? lowerAROON > 50 ? lowerAROON > lowerAROON[1] and upperAROON[1] >= upperAROON ? -1 : -0.5 : -0.25 : 0 //--------AROON END---------- //------------KDJ---------- ilong = input(9, title="period") isig = input(3, title="signal") bcwsma(s, l, m) => _bcwsma = float(na) _s = s _l = l _m = m _bcwsma := (_m * _s + (_l - _m) * nz(_bcwsma[1])) / _l _bcwsma c_KDJ = close, h_KDJ = highest(high, ilong), l_KDJ = lowest(low, ilong) RSV = 100 * ((c_KDJ - l_KDJ) / (h_KDJ - l_KDJ)), pK = bcwsma(RSV, isig, 1), pD = bcwsma(pK, isig, 1), pJ = 3 * pK - 2 * pD, KDJ = avg(pD,pJ,pK) // coloring col_KDJ = pJ>pD ? pD < 80 ? pD <= 20 ? color.aqua : #006ec5 : #024478 : pJ < pD ? pD > 20 ? pD >= 80 ? #fa3939 : #CE7A00 : #663d00 : color.gray weight_KDJ = pJ>pD ? pD < 80 ? pD <= 20 ? 1 : 0.5 : 0.25 : pJ < pD ? pD > 20 ? pD >= 80 ? -1 : -0.5 : -0.25 : 0 //------------KDJ END---------- //----------SUMMARY WEIGHT------------------ sum_weight = weight_VSLRT + weight_ATR + weight_OBV + weight_ADX + weight_MFI + weight_MOM + weight_WT + weight_MFIWW + weight_MACD + weight_CHOP + weight_AROON + weight_KDJ + weight_AO + weight_VSLRT_lt sum_color = sum_weight > 0 ? c1 : c2 //------------LABELS---------------- prd = input(defval = 5, title = "Pivot Period", minval = 1, maxval = 50) showlast = input(defval = true, title = "Show Only Last Divergence") var int maxarraysize = 20 var ph_positions = array.new_int(maxarraysize, 0) var pl_positions = array.new_int(maxarraysize, 0) var ph_vals = array.new_float(maxarraysize, 0.) var pl_vals = array.new_float(maxarraysize, 0.) float ph = pivothigh(high, prd, prd) float pl = pivotlow(low, prd, prd) // add PHs to the array if ph array.unshift(ph_positions, bar_index) array.unshift(ph_vals, ph) if array.size(ph_positions) > maxarraysize array.pop(ph_positions) array.pop(ph_vals) // add PLs to the array if pl array.unshift(pl_positions, bar_index) array.unshift(pl_vals, pl) if array.size(pl_positions) > maxarraysize array.pop(pl_positions) array.pop(pl_vals) var pos_div_lines = array.new_line(0) var neg_div_lines = array.new_line(0) var pos_div_labels = array.new_label(0) var neg_div_labels = array.new_label(0) // remove old lines and labels if showlast option is enabled delete_old_pos_div_lines()=> if array.size(pos_div_lines) > 0 for j = 0 to array.size(pos_div_lines) - 1 line.delete(array.get(pos_div_lines, j)) array.clear(pos_div_lines) delete_old_neg_div_lines()=> if array.size(neg_div_lines) > 0 for j = 0 to array.size(neg_div_lines) - 1 line.delete(array.get(neg_div_lines, j)) array.clear(neg_div_lines) delete_old_pos_div_labels()=> if array.size(pos_div_labels) > 0 for j = 0 to array.size(pos_div_labels) - 1 label.delete(array.get(pos_div_labels, j)) array.clear(pos_div_labels) delete_old_neg_div_labels()=> if array.size(neg_div_labels) > 0 for j = 0 to array.size(neg_div_labels) - 1 label.delete(array.get(neg_div_labels, j)) array.clear(neg_div_labels) // delete last creted lines and labels until we met new PH/PV delete_last_pos_div_lines_label(n)=> if n > 0 and array.size(pos_div_lines) >= n asz = array.size(pos_div_lines) for j = 1 to n line.delete(array.get(pos_div_lines, asz - j)) array.pop(pos_div_lines) if array.size(pos_div_labels) > 0 label.delete(array.get(pos_div_labels, array.size(pos_div_labels) - 1)) array.pop(pos_div_labels) delete_last_neg_div_lines_label(n)=> if n > 0 and array.size(neg_div_lines) >= n asz = array.size(neg_div_lines) for j = 1 to n line.delete(array.get(neg_div_lines, asz - j)) array.pop(neg_div_lines) if array.size(neg_div_labels) > 0 label.delete(array.get(neg_div_labels, array.size(neg_div_labels) - 1)) array.pop(neg_div_labels) // variables for Alerts pos_reg_div_detected = false neg_reg_div_detected = false pos_hid_div_detected = false neg_hid_div_detected = false // to remove lines/labels until we met new // PH/PL var last_pos_div_lines = 0 var last_neg_div_lines = 0 var remove_last_pos_divs = false var remove_last_neg_divs = false if pl remove_last_pos_divs := false last_pos_div_lines := 0 if ph remove_last_neg_divs := false last_neg_div_lines := 0 if showlast delete_old_neg_div_labels() array.push(neg_div_labels, label.new( x = bar_index+2,y = -2,text = "VSLRT",color = col_VSLRT,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -19,text = "VSLRT lt",color = col_VSLRT_lt,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 13,text = "ATR",color = col_ATR,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 16,text = "AROON",color = col_AROON,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 19,text = "AO",color = col_AO,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 7,text = "MACD",color = col_MACD,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 4,text = "OBV",color = col_OBV,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 1,text = "ADX",color = col_ADX,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -4,text = "MFI",color = col_MFI,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -7,text = "MFI ww",color = col_MFIWW,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = 10,text = "MOM",color = col_MOM,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -10,text = "WT",color = col_WT,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -13,text = "CHOP",color = col_CHOP,textcolor = color.white,style = label.style_label_left, size=size.normal)) array.push(neg_div_labels, label.new( x = bar_index+2,y = -16,text = "KDJ",color = col_KDJ,textcolor = color.white,style = label.style_label_left, size=size.normal)) //----------SUMMARY WEIGHT END------------------ smoothed = input(true, "Smoothed Coloomns?") smooth_period = input(2, "Smooth period") plot(smoothed?sma(sum_weight,smooth_period):sum_weight, color = sum_color, style = plot.style_columns, transp=75) bgcolor(ADX > 30?color.gray:na, transp=80) signal_line = 8 plot(signal_line, color = color.gray) plot(-signal_line, color = color.gray) //bgcolor(ADX > 30 and (sum_weight>signal_line or sum_weight<-signal_line) and sma(ADX[1],2)> sma(ADX,2)?color.gray:na, transp=80) //----------WILLIAMS %R + CCI END-------------- plusPlot = plot(ADX> 30?DIPlus/2:na, color=color.aqua, style = plot.style_linebr, linewidth = 3) minusPlot = plot(ADX> 30?DIMinus/2:na, color=#FF266E, style = plot.style_linebr, linewidth = 3)
MS Market Timing Model
https://www.tradingview.com/script/IoTcruIj/
waynem59
https://www.tradingview.com/u/waynem59/
31
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/ // © waynem59 // This script uses subtle sentiment analysis to try to reduce the risk of positioning in assets. // By "assets" I mean: the QQQ ETF as a synonym for positioning in Nasdaq-100 stocks and the TLT ETF // as a placeholder for US government bonds with very long maturity and that as a risk-averse // alternative. // The coloring of the pseudo capital curve means: // green = 100% QQQ, // red = 100% TLT, // yellow = 50% QQQ/50% TLT. //@version=4 study("MS Market Timing Model", overlay=false) pds1 = input(title="CTM MA periods", type=input.integer, defval=20, minval=2, maxval=400) pds2 = input(title="CMM MA short periods", type=input.integer, defval=15, minval=2, maxval=400) pds3 = input(title="STM MA short periods", type=input.integer, defval=10, minval=2, maxval=400) pds4 = input(title="STM MA long periods", type=input.integer, defval=20, minval=5, maxval=400) pds5 = input(title="SPY trend periods", type=input.integer, defval=10, minval=5, maxval=400) rcd = security("XLY", "D", close) rhs = security("XLP", "D", close) spy = security("QQQ", "D", close) qqq = security("QQQ", "D", close) tlt = security("TLT", "D", close) hyg = security("LQD", "D", close) ief = security("NASDAQ:IEF", "D", close) smh = security("SMH", "D", close) thrs = 2 // Consumer Trend Model ctm = rcd/rhs ctm_ma = sma(ctm, pds1) score_ctm = iff(ctm > ctm_ma, 1, -1) // Credit Market Model cmm = hyg/ief cmm_ma = ema(cmm, pds2) score_cmm = iff(cmm > cmm_ma, 1, -1) // Semiconductor Trend Model stm = smh/spy stm_mak = sma(stm, pds3) stm_mal = sma(stm, pds4) score_stm = iff(stm_mak > stm_mal, 1, -1) // Momentum spy_ma = sma(spy, pds5) score_mom = iff(spy > spy_ma, 1, -1) float eq = na, eq := nz(eq[1], 100000.0) float cash = na, cash := nz(cash[1], 0.0) n_spy = 0.0 n_tlt = 0.0 score = score_ctm + score_cmm + score_stm + score_mom n_spy := iff(score[1] != score and score > 1, eq/spy, iff(score[1] != score and score < -1, 0, iff(score[1] != score and score >= -1 and score <=1, eq/(2*spy), n_spy[1]))) n_tlt := iff(score[1] != score and score > 1, 0, iff(score[1] != score and score < -1, eq/tlt, iff(score[1] != score and score >= -1 and score <=1, eq/(2*tlt), n_tlt[1]))) cash := iff(score[1] != score and score > 1, 0, iff(score[1] != score and score < -1, eq, iff(score[1] != score and score >= -1 and score <=1, eq/2, cash[1]))) eq := n_spy * spy + n_tlt * tlt //eq := n_spy * spy + cash bgcol = if score > 1 color.green else if score < -1 color.red else color.yellow plot(eq, title="Equity", linewidth=2, style=plot.style_line,color=color.blue) //hline(0) bgcolor(bgcol, transp=70)
Fibonacci Ghost Cloud
https://www.tradingview.com/script/cpEhMXml-Fibonacci-Ghost-Cloud/
cryptofilio
https://www.tradingview.com/u/cryptofilio/
69
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/ // © cryptofilio //@version=5 indicator("Fibonacci Ghost Cloud", overlay=true, timeframe="", timeframe_gaps=false) // Integer Series Input a=(input.int(2, title = "1", inline="Integer Series", group="Integer Series")) b=(input.int(3, title = "2", inline="Integer Series", group="Integer Series")) c=(input.int(5, title = "3", inline="Integer Series", group="Integer Series")) d=(input.int(8, title = "4", inline="Integer Series", group="Integer Series")) e=(input.int(13, title = "5", inline="Integer Series", group="Integer Series")) f=(input.int(21, title = "6", inline="Integer Series", group="Integer Series")) g=(input.int(34, title = "7", inline="Integer Series", group="Integer Series")) h=(input.int(55, title = "8", inline="Integer Series", group="Integer Series")) i=(input.int(89, title = "9", inline="Integer Series", group="Integer Series")) j=(input.int(144,title = "10", inline="Integer Series", group="Integer Series")) k=(input.int(233,title = "11", inline="Integer Series", group="Integer Series")) //************************************* Highest ************************************************************* fib1o = ta.highest(open, a) fib1h = ta.highest(high, a) fib1l = ta.highest(low, a) fib1c = ta.highest(close, a) fib2o = ta.highest(open, a+b) fib2h = ta.highest(high, a+b) fib2l = ta.highest(low, a+b) fib2c = ta.highest(close, a+b) fib3o = ta.highest(open, b+c) fib3h = ta.highest(high, b+c) fib3l = ta.highest(low, b+c) fib3c = ta.highest(close, b+c) fib4o = ta.highest(open, c+d) fib4h = ta.highest(high, c+d) fib4l = ta.highest(low, c+d) fib4c = ta.highest(close, c+d) fib5o = ta.highest(open, d+e) fib5h = ta.highest(high, d+e) fib5l = ta.highest(low, d+e) fib5c = ta.highest(close, d+e) fib6o = ta.highest(open, e+f) fib6h = ta.highest(high, e+f) fib6l = ta.highest(low, e+f) fib6c = ta.highest(close, e+f) fib7o = ta.highest(open, f+g) fib7h = ta.highest(high, f+g) fib7l = ta.highest(low, f+g) fib7c = ta.highest(close, f+g) fib8o = ta.highest(open, g+h) fib8h = ta.highest(high, g+h) fib8l = ta.highest(low, g+h) fib8c = ta.highest(close, g+h) fib9o = ta.highest(open, h+i) fib9h = ta.highest(high, h+i) fib9l = ta.highest(low, h+i) fib9c = ta.highest(close, h+i) fib10o = ta.highest(open, i+j) fib10h = ta.highest(high, i+j) fib10l = ta.highest(low, i+j) fib10c = ta.highest(close, i+j) fib11o = ta.highest(open, j+k) fib11h = ta.highest(high, j+k) fib11l = ta.highest(low, j+k) fib11c = ta.highest(close, j+k) // transp_teal1 = color.new(color.teal, 45) transp_teal2 = color.new(color.teal, 50) transp_teal3 = color.new(color.teal, 55) transp_teal4 = color.new(color.teal, 45) transp_teal5 = color.new(color.teal, 50) transp_teal6 = color.new(color.teal, 55) transp_teal7 = color.new(color.teal, 60) transp_teal8 = color.new(color.teal, 65) transp_teal9 = color.new(color.teal, 70) transp_teal10 = color.new(color.teal, 75) transp_teal11 = color.new(color.teal, 80) // Plotting //1 //fib1_op = plot(fib1o, display=display.none) fib1_hp = plot(fib1h, display=display.none, editable=false) fib1_lp = plot(fib1l, display=display.none, editable=false) //fib1_cp = plot(fib1c, display=display.none) //fill(fib1_op, fib1_hp, transp_teal1) fill(fib1_hp, fib1_lp, transp_teal1, editable=false) //fill(fib1_lp, fib1_cp, transp_teal1) //2 //fib2_op = plot(fib2o, display=display.none) fib2_hp = plot(fib2h, display=display.none, editable=false) fib2_lp = plot(fib2l, display=display.none, editable=false) //fib2_cp = plot(fib2c, display=display.none) //fill(fib2_op, fib2_hp, transp_teal2) fill(fib2_hp, fib2_lp, transp_teal2, editable=false) //fill(fib2_lp, fib2_cp, transp_teal2) //3 //fib3_op = plot(fib3o, display=display.none) fib3_hp = plot(fib3h, display=display.none, editable=false) fib3_lp = plot(fib3l, display=display.none, editable=false) //fib3_cp = plot(fib3c, display=display.none) //fill(fib3_op, fib3_hp, transp_teal3) fill(fib3_hp, fib3_lp, transp_teal3, editable=false) //fill(fib3_lp, fib3_cp, transp_teal3) //4 //fib4_op = plot(fib4o, display=display.none, editable=false) fib4_hp = plot(fib4h, display=display.none, editable=false) fib4_lp = plot(fib4l, display=display.none, editable=false) //fib4_cp = plot(fib4c, display=display.none, editable=false) //fill(fib4_op, fib4_hp, transp_teal4, editable=false) fill(fib4_hp, fib4_lp, transp_teal4, editable=false) //fill(fib4_lp, fib4_cp, transp_teal4, editable=false) //5 //fib5_op = plot(fib5o, display=display.none, editable=false) fib5_hp = plot(fib5h, display=display.none, editable=false) fib5_lp = plot(fib5l, display=display.none, editable=false) //fib5_cp = plot(fib5c, display=display.none, editable=false) //fill(fib5_op, fib5_hp, transp_teal5, editable=false) fill(fib5_hp, fib5_lp, transp_teal5, editable=false) //fill(fib5_lp, fib5_cp, transp_teal5, editable=false) //6 //fib6_op = plot(fib6o, display=display.none, editable=false) fib6_hp = plot(fib6h, display=display.none, editable=false) fib6_lp = plot(fib6l, display=display.none, editable=false) //fib6_cp = plot(fib6c, display=display.none, editable=false) //fill(fib6_op, fib6_hp, transp_teal6, editable=false) fill(fib6_hp, fib6_lp, transp_teal6, editable=false) //fill(fib6_lp, fib6_cp, transp_teal6, editable=false) //7 //fib7_op = plot(fib7o, display=display.none, editable=false) fib7_hp = plot(fib7h, display=display.none, editable=false) fib7_lp = plot(fib7l, display=display.none, editable=false) //fib7_cp = plot(fib7c, display=display.none, editable=false) //fill(fib7_op, fib7_hp, transp_teal7, editable=false) fill(fib7_hp, fib7_lp, transp_teal7, editable=false) //fill(fib7_lp, fib7_cp, transp_teal7, editable=false) //8 //fib8_op = plot(fib8o, display=display.none, editable=false) fib8_hp = plot(fib8h, display=display.none, editable=false) fib8_lp = plot(fib8l, display=display.none, editable=false) //fib8_cp = plot(fib8c, display=display.none, editable=false) //fill(fib8_op, fib8_hp, transp_teal8, editable=false) fill(fib8_hp, fib8_lp, transp_teal8, editable=false) //fill(fib8_lp, fib8_cp, transp_teal8, editable=false) //9 //fib9_op = plot(fib9o, display=display.none, editable=false) fib9_hp = plot(fib9h, display=display.none, editable=false) fib9_lp = plot(fib9l, display=display.none, editable=false) //fib9_cp = plot(fib9c, display=display.none, editable=false) //fill(fib9_op, fib9_hp, transp_teal9, editable=false) fill(fib9_hp, fib9_lp, transp_teal9, editable=false) //fill(fib9_lp, fib9_cp, transp_teal9, editable=false) //10 //fib10_op = plot(fib10o, display=display.none, editable=false) fib10_hp = plot(fib10h, display=display.none, editable=false) fib10_lp = plot(fib10l, display=display.none, editable=false) //fib10_cp = plot(fib10c, display=display.none, editable=false) //fill(fib10_op, fib10_hp, transp_teal10, editable=false) fill(fib10_hp, fib10_lp, transp_teal10, editable=false) //fill(fib10_lp, fib10_cp, transp_teal10, editable=false) //11 //fib11_op = plot(fib11o, display=display.none, editable=false) fib11_hp = plot(fib11h, display=display.none, editable=false) fib11_lp = plot(fib11l, display=display.none, editable=false) //fib11_cp = plot(fib11c, display=display.none, editable=false) //fill(fib11_op, fib11_hp, transp_teal11, editable=false) fill(fib11_hp, fib11_lp, transp_teal11, editable=false) //fill(fib11_lp, fib11_cp, transp_teal11, editable=false) //*********************************************** LOWEST ************************************** //fiba1o = ta.lowest(open, a) fiba1h = ta.lowest(high, a) fiba1l = ta.lowest(low, a) //fiba1c = ta.lowest(close, a) //fiba2o = ta.lowest(open, a+b) fiba2h = ta.lowest(high, a+b) fiba2l = ta.lowest(low, a+b) //fiba2c = ta.lowest(close, a+b) //fiba3o = ta.lowest(open, b+c) fiba3h = ta.lowest(high, b+c) fiba3l = ta.lowest(low, b+c) //fiba3c = ta.lowest(close, b+c) //fiba4o = ta.lowest(open, c+d) fiba4h = ta.lowest(high, c+d) fiba4l = ta.lowest(low, c+d) //fiba4c = ta.lowest(close, c+d) //fiba5o = ta.lowest(open, d+e) fiba5h = ta.lowest(high, d+e) fiba5l = ta.lowest(low, d+e) //fiba5c = ta.lowest(close, d+e) //fiba6o = ta.lowest(open, e+f) fiba6h = ta.lowest(high, e+f) fiba6l = ta.lowest(low, e+f) //fiba6c = ta.lowest(close, e+f) //fiba7o = ta.lowest(open, f+g) fiba7h = ta.lowest(high, f+g) fiba7l = ta.lowest(low, f+g) //fiba7c = ta.lowest(close, f+g) //fiba8o = ta.lowest(open, g+h) fiba8h = ta.lowest(high, g+h) fiba8l = ta.lowest(low, g+h) //fiba8c = ta.lowest(close, g+h) //fiba9o = ta.lowest(open, h+i) fiba9h = ta.lowest(high, h+i) fiba9l = ta.lowest(low, h+i) //fiba9c = ta.lowest(close, h+i) //fiba10o = ta.lowest(open, i+j) fiba10h = ta.lowest(high, i+j) fiba10l = ta.lowest(low, i+j) //fiba10c = ta.lowest(close, i+j) //fiba11o = ta.lowest(open, j+k) fiba11h = ta.lowest(high, j+k) fiba11l = ta.lowest(low, j+k) //fiba11c = ta.lowest(close, j+k) // transp_maroon1 = color.new(color.maroon, 35) transp_maroon2 = color.new(color.maroon, 40) transp_maroon3 = color.new(color.maroon, 45) transp_maroon4 = color.new(color.maroon, 50) transp_maroon5 = color.new(color.maroon, 55) transp_maroon6 = color.new(color.maroon, 60) transp_maroon7 = color.new(color.maroon, 65) transp_maroon8 = color.new(color.maroon, 70) transp_maroon9 = color.new(color.maroon, 75) transp_maroon10 = color.new(color.maroon,80) transp_maroon11 = color.new(color.maroon,85) // Plotting //1 //fiba1_op = plot(fiba1o, display=display.none) fiba1_hp = plot(fiba1h, display=display.none) fiba1_lp = plot(fiba1l, display=display.none) //fiba1_cp = plot(fiba1c, display=display.none) //fill(fiba1_op, fiba1_hp, transp_maroon1) fill(fiba1_hp, fiba1_lp, transp_maroon1) //fill(fiba1_lp, fiba1_cp, transp_maroon1) //2 //fiba2_op = plot(fiba2o, display=display.none) fiba2_hp = plot(fiba2h, display=display.none) fiba2_lp = plot(fiba2l, display=display.none) //fiba2_cp = plot(fiba2c, display=display.none) //fill(fiba2_op, fiba2_hp, transp_maroon2) fill(fiba2_hp, fiba2_lp, transp_maroon2) //fill(fiba2_lp, fiba2_cp, transp_maroon2) //3 //fiba3_op = plot(fiba3o, display=display.none) fiba3_hp = plot(fiba3h, display=display.none) fiba3_lp = plot(fiba3l, display=display.none) //fiba3_cp = plot(fiba3c, display=display.none) //fill(fiba3_op, fiba3_hp, transp_maroon3) fill(fiba3_hp, fiba3_lp, transp_maroon3) //fill(fiba3_lp, fiba3_cp, transp_maroon3) //4 //fiba4_op = plot(fiba4o, display=display.none, editable=false) fiba4_hp = plot(fiba4h, display=display.none, editable=false) fiba4_lp = plot(fiba4l, display=display.none, editable=false) //fiba4_cp = plot(fiba4c, display=display.none, editable=false) //fill(fiba4_op, fiba4_hp, transp_maroon4, editable=false) fill(fiba4_hp, fiba4_lp, transp_maroon4, editable=false) //fill(fiba4_lp, fiba4_cp, transp_maroon4, editable=false) //5 //fiba5_op = plot(fiba5o, display=display.none, editable=false) fiba5_hp = plot(fiba5h, display=display.none, editable=false) fiba5_lp = plot(fiba5l, display=display.none, editable=false) //fiba5_cp = plot(fiba5c, display=display.none, editable=false) //fill(fiba5_op, fiba5_hp, transp_maroon5, editable=false) fill(fiba5_hp, fiba5_lp, transp_maroon5, editable=false) //fill(fiba5_lp, fiba5_cp, transp_maroon5, editable=false) //6 //fiba6_op = plot(fiba6o, display=display.none, editable=false) fiba6_hp = plot(fiba6h, display=display.none, editable=false) fiba6_lp = plot(fiba6l, display=display.none, editable=false) //fiba6_cp = plot(fiba6c, display=display.none, editable=false) //fill(fiba6_op, fiba6_hp, transp_maroon6, editable=false) fill(fiba6_hp, fiba6_lp, transp_maroon6, editable=false) //fill(fiba6_lp, fiba6_cp, transp_maroon6, editable=false) //7 //fiba7_op = plot(fiba7o, display=display.none, editable=false) fiba7_hp = plot(fiba7h, display=display.none, editable=false) fiba7_lp = plot(fiba7l, display=display.none, editable=false) //fiba7_cp = plot(fiba7c, display=display.none, editable=false) //fill(fiba7_op, fiba7_hp, transp_maroon7, editable=false) fill(fiba7_hp, fiba7_lp, transp_maroon7, editable=false) //fill(fiba7_lp, fiba7_cp, transp_maroon7, editable=false) //8 //fiba8_op = plot(fiba8o, display=display.none, editable=false) fiba8_hp = plot(fiba8h, display=display.none, editable=false) fiba8_lp = plot(fiba8l, display=display.none, editable=false) //fiba8_cp = plot(fiba8c, display=display.none, editable=false) //fill(fiba8_op, fiba8_hp, transp_maroon8, editable=false) fill(fiba8_hp, fiba8_lp, transp_maroon8, editable=false) //fill(fiba8_lp, fiba8_cp, transp_maroon8, editable=false) //9 //fiba9_op = plot(fiba9o, display=display.none, editable=false) fiba9_hp = plot(fiba9h, display=display.none, editable=false) fiba9_lp = plot(fiba9l, display=display.none, editable=false) //fiba9_cp = plot(fiba9c, display=display.none, editable=false) //fill(fiba9_op, fiba9_hp, transp_maroon9, editable=false) fill(fiba9_hp, fiba9_lp, transp_maroon9, editable=false) //fill(fiba9_lp, fiba9_cp, transp_maroon9, editable=false) //10 //fiba10_op = plot(fiba10o, display=display.none, editable=false) fiba10_hp = plot(fiba10h, display=display.none, editable=false) fiba10_lp = plot(fiba10l, display=display.none, editable=false) //fiba10_cp = plot(fiba10c, display=display.none, editable=false) //fill(fiba10_op, fiba10_hp, transp_maroon10, editable=false) fill(fiba10_hp, fiba10_lp, transp_maroon10, editable=false) //fill(fiba10_lp, fiba10_cp, transp_maroon10, editable=false) //11 //fiba11_op = plot(fiba11o, display=display.none, editable=false) fiba11_hp = plot(fiba11h, display=display.none, editable=false) fiba11_lp = plot(fiba11l, display=display.none, editable=false) //fiba11_cp = plot(fiba11c, display=display.none, editable=false) //fill(fiba11_op, fiba11_hp, transp_maroon11, editable=false) fill(fiba11_hp, fiba11_lp, transp_maroon11, editable=false) //fill(fiba11_lp, fiba11_cp, transp_maroon11, editable=false) average_fib = (fib1h +fib2h +fib3h +fib4h +fib5h +fib6h +fib7h +fib8h +fib9h +fib10h + fib11h)/11 average_fiba = (fiba1h+fiba2h+fiba3h+fiba4h+fiba5h+fiba6h+fiba7h+fiba8h+fiba9h+fiba10h+fiba11h)/11 plot (average_fib, color=color.new(color.green, 20), linewidth=2) plot (average_fiba,color=color.new(color.red, 20), linewidth=2)
Chop Zone - SamX
https://www.tradingview.com/script/8IaHOdPX-Chop-Zone-SamX/
SamAccountX
https://www.tradingview.com/u/SamAccountX/
141
study
5
MPL-2.0
// This source code provided free and open-source as defined by the terms of the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/) // with the following additional requirements: // // 1. Citations for sources and references must be maintained and updated when appropriate // 2. Links to strategy references included in indicator tooptips and/or alerts should be retained to give credit to the original source // while also providing a freely available source of information on proper use and interpretation // // Author: SamAccountX // // Original inspiration came from the built-in Chop Zone indicator (https://www.tradingview.com/chart/?solution=43000589111), // however I wanted to make some improvements and add some customization options to better suit varying market conditions. // // WARNING: Please be sure of what you're doing and understand the potential implications before altering any of the settings // in the "Advanced Configuration" section!!! // //@version=5 indicator(title = "Chop Zone - SamX", format=format.price, precision=2, max_labels_count=500) // *** Inputs *** // Basic input settings g_NormalInputs = 'Basic Configuration' tf = input.timeframe(title="Timeframe", defval="", group=g_NormalInputs) showGaps = input.bool(title="Show gaps for higher timeframes", defval=true, group=g_NormalInputs, tooltip="If selected, higher TF values will only be returned when " + 'the higher timeframe bar actually closes. This helps avoid real-time repaining at the expense of potential resolution clarity. \n\n' + 'If this option is unchecked, the current bar will be populated with the current higher TF bar\'s value (which will repaint), however ' + 'historical bars will not repaint.') src = input.source(title='MA Source', defval=close, group=g_NormalInputs, tooltip="Price source to use for calculating the MA basis for the chop zones.") len = input.int(title='MA Length', defval=34, minval=1, maxval=500, step=1, group=g_NormalInputs, tooltip="Length to use for calculating the MA basis for the chop zones.") showAsAngleArea = input.bool(title="Plot calculated angle", defval=false, group=g_NormalInputs, tooltip="If selected, the default bar-style chop zone will be replaced with an " + 'Area-style chart displaying the actual calculated angles. \n\n' + 'Note #1: This works best using the Gradient color settings below. \n\n' + 'Note #2: If configured to calculate on a timeframe HIGHER than the current chart timeframe, it is recommended to un-check the "Show gaps for higher timeframes" setting above ' + 'to avoid display anomolies.') // Coloring settings // Gradient settings g_GradientSettings = "Gradient Color Settings" colorAsGradient = input.bool(title="Color bars using gradient", defval=false, group=g_GradientSettings) downColor = input.color(title="Downslope:", defval=color.rgb(255, 0, 0, 0), inline="Gradient", group=g_GradientSettings) upColor = input.color(title="         Upslope:", defval=color.rgb(0, 255, 0, 0), inline="Gradient", group=g_GradientSettings) gradientLimit = input.int(title="Gradient Limit", defval=33, minval=1, maxval=89, step=1, group=g_GradientSettings, tooltip="Select the desired gradient threshold angle. This " + 'will be used in gradient color calculations. This value will be extrapolated as the absolute distance from 0. If the calculated angle exceeds this threshold, the resulting ' + 'bar color will be the equivilent of the closest in-range color.') // Fixed bar color settings g_BarColors = 'Bar colors' // Tier 0 - centered on 0 degrees colorLevel0 = input.color(title="                       Tier-1 Color:", defval=color.rgb(253, 216, 53, 0), group=g_BarColors) // Tier 1 - 1x past tier 0 colorLevel1Pos = input.color(title="Tier-2 Color - Positive:", defval=color.rgb(0, 150, 136, 0), group=g_BarColors, inline="tier-2") colorLevel1Neg = input.color(title="   Negative:", defval=color.rgb(255, 183, 77, 0), group=g_BarColors, inline="tier-2") // Tier 2 - 1x past tier 1 colorLevel2Pos = input.color(title="Tier-3 Color - Positive:", defval=color.rgb(165, 214, 167, 0), group=g_BarColors, inline="tier-3") colorLevel2Neg = input.color(title="   Negative:", defval=color.rgb(255, 109, 0, 0), group=g_BarColors, inline="tier-3") // Tier 3 - 1x past tier 2 colorLevel3Pos = input.color(title="Tier-4 Color - Positive:", defval=color.rgb(67, 160, 71, 0), group=g_BarColors, inline="tier-4") colorLevel3Neg = input.color(title="   Negative:", defval=color.rgb(233, 30, 99, 0), group=g_BarColors, inline="tier-4") // Tier 4 - 1x past tier 3 colorLevel4Pos = input.color(title="Tier-5 Color - Positive:", defval=color.rgb(38, 198, 218, 0), group=g_BarColors, inline="tier-5") colorLevel4Neg = input.color(title="   Negative:", defval=color.rgb(213, 0, 0, 0), group=g_BarColors, inline="tier-5") // // Advanced input settings - generally should not be changed... g_AdvancedInputs = 'Advanced Configuration' maType = input.string(title='Moving Average Calculation', group=g_AdvancedInputs, options=['Exponential', 'Simple', 'Smoothed', 'Weighted', 'Linear', 'Hull', 'Volume-Weigehted', 'RMA', 'ALMA'], defval='Exponential', tooltip='Type of moving average calculation to use (default is Exponential (EMA)). ALMA uses the standard values for sigma and offset. \n\n' + 'Note: DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU\'RE DOING!!!') periodsIn = input.int(title='Periods', defval=30, minval=1, maxval=300, step=1, group=g_AdvancedInputs, tooltip='Number of candles to check when searching for highest high and lowest low. \n\n' + 'Note: DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU\'RE DOING!!!') spanFactor = input.int(title='Span Length', defval=25, minval=1, maxval=100, step=1, group=g_AdvancedInputs, tooltip='Span length for range calculations. \n\n' + 'Note: DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU\'RE DOING!!!') periodAvgSrc = input.string(title='Period/Bar Average', defval="hlc3", options=["hl2", "hlc3", "ohlc4", "hlcc4"], tooltip='Method to use to derive the average price for a ' + 'given bar for use in slope calculations. \n\n' + 'Note: DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU\'RE DOING!!!') stepSize = input.float(title="Bar Step Size", defval=1.43, minval=.01, maxval=10, step=0.1, group=g_AdvancedInputs, tooltip='Step size to use for chop zone brackets. Increasing this will result ' + 'in each bar covering a wider range of angles, while decreasing this will result in each bar covering a narrower range of angles.') useAltSlopeCalc = input.bool(title='Use alternate slope calculation method', defval=false, group=g_AdvancedInputs, tooltip='Select this to find the MA slope using an alternate calculation method. \n\n' + 'Note: DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU\'RE DOING!!!') // // *** Function definitions *** // Smoothed MA smoothedMovingAvg(src, len) => smma = 0.0 // TV will complain about the use of the ta.sma function use inside a function saying that it should be called on each calculation, // but since we're only using it once to set the initial value for the smoothed MA (when the previous smma value is NaN - Not a Number) // and using the previous smma value for each subsequent iteration, this can be safely ignored smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len smma // // MA calculation ma(source, length, type) => switch type "Simple" => ta.sma(source, length) "Exponential" => ta.ema(source, length) "Weighted" => ta.wma(source, length) "Volume-Weigehted" => ta.vwma(source, length) "Smoothed" => smoothedMovingAvg(source, length) "RMA" => ta.rma(source, length) "Linear" => ta.linreg(source, length, 0) "Hull" => ta.hma(source, length) "ALMA" => ta.alma(source, length, 0.85, 6) // // *** Functional code start *** // // Explicitly define our ticker to help ensure that we're always getting ACTUAL price instead of relying on the input // ticker info and input vars (as they tend to inherit the type from what's displayed on the current chart) realPriceTicker = ticker.new(prefix=syminfo.prefix, ticker=syminfo.ticker) avgCalc = switch periodAvgSrc "hl2" => hl2 "hlc3" => hlc3 "ohlc4" => ohlc4 "hlcc4" => hlcc4 => hlc3 avg = showGaps ? request.security(symbol=realPriceTicker, timeframe=tf, expression=avgCalc, lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on) : request.security(symbol=realPriceTicker, timeframe=tf, expression=avgCalc, lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) pi = math.pi periods = periodsIn highestHigh = showGaps ? request.security(symbol=realPriceTicker, timeframe=tf, expression=ta.highest(periods), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on) : request.security(symbol=realPriceTicker, timeframe=tf, expression=ta.highest(periods), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) lowestLow = showGaps ? request.security(symbol=realPriceTicker, timeframe=tf, expression=ta.lowest(periods), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on) : request.security(symbol=realPriceTicker, timeframe=tf, expression=ta.lowest(periods), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) span = spanFactor / (highestHigh - lowestLow) * lowestLow ema34 = showGaps ? request.security(symbol=realPriceTicker, timeframe=tf, expression=ma(src, len, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on) : request.security(symbol=realPriceTicker, timeframe=tf, expression=ma(src, len, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) ema34_prev = showGaps ? request.security(symbol=realPriceTicker, timeframe=tf, expression=ma(src[1], len, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_on) : request.security(symbol=realPriceTicker, timeframe=tf, expression=ma(src[1], len, maType), lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) var emaAngle = 0.0 if (useAltSlopeCalc) rightX = 1 rightY = ema34 leftX = 0 leftY = ema34_prev slope = (rightY - leftY) / (rightX - leftX) angleRadians = math.atan(slope) angleDegrees = math.todegrees(angleRadians) emaAngle := angleDegrees //slope < 0 ? -angleDegrees : angleDegrees else x1_ema34 = 0 x2_ema34 = 1 y1_ema34 = 0 y2_ema34 = (ema34_prev - ema34) / avg * span c_ema34 = math.sqrt((x2_ema34 - x1_ema34)*(x2_ema34 - x1_ema34) + (y2_ema34 - y1_ema34)*(y2_ema34 - y1_ema34)) emaAngle_1 = math.round(180 * math.acos((x2_ema34 - x1_ema34)/c_ema34) / pi) emaAngle := y2_ema34 > 0 ? -emaAngle_1 : emaAngle_1 // Select color based on inputs and calculated MA angle... // // First, we need to calculate our 0-level zone. Since we need to also include the ACTUAL 0.00 angle as well, we // have a few options for sizing this zone... For simplicity, we're going to divide our bar step size by 2 and // round to 2 decimal places. Should rounding be required, we'll always round down. // // Unfortunately, TV doesn't have a `floor` function that can round to decimals (only integers), so we'll have to // use some clever math gymnastics to accomplish this. halfStep = math.floor((stepSize / 2) * 100) / 100 var color chopZoneColor = na if (emaAngle >= 3*stepSize + halfStep) chopZoneColor := colorLevel4Pos else if (emaAngle < 3*stepSize + halfStep and emaAngle >= 2*stepSize + halfStep) chopZoneColor := colorLevel3Pos else if (emaAngle < 2*stepSize + halfStep and emaAngle >= stepSize + halfStep) chopZoneColor := colorLevel2Pos else if (emaAngle < stepSize + halfStep and emaAngle >= halfStep) chopZoneColor := colorLevel1Pos else if (emaAngle > -halfStep and emaAngle < halfStep) // Between -.71 and .71 chopZoneColor := colorLevel0 else if (emaAngle > -stepSize - halfStep and emaAngle <= -halfStep) chopZoneColor := colorLevel1Neg else if (emaAngle > -2*stepSize - halfStep and emaAngle <= -stepSize - halfStep) chopZoneColor := colorLevel2Neg else if (emaAngle > -3*stepSize - halfStep and emaAngle <= -2*stepSize - halfStep) chopZoneColor := colorLevel3Neg else if (emaAngle <= -3*stepSize - halfStep) chopZoneColor := colorLevel4Neg if (colorAsGradient) chopZoneColor := color.from_gradient(emaAngle, -gradientLimit, gradientLimit, downColor, upColor) plot(showAsAngleArea ? na : 1, title='Chop Zone', color=na(avg) ? na : chopZoneColor, style=plot.style_columns) plot(showAsAngleArea ? emaAngle : na, title='MA Angle', color=na(avg) ? na : chopZoneColor, style=plot.style_area) // Label plots - for testing use only //if not na(avg) // label.new(bar_index, 1.25, text=str.tostring(math.round(emaAngle)), style=label.style_label_down)
Indicator Visualizer V1.0
https://www.tradingview.com/script/67R7x8I6-Indicator-Visualizer-V1-0/
Exmodaus
https://www.tradingview.com/u/Exmodaus/
25
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Exmodaus //@version=5 indicator("Indicator Visualizer", shorttitle="IVZ", overlay=true) //__________________ //Inputs deRsi = input.bool(true, "Default RSI On/Off", group="Indicator Source", tooltip="Turn this off if you want to use Close as your input source, Otherwise this option will default to visualize RSI(14) crossing over/under the levels. This will not affect the Source if you change it from Close.") i_src = input.source(close, "Indicator", group="Indicator Source", tooltip="Select the Indicator you want to visualize on the chart. If this value is Close and the Default RSI is checked, then the indicator will use RSI(length 14) as the default.") lines = input.bool(false, "Plot Lines", group="Plots On / Off", inline="Plots", tooltip="Do you want lines or boxes plotted?") boxes = input.bool(true, "Plot Boxes", group="Plots On / Off", inline="Plots", tooltip="Do you want lines or boxes plotted?") lvl1 = input.float(70, "level 1", group="Levels", inline="level1", tooltip="When the Indicator selected(Indicator source) crosses over this level it will begin plotting. When it crosses back under this level it will stop plotting") lvl2 = input.float(30, "level 2", group="Levels", inline="level2", tooltip="When the Indicator selected(Indicator source) crosses under this level it will begin plotting. When it crosses back over this level it will stop plotting") ext1 = input.int(1, "Line 1", group="Line Settings", inline="Line", tooltip="How many bars should the line extend after it stops plotting?") ext2 = input.int(1, "Line 2", group="Line Settings", inline="Line", tooltip="How many bars should the line extend after it stops plotting?") color co2color = input.color(color.rgb(14, 232, 72, 0), title="Cross Over Line", group="Line Settings", inline="COLORS") color cu2color = input.color(color.rgb(255, 0, 0, 0), title="Cross Under Line", group="Line Settings", inline="COLORS") color cocolor = input.color(color.rgb(14, 232, 72, 50), title="Cross Over Box", group="Box Colors", inline="Over COLORS") color cucolor = input.color(color.rgb(255, 0, 0, 50), title="Cross Under Box", group="Box Colors", inline="Under COLORS") color co1color = input.color(color.rgb(14, 232, 72, 50), title="Cross Over Border", group="Box Colors", inline="Over COLORS") color cu1color = input.color(color.rgb(255, 0, 0, 50), title="Cross Under Border", group="Box Colors", inline="Under COLORS") //________________________ //Variables //Default RSI length of 14 if Source is close i_src1= deRsi == true and i_src==close ? ta.rsi(close, 14) : i_src //Lines var line line1 = na var line line2 = na //Boxes var box box1 = na var box box2 = na //Crossover ob1 = (i_src1[0] > lvl1)? true : false ob2 = (i_src1[1] > lvl1 and i_src1[0] < lvl1)? true : false os1 = (i_src1[0] < lvl2)? true : false os2 = (i_src1[0] > lvl2 and i_src1[1] < lvl2)? true : false //______________________ //Conditions //Lines //Crossover Line if ob1 and lines == true and ob1[1] == false line1 := line.new(bar_index,close,bar_index, close, extend=extend.right, color=co2color, width=3) else if ob1[1] == true and ob1[0] == true line.set_x2(line1, bar_index) line.set_y2(line1, close) else if ob2 and lines == true line.set_x2(line1, bar_index+ext1) line.set_extend(line1, extend.none) line.set_y2(line1, close) //Crossunder Line if os1 and lines == true and os1[1] == false line2 := line.new(bar_index,close,bar_index, close, extend=extend.right, color=cu2color, width=3) else if os1[1] == true and os1[0] == true line.set_x2(line2, bar_index) line.set_y2(line2, close) else if os2 and lines == true line.set_x2(line2, bar_index+ext2) line.set_extend(line2, extend.none) line.set_y2(line2, close) //BOXES //Crossover Box if ob1 and boxes == true and ob1[1] == false box1 := box.new(bar_index,high,bar_index+(ta.barssince(os1)), low, extend=extend.right, bgcolor=cocolor, border_width=1, border_color= co1color) else if ob1[1] == true and ob1[0] == true box.set_top(box1, ta.highest(high,(ta.barssince(ob1)>1?ta.barssince(ob1):1))) else if ob2 and boxes == true box.set_right(box1, bar_index) box.set_extend(box1, extend.none) box.set_top(box1, ta.highest(high,(ta.barssince(ob1)>1?ta.barssince(ob1):1))) //Crossunder Box if os1 and boxes == true and os1[1] == false box2 := box.new(bar_index,high,bar_index, low, extend=extend.right, bgcolor=cucolor, border_width=1, border_color= cu1color) else if os1[1] == true and os1[0] == true box.set_bottom(box2, ta.lowest(low,(ta.barssince(os1)>1?ta.barssince(os1):1))) else if os2 and boxes == true box.set_right(box2, bar_index) box.set_extend(box2, extend.none) box.set_bottom(box2, ta.lowest(low,(ta.barssince(os1)>1?ta.barssince(os1):1)))
MA Line Break
https://www.tradingview.com/script/GhYHU5B8-MA-Line-Break/
jrob24
https://www.tradingview.com/u/jrob24/
8
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/ // © jrob24 //@version=4 study("MA Line Break") ma = input(title="MA Legnth", type=input.integer, defval=9) type = input(title="MA Type", type=input.string, options=["SMA","EMA"], defval="SMA") ma_value = if type == "SMA" sma(close,ma) else if type == "EMA" ema(close,ma) plot(series = (close > ma_value) ? close : na, style=plot.style_linebr, color=color.green, linewidth=2) plot(series = (close < ma_value) ? close : na, style=plot.style_linebr, color=color.red, linewidth=2, display=display.none)
Systematic Investment Plan
https://www.tradingview.com/script/yNkGoJmW-Systematic-Investment-Plan/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
146
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © HeWhoMustNotBeNamed // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __ // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / | // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ | // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ | // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ | // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ | // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ | // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ | // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/ // // // //@version=5 indicator(title='Systematic Investment Plan',overlay=false, timeframe='D') startYear = input.int(2010, maxval=2999, minval=0, title='Start Year', group='Inital Investment', tooltip='Year on which investment is started', confirm=true) initialDeposit = input.float(10000, "Deposit", minval=0, step=5000, group="Inital Investment", tooltip='Initial one time deposit to start with', confirm=true) recurringDepositFrequency = input.string("monthly", "Frequency", group="Recurring Investment", options=["monthly", "weekly"], tooltip="Periodic investment frequency", confirm=true) recurringDeposit = input.float(1000, "Deposit", step=1000, minval=0, group="Recurring Investment", tooltip="Periodic investment", confirm=true) var buyAndHoldQty = 0.0 var totalInvestment = 0.0 term = recurringDepositFrequency == "monthly"? month : weekofyear var started = false recDep = ta.change(term)!=0? recurringDeposit : 0 if(year >= startYear and ta.change(term)!=0) bnhAmount = started ? recDep : initialDeposit started := true bnhPrice = close bnhQty = bnhAmount/bnhPrice if(bnhQty!=0) totalInvestment += bnhAmount buyAndHoldQty += bnhQty bnhEquity = close*buyAndHoldQty plot(bnhEquity, "Equity", color=color.new(color.green, 80), style=plot.style_area) plot(totalInvestment, "Investment", color=color.new(color.purple, 50), style=plot.style_area)
NiGapo Notes / Remember Rules / Anchored Text
https://www.tradingview.com/script/T1E96M8l/
smart-money-indicators
https://www.tradingview.com/u/smart-money-indicators/
136
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/ // © NiGapo //@version=4 study("Notes / Remember Rules / Anchored Text [smart-money-indicators]", shorttitle="Notes [smart-money-indicators]", overlay=true) table_top_left = "top_left" table_top_center = "top_center" table_top_right = "top_right" table_middle_left = "middle_left" table_middle_center = "middle_center" table_middle_right = "middle_right" table_bottom_left = "bottom_left" table_bottom_center = "bottom_center" table_bottom_right = "bottom_right" i_bgcolor = input(color.white, title="Background", group="settings") i_border_color = input(color.white, title="Border", group="settings", inline="border") i_border_width = input(1, title="", minval=0, maxval=3, group="settings", inline="border") i_table_position = input(table_bottom_right, title="Position", options=[table_top_left, table_top_center, table_top_right, table_middle_left, table_middle_center, table_middle_right, table_bottom_left, table_bottom_center, table_bottom_right], group="settings") table tbl = table.new(i_table_position, columns = 1, rows = 15, bgcolor=i_bgcolor, frame_color = i_border_color, frame_width=-1, border_color=i_border_color, border_width=i_border_width) i_show_1 = input(false, title="", group="Line 1", inline="text1") i_color_1 = input(color.white, title="", group="Line 1", inline="text1") i_bg_1 = input(color.black, title="", group="Line 1", inline="text1") i_text_1 = input("", type=input.string, title="", group="Line 1", inline="text1") i_height_1 = input(2.5, title="", group="Line 1", inline="text1_2") i_size_1 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 1", inline="text1_2") i_align_1 = input("center", title="", options = ["center","left", "right"], group="Line 1", inline="text1_2") if i_show_1 table.cell(tbl, 0, 0, i_text_1, text_size = i_size_1, text_color = i_color_1, height=i_height_1, bgcolor=i_bg_1, text_halign=i_align_1) i_show_2 = input(false, title="", group="Line 2", inline="text2") i_color_2 = input(color.white, title="", group="Line 2", inline="text2") i_bg_2 = input(color.black, title="", group="Line 2", inline="text2") i_text_2 = input("", type=input.string, title="", group="Line 2", inline="text2") i_height_2 = input(2.5, title="", group="Line 2", inline="text2_2") i_size_2 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 2", inline="text2_2") i_align_2 = input("center", title="", options = ["center","left", "right"], group="Line 2", inline="text2_2") if i_show_2 table.cell(tbl, 0, 1, i_text_2, text_size = i_size_2, text_color = i_color_2, height=i_height_2, bgcolor=i_bg_2, text_halign=i_align_2) i_show_3 = input(false, title="", group="Line 3", inline="text3") i_color_3 = input(color.white, title="", group="Line 3", inline="text3") i_bg_3 = input(color.black, title="", group="Line 3", inline="text3") i_text_3 = input("", type=input.string, title="", group="Line 3", inline="text3") i_height_3 = input(2.5, title="", group="Line 3", inline="text3_2") i_size_3 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 3", inline="text3_2") i_align_3 = input("center", title="", options = ["center","left", "right"], group="Line 3", inline="text3_2") if i_show_3 table.cell(tbl, 0, 2, i_text_3, text_size = i_size_3, text_color = i_color_3, height=i_height_3, bgcolor=i_bg_3, text_halign=i_align_3) i_show_4 = input(false, title="", group="Line 4", inline="text4") i_color_4 = input(color.white, title="", group="Line 4", inline="text4") i_bg_4 = input(color.black, title="", group="Line 4", inline="text4") i_text_4 = input("", type=input.string, title="", group="Line 4", inline="text4") i_height_4 = input(2.5, title="", group="Line 4", inline="text4_2") i_size_4 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 4", inline="text4_2") i_align_4 = input("center", title="", options = ["center","left", "right"], group="Line 4", inline="text4_2") if i_show_4 table.cell(tbl, 0, 3, i_text_4, text_size = i_size_4, text_color = i_color_4, height=i_height_4, bgcolor=i_bg_4, text_halign=i_align_4) i_show_5 = input(false, title="", group="Line 5", inline="text5") i_color_5 = input(color.white, title="", group="Line 5", inline="text5") i_bg_5 = input(color.black, title="", group="Line 5", inline="text5") i_text_5 = input("", type=input.string, title="", group="Line 5", inline="text5") i_height_5 = input(2.5, title="", group="Line 5", inline="text5_2") i_size_5 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 5", inline="text5_2") i_align_5 = input("center", title="", options = ["center","left", "right"], group="Line 5", inline="text5_2") if i_show_5 table.cell(tbl, 0, 4, i_text_5, text_size = i_size_5, text_color = i_color_5, height=i_height_5, bgcolor=i_bg_5, text_halign=i_align_5) i_show_6 = input(false, title="", group="Line 6", inline="text6") i_color_6 = input(color.white, title="", group="Line 6", inline="text6") i_bg_6 = input(color.black, title="", group="Line 6", inline="text6") i_text_6 = input("", type=input.string, title="", group="Line 6", inline="text6") i_height_6 = input(2.5, title="", group="Line 6", inline="text6_2") i_size_6 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 6", inline="text6_2") i_align_6 = input("center", title="", options = ["center","left", "right"], group="Line 6", inline="text6_2") if i_show_6 table.cell(tbl, 0, 5, i_text_6, text_size = i_size_6, text_color = i_color_6, height=i_height_6, bgcolor=i_bg_6, text_halign=i_align_6) i_show_7 = input(false, title="", group="Line 7", inline="text7") i_color_7 = input(color.white, title="", group="Line 7", inline="text7") i_bg_7 = input(color.black, title="", group="Line 7", inline="text7") i_text_7 = input("", type=input.string, title="", group="Line 7", inline="text7") i_height_7 = input(2.5, title="", group="Line 7", inline="text7_2") i_size_7 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 7", inline="text7_2") i_align_7 = input("center", title="", options = ["center","left", "right"], group="Line 7", inline="text7_2") if i_show_7 table.cell(tbl, 0, 6, i_text_7, text_size = i_size_7, text_color = i_color_7, height=i_height_7, bgcolor=i_bg_7, text_halign=i_align_7) i_show_8 = input(false, title="", group="Line 8", inline="text8") i_color_8 = input(color.white, title="", group="Line 8", inline="text8") i_bg_8 = input(color.black, title="", group="Line 8", inline="text8") i_text_8 = input("", type=input.string, title="", group="Line 8", inline="text8") i_height_8 = input(2.5, title="", group="Line 8", inline="text8_2") i_size_8 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 8", inline="text8_2") i_align_8 = input("center", title="", options = ["center","left", "right"], group="Line 8", inline="text8_2") if i_show_8 table.cell(tbl, 0, 7, i_text_8, text_size = i_size_8, text_color = i_color_8, height=i_height_8, bgcolor=i_bg_8, text_halign=i_align_8) i_show_9 = input(false, title="", group="Line 9", inline="text9") i_color_9 = input(color.white, title="", group="Line 9", inline="text9") i_bg_9 = input(color.black, title="", group="Line 9", inline="text9") i_text_9 = input("", type=input.string, title="", group="Line 9", inline="text9") i_height_9 = input(2.5, title="", group="Line 9", inline="text9_2") i_size_9 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 9", inline="text9_2") i_align_9 = input("center", title="", options = ["center","left", "right"], group="Line 9", inline="text9_2") if i_show_9 table.cell(tbl, 0, 8, i_text_9, text_size = i_size_9, text_color = i_color_9, height=i_height_9, bgcolor=i_bg_9, text_halign=i_align_9) i_show_10 = input(false, title="", group="Line 10", inline="text10") i_color_10 = input(color.white, title="", group="Line 10", inline="text10") i_bg_10 = input(color.black, title="", group="Line 10", inline="text10") i_text_10 = input("", type=input.string, title="", group="Line 10", inline="text10") i_height_10 = input(2.5, title="", group="Line 10", inline="text10_2") i_size_10 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 10", inline="text10_2") i_align_10 = input("center", title="", options = ["center","left", "right"], group="Line 10", inline="text10_2") if i_show_10 table.cell(tbl, 0, 9, i_text_10, text_size = i_size_10, text_color = i_color_10, height=i_height_10, bgcolor=i_bg_10, text_halign=i_align_10) i_show_11 = input(false, title="", group="Line 11", inline="text11") i_color_11 = input(color.white, title="", group="Line 11", inline="text11") i_bg_11 = input(color.black, title="", group="Line 11", inline="text11") i_text_11 = input("", type=input.string, title="", group="Line 11", inline="text11") i_height_11 = input(2.5, title="", group="Line 11", inline="text11_2") i_size_11 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 11", inline="text11_2") i_align_11 = input("center", title="", options = ["center","left", "right"], group="Line 11", inline="text11_2") if i_show_11 table.cell(tbl, 0, 10, i_text_11, text_size = i_size_11, text_color = i_color_11, height=i_height_11, bgcolor=i_bg_11, text_halign=i_align_11) i_show_12 = input(false, title="", group="Line 12", inline="text12") i_color_12 = input(color.white, title="", group="Line 12", inline="text12") i_bg_12 = input(color.black, title="", group="Line 12", inline="text12") i_text_12 = input("", type=input.string, title="", group="Line 12", inline="text12") i_height_12 = input(2.5, title="", group="Line 12", inline="text12_2") i_size_12 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 12", inline="text12_2") i_align_12 = input("center", title="", options = ["center","left", "right"], group="Line 12", inline="text12_2") if i_show_12 table.cell(tbl, 0, 11, i_text_12, text_size = i_size_12, text_color = i_color_12, height=i_height_12, bgcolor=i_bg_12, text_halign=i_align_12) i_show_13 = input(false, title="", group="Line 13", inline="text13") i_color_13 = input(color.white, title="", group="Line 13", inline="text13") i_bg_13 = input(color.black, title="", group="Line 13", inline="text13") i_text_13 = input("", type=input.string, title="", group="Line 13", inline="text13") i_height_13 = input(2.5, title="", group="Line 13", inline="text13_2") i_size_13 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 13", inline="text13_2") i_align_13 = input("center", title="", options = ["center","left", "right"], group="Line 13", inline="text13_2") if i_show_13 table.cell(tbl, 0, 12, i_text_13, text_size = i_size_13, text_color = i_color_13, height=i_height_13, bgcolor=i_bg_13, text_halign=i_align_13) i_show_14 = input(false, title="", group="Line 14", inline="text14") i_color_14 = input(color.white, title="", group="Line 14", inline="text14") i_bg_14 = input(color.black, title="", group="Line 14", inline="text14") i_text_14 = input("", type=input.string, title="", group="Line 14", inline="text14") i_height_14 = input(2.5, title="", group="Line 14", inline="text14_2") i_size_14 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 14", inline="text14_2") i_align_14 = input("center", title="", options = ["center","left", "right"], group="Line 14", inline="text14_2") if i_show_14 table.cell(tbl, 0, 13, i_text_14, text_size = i_size_14, text_color = i_color_14, height=i_height_14, bgcolor=i_bg_14, text_halign=i_align_14) i_show_15 = input(false, title="", group="Line 15", inline="text15") i_color_15 = input(color.white, title="", group="Line 15", inline="text15") i_bg_15 = input(color.black, title="", group="Line 15", inline="text15") i_text_15 = input("", type=input.string, title="", group="Line 15", inline="text15") i_height_15 = input(2.5, title="", group="Line 15", inline="text15_2") i_size_15 = input("auto", title="", options = ["tiny", "small", "normal", "large", "auto"], group="Line 15", inline="text15_2") i_align_15 = input("center", title="", options = ["center","left", "right"], group="Line 15", inline="text15_2") if i_show_15 table.cell(tbl, 0, 14, i_text_15, text_size = i_size_15, text_color = i_color_15, height=i_height_15, bgcolor=i_bg_15, text_halign=i_align_15)
MA total distance on chart
https://www.tradingview.com/script/aoNWChW1-MA-total-distance-on-chart/
AliSignals
https://www.tradingview.com/u/AliSignals/
128
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/ // © AliSignals //@version=5 indicator('MA total distance on chart',shorttitle="MATD", overlay=true, timeframe="") //declaring function to use different types of MA maf(source, length, type) => type == 'SMA' ? ta.sma(source, length) : type == 'EMA' ? ta.ema(source, length) : type == 'SMMA (RMA)' ? ta.rma(source, length) : type == 'WMA' ? ta.wma(source, length) : type == 'VWMA' ? ta.vwma(source, length) : na // inputs Malength = input(100, title = "MA Length") src = input(close, title = "MA Source") type = input.string( 'SMA', title='MA type', inline='MA Type', options=['SMA', 'EMA', 'SMMA (RMA)', 'WMA', 'VWMA', 'linreg']) Madistancelength = input(40, title = "Distance Length") srcdistance = input(hl2, title = "Distance Source") smoothing = input(40, title = "smooothing") // running fuction ma = maf(src, Malength, type) // calculating distance distance = srcdistance - ma // Average of distances smadistance = ta.sma(distance, Madistancelength) // MATD and smoothing of it MATD = srcdistance - smadistance Smoothed = ta.sma(MATD, smoothing) fillcolor= color.rgb(55,198,255,90) p1 = plot(Smoothed, color=color.new(color.red, 0), title="MATD") p2 = plot(ma, color=color.new(color.blue, 0), title = "MA") // I know it's not a real cloud. LOL fill(p1, p2, color=fillcolor, title = "cloud")
Impermanent Loss Tracker
https://www.tradingview.com/script/TXbX7sNT-Impermanent-Loss-Tracker/
andrew.ryabchenko
https://www.tradingview.com/u/andrew.ryabchenko/
30
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/ // © andrew.ryabchenko //@version=4 study("Impermanent Loss") unixTimeNow = time timeAdded = input(defval = timestamp("January 1, 2022 00:00:00"), title = "Date and time the liquidity was added", type = input.time) assetA = input(defval = "BINANCE:CAKEUSDT", title = "Asset A", type = input.symbol) quanA = input(defval = 1.0, title = "Amount", type = input.float) assetB = input(defval = "BINANCE:ETHUSDT", title = "Asset B", type = input.symbol) quanB = input(defval = 1.0, title = "Amount", type = input.float) offset = barssince(unixTimeNow <= timeAdded) priceA = security(assetA, timeframe.period, close) priceB = security(assetB, timeframe.period, close) var k = quanA * quanB rt = float(na) deviationA = float(na) deviationB = float(na) //Initial Prices var initialPriceA = if offset > 0 priceA[1] var initialPriceB = if offset > 0 priceB[1] var ri = if offset > 0 initialPriceA / initialPriceB if offset > 0 rt := priceA / priceB if offset > 0 deviationA := ((quanA - sqrt(k / rt)) / quanA) * 100 if offset > 0 deviationB := ((quanB - sqrt(k * rt)) / quanB) * 100 plot(0, color = #00c96b) plot(deviationA, title = "Percent difference of asset A", color = #00c96b, style = plot.style_histogram) plot(deviationB, title = "Percent difference of asset B", color = #df3612, style = plot.style_histogram)
VWAP Gaps
https://www.tradingview.com/script/aEFka0rV-VWAP-Gaps/
Koalafied_3
https://www.tradingview.com/u/Koalafied_3/
302
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/ // © TJ_667 //@version=5 indicator("VWAP Gaps", overlay = true, max_lines_count = 50) // ---------- Functions ---------- // // TradingView vwap function. Taken out stdev calcs to put in seperate function. computeVWAP(src, isNewPeriod) => var float sumSrcVol = na var float sumVol = na var float sumSrcSrcVol = na sumSrcVol := isNewPeriod ? src * volume : src * volume + sumSrcVol[1] sumVol := isNewPeriod ? volume : volume + sumVol[1] // sumSrcSrcVol calculates the dividend of the equation that is later used to calculate the standard deviation sumSrcSrcVol := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sumSrcSrcVol[1] _vwap = sumSrcVol / sumVol previouslevels(period, VWAP) => var float pL = na pL := period ? VWAP[1] : pL // Function adapted from script "Naked - Daily Weekly Monthly" by Frien_dd untappedVWAP(p_vwap, isNewPeriod) => var line[] vwapLinesUp = array.new_line() var float[] p_vwapUp = array.new_float() var line[] vwapLinesDown = array.new_line() var float[] p_vwapDown = array.new_float() if isNewPeriod array.push(vwapLinesUp, line.new(time, p_vwap, time+1, p_vwap, xloc=xloc.bar_time, style=line.style_solid, color=color.orange, extend=extend.right)) array.push(vwapLinesDown, line.new(time, p_vwap, time+1, p_vwap, xloc=xloc.bar_time, style=line.style_solid, color=color.orange, extend=extend.right)) array.push(p_vwapUp, p_vwap) array.push(p_vwapDown, p_vwap) if array.size(p_vwapUp) > 0 for i = 0 to array.size(p_vwapUp)-1 vwapUp = array.get(p_vwapUp,i) if vwapUp < high line.delete(array.get(vwapLinesUp,i)) for i = 0 to array.size(p_vwapDown)-1 vwapDown = array.get(p_vwapDown,i) if vwapDown > low line.delete(array.get(vwapLinesDown,i)) // ---------- VWAP selection ---------- // src = input(hlc3, "VWAP Source") vwap_selection = input.string(title = "VWAP Options", defval="Day", options = ["Day", "Week", "Month", "Quarter", "Year"]) plot_vwap = input(true, "Plot vwap") vwapGap = input(true, 'Plot VWAP Gap levels') plot_pL = input(true, 'Plot pVWAP levels') // ---------- VWAP Calculations ---------- // timeChange(period) => ta.change(time(period)) newSession = vwap_selection == "Day" ? timeChange("D") : vwap_selection == "Week" ? timeChange("W") : vwap_selection == "Month" ? timeChange("M") : vwap_selection == "Quarter" ? timeChange("3M") : vwap_selection == "Year" ? timeChange("12M") : na // ---------- VWAP Function Calls ---------- // _vwap = vwap_selection == "Day" ? computeVWAP(src, newSession) : vwap_selection == "Week" ? computeVWAP(src, newSession) : vwap_selection == "Month" ? computeVWAP(src, newSession) : vwap_selection == "Quarter" ? computeVWAP(src, newSession) : vwap_selection == "Year" ? computeVWAP(src, newSession) : na p_vwap = previouslevels(newSession, _vwap) // ---------- Plots ---------- // v_plot = plot(plot_vwap ? _vwap : na, title = "VWAP", color = color.new(color.white, 25), style = plot.style_stepline, linewidth = 1) if vwapGap untappedVWAP(p_vwap, newSession) pV = previouslevels(newSession, _vwap) pVplot = plot(plot_pL ? pV : na, title = "Previous VWAP", color = color.orange, style = plot.style_linebr, transp = 60, linewidth = 1) //-------------------- Sweeps --------------------// // Only calculates sweeps from the previous period. vwap_sweep = input(true, 'Plot pVWAP sweep') // Filters bull = close > open bear = close < open sweep_up = open < pV and high > pV and close < pV sweep_down = open > pV and low < pV and close > pV v_under = _vwap < pV v_over = _vwap > pV barcolor(sweep_up and v_under ? color.red : sweep_down and v_over ? color.green : na) plotshape(vwap_sweep ? sweep_up and bear and v_under : na, style=shape.triangledown, location=location.abovebar, color=color.red, size = size.tiny) plotshape(vwap_sweep ? sweep_down and bull and v_over : na, style=shape.triangleup, location=location.belowbar, color=color.white, size = size.tiny)
Candilator RSI [AstrideUnicorn]
https://www.tradingview.com/script/aWwNQO7C-Candilator-RSI-AstrideUnicorn/
AstrideUnicorn
https://www.tradingview.com/u/AstrideUnicorn/
1,185
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/ // © AstrideUnicorn //@version=5 indicator("Candilator RSI", overlay=false) // indicator inputs length = input(defval=14, title="Period", group="Main Settings") overbought = input(defval=70.0, title="Overbought Level", group="Main Settings") oversold = input(defval=30.0, title="Oversold Level", group="Main Settings") ShowOutside = input(defval=true, title="Outside Bar Pattern", group="Pattern Detection") ShowInside = input(defval=true, title="Inside Bar Pattern", group="Pattern Detection") // calculate RSI with open, high, low and close time series candilator_open = ta.rsi(open, length) candilator_high = math.max(ta.rsi(high, length),ta.rsi(low, length)) candilator_low = math.min(ta.rsi(high, length),ta.rsi(low, length)) candilator_close = ta.rsi(close, length) //Outside bar outside_bar_bull = barstate.isconfirmed and ShowOutside and candilator_high[0]>candilator_high[1] and candilator_low[0]<candilator_low[1] and candilator_open[0]<candilator_open[1] and candilator_close[0]>candilator_close[1] and candilator_close[0]>candilator_open[0] and candilator_close[1]<candilator_close[2] and candilator_close[0]>candilator_open[1] outside_bar_bear = barstate.isconfirmed and ShowOutside and candilator_high[0]>candilator_high[1] and candilator_low[0]<candilator_low[1] and candilator_open[0]>candilator_open[1] and candilator_close[0]<candilator_close[1] and candilator_close[0]<candilator_open[0] and candilator_close[1]>candilator_close[2] and candilator_close[0]<candilator_open[1] //Inside bar inside_bar_bull = barstate.isconfirmed and ShowInside and candilator_open[1]>candilator_close[1] and candilator_close[1]<candilator_close[2] and candilator_open[0]>candilator_close[1] and candilator_open[0]<candilator_open[1] and candilator_close[0]>candilator_close[1] and candilator_close[0]<candilator_open[1] and candilator_high[0]<candilator_high[1] and candilator_low[0]>candilator_low[1] and candilator_close[0]>=candilator_open[0] inside_bar_bear = barstate.isconfirmed and ShowInside and candilator_open[1]<candilator_close[1] and candilator_close[1]>candilator_close[2] and candilator_open[0]<candilator_close[1] and candilator_open[0]>candilator_open[1] and candilator_close[0]<candilator_close[1] and candilator_close[0]>candilator_open[1] and candilator_high[0]<candilator_high[1] and candilator_low[0]>candilator_low[1] and candilator_close[0]<=candilator_open[0] // Define overbought and oversold conditions oversold_condition = (candilator_open[1] < oversold) or (candilator_open < oversold) overbought_condition = (candilator_open[1] > overbought) or (candilator_open > overbought) // Define a conditional color for the candilator bars candilator_color = candilator_close > candilator_open ? color.green : color.red // Plot candilator candles and levels plotcandle(candilator_open,candilator_high,candilator_low,candilator_close,color=candilator_color) plot(50, color=color.new(color.white,60)) plot(overbought, color=color.new(color.blue,60)) plot(oversold, color=color.new(color.blue,60)) // plot lablels for detected patterns plotshape(outside_bar_bull and oversold_condition ? 0.6*candilator_low : na, text='Outside Bar', style=shape.labelup, color=color.green, textcolor=color.white, location=location.absolute, size=size.normal, editable=false) plotshape(outside_bar_bear and overbought_condition ? 1.1*candilator_high : na,text='Outside Bar', style=shape.labeldown, color=color.red, textcolor=color.white, location=location.absolute, size=size.normal, editable=false) plotshape(inside_bar_bull and oversold_condition ? 0.6*candilator_low : na,text='Inside Bar', style=shape.labelup, color=color.green, textcolor=color.white, location=location.absolute, size=size.normal, editable=false) plotshape(inside_bar_bear and overbought_condition ? 1.1*candilator_high : na ,text='Inside Bar', style=shape.labeldown, color=color.red, textcolor=color.white, location=location.absolute, size=size.normal, editable=false)
Average Daily Range x 3 by Serge
https://www.tradingview.com/script/BHPdmXaq-Average-Daily-Range-x-3-by-Serge/
Serge_Trades
https://www.tradingview.com/u/Serge_Trades/
306
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/ // © Serge_Trades //@version=5 indicator(title='ADRx3 by Serge', shorttitle='ADRx3 by Serge', overlay=true) text_ADR1_high = 'ADR1 High' text_ADR2_high = 'ADR2 High' text_ADR3_high = 'ADR3 High' text_ADR1_low = 'ADR1 Low' text_ADR2_low = 'ADR2 Low' text_ADR3_low = 'ADR3 Low' text_open = 'Open' var mint = #00FF80 //ADR3 Low var lime = #00FF00 //ADR2 Low var chartreuse = #80FF00 //ADR1 Low var orange = #FF8000 //ADR1 High var redorange = #FF4000 //ADR2 High var red = #FF0000 //ADR3 High var gray = #808080 //Open //***Start of Inputs var labels_enabled = input.bool(defval=true, title='Show labels') var plot_history = input.bool(defval=true, title='Historical levels') var use_ema = input.bool(defval=false, title='Use EMA') var adr_1 = input.int(title='ADR 1', defval = 14, minval = 1, group='ADR Periods') var adr_2 = input.int(title='ADR 2', defval = 7, minval = 1, group='ADR Periods') var adr_3 = input.int(title='ADR 3', defval = 5, minval = 1, group='ADR Periods') var color_ADR1_high = input.color(defval=color.new(orange ,0), title=text_ADR1_high, group='Colors') var color_ADR2_high = input.color(defval=color.new(redorange,0), title=text_ADR2_high, group='Colors') var color_ADR3_high = input.color(defval=color.new(red,0), title=text_ADR3_high, group='Colors') var color_ADR1_low = input.color(defval=color.new(chartreuse ,0), title=text_ADR1_low, group='Colors') var color_ADR2_low = input.color(defval=color.new(lime,0), title=text_ADR2_low, group='Colors') var color_ADR3_low = input.color(defval=color.new(mint ,0), title=text_ADR3_low, group='Colors') var color_open = input.color(defval=color.new(gray ,0), title=text_open, group='Colors') //***End of Inputs //***Start of local functions definiton*** draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) => dline = line.new(x1=_x1, y1=_y1, x2=_x2, y2=_y2, xloc=_xloc, extend=_extend, color=_color, style=_style, width=_width) line.delete(dline[1]) draw_label(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) => dlabel = label.new(x=_x, y=_y, text=_text, xloc=_xloc, yloc=_yloc, color=_color, style=_style, textcolor=_textcolor, size=_size, textalign=_textalign, tooltip=_tooltip) label.delete(dlabel[1]) //If security is futures - replace the ticker with continuous contract tickerid_func() => tickerid = syminfo.prefix + ':' + syminfo.tickerid if syminfo.type == 'futures' tickerid := syminfo.prefix + ':' + syminfo.root + '1!' //Function to calculate ADR levels //Parameters: // * lengthInput - ADR period // * hi_low - true-->High, else-->Low adr_func(lengthInput,hi_low) => float result = 0 float adr = 0 open_ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on) adr_High_sma = request.security(tickerid_func(), "D", ta.sma(high[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) adr_Low_sma = request.security(tickerid_func(), "D", ta.sma(low[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) adr_High_ema = request.security(tickerid_func(), "D", ta.ema(high[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) adr_Low_ema = request.security(tickerid_func(), "D", ta.ema(low[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on) if use_ema adr := adr_High_ema - adr_Low_ema else adr := adr_High_sma - adr_Low_sma if hi_low//High result := adr/2 + open_ else //Low result := open_ - adr/2 //Workaround to disable color management on the standard tab Style for plots //Custom inputs for colors should be used instead transp_func() => transp_0 = 0 //***End of local functions definiton*** //***Start of getting data start_time = request.security(tickerid_func(), "D", time_close[1],barmerge.gaps_off,barmerge.lookahead_on) open__ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on) adr1_high = adr_func(adr_1,true) adr1_low = adr_func(adr_1,false) adr2_high = adr_func(adr_2,true) adr2_low = adr_func(adr_2,false) adr3_high = adr_func(adr_3,true) adr3_low = adr_func(adr_3,false) //***End of getting data float _adr1_high = na float _adr1_low = na float _adr2_high = na float _adr2_low = na float _adr3_high = na float _adr3_low = na float _open = na //********************* //***Start of plotting* //Decide if we can show the chart: //Daily levels should be visible on intraday chart only var show_chart = false if timeframe.isintraday show_chart := true if show_chart == false runtime.error("Change timeframe to intraday to see ADRx3 levels.") //Plot all days if show_chart and plot_history _adr1_high := adr1_high _adr1_low := adr1_low _adr2_high := adr2_high _adr2_low := adr2_low _adr3_high := adr3_high _adr3_low := adr3_low _open := open__ plot(_adr1_high, title=text_ADR1_high, color=color_ADR1_high, linewidth=1) plot(_adr2_high, title=text_ADR2_high, color=color_ADR2_high, linewidth=1) plot(_adr3_high, title=text_ADR3_high, color=color_ADR3_high, linewidth=1) plot(_adr1_low, title=text_ADR1_low, color=color_ADR1_low, linewidth=1) plot(_adr2_low, title=text_ADR2_low, color=color_ADR2_low, linewidth=1) plot(_adr3_low, title=text_ADR3_low, color=color_ADR3_low, linewidth=1) plot(_open, title=text_open, color=color_open, linewidth=2) ////Plot today only if show_chart and not plot_history draw_line(start_time, adr1_high, time, adr1_high, xloc.bar_time, extend.none, color_ADR1_high, line.style_solid, 1) draw_line(start_time, adr2_high, time, adr2_high, xloc.bar_time, extend.none, color_ADR2_high, line.style_solid, 1) draw_line(start_time, adr3_high, time, adr3_high, xloc.bar_time, extend.none, color_ADR3_high, line.style_solid, 1) draw_line(start_time, adr1_low, time, adr1_low, xloc.bar_time, extend.none, color_ADR1_low, line.style_solid, 1) draw_line(start_time, adr2_low, time, adr2_low, xloc.bar_time, extend.none, color_ADR2_low, line.style_solid, 1) draw_line(start_time, adr3_low, time, adr3_low, xloc.bar_time, extend.none, color_ADR3_low, line.style_solid, 1) draw_line(start_time, open__, time, open__, xloc.bar_time, extend.none, color_open, line.style_solid, 2) //***End of plotting*** //********************* //********************* //***Start of Labels*** label_ADR1_high = '' label_ADR2_high = '' label_ADR3_high = '' label_ADR1_low = '' label_ADR2_low = '' label_ADR3_low = '' label_open = '' if labels_enabled == true label_ADR1_high := str.tostring(math.round_to_mintick(adr1_high)) label_ADR2_high := str.tostring(math.round_to_mintick(adr2_high)) label_ADR3_high := str.tostring(math.round_to_mintick(adr3_high)) label_ADR1_low := str.tostring(math.round_to_mintick(adr1_low)) label_ADR2_low := str.tostring(math.round_to_mintick(adr2_low)) label_ADR3_low := str.tostring(math.round_to_mintick(adr3_low)) label_open := str.tostring(math.round_to_mintick(open__)) string_ADR1_high = ' (' + label_ADR1_high + ')' string_ADR2_high = ' (' + label_ADR2_high + ')' string_ADR3_high = ' (' + label_ADR3_high + ')' string_ADR1_low = ' (' + label_ADR1_low + ')' string_ADR2_low = ' (' + label_ADR2_low + ')' string_ADR3_low = ' (' + label_ADR3_low + ')' string_open_low = ' (' + label_open + ')' //Labels if show_chart and labels_enabled == true draw_label(bar_index, adr1_high, text_ADR1_high + string_ADR1_high, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR1_high,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, adr2_high, text_ADR2_high + string_ADR2_high, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR2_high,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, adr3_high, text_ADR3_high + string_ADR3_high, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR3_high,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, adr1_low, text_ADR1_low + string_ADR1_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR1_low,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, adr2_low, text_ADR2_low + string_ADR2_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR2_low,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, adr3_low, text_ADR3_low + string_ADR3_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR3_low,transp_func()), size.normal, text.align_left, '') draw_label(bar_index, open__, text_open + string_open_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_open,transp_func()), size.normal, text.align_left, '') //*********************
Naked Bar Upward Reversal
https://www.tradingview.com/script/FWITgWCo-Naked-Bar-Upward-Reversal/
MrDevDevy
https://www.tradingview.com/u/MrDevDevy/
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/ // © MrDevDevy //@version=5 indicator("Naked Bar Upward Reversal", overlay=true, max_lines_count=500) Text = input.string( defval="NBUR", title="Text above bar", group="Settings") BoundaryColor = input.color( defval=color.blue, title="Bounding Box Color", group="Settings") // A Naked Bar is one that closes BELOW the previous LOW and is a down bar. // Rules for the inside bar are as follows: Must follow the Naked Bar with an OPEN GREATER than the Naked Bar CLOSE. bool IsNaked = ( close[1] < low[2] and close[1] < open[1]) ? true : false bool IsInside = ( (high[0] < high[1]) and (low[0] > low[1]) and (open[0] > close[1]) ) ? true : false if(IsNaked and IsInside) TopBound = math.max(high[0], high[1], high[2]) LowBound = math.min(low[0], low[1], low[2]) label.new(bar_index[1], TopBound, style=label.style_none, text=Text) //top boundary line.new(bar_index[2], TopBound, bar_index, TopBound, color=BoundaryColor) //bottom boundary line.new(bar_index[2], LowBound, bar_index, LowBound, color=BoundaryColor) //left boundary line.new(bar_index[2], TopBound, bar_index[2], LowBound, color=BoundaryColor) //right boundary line.new(bar_index[0], TopBound, bar_index[0], LowBound, color=BoundaryColor)
RSI Glow
https://www.tradingview.com/script/69rfDAEb-RSI-Glow/
scarf
https://www.tradingview.com/u/scarf/
189
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/ // © scarf //@version=5 indicator("RSI Glow", overlay=true) rsi = ta.rsi(close, 14) rsi_high = rsi >= 65 rsi_low = rsi <= 35 neon_green = #39FF14 neon_pink = #ff6ec7 neon_blue = #04d9ff neon_orange = #ff9800 transp = 50 plotcandle(high + (ta.atr(5)*0.1), close, close, close, title='Title', color = close > open and rsi_high ? color.new(neon_blue, transp) : na, wickcolor=na, bordercolor=na) plotcandle(low - (ta.atr(5)*0.1), open, open, open, title='Title', color = close > open and rsi_low ? color.new(neon_orange, transp) : na, wickcolor=na, bordercolor=na)
ATR Position Size Automation
https://www.tradingview.com/script/qzy6ZR9n-ATR-Position-Size-Automation/
TraderCreatorPro
https://www.tradingview.com/u/TraderCreatorPro/
105
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/ // © TraderCreatorPro //@version=5 indicator("ATR Position Size", "Position Size", true) //User Inputs TimeFrame = input.timeframe("D", "Timeframe the ATR is Calculated off of") AccountSize = input.float(10000, "Account Size to base Risk off of") AccountRisk = input.float(2, "Percentage Risk Of your Account Size") ATRPercentageRisk = input.float (100, "Percentage Risk of the ATR (put in 200 for 2x ATR etc.)") ShowAccountSize = input.bool (true, "Your Account Size") ShowRisk = input.bool (true, "Percentage on the table?") ShowDollarRisk = input.bool(true, "Dollar Risk (based off your percentage risk)") ShowStop = input.bool (true, "Long Stop Price") ShowStopS = input.bool (true, "Short Stop Price") ShowATR = input.bool(true, "Show ATR on the table?") ShowATRP = input.bool(true, "Shows ATR * The Percentage of the ATR you want (ATR STOP)") PlotLongStop = input.bool(true, "A line on the Long Stop Level", tooltip = "These will keep moving") PlotShortStop = input.bool(true, "A line on the Short Stop Level", tooltip = "These will keep moving") textcolor = input.color(color.white, "Color of Table Text") backgroundcolor= input.color (color.gray, "Color of Table Background") BoxPlacement = input.string(position.top_right, "Box Placement", options = [position.bottom_right, position.bottom_left, position.top_right, position.top_center, position.bottom_center]) //import time frame O = request.security(syminfo.ticker, TimeFrame, open) H = request.security(syminfo.ticker, TimeFrame, high) L = request.security(syminfo.ticker, TimeFrame, low) C = request.security(syminfo.ticker, TimeFrame, close) //Indicator math stuff atr = request.security(syminfo.ticker, TimeFrame, ta.atr(14)) atr2 = math.round(atr,2) dtr = request.security(syminfo.ticker, "D", math.round(high - low,2)) atrp = math.round(dtr/atr * 100) //position size math stuff ATRPRisk = (ATRPercentageRisk/100) * atr2 StopPsize = math.round((AccountRisk /100) * AccountSize,precision = 2) //200 PositionSize = math.round((StopPsize / ATRPRisk),2) Stop = C - ATRPRisk StopS = C + ATRPRisk var table myTable = table.new(BoxPlacement, 1, 8, border_width=1) if barstate.islast //Table Cells table.cell(myTable, 0,0, "Max Size: " + str.tostring(PositionSize), text_color = textcolor, bgcolor = backgroundcolor) table.cell(myTable, 0,6, "ATR: " + str.tostring(atr2),text_color = ShowATR? textcolor : na, bgcolor = ShowATR? backgroundcolor : na) table.cell(myTable, 0,2,ShowRisk? "Risking: " + str.tostring(AccountRisk) + "%":na,text_color = ShowRisk? textcolor : na, bgcolor = ShowRisk? backgroundcolor : na) table.cell(myTable, 0,1,ShowAccountSize? "Act Sz: $" + str.tostring(AccountSize):na,text_color = ShowAccountSize? textcolor : na, bgcolor = ShowAccountSize? backgroundcolor : na) table.cell(myTable, 0,4, ShowStop? "St Long: " + str.tostring(Stop):na, text_color = ShowStop? textcolor : na, bgcolor = ShowStop? backgroundcolor : na) table.cell(myTable, 0,5, ShowStopS? "St Short: " + str.tostring(StopS):na, text_color = ShowStopS? textcolor : na, bgcolor = ShowStopS? backgroundcolor : na) table.cell(myTable, 0,3, ShowDollarRisk? "Risking: $" + str.tostring(StopPsize):na, text_color = ShowDollarRisk? textcolor : na, bgcolor = ShowDollarRisk? backgroundcolor : na) table.cell(myTable, 0,7, ShowATRP? "ATR Stop: " + str.tostring(ATRPRisk):na,text_color = ShowATRP? textcolor : na, bgcolor = ShowATRP? backgroundcolor : na) //Plot Lines? plot(PlotLongStop? Stop: na, "Long Stop", color.green) plot (PlotShortStop? StopS :na, "Short Stop", color.red)
TPTR_Dynamic_Ratio_Correlator
https://www.tradingview.com/script/StaygYJU-TPTR-Dynamic-Ratio-Correlator/
silver_efficiency
https://www.tradingview.com/u/silver_efficiency/
57
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/ // © silver_efficiency //@version=5 indicator('TPTR_Dynamic_Ratio_Correlator', overlay=true, precision=2) // Dynamic symbol choice defaults to XLE and XLF sec_1 = input.symbol('XLE') sec_2 = input.symbol('XLK') ratio_threshold = input(0.40) // Computes Sec_1 and Sec_2's price by current period close_D_sec_1 = request.security(sec_1, timeframe.period, close) close_D_sec_2 = request.security(sec_2, timeframe.period, close) //Computes the ratio between Sec_1 and Sec_2 ratio_D_sec_1_sec_2 = close_D_sec_1 / close_D_sec_2 // Computes Graphic display indicator in summary table for current candle ratio state trendGraphic(trend) => trend == 1 ? ' 🟢 ' : ' 🔴 ' // Plots the value of the ratio as a part of the study in header plotchar(ratio_D_sec_1_sec_2, color=color.new(color.yellow, 0), char='') // Summary table framework var statsTable = table.new(position=position.bottom_right, columns=3, rows=2, bgcolor=color.black, border_width=1, border_color=color.white) table.cell(table_id=statsTable, column=0, row=0, text=str.tostring(sec_1), text_color=color.white, text_halign=text.align_left, text_size=size.normal, bgcolor=#000004) table.cell(table_id=statsTable, column=1, row=0, text=str.tostring(sec_2), text_color=color.white, text_halign=text.align_left, text_size=size.normal, bgcolor=#000004) table.cell(table_id=statsTable, column=2, row=0, text='Ratio -' + str.tostring(sec_1) + " & " + str.tostring(sec_2), text_color=color.white, text_halign=text.align_left, text_size=size.normal, bgcolor=#000004) table.cell(table_id=statsTable, column=0, row=1, text=str.tostring(close_D_sec_1), text_color=color.white, text_halign=text.align_left) table.cell(table_id=statsTable, column=1, row=1, text=str.tostring(close_D_sec_2), text_color=color.white, text_halign=text.align_left) table.cell(table_id=statsTable, column=2, row=1, text=trendGraphic(ratio_D_sec_1_sec_2 >= ratio_threshold) + str.tostring(ratio_D_sec_1_sec_2, '#.###'), text_color=color.white, text_halign=text.align_left) // Generate Alert condition when sec_1 / sec_2 ratio cross above threshold (default 0.4) ratioUp = ta.crossover(math.round(ratio_D_sec_1_sec_2, 2), ratio_threshold) if ratioUp // Trigger the alert the first time a cross occurs during the real-time bar. // If you want to change to once per bar close; alter the alert.freq_once_per_bar to alert.freq_once_per_bar_close alert('ratio_Sec_1_Sec_2 (' + str.tostring(ratio_D_sec_1_sec_2) + ') crossed over threshold (' + str.tostring(ratio_threshold) + ').', alert.freq_once_per_bar) // Paint indicator above bar plotchar(ratioUp, 'ratioUp', '▲', location.belowbar, size=size.tiny, color=color.new(color.yellow, 0))
ATR vs Day Trading Range and Percentage
https://www.tradingview.com/script/G90uScAS-ATR-vs-Day-Trading-Range-and-Percentage/
TraderCreatorPro
https://www.tradingview.com/u/TraderCreatorPro/
102
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/ // © TraderCreatorPro //@version=5 indicator("ATR/DTR", overlay = true) //inputs TimeFrame = input.timeframe("D", "Timeframe the ATR is Calculated off of") percolor = input.int(100, "Percentage the color will change at")// the percerntage the color will change with normalcolor = input.color (color.gray, "Color under percentage") // the color if it is under the certain percentage colorchange = input.color(color.white, "Color over percentage") //the color it will change to if... BoxPlacement = input.string(position.bottom_right, "Box Placement", options = [position.bottom_right, position.bottom_left, position.top_right, position.top_center, position.bottom_center]) //Prepare a table var table atrdtr = table.new(BoxPlacement, 3, 1, bgcolor = normalcolor, border_color = color.teal, border_width = 2) //Indicator math stuff atr = request.security(syminfo.ticker, TimeFrame, ta.atr(14)) atr2 = math.round(atr,2) dtr = request.security(syminfo.ticker,TimeFrame, math.round(high - low,2)) atrp = math.round(dtr/atr * 100) //Draw Table if barstate.islast table.cell(atrdtr, 0,0, text = "ATR: " + str.tostring(atr2)) table.cell(atrdtr, 1,0, text = "DTR: " + str.tostring(dtr)) table.cell(atrdtr, 2,0, text = str.tostring(atrp)+ "%") if atrp > percolor table.set_bgcolor(atrdtr, colorchange) plot(na)