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
BTC Composite Man V.1
https://www.tradingview.com/script/i21nVUTE-BTC-Composite-Man-V-1/
cryptoonchain
https://www.tradingview.com/u/cryptoonchain/
74
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/ // © MJShahsavar //@version=5 indicator("BTC Composite Man") R = input.symbol("BTC_RECEIVINGADDRESSES", "Symbol") r = request.security(R, 'D', close) S=input.symbol("BTC_SENDINGADDRESSES", "Symbol") s = request.security(S, 'D', close) C = r/s M= ta.alma(C, 21, 6, 0.85) M100=ta.sma(C, 100) MM=ta.alma(M, 100, 6, 0.85) plot (M, color = M >= M100 ? color.fuchsia : color.blue, linewidth=1) plot (M100, color = M >= M100 ? color.red : color.green, linewidth=3)
AlphaTrend
https://www.tradingview.com/script/o50NYLAZ-AlphaTrend/
KivancOzbilgic
https://www.tradingview.com/u/KivancOzbilgic/
15,468
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/ // author © KivancOzbilgic // developer © KivancOzbilgic //@version=5 indicator('AlphaTrend', shorttitle='AT', overlay=true, format=format.price, precision=2, timeframe='') coeff = input.float(1, 'Multiplier', step=0.1) AP = input(14, 'Common Period') ATR = ta.sma(ta.tr, AP) src = input(close) showsignalsk = input(title='Show Signals?', defval=true) novolumedata = input(title='Change calculation (no volume data)?', defval=false) upT = low - ATR * coeff downT = high + ATR * coeff AlphaTrend = 0.0 AlphaTrend := (novolumedata ? ta.rsi(src, AP) >= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B k1 = plot(AlphaTrend, color=color.new(#0022FC, 0), linewidth=3) k2 = plot(AlphaTrend[2], color=color.new(#FC0400, 0), linewidth=3) fill(k1, k2, color=color1) buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2]) sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2]) K1 = ta.barssince(buySignalk) K2 = ta.barssince(sellSignalk) O1 = ta.barssince(buySignalk[1]) O2 = ta.barssince(sellSignalk[1]) plotshape(buySignalk and showsignalsk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(#0022FC, 0), textcolor=color.new(color.white, 0)) plotshape(sellSignalk and showsignalsk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.maroon, 0), textcolor=color.new(color.white, 0)) alertcondition(buySignalk and O1 > K2, title='Potential BUY Alarm', message='BUY SIGNAL!') alertcondition(sellSignalk and O2 > K1, title='Potential SELL Alarm', message='SELL SIGNAL!') alertcondition(buySignalk[1] and O1[1] > K2, title='Confirmed BUY Alarm', message='BUY SIGNAL APPROVED!') alertcondition(sellSignalk[1] and O2[1] > K1, title='Confirmed SELL Alarm', message='SELL SIGNAL APPROVED!') alertcondition(ta.cross(close, AlphaTrend), title='Price Cross Alert', message='Price - AlphaTrend Crossing!') alertcondition(ta.crossover(low, AlphaTrend), title='Candle CrossOver Alarm', message='LAST BAR is ABOVE ALPHATREND') alertcondition(ta.crossunder(high, AlphaTrend), title='Candle CrossUnder Alarm', message='LAST BAR is BELOW ALPHATREND!') alertcondition(ta.cross(close[1], AlphaTrend[1]), title='Price Cross Alert After Bar Close', message='Price - AlphaTrend Crossing!') alertcondition(ta.crossover(low[1], AlphaTrend[1]), title='Candle CrossOver Alarm After Bar Close', message='LAST BAR is ABOVE ALPHATREND!') alertcondition(ta.crossunder(high[1], AlphaTrend[1]), title='Candle CrossUnder Alarm After Bar Close', message='LAST BAR is BELOW ALPHATREND!')
USD STOP LOSS
https://www.tradingview.com/script/Fi9GH4qr/
TraderRichard02
https://www.tradingview.com/u/TraderRichard02/
4
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © riky7arlunno //@version=5 indicator(title="USD STOP LOSS", overlay=true) pips=input(2,title="PIPS") ris=pips/10000 plot(high+ris,color=color.red,title="SHORT") plot(low-ris,color=color.green,title="LONG")
Linea Bruja
https://www.tradingview.com/script/xP8mFUCa-Linea-Bruja/
ceka2021
https://www.tradingview.com/u/ceka2021/
6
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/ // I took this code from infernixx, so we can say its like a copy, and I took it too, so it's another copy - Carlos K //@version=4 study("Linea Bruja", overlay = true) bool show_daily_open = input(group="Daily Open", title="Show daily open", type=input.bool, defval=true) bool show_daily_open_label = input(group="Daily Open", title="Show daily open label", type=input.bool, defval=true) color daily_open_color = input(group="Daily Open", title="Daily Open Color", type=input.color, defval=color.new(color.yellow,5)) //Non repainting security f_security(_symbol, _res, _src, _repaint) => security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1] // Basic vars (needed in functions) // Only render intraday validTimeFrame = timeframe.isintraday == true // If above the 5 minute, we start drawing yesterday. below, we start today levelsstart = iff((timeframe.isseconds == true) or (timeframe.isminutes == true and timeframe.multiplier < 5), time('D'), time('D') - (86400 * 1000)) levelsstartbar = barssince(levelsstart) // Functions // new_bar: check if we're on a new bar within the session in a given resolution new_bar(res) => change(time(res)) != 0 // Get Daily price data dayOpen = f_security(syminfo.tickerid, "D",open, false) // Daily open daily_open = security(syminfo.tickerid, 'D', open, lookahead=barmerge.lookahead_on) // Date & time variables current_year = year(timenow) current_month = month(timenow) current_weekofyear = weekofyear(timenow) current_dayofmonth = dayofmonth(timenow) current_dayofweek = dayofweek(timenow) // Opens (re-test previous values, so we take the closing price as that is defining the upcoming open price) bar_is_today = (year == current_year and weekofyear == current_weekofyear and dayofweek == current_dayofweek) plot(show_daily_open and bar_is_today and validTimeFrame? daily_open : na, title="Daily open", color=daily_open_color, style=plot.style_linebr, linewidth=2)
JPY STOP LOSS
https://www.tradingview.com/script/jNsyvt20/
TraderRichard02
https://www.tradingview.com/u/TraderRichard02/
4
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © riky7arlunno //@version=5 indicator(title="JPY STOP LOSS", overlay=true) pips=input(2,title="PIPS") ris=pips/100 plot(high+ris,color=color.red,title="SHORT") plot(low-ris,color=color.green,title="LONG")
pp classic
https://www.tradingview.com/script/GNTImzvR-pp-classic/
Stanistas
https://www.tradingview.com/u/Stanistas/
18
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/ // © Stanistas //@version=4 study("highlight overnight") // Pivot Points pivotX_open = float(na) pivotX_open := nz(pivotX_open[1],open) pivotX_high = float(na) pivotX_high := nz(pivotX_high[1],high) pivotX_low = float(na) pivotX_low := nz(pivotX_low[1],low) pivotX_prev_open = float(na) pivotX_prev_open := nz(pivotX_prev_open[1]) pivotX_prev_high = float(na) pivotX_prev_high := nz(pivotX_prev_high[1]) pivotX_prev_low = float(na) pivotX_prev_low := nz(pivotX_prev_low[1]) pivotX_prev_close = float(na) pivotX_prev_close := nz(pivotX_prev_close[1]) pivotXGetCurTF()=> result = "1M" if timeframe.isintraday result := timeframe.multiplier <= 15 ? "1D" : "1W" else if timeframe.isweekly or timeframe.ismonthly result := "12M" result fNeg(value) => value <= 0 ? na : value pivotX_Interval = time(pivotXGetCurTF()) if pivotX_Interval != pivotX_Interval[1] pivotX_prev_open := pivotX_open pivotX_prev_close := close[1] pivotX_prev_high := pivotX_high pivotX_prev_low := pivotX_low pivotX_open := open pivotX_high := high pivotX_low := low else pivotX_high := max(pivotX_high, high) pivotX_low := min(pivotX_low, low) // Classic pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close)/3 plot(fNeg(pivotX_Median + 2*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.R3') plot(fNeg(pivotX_Median + 1*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.R2') plot(fNeg(pivotX_Median * 2 - pivotX_prev_low), title = 'Pivot.M.Classic.R1') plot(fNeg(pivotX_Median), title = 'Pivot.M.Classic.Middle') plot(fNeg(pivotX_Median * 2 - pivotX_prev_high), title = 'Pivot.M.Classic.S1') plot(fNeg(pivotX_Median - 1*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.S2') plot(fNeg(pivotX_Median - 2*(pivotX_prev_high - pivotX_prev_low)), title = 'Pivot.M.Classic.S3')
Seth_Signal
https://www.tradingview.com/script/nHLQPbDC-Seth-Signal/
Seth_Thada
https://www.tradingview.com/u/Seth_Thada/
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/ //@version=5 //Indicator by STH_Seththeesin_Thakanok - Published //Test Indicator - This script/indicator is designed with the main purpose of identifying the strength of the instrument. //Description added at each methods. Inputs can be changed by users as per their own rules as per their matching style. indicator(title='Seth_Signal', shorttitle='STH_Signal', overlay=true) //PSAR - Default PSAR setting with the marking of red and green as per position of above or below candle pSARbeginningValue = input.int(2, minval=0, maxval=10, title='PSAR Beginning Value') pSARendValue = input.int(2, minval=1, maxval=10, title='PSAR End Value') pSARmultiplierValue = input.int(2, minval=0, maxval=10, title=' PSAR Multiplier Value') pSARbeginningMethod = pSARbeginningValue * .01 pSARendMethod = pSARendValue * .10 pSARmultiplierMethod = pSARmultiplierValue * .01 pSAR_UpValue = ta.sar(pSARbeginningMethod, pSARmultiplierMethod, pSARendMethod) pSAR_DownValue = ta.sar(pSARbeginningMethod, pSARmultiplierMethod, pSARendMethod) pSAR_UpColor = close >= pSAR_DownValue ? color.green : na pSAR_DownColor = close <= pSAR_UpValue ? color.red : na plot(pSAR_UpValue ? pSAR_UpValue : na, style=plot.style_circles, color=pSAR_UpColor, linewidth=1, title='Upside PSAR') plot(pSAR_DownValue ? pSAR_DownValue : na, style=plot.style_circles, color=pSAR_DownColor, linewidth=1, title='Downside PSAR') //Zone Identification - This is once again ATR based method to identify the zone based on its strength zoneSource = input(hl2, title='Source') zoneLength = input(defval=8, title='ATR Zone Length') zoneMultiplier = input.float(defval=3.3, step=0.1, title='ATR Zone Multiplier') zoneATR = ta.atr(zoneLength) downZone = zoneSource + zoneMultiplier * zoneATR downZoneNew = nz(downZone[1], downZone) downZone := close[1] < downZoneNew ? math.min(downZone, downZoneNew) : downZone upZone = zoneSource - zoneMultiplier * zoneATR upZoneNew = nz(upZone[1], upZone) upZone := close[1] > upZoneNew ? math.max(upZone, upZoneNew) : upZone zoneDecider = 1 zoneDecider := nz(zoneDecider[1], zoneDecider) zoneDecider := zoneDecider == -1 and close > downZoneNew ? 1 : zoneDecider == 1 and close < upZoneNew ? -1 : zoneDecider redZone = zoneDecider == -1 and zoneDecider[1] == 1 greenZone = zoneDecider == 1 and zoneDecider[1] == -1 downZoneColor = zoneDecider == -1 ? color.red : color.gray upZoneColor = zoneDecider == 1 ? color.green : color.gray downZonePlot = plot(zoneDecider == 1 ? na : downZone, style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0), title='Sell') plotshape(redZone ? downZone : na, location=location.absolute, style=shape.diamond, size=size.tiny, color=color.new(color.red, 0), title='Sell') plotshape(redZone ? downZone : na, location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), title='Sell', text='Sell') upZonePlot = plot(zoneDecider == 1 ? upZone : na, style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0), title='Buy') plotshape(greenZone ? upZone : na, location=location.absolute, style=shape.diamond, size=size.tiny, color=color.new(color.green, 0), title='Buy') plotshape(greenZone ? upZone : na, location=location.absolute, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), title='Buy', text='Buy') neutralZonePlot = plot(ohlc4, style=plot.style_circles, linewidth=0, title='Zone Style') fill(neutralZonePlot, downZonePlot, color=downZoneColor, title='Down Zone Color', transp=90) fill(neutralZonePlot, upZonePlot, color=upZoneColor, title='Up Zone Color', transp=90) //1 EMA - Short Term emaLowerPeriod = input.int(9, minval=1, title='EMA Lower Period') emaLower = ta.ema(input(close), emaLowerPeriod) plot(emaLower, color=color.new(color.fuchsia, 0), linewidth=2, title='EMA Lower Period') //2 EMA - Medium Term - Optional showEMA2 = input(false, title='EMA - Medium Term') emaMediumPeriod = input.int(27, minval=1, title='EMA Medium Period') emaMedium = ta.ema(input(close), emaMediumPeriod) plot(showEMA2 and emaMedium ? emaMedium : na, color=color.new(color.aqua, 0), linewidth=2, title='EMA Medium Period') //1 HMA - Long Term hmaLongPeriod = input.int(200, minval=1, title='HMA Long Period') hmaLong = ta.hma(input(close), hmaLongPeriod) plot(hmaLong, color=color.new(color.gray, 0), linewidth=2, title='HMA Long Period') //Bar Color isCloseAbove = close > emaLower and close > hmaLong isCloseBelow = close < emaLower and close < hmaLong isCloseBetween = close > emaLower and close < hmaLong or close < emaLower and close > hmaLong //isBullish = (close > upZone) //isBearish = (close < downZone) isNeutral = close > pSAR_DownValue and isCloseBelow or close < pSAR_DownValue and isCloseAbove //barcolor((isNeutral or isCloseBetween) ? color.yellow: (isCloseBelow and isBearish) ? color.red: (isCloseBelow and isBullish) ? color.orange: (isCloseAbove and isBearish) ? color.lime: (isCloseAbove and isBullish) ? color.green : color.black ) barcolor(isNeutral or isCloseBetween ? color.yellow : isCloseBelow ? color.red : isCloseAbove ? color.green : color.black) //Disclaimer: Idea of publishing this script is to identify the strength of the instrument using multiple confirmation. //Disclaimer: Using this indicator, changing inputs, and trading decisions are upto the users/traders.
ICT Fair Value Gap [LM]
https://www.tradingview.com/script/lh5HrJjj-ICT-Fair-Value-Gap-LM/
lmatl
https://www.tradingview.com/u/lmatl/
1,656
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/ // © lmatl //@version=5 indicator("ICT Fair Value Gap [LM]", "ICT FVG [LM]", overlay=true) // atr settings i_atrLength = input.int(28, 'ATR MA length', group='general settings') i_atrMultiplier = input.float(1.5, 'ATR multiplier', group='general settings') // box settings i_boxCount = input.int(5, 'Box count', minval=1, group='box settings') i_upCandleBoxColor = input.color(color.green, 'Up candle box color', group='box settings') i_downCandleBoxColor = input.color(color.red, 'Down candle box color', group='box settings') i_shrinkBoxes = input(false, 'Shrink where PA touches', group='box settings') upBoxColor = color.new(i_upCandleBoxColor, 70) downBoxColor = color.new(i_downCandleBoxColor, 70) var boxArray = array.new_box() f_isUpCandle(_index) => open[_index] <= close[_index] f_isFairValueGap() => bool bearCondition = close[3] <= high[2] and close[1] <= close[2] and high < low[2] bool bullCondition = close[3] >= low[2] and close[1] >= close[2] and low > high[2] priceDiff = high[1] - low[1] atrValue = ta.atr(i_atrLength) bool middleCandleVolatilityCondition = priceDiff > atrValue * i_atrMultiplier bool isUpCandle = f_isUpCandle(1) bool isGapClosed = isUpCandle ? high[2] >= low : low[2] <= high [isGapClosed, bearCondition, bullCondition, middleCandleVolatilityCondition] f_extendArray(_boxArray) => if array.size(_boxArray) > 0 for i = array.size(_boxArray) - 1 to 0 by 1 boxToExtend = array.get(_boxArray, i) bottom = box.get_bottom(boxToExtend) top = box.get_top(boxToExtend) right = box.get_right(boxToExtend) box.set_right(array.get(_boxArray, i), bar_index) hasClosed = (open <= bottom and high > bottom and high >= top or open >= top and low < top and low <= bottom) if i_shrinkBoxes and open >= top and low < top and low > bottom box.set_top(array.get(_boxArray, i), low) if i_shrinkBoxes and open <= bottom and high > bottom and high < top box.set_bottom(array.get(_boxArray, i), high) if (hasClosed) alert('box has closed') if i_shrinkBoxes and hasClosed box.delete(array.get(_boxArray, i)) array.remove(boxArray, i) [isGapClosed, bearCondition, bullCondition, middleCandleVolatilityCondition] = f_isFairValueGap() bool isFairValueGap = false isFairValueGap := (bearCondition or bullCondition) and not isGapClosed and middleCandleVolatilityCondition and not isFairValueGap[1] if isFairValueGap isUpCandle = f_isUpCandle(1) top = isUpCandle ? low : low[2] bottom = isUpCandle ? high[2] : high fvgBox = box.new(bar_index[1], top, bar_index, bottom, bgcolor=isUpCandle ? upBoxColor : downBoxColor, border_style=line.style_dashed, border_color=isUpCandle ? upBoxColor : downBoxColor, xloc=xloc.bar_index) if array.size(boxArray) >= i_boxCount box.delete(array.shift(boxArray)) array.push(boxArray, fvgBox) f_extendArray(boxArray)
Natenberg's Volatility
https://www.tradingview.com/script/pSa40WxX-Natenberg-s-Volatility/
crypteisfuture
https://www.tradingview.com/u/crypteisfuture/
13
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © crypteisfuture //@version=5 indicator("Natenberg's Volatility") smooth = input.int(14, title = 'SMA Smooth Length') natenberg_daily = ta.stdev( math.log( close / close[1] ), 10 ) * math.sqrt( 365 ) natenberg_weekly = ta.stdev( math.log( close / close[1] ), 10 ) * math.sqrt( 365 / 7 ) volatility_smoothed = ta.sma(natenberg_daily, smooth) plot(natenberg_daily, color = color.new(color.aqua, 0)) plot(volatility_smoothed, color = color.new(color.maroon, 0)) //plot(natenberg_weekly, color = color.new(color.maroon, 0))
Price Region Regression
https://www.tradingview.com/script/f63LYmtL/
dandrideng
https://www.tradingview.com/u/dandrideng/
267
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/ // © dandrideng //@version=5 indicator(title="Price Region Regression", shorttitle="PRR", overlay=true, max_bars_back=1000, max_lines_count=400, max_labels_count=400) import dandrideng/least_squares_regression/1 as lsr //optimized Price Region regression reg_forward = input.int(defval=20, title="Regression Lookback Forward", group="Price Region Regression") min_length = input.int(defval=100, title="Min Regression Length", maxval=500, group="Price Region Regression") max_length = input.int(defval=200, title="Max Regression Length", maxval=500, group="Price Region Regression") length_step = input.int(defval=50, title="Regression Length Step", maxval=500, group="Price Region Regression") std_offset = input.float(defval=2.0, title="Multiply Regression Std", group="Price Region Regression") draw_region = input.bool(defval=true, title="Draw Regression Region", group="Price Region Regression") extend_lines = input(defval=true, title="Extend Lines", group="Price Region Regression") ? extend.right : extend.none int x1 = na int x2 = na float y1 = na float y2 = na float r = 0 float s = 0 float o = na for length = min_length to max_length by length_step tick = array.new_int(length, 0) price = array.new_float(length, 0) for i = 0 to length - 1 array.set(tick, i, i + reg_forward) array.set(price, i, close[i + reg_forward]) [_a, _b, _r, _s] = lsr.basic_lsr(tick, price, length) if r < _r x2 := array.get(tick, 0) x1 := array.get(tick, length - 1) y1 := x1 * _a + _b y2 := x2 * _a + _b r := _r s := _s o := _s * std_offset if draw_region var line reg_mid_line = na line.delete(reg_mid_line) reg_mid_line := line.new(x1=bar_index - x1, y1=y1, x2=bar_index - x2, y2=y2) line.set_width(reg_mid_line, 2) line.set_color(reg_mid_line, color.new(color.purple, 20)) line.set_extend(reg_mid_line, extend_lines) line.set_style(reg_mid_line, line.style_dashed) var line reg_upp_line = na line.delete(reg_upp_line) reg_upp_line := line.new(x1=bar_index - x1, y1=y1 + o, x2=bar_index - x2, y2=y2 + o) line.set_width(reg_upp_line, 2) line.set_color(reg_upp_line, color.new(color.purple, 20)) line.set_extend(reg_upp_line, extend_lines) var line reg_low_line = na line.delete(reg_low_line) reg_low_line := line.new(x1=bar_index - x1, y1=y1 - o, x2=bar_index - x2, y2=y2 - o) line.set_width(reg_low_line, 2) line.set_color(reg_low_line, color.new(color.purple, 20)) line.set_extend(reg_low_line, extend_lines) linefill.new(reg_mid_line, reg_upp_line, color=color.new(color.purple, 90)) linefill.new(reg_mid_line, reg_low_line, color=color.new(color.purple, 90)) var label reg_label = na label.delete(reg_label) reg_label := label.new(x=bar_index - reg_forward, y=y2 + o, textcolor=color.white) label.set_color(reg_label, color.new(color.blue, 50)) label.set_text(reg_label, "LEVEL: " + str.tostring(r, "#.###") + "\nOFFSET: " + str.tostring(o, "#.###") + "\nKLINES: " + str.tostring(x1-x2+1, "#.###")) // reg_mid_plot = plot(draw_region ? y2 : na, linewidth=1, color=color.new(color.blue, 50), offset=-reg_forward) // reg_upp_plot = plot(draw_region ? y2 + o : na, linewidth=2, color=color.new(color.blue, 50), offset=-reg_forward) // reg_low_plot = plot(draw_region ? y2 - o : na, linewidth=2, color=color.new(color.blue, 50), offset=-reg_forward) // fill(reg_mid_plot, reg_upp_plot, color=color.new(color.blue, 95)) // fill(reg_mid_plot, reg_low_plot, color=color.new(color.blue, 95)) //end of file
ema gks
https://www.tradingview.com/script/og6qKeD1-ema-gks/
workrisewr
https://www.tradingview.com/u/workrisewr/
16
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © workrisewr //@version=5 indicator("ema gks", overlay=true) r = ta.ema(close, 9) shortema = ta.ema(close, 9) longema = ta.ema(close, 13) xUp = ta.crossover(shortema, longema) xDn = ta.crossunder(shortema, longema) if xUp alert("Go long (EMA is " + str.tostring(r, "#.00)")) else if xDn alert("Go short (RSI is " + str.tostring(r, "#.00)")) plotchar(xUp, "Go Long", "▲", location.belowbar , color.green, size = size.tiny) plotchar(xDn, "Go Short", "▼", location.abovebar, color.red, size = size.tiny) plot (shortema) plot (longema, color=color.green)
Previous OHLC (Nephew_Sam_)
https://www.tradingview.com/script/gMQB15xA-Previous-OHLC-Nephew-Sam/
nephew_sam_
https://www.tradingview.com/u/nephew_sam_/
1,838
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/ // © Nephew_Sam_ //@version=5 indicator('Previous OHLC (Nephew_Sam_)', overlay=true, max_labels_count=500, max_lines_count=500) // Inputs var GRP1 = "Timeframes" line1 = input.bool(false, title="=============== DAILY ===============", group=GRP1) daily = input.string(title='View', defval='HL', options=['Off', 'HL', 'OC', 'OHLC', 'OHLC + Candle'], group=GRP1) dailyHText = input.string(defval='PDH', title='H', inline="1", group=GRP1) dailyLText = input.string(defval='PDL', title='L', inline="1", group=GRP1) dailyOText = input.string(defval='PDO', title='O', inline="1", group=GRP1) dailyCText = input.string(defval='PDC', title='C', inline="1", group=GRP1) dailyDrawBox = input.bool(false, "Draw pip box", inline="2", group=GRP1) dailyBoxFrom = input.int(5, title='Start', minval=0, inline="2", group=GRP1) dailyBoxTo = input.int(12, title='End', minval=0, inline="2", group=GRP1) line2 = input.bool(false, title="=============== WEEKLY ===============", group=GRP1) weekly = input.string(title='View', defval='Off', options=['Off', 'HL', 'OC', 'OHLC', 'OHLC + Candle'], group=GRP1) weeklyHText = input.string(defval='PWH', title='H', inline="3", group=GRP1) weeklyLText = input.string(defval='PWL', title='L', inline="3", group=GRP1) weeklyCText = input.string(defval='PWC', title='C', inline="3", group=GRP1) weeklyOText = input.string(defval='PWO', title='O', inline="3", group=GRP1) weeklyDrawBox = input.bool(false, "Draw pip box", inline="4", group=GRP1) weeklyBoxFrom = input.int(10, title='Start', minval=0, inline="4", group=GRP1) weeklyBoxTo = input.int(20, title='End', minval=0, inline="4", group=GRP1) line3 = input.bool(false, title="=============== MONTHLY ===============", group=GRP1) monthly = input.string(title='View', defval='Off', options=['Off', 'HL', 'OC', 'OHLC', 'OHLC + Candle'], group=GRP1) monthlyHText = input.string(defval='PMH', title='H', inline="5", group=GRP1) monthlyLText = input.string(defval='PML', title='L', inline="5", group=GRP1) monthlyOText = input.string(defval='PMO', title='O', inline="5", group=GRP1) monthlyCText = input.string(defval='PMC', title='C', inline="5", group=GRP1) monthlyDrawBox = input.bool(false, "Draw pip box", inline="6", group=GRP1) monthlyBoxFrom = input.int(20, title='Start', minval=0, inline="6", group=GRP1) monthlyBoxTo = input.int(40, title='End', minval=0, inline="6", group=GRP1) line4 = input.bool(false, title="=============== CUSTOM ===============", group=GRP1) custom_timeframe = input.timeframe('240', title='View', inline='7', group=GRP1) custom = input.string(title='', defval='Off', options=['Off', 'HL', 'OC', 'OHLC', 'OHLC + Candle'], inline='7', group=GRP1) customHText = input.string(defval='PCH', title='H', inline="8", group=GRP1) customLText = input.string(defval='PCL', title='L', inline="8", group=GRP1) customOText = input.string(defval='PCO', title='O', inline="8", group=GRP1) customCText = input.string(defval='PCC', title='C', inline="8", group=GRP1) customDrawBox = input.bool(false, "Draw pip box", inline="9", group=GRP1) customBoxFrom = input.int(3, title='Start', minval=0, inline="9", group=GRP1) customBoxTo = input.int(10, title='End', minval=0, inline="9", group=GRP1) line5 = input.bool(false, title="=======================================", group=GRP1) var GRP2 = "Lines + Label Settings" showOne = input.bool(false, 'Show only 1 previous OHLC?', group = GRP2) _offset = input.int(1, title='Offset', minval=0, maxval=2) showLabels = input(true, 'Show Labels', group=GRP2) labelPosition = input.string(title='Label Position', defval='End', options=['Start', 'End'], group=GRP2) o_color = input.color(color.new(color.gray, 50), "Open Color", inline="1", group = GRP2) c_color = input.color(color.new(color.gray, 50), "Close Color", inline="1", group = GRP2) h_color = input.color(color.new(color.red, 50), "High Color", inline="2", group = GRP2) l_color = input.color(color.new(color.lime, 50), "Low Color", inline="2", group = GRP2) box_h_color = input.color(color.new(color.red, 80), "Box H Color", inline="3", group = GRP2) box_l_color = input.color(color.new(color.lime, 80), "Box L Color", inline="3", group = GRP2) // FUNCTIONS t = time(custom_timeframe) TRANSPARENT = color.new(color.white, 100) isNewbar = not na(t) and (na(t[1]) or t > t[1]) tfInMinutes(simple string tf = "") => float chartTf = timeframe.multiplier * ( timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) float result = tf == "" ? chartTf : request.security(syminfo.tickerid, tf, chartTf) inTimeframe(_t) => tfInMinutes(_t) > tfInMinutes(timeframe.period) GetPipSize() => syminfo.mintick * (syminfo.type == "forex" ? 10 : 1) // Range reso(exp, res) => request.security(syminfo.tickerid, res, exp, lookahead=barmerge.lookahead_on) getData(_t, _var) => o = reso(open[_offset], _t) h = reso(high[_offset], _t) l = reso(low[_offset], _t) c = reso(close[_offset], _t) show = _var != "Off" and inTimeframe(_t) show_candle = show and str.contains(_var, "Candle") _time = time(_t) newbar = na(_time[1]) or _time > _time[1] hl = _var == 'HL' or _var == 'OHLC' or _var == 'OHLC + Candle' oc = _var == 'OC' or _var == 'OHLC' or _var == 'OHLC + Candle' [o, h, l, c, show, show_candle, newbar, hl, oc] labelPos(_tf) => labelPosition == "End" ? time_close(_tf) : time // ---------- Daily ---------- var line d_o_line = na var line d_h_line = na var line d_l_line = na var line d_c_line = na var label d_o_label = na var label d_h_label = na var label d_l_label = na var label d_c_label = na var box d_h_box = na var box d_l_box = na [d_o, d_h, d_l, d_c, d_show, d_show_candle, d_newbar, d_hl, d_oc] = getData("D", daily) plotcandle(d_show_candle and d_newbar ? d_o : na, d_h, d_l, d_c, color=d_c >= d_o ? color.lime : color.red) if d_newbar and d_show if showOne line.delete(d_o_line) line.delete(d_h_line) line.delete(d_l_line) line.delete(d_c_line) label.delete(d_o_label) label.delete(d_h_label) label.delete(d_l_label) label.delete(d_c_label) box.delete(d_h_box) box.delete(d_l_box) if d_oc d_o_line := line.new(x1=time, y1=d_o, x2=time_close("D"), y2=d_o, xloc=xloc.bar_time, style=line.style_solid, color=o_color) d_c_line := line.new(x1=time, y1=d_c, x2=time_close("D"), y2=d_c, xloc=xloc.bar_time, style=line.style_solid, color=c_color) if showLabels d_o_label := label.new(x=labelPos("D"), y= d_o, xloc=xloc.bar_time, text=dailyOText + " ", textcolor=o_color, style=label.style_none) d_c_label := label.new(x=labelPos("D"), y= d_c, xloc=xloc.bar_time, text=dailyCText + " ", textcolor=c_color, style=label.style_none) if d_hl d_h_line := line.new(x1=time, y1=d_h, x2=time_close("D"), y2=d_h, xloc=xloc.bar_time, style=line.style_solid, color=h_color) d_l_line := line.new(x1=time, y1=d_l, x2=time_close("D"), y2=d_l, xloc=xloc.bar_time, style=line.style_solid, color=l_color) if showLabels d_h_label := label.new(x=labelPos("D"), y= d_h, xloc=xloc.bar_time, text=dailyHText + " ", textcolor=h_color, style=label.style_none) d_l_label := label.new(x=labelPos("D"), y= d_l, xloc=xloc.bar_time, text=dailyLText + " ", textcolor=l_color, style=label.style_none) if dailyDrawBox boxTL = d_h + (dailyBoxFrom * GetPipSize()) boxTH = d_h + (dailyBoxTo * GetPipSize()) d_h_box := box.new(time, boxTH, time_close("D"), boxTL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_h_color) boxBH = d_l - (dailyBoxFrom * GetPipSize()) boxBL = d_l - (dailyBoxTo * GetPipSize()) d_l_box := box.new(time, boxBH, time_close("D"), boxBL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_l_color) // ---------- Weekly ---------- var line w_o_line = na var line w_h_line = na var line w_l_line = na var line w_c_line = na var label w_o_label = na var label w_h_label = na var label w_l_label = na var label w_c_label = na var box w_h_box = na var box w_l_box = na [w_o, w_h, w_l, w_c, w_show, w_show_candle, w_newbar, w_hl, w_oc] = getData("W", weekly) plotcandle(w_show_candle and w_newbar ? w_o : na, w_h, w_l, w_c, color=w_c >= w_o ? color.lime : color.red) if w_newbar and w_show if showOne line.delete(w_o_line) line.delete(w_h_line) line.delete(w_l_line) line.delete(w_c_line) label.delete(w_o_label) label.delete(w_h_label) label.delete(w_l_label) label.delete(w_c_label) box.delete(w_h_box) box.delete(w_l_box) if w_oc w_o_line := line.new(x1=time, y1=w_o, x2=time_close("W"), y2=w_o, xloc=xloc.bar_time, style=line.style_solid, color=o_color) w_c_line := line.new(x1=time, y1=w_c, x2=time_close("W"), y2=w_c, xloc=xloc.bar_time, style=line.style_solid, color=c_color) if showLabels w_o_label := label.new(x=labelPos("W"), y= w_o, xloc=xloc.bar_time, text=weeklyOText + " ", textcolor=o_color, style=label.style_none) w_c_label := label.new(x=labelPos("W"), y= w_c, xloc=xloc.bar_time, text=weeklyCText + " ", textcolor=c_color, style=label.style_none) if w_hl w_h_line := line.new(x1=time, y1=w_h, x2=time_close("W"), y2=w_h, xloc=xloc.bar_time, style=line.style_solid, color=h_color) w_l_line := line.new(x1=time, y1=w_l, x2=time_close("W"), y2=w_l, xloc=xloc.bar_time, style=line.style_solid, color=l_color) if showLabels w_h_label := label.new(x=labelPos("W"), y= w_h, xloc=xloc.bar_time, text=weeklyHText + " ", textcolor=h_color, style=label.style_none) w_l_label := label.new(x=labelPos("W"), y= w_l, xloc=xloc.bar_time, text=weeklyLText + " ", textcolor=l_color, style=label.style_none) if weeklyDrawBox boxTL = w_h + (weeklyBoxFrom * GetPipSize()) boxTH = w_h + (weeklyBoxTo * GetPipSize()) w_h_box := box.new(time, boxTH, time_close("W"), boxTL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_h_color) boxBH = w_l - (weeklyBoxFrom * GetPipSize()) boxBL = w_l - (weeklyBoxTo * GetPipSize()) w_l_box := box.new(time, boxBH, time_close("W"), boxBL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_l_color) // ---------- Monthly ---------- var line m_o_line = na var line m_h_line = na var line m_l_line = na var line m_c_line = na var label m_o_label = na var label m_h_label = na var label m_l_label = na var label m_c_label = na var box m_h_box = na var box m_l_box = na [m_o, m_h, m_l, m_c, m_show, m_show_candle, m_newbar, m_hl, m_oc] = getData("M", monthly) plotcandle(m_show_candle and m_newbar ? m_o : na, m_h, m_l, m_c, color=m_c >= m_o ? color.lime : color.red) if m_newbar and m_show if showOne line.delete(m_o_line) line.delete(m_h_line) line.delete(m_l_line) line.delete(m_c_line) label.delete(m_o_label) label.delete(m_h_label) label.delete(m_l_label) label.delete(m_c_label) box.delete(m_h_box) box.delete(m_l_box) if m_oc m_o_line := line.new(x1=time, y1=m_o, x2=time_close("M"), y2=m_o, xloc=xloc.bar_time, style=line.style_solid, color=o_color) m_c_line := line.new(x1=time, y1=m_c, x2=time_close("M"), y2=m_c, xloc=xloc.bar_time, style=line.style_solid, color=c_color) if showLabels m_o_label := label.new(x=labelPos("M"), y= m_o, xloc=xloc.bar_time, text=monthlyOText + " ", textcolor=o_color, style=label.style_none) m_c_label := label.new(x=labelPos("M"), y= m_c, xloc=xloc.bar_time, text=monthlyCText + " ", textcolor=c_color, style=label.style_none) if m_hl m_h_line := line.new(x1=time, y1=m_h, x2=time_close("M"), y2=m_h, xloc=xloc.bar_time, style=line.style_solid, color=h_color) m_l_line := line.new(x1=time, y1=m_l, x2=time_close("M"), y2=m_l, xloc=xloc.bar_time, style=line.style_solid, color=l_color) if showLabels m_h_label := label.new(x=labelPos("M"), y= m_h, xloc=xloc.bar_time, text=monthlyHText + " ", textcolor=h_color, style=label.style_none) m_l_label := label.new(x=labelPos("M"), y= m_l, xloc=xloc.bar_time, text=monthlyLText + " ", textcolor=l_color, style=label.style_none) if monthlyDrawBox boxTL = m_h + (monthlyBoxFrom * GetPipSize()) boxTH = m_h + (monthlyBoxTo * GetPipSize()) m_h_box := box.new(time, boxTH, time_close("M"), boxTL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_h_color) boxBH = m_l - (monthlyBoxFrom * GetPipSize()) boxBL = m_l - (monthlyBoxTo * GetPipSize()) m_l_box := box.new(time, boxBH, time_close("M"), boxBL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_l_color) // ---------- Custom ---------- var line c_o_line = na var line c_h_line = na var line c_l_line = na var line c_c_line = na var label c_o_label = na var label c_h_label = na var label c_l_label = na var label c_c_label = na var box c_h_box = na var box c_l_box = na [c_o, c_h, c_l, c_c, c_show, c_show_candle, c_newbar, c_hl, c_oc] = getData(custom_timeframe, custom) plotcandle(c_show_candle and c_newbar ? c_o : na, c_h, c_l, c_c, color=c_c >= c_o ? color.lime : color.red) if c_newbar and c_show if showOne line.delete(c_o_line) line.delete(c_h_line) line.delete(c_l_line) line.delete(c_c_line) label.delete(c_o_label) label.delete(c_h_label) label.delete(c_l_label) label.delete(c_c_label) box.delete(c_h_box) box.delete(c_l_box) if c_oc c_o_line := line.new(x1=time, y1=c_o, x2=time_close(custom_timeframe), y2=c_o, xloc=xloc.bar_time, style=line.style_solid, color=o_color) c_c_line := line.new(x1=time, y1=c_c, x2=time_close(custom_timeframe), y2=c_c, xloc=xloc.bar_time, style=line.style_solid, color=c_color) if showLabels c_o_label := label.new(x=time_close(custom_timeframe), y= c_o, xloc=xloc.bar_time, text=customOText + " ", textcolor=o_color, style=label.style_none) c_c_label := label.new(x=time_close(custom_timeframe), y= c_c, xloc=xloc.bar_time, text=customCText + " ", textcolor=c_color, style=label.style_none) if c_hl c_h_line := line.new(x1=time, y1=c_h, x2=time_close(custom_timeframe), y2=c_h, xloc=xloc.bar_time, style=line.style_solid, color=h_color) c_l_line := line.new(x1=time, y1=c_l, x2=time_close(custom_timeframe), y2=c_l, xloc=xloc.bar_time, style=line.style_solid, color=l_color) if showLabels c_h_label := label.new(x=time_close(custom_timeframe), y= c_h, xloc=xloc.bar_time, text=customHText + " ", textcolor=h_color, style=label.style_none) c_l_label := label.new(x=time_close(custom_timeframe), y= c_l, xloc=xloc.bar_time, text=customLText + " ", textcolor=l_color, style=label.style_none) if customDrawBox boxTL = c_h + (customBoxFrom * GetPipSize()) boxTH = c_h + (customBoxTo * GetPipSize()) c_h_box := box.new(time, boxTH, time_close(custom_timeframe), boxTL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_h_color) boxBH = c_l - (customBoxFrom * GetPipSize()) boxBL = c_l - (customBoxTo * GetPipSize()) c_l_box := box.new(time, boxBH, time_close(custom_timeframe), boxBL, xloc=xloc.bar_time, border_color=TRANSPARENT, bgcolor=box_l_color) // Alerts alertcondition(d_o, title='Daily Open Price', message='Crossing previous Daily Open price on {{ticker}}') alertcondition(d_c, title='Daily Close Price', message='Crossing previous Daily Close price on {{ticker}}') alertcondition(d_h, title='Daily High Price', message='Crossing previous Daily High price on {{ticker}}') alertcondition(d_l, title='Daily Low Price', message='Crossing previous Daily Low price on {{ticker}}') alertcondition(w_o, title='Weekly Open Price', message='Crossing previous Weekly Open price on {{ticker}}') alertcondition(w_c, title='Weekly Close Price', message='Crossing previous Weekly Close price on {{ticker}}') alertcondition(w_h, title='Weekly High Price', message='Crossing previous Weekly High price on {{ticker}}') alertcondition(w_l, title='Weekly Low Price', message='Crossing previous Weekly Low price on {{ticker}}') alertcondition(m_o, title='Monthly Open Price', message='Crossing previous Monthly Open price on {{ticker}}') alertcondition(m_c, title='Monthly Close Price', message='Crossing previous Monthly Close price on {{ticker}}') alertcondition(m_h, title='Monthly High Price', message='Crossing previous Monthly High price on {{ticker}}') alertcondition(m_l, title='Monthly Low Price', message='Crossing previous Monthly Low price on {{ticker}}') alertcondition(c_o, title='Custom Open Price', message='Crossing previous {{interval}} Open price on {{ticker}}') alertcondition(c_c, title='Custom Close Price', message='Crossing previous {{interval}} Close price on {{ticker}}') alertcondition(c_h, title='Custom High Price', message='Crossing previous {{interval}} High price on {{ticker}}') alertcondition(c_l, title='Custom Low Price', message='Crossing previous {{interval}} Low price on {{ticker}}')
Position Sizing Calculator
https://www.tradingview.com/script/BrrtvU2R/
AktieAI
https://www.tradingview.com/u/AktieAI/
398
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © AktieAI // This calculator will determine your position size per trade, profit, loss, risk/reward ratio and leverage if any. // It will calculate your leverage if you are trading financial instruments e.g. Mini Futures, Turbo Warrants etc. that have a financing level. //@version=5 // Variables float leverage = na float stopLossProcent = na float positionSize = na float profit = na float loss = na float riskReward = na // User inputs indicator('Position Sizing Calculator', 'Position Sizing', overlay=true) position = input.string(defval='Long', title='Position Type', options=['Long', 'Short']) accountBalance = input.float(defval=100000, title='Account Balance', minval=1, step=0.01) riskPerTrade = input.float(defval=3.0, title='Risk Per Trade %', minval=0.25, step=0.01) / 100 financingLevel = input.float(defval=0, title='Financing Level', minval=0, step=0.01) entryPrice = input.float(defval=100.0, title='Entry Price', step=0.01) targetPrice = input.float(defval=110.0, title='Target Price', step=0.01) stopLossPrice = input.float(defval=95.0, title='Stop-Loss Price', step=0.01) textColor = input.color(color.white, 'Text Color') backgroundColor= input.color (#37383b, 'Background Color') placement = input.string(position.top_right, 'Placement', options = [position.bottom_right, position.bottom_left, position.top_right, position.top_center, position.bottom_center]) // Calculations depending on Long/Short position if position == 'Long' riskReward := (targetPrice - entryPrice) / (entryPrice - stopLossPrice) leverage := financingLevel > 0 ? 0.01 * entryPrice / (entryPrice - financingLevel) * 100 : 1 stopLossProcent := 1 - stopLossPrice / entryPrice else riskReward := (entryPrice - targetPrice) / (stopLossPrice - entryPrice) leverage := financingLevel > 0 ? 0.01 * entryPrice / (financingLevel - entryPrice) * 100 : 1 stopLossProcent := stopLossPrice / entryPrice - 1 // Round to 2 decimals riskReward := math.round(riskReward * 100) / 100 // Calculate Position Size positionSize := math.round(accountBalance * riskPerTrade / (stopLossProcent * leverage), 2) // Adjust Position Size if positionSize > accountBalance // if it exeeds account balance positionSize := accountBalance else if positionSize < accountBalance * riskPerTrade // if it is less than the risk per trade size positionSize := accountBalance * riskPerTrade // Calculate Profit if financingLevel == 0 // if there is no leverage profit := position == 'Long' ? positionSize * ((targetPrice - entryPrice) / (entryPrice)) : positionSize * ((entryPrice - targetPrice) / (entryPrice)) else // if there is leverage profit := position == 'Long' ? positionSize * ((targetPrice - entryPrice) / (entryPrice - financingLevel)) : positionSize * ((entryPrice - targetPrice) / (financingLevel - entryPrice)) // Calculate Loss if financingLevel == 0 // if there is no leverage // Using a different type of formula here, which is more compact loss := position == 'Long' ? positionSize - (positionSize * (stopLossPrice / entryPrice)) : positionSize * ((stopLossPrice / entryPrice) - 1) else // if there is leverage loss := position == 'Long' ? positionSize * ((entryPrice - stopLossPrice) / (entryPrice - financingLevel)) : positionSize * ((stopLossPrice - entryPrice) / (financingLevel - entryPrice)) //Table table resultTable = table.new(placement, 1, 7, border_width=1) if barstate.islast table.cell(resultTable, 0,0, ' ', text_color = textColor, bgcolor = na) table.cell(resultTable, 0,1, 'Acc. Balance: ' + str.tostring(accountBalance), text_color = textColor, bgcolor = backgroundColor) table.cell(resultTable, 0,2, 'Position Size: ' + str.tostring(positionSize), text_color = textColor, bgcolor = backgroundColor) table.cell(resultTable, 0,3, 'Profit: ' + str.tostring(math.round(profit, 2)), text_color = textColor, bgcolor = backgroundColor) table.cell(resultTable, 0,4, 'Loss: ' + str.tostring(math.round(loss, 2)), text_color = textColor, bgcolor = backgroundColor) table.cell(resultTable, 0,5, 'Leverage: 1:' + str.tostring(math.round(leverage)), text_color = textColor, bgcolor = backgroundColor) table.cell(resultTable, 0,6, 'R/R Ratio: ' + str.tostring(riskReward), text_color = textColor, bgcolor = backgroundColor)
Ema Change speed special
https://www.tradingview.com/script/bsxQJkpH/
werrasd508
https://www.tradingview.com/u/werrasd508/
55
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/ // © werrasd508 //@version=4 study("Ema Change speed special") e1= input(title="e1", defval=400) ema1= ema(close,e1) ema1_1= ema(close[1],e1) diff1=ema1-ema1_1 clr = diff1 > 0 ? color.green : color.red hline(0, "Baseline", color.white) plot(diff1, color=clr, linewidth=2)
Ratings Algo
https://www.tradingview.com/script/zDZkdaLn-Ratings-Algo/
Jaerevan47
https://www.tradingview.com/u/Jaerevan47/
233
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/ // © Jaerevan47 //@version=5 indicator("Ratings Algo", overlay = true) maweight = input(5, title = "MA Weighting") oscweight = input(5, title = "OSC Weighting") threshold = input(2.0, title = "Threshold") longma = if ta.sma(close,50) > ta.sma(close, 200) 1 else if ta.sma(close,50) < ta.sma(close, 200) -1 else 0 shortma = if ta.sma(close,10) > ta.sma(close, 20) 1 else if ta.sma(close,10) < ta.sma(close, 20) -1 else 0 lsma = if ta.linreg(close, 10, 0) > ta.linreg(close, 20, 0) 1 else if ta.linreg(close, 10, 0) < ta.linreg(close, 20, 0) -1 else 0 ema = if ta.ema(close,10) > ta.ema(close, 20) 1 else if ta.ema(close,10) < ta.ema(close, 20) -1 else 0 [macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9) macd = if macdLine > 0 and macdLine > signalLine 1 else if macdLine < 0 and macdLine < signalLine -1 else 0 lsma2 = ta.linreg(ta.ema(close, 5), 10, 0) alma = ta.alma(close, 10, 0.85, 6) arnold = if lsma2 > lsma2[1] and alma > alma[1] 1 else if lsma2 < lsma2[1] and alma < alma[1] -1 else 0 obv = if ta.linreg(ta.obv, 10, 0) > ta.linreg(ta.obv, 20, 0) 1 else if ta.linreg(ta.obv, 10, 0) < ta.linreg(ta.obv, 20, 0) -1 else 0 pvt = if ta.linreg(ta.pvt, 10, 0) > ta.linreg(ta.pvt, 20, 0) 1 else if ta.linreg(ta.pvt, 10, 0) < ta.linreg(ta.pvt, 20, 0) -1 else 0 up = ta.change(high) down = -ta.change(low) plusDM = na(up) ? na : (up > down and up > 0 ? up : 0) trur = ta.rma(ta.tr, 14) plus = fixnan(100 * ta.rma(plusDM, 14) / trur) minusDM = na(down) ? na : (down > up and down > 0 ? down : 0) minus = fixnan(100 * ta.rma(minusDM, 14) / trur) dmi = if plus > minus 1 else if plus < minus -1 else 0 rsi = if ta.rsi(close, 14) > 50 1 else if ta.rsi(close, 14) < 50 -1 else 0 high_ = ta.highest(hl2, 9) low_ = ta.lowest(hl2, 9) round_(val) => val > .99 ? .999 : val < -.99 ? -.999 : val value = 0.0 value := round_(.66 * ((hl2 - low_) / (high_ - low_) - .5) + .67 * nz(value[1])) fish1 = 0.0 fish1 := .5 * math.log((1 + value) / (1 - value)) + .5 * nz(fish1[1]) fish2 = fish1[1] fish = if fish1 > fish2 1 else if fish2 > fish1 -1 else 0 rating = maweight*(longma + shortma + lsma + ema + arnold)/5 + oscweight*(macd + obv + pvt + dmi + rsi + fish)/6 colorr = rating > threshold and rating < 2.5*threshold ? color.teal : rating > 2.5*threshold ? #00FF00 : rating < -threshold and rating > -2.5 * threshold ? color.orange : rating < -2.5*threshold ? #FF0000 : color.purple plotcandle(open, high, low, close, color = colorr, wickcolor = colorr) var ratings = table.new(position = position.bottom_left, columns = 20, rows = 3, bgcolor = color.white, border_color = #6A0DAD, border_width = 2) table.cell(table_id = ratings, column = 1, row = 1, text = "50/200ma") table.cell(table_id = ratings, column = 1, row = 2, text = longma == 1 ? "Buy" : longma == -1 ? "Sell" : "Hold", bgcolor = longma == 1 ? #00FF00 : longma == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 2, row = 1, text = "10/20ma") table.cell(table_id = ratings, column = 2, row = 2, text = shortma == 1 ? "Buy" : shortma == -1 ? "Sell" : "Hold", bgcolor = shortma== 1 ? #00FF00 : shortma == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 3, row = 1, text = "10/20lsma") table.cell(table_id = ratings, column = 3, row = 2, text = lsma == 1 ? "Buy" : lsma == -1 ? "Sell" : "Hold", bgcolor = lsma == 1 ? #00FF00 : lsma == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 4, row = 1, text = "10/20ema") table.cell(table_id = ratings, column = 4, row = 2, text = ema == 1 ? "Buy" : ema == -1 ? "Sell" : "Hold", bgcolor = ema == 1 ? #00FF00 : ema == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 5, row = 1, text = "arnold") table.cell(table_id = ratings, column = 5, row = 2, text = arnold == 1 ? "Buy" : arnold == -1 ? "Sell" : "Hold", bgcolor = arnold== 1 ? #00FF00 : arnold == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 6, row = 1, text = "macd") table.cell(table_id = ratings, column = 6, row = 2, text = macd == 1 ? "Buy" : macd == -1 ? "Sell" : "Hold", bgcolor = macd == 1 ? #00FF00 : macd == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 7, row = 1, text = "obv") table.cell(table_id = ratings, column = 7, row = 2, text = obv == 1 ? "Buy" : obv == -1 ? "Sell" : "Hold", bgcolor = obv == 1 ? #00FF00 : obv == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 8, row = 1, text = "pvt") table.cell(table_id = ratings, column = 8, row = 2, text = pvt == 1 ? "Buy" : pvt == -1 ? "Sell" : "Hold", bgcolor = pvt == 1 ? #00FF00 : pvt == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 9, row = 1, text = "dmi") table.cell(table_id = ratings, column = 9, row = 2, text = dmi == 1 ? "Buy" : dmi == -1 ? "Sell" : "Hold", bgcolor = dmi == 1 ? #00FF00 : dmi == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 10, row = 1, text = "rsi") table.cell(table_id = ratings, column = 10, row = 2, text = rsi == 1 ? "Buy" : rsi == -1 ? "Sell" : "Hold", bgcolor = rsi == 1 ? #00FF00 : rsi == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 11, row = 1, text = "fish") table.cell(table_id = ratings, column = 11, row = 2, text = fish == 1 ? "Buy" : fish == -1 ? "Sell" : "Hold", bgcolor = fish == 1 ? #00FF00 : fish == -1 ? #FF0000 : #FFFF00) table.cell(table_id = ratings, column = 12, row = 1, text = "Total" + "/" + str.tostring(maweight + oscweight)) table.cell(table_id = ratings, column = 12, row = 2, text = str.tostring(rating), bgcolor = color.white) Buy = colorr == #00FF00 and colorr[1] != #00FF00 Sell= colorr == #FF0000 and colorr[1] != #FF0000 Exit = colorr[1] == #00FF00 and colorr != #00FF00 or colorr[1] == #FF0000 and colorr != #FF0000 plotshape(Buy, title = "Buy", style = shape.labelup, location = location.belowbar, color = #00FF00, text = "STRONG", textcolor = color.white) plotshape(Sell, title = "Sell", style = shape.labeldown, location = location.abovebar, color = #FF0000, text = "STRONG", textcolor = color.white) plotshape(Exit, title = "Exit", style = shape.xcross, location = location.abovebar, color = #00E2FF, text = "", textcolor = color.white) plot(rating, display = display.none) plot(0, display = display.none) mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") basis = ta.sma(close, 20) dev = mult * ta.stdev(close, 20) upper = basis + dev lower = basis - dev upper2 = basis + 2*dev lower2 = basis - 2*dev p1 = plot(upper, display = display.none) p2 = plot(upper2, display = display.none) p3 = plot(lower, display = display.none) p4 = plot(lower2, display = display.none) fill(p1, p2, color = color.rgb(155,0,0,50)) fill(p3, p4, color = color.rgb(0,155,0,50))
ICT Index Futures Vertical Lines
https://www.tradingview.com/script/pTcmD9mD-ICT-Index-Futures-Vertical-Lines/
ArdOfCrypto
https://www.tradingview.com/u/ArdOfCrypto/
1,388
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/ // © ArdOfCrypto // //@version=5 // // Last working production version: 378.0 // 13-June-2023 indicator("ICT Index Futures Vertical Lines", shorttitle="ICT Index Futures" ,overlay=true, max_lines_count=500, max_labels_count=500) // Sessions and inputs i_timezone = input.string(defval="America/New_York", title="Timezone Selection", options=["GMT", "America/Los_Angeles", "America/Phoenix", "America/Vancouver", "America/El_Salvador", "America/Bogota", "America/Chicago", "America/New_York", "America/Toronto", "America/Argentina/Buenos_Aires", "America/Sao_Paulo", "Etc/UTC", "Europe/Amsterdam", "Europe/London", "Europe/Berlin", "Europe/Madrid", "Europe/Paris", "Europe/Warsaw", "Europe/Athens", "Europe/Moscow", "Asia/Tehran", "Asia/Dubai", "Asia/Ashkhabad", "Asia/Kolkata", "Asia/Almaty", "Asia/Bangkok", "Asia/Hong_Kong", "Asia/Shanghai", "Asia/Singapore", "Asia/Taipei", "Asia/Seoul", "Asia/Tokyo", "Australia/ACT", "Australia/Adelaide", "Australia/Brisbane", "Australia/Sydney", "Pacific/Auckland", "Pacific/Fakaofo", "Pacific/Chatham", "Pacific/Honolulu"], tooltip="Select the Exchange Timezone, or your own. Whatever works best for you.", group="Global Settings") i_showDaysDraw = input.int(title="Show Drawings of last # Session Days", defval=1, minval=0, maxval=100, group="Global Settings", tooltip="Remove all drawings older than x days. 0 = Only today's session") // Use in combination with the housekeeping function. var TodayStart = time // Store the timestamp when a new day starts showDOW = input.bool(defval=true, title="Show Day of Week", tooltip="Displays the weekday at the bottom of the chart", group="Global Settings", inline="DOW") // Shows the weekdays at the bottom of the screen i_DOWCol = input.color(title="",tooltip="Change the color of the weekday text", defval=color.black, group="Global Settings", inline="DOW") // Color setting for Weekday text inputMaxInterval = input.int(30, title="Hide indicator above specified time", tooltip="Above 30 minutes the chart will become messy and unreadable", group="Global Settings") // Input for max timeframe to show indicator showIndicator = (timeframe.multiplier <= inputMaxInterval) and (timeframe.isintraday) // If current timeframe is lower or equal to input then showIndicator = true // Drawings: Labels and Lines group_draw = "Line and Label Style Settings" showLabels = input.bool(defval=true, title="Show labels on horizontal Lines ", tooltip="Show Session Labels on every line", group=group_draw, inline="labels") // Toggle display of labels and tooltips on price levels showCaptions = input.bool(defval=false, title="Show label text", tooltip="Show Session Labels on every price line with or without captions", group=group_draw, inline="labels") // Toggle captions on labels i_LabelCol = input.color(title="Label Color", defval=color.new(color.gray, 70), group=group_draw, inline="labelcol") // Set the color of the labels on levels i_LabelTextcol = input.color(title="Label Text Color", defval=color.new(color.white,0), group=group_draw, inline="labelcol", tooltip="Color settings for the horizontal priceline labels") // Set the textcolor of the labels on levels i_linestyle = input.string(title="Vertical Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)"], defval="solid (─)",group=group_draw, inline="Line") // Default value is solid to avoid drawing over wicks i_lineWidth = input.int(title="Width", defval=1, minval=1, maxval=5, group=group_draw, inline="Line", tooltip="Linestyle settings for the vertical dividers") // Set the linewidth of the vertical lines i_lineExtend = input.bool(title="Extend", defval=true, group=group_draw, inline="Line", tooltip="Extend the vertical dividers or only to the high an low of the day") // Extend the lines or not i_linestyleLevels = input.string(title="Horizontal Line Style", options=["solid (─)", "dotted (┈)", "dashed (╌)"], defval="dashed (╌)", group=group_draw, inline="HLine") // Default value is dashed for price levels i_lineWidthLevels = input.int(title="Width", defval=1, minval=1, maxval=5, group=group_draw, inline="HLine", tooltip="Linestyle settings for the horitontal price levels") // Set the linewidth of the horizontal lines // Daily Session settings group_daily = "Daily Session" i_DailySession = input.session(title="Daily High/Low Time Window", defval="0000-1700:1234567", group=group_daily, tooltip="Scan for High and Low of the day during this time window") // Daily Session, Every day DailySession = time(timeframe.period, i_DailySession, i_timezone) // Calculate time for the Globex/Overnight session. var float Daily_hi = na // Daily High var Daily_hi_time = time // Store High's timestamp var float Daily_lo = na // Daily Low var Daily_lo_time = time // Store Low's timestamp showDailyHigh = input.bool(defval=true, title="Show Today's High", group=group_daily, inline="High") i_DailyHighCol = input.color(title="", defval=color.new(color.lime,0), group=group_daily, inline="High") showDailyLow = input.bool(defval=true, title="Show Today's Low", group=group_daily, inline="High") i_DailyLowCol = input.color(title="", tooltip="Today's High and Low Line Color", defval=color.new(color.lime,0), group=group_daily, inline="High") var DailyHighLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyHighCol, width=i_lineWidthLevels) // Today's High Price level line var DailyHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Today's High Price label var DailyLowLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyLowCol, width=i_lineWidthLevels) // Today's Low Price level line var DailyLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Today's Low Price label // PD High and PD Low var float PD_hi = na // Previous Daily High var float PD_lo = na // Previous Daily Low var PD_hi_time = time // Previous Daily High timestamp var PD_lo_time = time // Previous Daily Low timestamp extendPDHL = input.bool(defval=true, title="Extend previous Day's High and Low", group=group_daily, tooltip="Extend the PD High and PD Low line all to the end of the chart") var PDHighLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyHighCol, width=i_lineWidthLevels) // PD's High Price level line var PDHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // PD's High Price label var PDLowLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_DailyLowCol, width=i_lineWidthLevels) // PD's Low Price level line var PDLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // PD's Low Price label var DailySessionStart = time // To register the timestamp when the Daily Session begins // Globex (or Overnight) session settings and inputs showGlobex = input.bool(defval=true, title="Show Start Globex Overnight", group="Globex Session Settings", inline="GS1") // Show Globex Vertical Starting Line i_GlobexSessionCol = input.color(title="", tooltip="Show Globex/Overnight Starting Line", defval=color.new(color.blue,0), group="Globex Session Settings", inline="GS1") // Globex Session Color setting showGlobexDrawings = input.bool(defval=true, title="Show Globex/Overnight Levels", group="Globex Session Settings", inline="GS2") // Show Globex price levels i_GlobexLevelCol = input.color(title="", tooltip="Show Globex/Overnight High and Low", defval=color.new(color.gray,0), group="Globex Session Settings", inline="GS2") // Globex (Overnight) Session, color setting for level lines showGlobexOpenLine = input.bool(defval=true, title="Show Globex/Overnight Opening Price", group="Globex Session Settings", inline="GS3") // Show Globex Open price level i_GlobexOpenCol = input.color(title="", tooltip="Show Globex/Overnight Open priceline", defval=color.new(color.yellow,0), group="Globex Session Settings", inline="GS3") // Globex (Overnight) Session, color setting for Open price lines i_GlobexSession = input.session(title="Globex/Overnight Time Window", defval="1700-0830:1234567", group="Globex Session Settings") // Globex (Overnight) Session, Monday - Friday 17:00 - 0830. Globex opens at 5pm CST and closes when the US session starts 8:30CST. GlobexSession = time(timeframe.period, i_GlobexSession, i_timezone) // Calculate time for the Globex/Overnight session. var float Globex_open = na // Store the Globex Opening price var float Globex_hi = na // High for the Globex Session var float Globex_lo = na // Low for the Globex Session var Globex_line = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexOpenCol, width=i_lineWidthLevels) // Globex Start Vertical line var Globex_line_open= line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexOpenCol, width=i_lineWidthLevels) // Globex Open Price line var Globex_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol, width=i_lineWidthLevels) // Globex High line var Globex_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_GlobexLevelCol, width=i_lineWidthLevels) // Globex Low line var GlobexOpenLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Globex Open Price label var GlobexHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Globex High Price label var GlobexLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Globex Low Price label var GlobexSessionStart = time // To register the timestamp when the Globex Overnight Session begins // -------------------------------- KILLZONE SESSIONS --------------------------------------------------------------------------- // ASIA Killzone Inputs and Settings showLine_Asian = input.bool(defval=false, title="Show Asian Killzone", tooltip="Show Asian Killzone Vertical Lines", group="Asian Session Settings", inline="AKZ") // Asian Killzone Toggle i_AsianSession = input.session(title="Asian Session", defval="2000-0000", group="Asian Session Settings", tooltip="This is needed for the high low calculations") // Asian Session, Monday - Friday AsianSession = time(timeframe.period, i_AsianSession, i_timezone) // Calculate time for the Asian session. i_AsianSessionHour = input.int(title="Asian Killzone Start Hr.", defval=20, minval=0, maxval=23, group="Asian Session Settings", inline="Asian") // Asian Killzone Opening Hour i_AsianSessionMin = input.int(title="Min.", defval=00, minval=0, maxval=59, group="Asian Session Settings", inline="Asian", tooltip="This is the Start of the Asian Killzone") // Asian Killzone Opening Minute AsianSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_AsianSessionHour, i_AsianSessionMin, 00)-86400000 // Coordinate for Asian Killzone Start time (minus 1 day) i_AsianSessionEndHour = input.int(title="Asian Killzone End Hour", defval=23, minval=0, maxval=23, group="Asian Session Settings", inline="AsianEnd") // Asian Killzone Closing Hour i_AsianSessionEndMin = input.int(title="Min.", defval=59, minval=0, maxval=59, group="Asian Session Settings", inline="AsianEnd", tooltip="This is the end of the Asian Killzone") // Asian Killzone Closing Minute AsianSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_AsianSessionEndHour, i_AsianSessionEndMin, 00)-86400000 // Coordinate for Asian Killzone End time (minus 1 day) i_AsianSessionCol = input.color(title="",tooltip="Asian Killzone Line Color", defval=color.new(color.yellow,0), group="Asian Session Settings", inline="Asian") // Asian Killzone Color setting var Asian_KZ_start = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol, width=i_lineWidth) // Asian Killzone Start Vertical Line var Asian_KZ_end = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianSessionCol, width=i_lineWidth) // Asian Killzone End Vertical Line i_AsianKZHighlight = input.bool(defval=true, title="Highlight KZ", tooltip="Fills the Killzone with a solid color", group="Asian Session Settings", inline="AKZ") // Asian Killzone Fill the area between start and end time i_AsianSessionFillCol = input.color(title="",tooltip="Asian Killzone Fill Color", defval=color.new(color.yellow,80), group="Asian Session Settings", inline="AKZ") // Asian Killzone Fill Color setting var AsianKZFill = linefill.new(Asian_KZ_start, Asian_KZ_end, i_AsianSessionFillCol) // Asian Killzone Vertical Linefill showLevel_Asian = input.bool(defval=false, title="Show Asian High/Low", tooltip="Show Asian Killzone Horizontal price levels", group="Asian Session Settings", inline="ALvl") // Asian Killzone High/Low Toggle i_AsianLevelCol = input.color(title="Levels",tooltip="Asian KZ Levels Color", defval=color.gray, group="Asian Session Settings", inline="ALvl") // Asian KZ Session, color setting for level lines // London Killzone session settings and inputs showLine_London = input.bool(defval=false, title="Show London Killzone", tooltip="Show London Killzone Vertical Lines", group="London Session Settings", inline="LKZ") // London Killzone Toggle i_LondonSessionHour = input.int(title="London Killzone Start Hr.", defval=02, minval=0, maxval=23, group="London Session Settings", inline="London") // London Killzone Opening Hour i_LondonSessionMin = input.int(title="Min.", defval=00, minval=0, maxval=59, group="London Session Settings", inline="London", tooltip="This is the Start of the London Killzone") // London Killzone Opening Minute LondonSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_LondonSessionHour, i_LondonSessionMin, 00) // Coordinate for London Killzone Start time i_LondonSessionEndHour = input.int(title="London Killzone End Hour", defval=5, minval=0, maxval=23, group="London Session Settings", inline="LondonEnd") // London Killzone Closing Hour i_LondonSessionEndMin = input.int(title="Min.", defval=0, minval=0, maxval=59, group="London Session Settings", inline="LondonEnd", tooltip="This is the end of the London Killzone") // London Killzone Closing Minute LondonSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_LondonSessionEndHour, i_LondonSessionEndMin, 00) // Coordinate for London Killzone End time i_LondonSessionCol = input.color(title="",tooltip="London Killzone Line Color", defval=color.new(color.green,0), group="London Session Settings", inline="London") // London Killzone Color setting var London_KZ_start = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol, width=i_lineWidth) // London Killzone Start Vertical Line var London_KZ_end = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonSessionCol, width=i_lineWidth) // London Killzone End Vertical Line i_LondonKZHighlight = input.bool(defval=true, title="Highlight KZ", tooltip="Fills the Killzone with a solid color", group="London Session Settings", inline="LKZ") // London Killzone Fill the area between start and end time i_LondonSessionFillCol = input.color(title="",tooltip="London Killzone Fill Color", defval=color.new(color.green,80), group="London Session Settings", inline="LKZ") // London Killzone Fill Color setting var LondonKZFill = linefill.new(London_KZ_start, London_KZ_end, i_LondonSessionFillCol) // London Killzone Vertical Linefill showLevel_London = input.bool(defval=false, title="Show London High/Low", tooltip="Show London Killzone Horizontal price levels", group="London Session Settings", inline="LVL") // London Killzone High/Low Toggle i_LondonLevelCol = input.color(title="Levels",tooltip="London KZ Levels Color", defval=color.gray, group="London Session Settings", inline="LVL") // London KZ Session, color setting for level lines // NY Open Killzone session settings and inputs nykz_group = "NY KZ Session Settings" showLine_NYKZ = input.bool(defval=false, title="Show NY Open Killzone", tooltip="Show NY Open Killzone Vertical Lines", group=nykz_group, inline="NYKZ") // NY Killzone Toggle i_NYKZSessionHour = input.int(title="NY Killzone Start Hr.", defval=07, minval=0, maxval=23, group=nykz_group, inline="NYKZS") // NY Killzone Opening Hour i_NYKZSessionMin = input.int(title="Min.", defval=00, minval=0, maxval=59, group=nykz_group, inline="NYKZS", tooltip="This is the Start of the NY Killzone") // NY Killzone Opening Minute NYKZSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_NYKZSessionHour, i_NYKZSessionMin, 00) // Coordinate for NY Killzone Start time i_NYKZSessionEndHour = input.int(title="NY Killzone End Hour", defval=10, minval=0, maxval=23, group=nykz_group, inline="NYKZEnd") // NY Killzone Closing Hour i_NYKZSessionEndMin = input.int(title="Min.", defval=0, minval=0, maxval=59, group=nykz_group, inline="NYKZEnd", tooltip="This is the end of the NY Killzone") // NY Killzone Closing Minute NYKZSessionEndTime = timestamp(i_timezone, year, month, dayofmonth, i_NYKZSessionEndHour, i_NYKZSessionEndMin, 00) // Coordinate for NY Killzone End time i_NYKZSessionCol = input.color(title="",tooltip="NY Killzone Line Color", defval=color.new(color.orange,0), group=nykz_group, inline="NYKZS") // NY Killzone Color setting var NY_KZ_start = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYKZSessionCol, width=i_lineWidth) // NY Killzone Start Vertical Line var NY_KZ_end = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYKZSessionCol, width=i_lineWidth) // NY Killzone End Vertical Line i_NYKZHighlight = input.bool(defval=true, title="Highlight KZ", tooltip="Fills the NY Killzone with a solid color", group=nykz_group, inline="NYKZ") // NY Killzone Fill the area between start and end time i_NYKZSessionFillCol = input.color(title="",tooltip="NY Killzone Fill Color", defval=color.new(color.orange,80), group=nykz_group, inline="NYKZ") // NY Killzone Fill Color setting var NYKZFill = linefill.new(NY_KZ_start, NY_KZ_end, i_NYKZSessionFillCol) // NY Killzone Vertical Linefill showLevel_NYKZ = input.bool(defval=false, title="Show NYKZ High/Low", tooltip="Show NYKZ Killzone Horizontal price levels", group=nykz_group, inline="NYKZLvl") // NYKZ Killzone High/Low Toggle i_NYKZLevelCol = input.color(title="Levels",tooltip="NYKZ KZ Levels Color", defval=color.gray, group=nykz_group, inline="NYKZLvl") // NYKZ KZ Session, color setting for level lines // New York Session settings and inputs ny_group = "New York Session Vertical Settings" nyprice_group = "New York Price Horizontal Level Settings" nytime_group = "New York Session Time Settings" cmeprice_group = "CME Price Horizontal Level Settings" showLine_MOP = input.bool(defval=true, title="Show New York Midnight Line", group=ny_group ,inline="NYMNV") // Show New York AM Vertical Line i_NYMNVertCol = input.color(title="", tooltip="Show New York Midnight Vertical Line", defval=color.new(color.fuchsia,0), group=ny_group, inline="NYMNV") // New York Midnight Opening Vertical Line, color setting showLine_AM = input.bool(defval=true, title="Show New York AM Vertical Line", group=ny_group, inline="NYAM") // Show New York AM Vertical Line i_AMSessionCol = input.color(title="", tooltip="Show New York AM Vertical Line", defval=color.new(color.blue,0), group=ny_group, inline="NYAM") // New York Session Color setting showLine_CME = input.bool(defval=true, title="Show CME Open Vertical Line", group=ny_group, inline="CMEL") // Show CME Open Vertical Line i_CMESessionCol = input.color(title="", tooltip="Show CME Open Vertical Line", defval=color.new(color.orange,0), group=ny_group, inline="CMEL") // CME Session Color setting showLine_Lunch = input.bool(defval=true, title="Show New York Lunch", group=ny_group, inline="LunchL") // Show New York Lunch Vertical Line i_LunchSessionCol = input.color(title="", tooltip="Show New York Lunch Vertical Line" , defval=color.new(color.red,0), group=ny_group, inline="LunchL") // Lunch Color setting i_LunchSessionNTZ = input.bool(defval=true, title="Show New York Lunch No-Trade-Zone", group=ny_group, inline="LunchNTZ") // No Trades During Lunch Color setting i_LunchSessionFillCol= input.color(title="",tooltip="Highlight NY Lunch No Trade Zone", defval=color.new(color.red,80), group=ny_group, inline="LunchNTZ") // Lunch Color setting showLine_PM = input.bool(defval=true, title="Show New York PM Vertical Line", group=ny_group, inline="PML") // Show New York PM Vertical Line i_PMSessionCol = input.color(title="", tooltip="Show New York PM Vertical Line", defval=color.new(color.blue,0), group=ny_group, inline="PML") // New York Session PM Color setting showLine_NYEnd = input.bool(defval=true, title="Show New York End Vertical Line", group=ny_group, inline="NYEL") // Show New York End of Day Vertical Line i_NYSessionEndCol = input.color(title="", tooltip="Show New York End of Day Vertical Line", defval=color.new(color.blue,0), group=ny_group, inline="NYEL") // New York Session Color setting NYMNOpenTime = timestamp(i_timezone, year, month, dayofmonth, 00, 00, 00) // Coordinate for NY Midnight Opening Time coordinate (Every day 00:00) var NYMN_line = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=na, color=i_NYMNVertCol, width=i_lineWidth) // New York Midnight Open Vertical line i_AMSessionHour = input.int(title="New York AM Hour", defval=08, minval=0, maxval=23, group=nytime_group, inline="AM") // New York Session Opening Hour i_AMSessionMin = input.int(title="Min.", defval=30, minval=0, maxval=59, group=nytime_group, inline="AM", tooltip="Start of the NY Session") // New York Session Opening Minute AMSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_AMSessionHour, i_AMSessionMin, 00) // Coordinate for NY AM Start session time var AMSessionLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AMSessionCol, width=i_lineWidth) // New York AM Vertical Line showNYMNOpenLine = input.bool(defval=true, title="Show New York Midnight Opening Price Level", group=nyprice_group, inline="NYMOP") // Show New York Open price level line i_NYMNOpenCol = input.color(title="", tooltip="Show New York Midnight Opening Horizontal Price Level", defval=color.new(color.fuchsia,0), group=nyprice_group, inline="NYMOP") // New York Midnight Open Price, color setting var NYMN_line_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYMNOpenCol, width=i_lineWidthLevels) // New York Midnight Open Price level line var NYMNOpenLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // New York Midnight Open Price label showNYAMOpenLine = input.bool(defval=true, title="Show New York AM Opening Horizontal Price Level",group=nyprice_group, inline="NYOP") // Show New York Open price level line i_NYAMOpenCol = input.color(title="", tooltip="Show New York AM Opening Horizontal Price Level", defval=color.new(color.yellow,0), group=nyprice_group, inline="NYOP") // New York AM Opening Price, color setting var NYAM_line_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYAMOpenCol, width=i_lineWidthLevels) // New York AM Open Price level line var NYAMOpenLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // New York AM Open Price label showCMEOpenLine = input.bool(defval=true, title="Show CME Opening Horizontal Price Level",group=cmeprice_group, inline="CMEOP") // Show CME Open price level line i_CMEOpenCol = input.color(title="", tooltip="Show CME Opening Horizontal Price Level", defval=color.new(color.orange,0), group=cmeprice_group, inline="CMEOP") // CME Opening Price, color setting var CME_line_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_CMEOpenCol, width=i_lineWidthLevels) // CME Open Price level line var CMEOpenLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // CME Open Price label i_CMESessionHour = input.int(title="CME Open Hour", defval=9, minval=0, maxval=23, group=nytime_group, inline="CME") // CME Session Opening Hour i_CMESessionMin = input.int(title="Min.", defval=30, minval=0, maxval=59, group=nytime_group, inline="CME", tooltip="Start of the CME session") // CME Session Opening Minute CMESessionTime = timestamp(i_timezone, year, month, dayofmonth, i_CMESessionHour, i_CMESessionMin, 00) // Coordinate for CME Start session time var CMESessionLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_CMESessionCol, width=i_lineWidth) // CME Open Vertical Line i_LunchSessionHour = input.int(title="Lunch Hour", defval=12, minval=0, maxval=23, group=nytime_group, inline="Lunch") // Lunch Hour i_LunchSessionMin = input.int(title="Min.", defval=00, minval=0, maxval=59, group=nytime_group, inline="Lunch", tooltip="This is the Start of Lunch ") // Lunch Minute LunchSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_LunchSessionHour, i_LunchSessionMin, 00) // Coordinate for Lunch Start time var LunchStartLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LunchSessionCol, width=i_lineWidth) // Lunch Start Vertical Line i_PMSessionHour = input.int(title="New York PM Session Hr.", defval=13, minval=0, maxval=23, group=nytime_group, inline="PM") // New York Session PM Opening Hour i_PMSessionMin = input.int(title="Min.", defval=00, minval=0, maxval=59, group=nytime_group, inline="PM", tooltip="Start of the PM Session ") // New York Session PM Opening Minute PMSessionTime = timestamp(i_timezone, year, month, dayofmonth, i_PMSessionHour, i_PMSessionMin, 00) // Coordinate for NY PM Start session time var PMSessionLine = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AMSessionCol, width=i_lineWidth) // New York AM Vertical Line var LunchLineFill = linefill.new(LunchStartLine, PMSessionLine, i_LunchSessionFillCol) // Lunch Vertical Linefill (No Trade Zone) showNYPMOpenLine = input.bool(defval=true, title="Show New York PM Opening Horizontal Price Level",group=nyprice_group, inline="NYPMOP") // Show New York PM Open price level line i_NYPMOpenCol = input.color(title="", tooltip="Show New York PM Opening Horizontal Price Level", defval=color.new(color.blue,0), group=nyprice_group, inline="NYPMOP") // New York PM Opening Price, color setting var NYPM_line_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYPMOpenCol, width=i_lineWidthLevels) // New York PM Open Price level line var NYPMOpenLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // New York PM Open Price label i_NYSessionEndHour = input.int(title="New York Session End Hour", defval=16, minval=0, maxval=23, group=nytime_group, inline="NYE") // New York Session Closing Hour i_NYSessionEndMin = input.int(title="Min.", defval=30, minval=0, maxval=59, group=nytime_group, inline="NYE", tooltip="This is the end of trading day") // New York Session Closing Minute var NYSessionEndTime= timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of session time (this is also the terminus for the Level lines) var NYSessionEndLine= line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYSessionEndCol, width=i_lineWidth) // New York Session Vertical Closing line // HTF Lines showWeekOpen = input.bool(defval=false, title="Show Weekly Open", group="HTF Levels", inline="WO") i_WeekOpenCol = input.color(title="", tooltip="Weekly Open Line Color", defval=color.new(color.lime,0), group="HTF Levels", inline="WO") var Weekly_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_WeekOpenCol, width=i_lineWidthLevels) // Weekly Open Price level line var Weekly_openlbl = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Weekly Open Price label var WeeklyOpenTime = time // Coordinate for Weekly Open Price - will be set with newWeek function showMonthOpen = input.bool(defval=false, title="Show Monthly Open", group="HTF Levels", inline="MO") i_MonthOpenCol = input.color(title="", tooltip="Monthly Open Line Color", defval=color.new(color.lime,0), group="HTF Levels", inline="MO") var Monthly_open = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_MonthOpenCol, width=i_lineWidthLevels) // Monthly Open Price level line var Monthy_openlbl = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // Monthly Open Price label var MonthlyOpenTime = time // Coordinate for Monthly Open Price - will be set with newMonth function showDebug = input.bool(title="Show Debugging Info", defval=false, group="Debug") // Toggle display of the table with debug information log_show_msg = input.int(10, title = "# of message to show", group = "Debug") log_offset = input.int(0, title = "# of messages to offset", group = "Debug", step = 1) // LOGGING FUNCTION var logsize = 50 var bar_arr = array.new_int(logsize) var time_arr = array.new_string(logsize) var msg_arr = array.new_string(logsize) var type_arr = array.new_string(logsize) log_msg(message, type) => array.push(bar_arr, bar_index) array.push(time_arr, str.tostring(year) + "-" + str.tostring(month) + "-" + str.tostring(dayofmonth) + " " + str.tostring(hour(time,i_timezone)) + ":" + str.tostring(minute(time,i_timezone)) + ":" + str.tostring(second(time,i_timezone))) array.push(msg_arr, message) array.push(type_arr, type) // Housekeeping, delete the oldest log entries. This prevents the array from becoming too big. array.shift(bar_arr) array.shift(time_arr) array.shift(msg_arr) array.shift(type_arr) // END LOGGING CODE // Get HTF Price levels WeeklyOpen = request.security(syminfo.tickerid, "W", open, lookahead = barmerge.lookahead_on) // Get the Week's opening price MonthlyOpen = request.security(syminfo.tickerid, "M", open, lookahead = barmerge.lookahead_on) // Get the Month's opening price // END HTF // Detect the Start of a new week newWeek = ta.change(weekofyear) // Needed for drawing the HTF lines and levels just once per week if newWeek WeeklyOpenTime := time log_msg("New Week Started", 'low') // Detect the Start of a new month newMonth = ta.change(time("M")) // Needed for drawing the HTF lines and levels just once per month if newMonth MonthlyOpenTime := time log_msg("New Month Started", 'low') // *** End of inputs and variables // Convert linestyle linestyle = (i_linestyle == "solid (─)") ? line.style_solid : (i_linestyle == "dashed (╌)") ? line.style_dashed : line.style_dotted // Default value is dotted to avoid drawing over wicks // Convert linestyle for Levels linestyle_level = (i_linestyleLevels == "solid (─)") ? line.style_solid : (i_linestyleLevels == "dashed (╌)") ? line.style_dashed : line.style_dotted // Default value is dotted // Functions // Function to draw Vertical Lines vline(Start, Color, linestyle, LineWidth) => if i_lineExtend // If the option is set to extend all vertical lines... line.new(x1=Start, y1=low - ta.tr, x2=Start, y2=high + ta.tr, xloc=xloc.bar_time, extend=extend.both, color=Color, style=linestyle, width=LineWidth) else line.new(x1=Start, y1=Daily_hi, x2=Start, y2=Daily_hi, xloc=xloc.bar_time, extend=extend.none, color=Color, style=linestyle, width=LineWidth) // Else the vertical lines will print to the daily high and low // End function // Draw Horizontal Lines _hline(StartTime, EndTime, Price, Extend, Color, Style, Width) => return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=Extend, color=Color, style=Style, width=Width) // Function for determining the Start of a Session (taken from the Pinescript manual: https://www.tradingview.com/pine-script-docs/en/v5/concepts/Sessions.html ) sessionBegins(sess) => t = time("", sess , i_timezone) showIndicator and (not barstate.isfirst) and na(t[1]) and not na(t) // End session function // Housekeeping - Remove old drawing objects housekeeping(days) => // Delete old drawing objects // One day is 86400000 milliseconds removal_timestamp = AsianSessionTime - (days * 86400000) // Remove every drawing object older than the start of the Asian Session. a_allLines = line.all a_allLabels = label.all // Remove old lines if array.size(a_allLines) > 0 for i = 0 to array.size(a_allLines) - 1 line_x2 = line.get_x2(array.get(a_allLines, i)) if line_x2 < removal_timestamp line.delete(array.get(a_allLines, i)) // Remove old labels if array.size(a_allLabels) > 0 for i = 0 to array.size(a_allLabels) - 1 label_x = label.get_x(array.get(a_allLabels, i)) if label_x < removal_timestamp label.delete(array.get(a_allLabels, i)) // End of housekeeping function // *** End of all functions // ************************** << // Start MAIN Logic // Daily Session Start | this works for everything but stocks if sessionBegins(i_DailySession) // When a new Daily Session is started log_msg("Daily Session Start", 'medium') log_msg("You are trading: " + syminfo.ticker + " and its asset class is: " + syminfo.type, 'medium') DailySessionStart := time // Store the Session Starting timestamp NYMNOpenTime := time // Store Previous Day's High and Low PD_hi := Daily_hi PD_hi_time := Daily_hi_time PD_lo := Daily_lo PD_lo_time := Daily_lo_time // Calculate timestamps for the coming session // Killzone vertical line timestamps if AsianSessionTime < DailySessionStart // If the AsianSessionTime is in the past, then add 1 day AsianSessionTime := AsianSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if AsianSessionEndTime < DailySessionStart // If the AsianSessionEndTime is in the past, then add 1 day AsianSessionEndTime := AsianSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LondonSessionTime < DailySessionStart // If the LondonSessionTime is in the past, then add 1 day LondonSessionTime := LondonSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LondonSessionEndTime < DailySessionStart // If the LondonSessionEndTime is in the past, then add 1 day LondonSessionEndTime := LondonSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if NYKZSessionTime < DailySessionStart // If the NYKZSessionTime is in the past, then add 1 day NYKZSessionTime := NYKZSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if NYKZSessionEndTime < DailySessionStart // If the NYKZSessionEndTime is in the past, then add 1 day NYKZSessionEndTime := NYKZSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should // Session vertical line timestamps if AMSessionTime < DailySessionStart // If the AMSessionTime is in the past, then add 1 day AMSessionTime := AMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if AMSessionTime < DailySessionStart // If the AMSessionTime is in the past, then add 1 day AMSessionTime := AMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if CMESessionTime < DailySessionStart // If the NYSessionEndTime is in the past, then add 1 day CMESessionTime := CMESessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if LunchSessionTime < DailySessionStart // If the LunchSessionTime is in the past, then add 1 day LunchSessionTime := LunchSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if PMSessionTime < DailySessionStart // If the PMSessionTime is in the past, then add 1 day PMSessionTime := PMSessionTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should NYSessionEndTime := timestamp(i_timezone, year, month, dayofmonth, i_NYSessionEndHour, i_NYSessionEndMin, 00) // Coordinate for NY End of Cash session time (this is the terminus for the Level lines) if NYSessionEndTime < DailySessionStart // If the NYSessionEndTime is in the past, then add 1 day NYSessionEndTime := NYSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should // Extend previous day's High and Low line. // This needs to be done after the housekeeping, otherwise it could get cleaned up again. if showDailyHigh and extendPDHL PDHighLine := line.new(x1=PD_hi_time, y1=PD_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=PD_hi, color=i_DailyHighCol, width=i_lineWidthLevels) // Extend PD's High Price level line if showLabels PDHighLabel := label.new(x=NYSessionEndTime, y=PD_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // PD's High Price label label.set_tooltip(PDHighLabel, "Previous Daily High: " + str.tostring(PD_hi)) if showCaptions label.set_text(PDHighLabel, "PD High") if showDailyLow and extendPDHL PDLowLine := line.new(x1=PD_lo_time, y1=PD_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=PD_lo, color=i_DailyLowCol, width=i_lineWidthLevels) // Extend PD's Low Price level line if showLabels PDLowLabel := label.new(x=NYSessionEndTime, y=PD_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) // PD's Low Price label label.set_tooltip(PDLowLabel, "Previous Daily Low: " + str.tostring(PD_lo)) if showCaptions label.set_text(PDLowLabel, "PD Low") // Now for the Current High and Low // We are entering Daily Session hours; reset hi/lo. Daily_hi := high Daily_lo := low // Initialize the drawings for today if showDailyHigh // Draw the Daily Open Vertical Line DailyHighLine := line.new(x1=NYMNOpenTime, y1=Daily_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Daily_hi, color=i_DailyHighCol, width=i_lineWidthLevels) // Today's High Price level line if showLabels DailyHighLabel := label.new(x=NYMNOpenTime, y=Daily_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_right, size=size.small) // Today's High Price label if showCaptions label.set_text(DailyHighLabel, "Daily High") if showDailyLow DailyLowLine := line.new(x1=NYMNOpenTime, y1=Daily_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Daily_lo, color=i_DailyLowCol, width=i_lineWidthLevels) // Today's Low Price level line if showLabels DailyLowLabel := label.new(x=NYMNOpenTime, y=Daily_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_right, size=size.small) // Today's Low Price label if showCaptions label.set_text(DailyLowLabel, "Daily Low") // When a new day start, draw all the vertical lines // Draw the Asian Killzone Lines if (showLine_Asian and showIndicator) log_msg("Asian Killzone printed", 'low') Asian_KZ_start := vline(AsianSessionTime, i_AsianSessionCol, linestyle, i_lineWidth) Asian_KZ_end := vline(AsianSessionEndTime, i_AsianSessionCol, linestyle, i_lineWidth) // Fill the area during Asian Killzone if (i_AsianKZHighlight and showIndicator) AsianKZFill := linefill.new(Asian_KZ_start, Asian_KZ_end, i_AsianSessionFillCol) // Draw the London Killzone Lines if (showLine_London and showIndicator) log_msg("London KZ Started", 'low') London_KZ_start := vline(LondonSessionTime, i_LondonSessionCol, linestyle, i_lineWidth) London_KZ_end := vline(LondonSessionEndTime, i_LondonSessionCol, linestyle, i_lineWidth) // Fill the area during London Killzone if (i_LondonKZHighlight and showIndicator) LondonKZFill := linefill.new(London_KZ_start, London_KZ_end, i_LondonSessionFillCol) // Draw the NY Midnight Open Line if (showLine_MOP and showIndicator) NYMN_line := vline(NYMNOpenTime, i_NYMNVertCol, linestyle, i_lineWidth) log_msg("New York Midnight Open Vertical line | OpenTime: " + str.tostring(year) + "-" + str.tostring(month) + "-" + str.tostring(dayofmonth) + " " + str.tostring(hour(NYMNOpenTime,i_timezone)) + ":" + str.tostring(minute(NYMNOpenTime,i_timezone)) + ":" + str.tostring(second(NYMNOpenTime,i_timezone)), 'low') // Draw the NY AM Session Start Line if (showLine_AM and showIndicator) AMSessionLine := vline(AMSessionTime, i_AMSessionCol, linestyle, i_lineWidth) log_msg("New York AM Open Vertical line", 'low') // Draw the CME Open Start Line if (showLine_CME and showIndicator) CMESessionLine := vline(CMESessionTime, i_CMESessionCol, linestyle, i_lineWidth) log_msg("CME Open Vertical line", 'low') // Draw the NY Killzone Lines if (showLine_NYKZ and showIndicator) log_msg("NY Open Killzone Started", 'low') NY_KZ_start := vline(NYKZSessionTime, i_NYKZSessionCol, linestyle, i_lineWidth) NY_KZ_end := vline(NYKZSessionEndTime, i_NYKZSessionCol, linestyle, i_lineWidth) // Fill the area during NY Killzone if (i_NYKZHighlight and showIndicator) NYKZFill := linefill.new(NY_KZ_start, NY_KZ_end, i_NYKZSessionFillCol) // Draw the NY Lunch Start Line if (showLine_Lunch and showIndicator) LunchStartLine := vline(LunchSessionTime, i_LunchSessionCol, linestyle, i_lineWidth) // Draw the NY PM Session Start Line if (showLine_PM and showIndicator) PMSessionLine := vline(PMSessionTime, i_PMSessionCol, linestyle, i_lineWidth) // Fill the area during lunch no trading zone if (i_LunchSessionNTZ and showIndicator) LunchLineFill := linefill.new(LunchStartLine, PMSessionLine, i_LunchSessionFillCol) // Draw the NY Session End Line if (showLine_NYEnd and showIndicator) NYSessionEndLine := vline(NYSessionEndTime, i_NYSessionEndCol, linestyle, i_lineWidth) log_msg("New York Session END Vertical line", 'low') // // *** End of Vertical Lines section // HTF Levels if showWeekOpen // Weekly line will be re-drawn each day line.delete(Weekly_open[1]) // Delete Previous line if showLabels label.delete(Weekly_openlbl[1]) Weekly_open:= line.new(x1=WeeklyOpenTime, y1=WeeklyOpen, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=WeeklyOpen, color=i_WeekOpenCol, style=linestyle_level, width=i_lineWidthLevels) // Weekly Open priceline log_msg("Weekly Open Horizontal Line", 'low') if showLabels Weekly_openlbl := label.new(x=NYSessionEndTime, y=WeeklyOpen, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(Weekly_openlbl, "Weekly Open: " + str.tostring(WeeklyOpen)) if showCaptions label.set_text(Weekly_openlbl, "Weekly Open") if showMonthOpen // Monthly line will be re-drawn each day line.delete(Monthly_open[1]) // Delete Previous line if showLabels label.delete(Monthy_openlbl[1]) Monthly_open:= line.new(x1=MonthlyOpenTime, y1=MonthlyOpen, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=MonthlyOpen, color=i_MonthOpenCol, style=linestyle_level, width=i_lineWidthLevels) // Monthly Open priceline log_msg("Monthly Open Horizontal Line", 'low') if showLabels Monthy_openlbl := label.new(x=NYSessionEndTime, y=MonthlyOpen, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(Monthy_openlbl, "Monthly Open: " + str.tostring(MonthlyOpen)) if showCaptions label.set_text(Monthy_openlbl, "Monthly Open") else if DailySession // We are in allowed DailySession hours; track hi/lo. Daily_hi := math.max(high, Daily_hi) Daily_lo := math.min(low, Daily_lo) if (Daily_hi > Daily_hi[1]) if showDailyHigh log_msg("New Daily High formed", 'low') Daily_hi_time := time line.set_y1(id=DailyHighLine, y=Daily_hi) line.set_y2(id=DailyHighLine, y=Daily_hi) if showLabels label.set_y(id=DailyHighLabel, y=Daily_hi) label.set_y(id=DailyHighLabel, y=Daily_hi) label.set_tooltip(DailyHighLabel, "Daily High: " + str.tostring(Daily_hi)) if showCaptions label.set_text(DailyHighLabel, "High") if (Daily_lo < Daily_lo[1]) if showDailyLow log_msg("New Daily Low formed", 'low') Daily_lo_time := time line.set_y1(id=DailyLowLine, y=Daily_lo) line.set_y2(id=DailyLowLine, y=Daily_lo) if showLabels label.set_y(id=DailyLowLabel, y=Daily_lo) label.set_y(id=DailyLowLabel, y=Daily_lo) label.set_tooltip(DailyLowLabel, "Daily Low: " + str.tostring(Daily_lo)) if showCaptions label.set_text(DailyLowLabel, "Low") // END Daily Session Code // Start of Horizontal Price Levels // New York Midnight Open Price line if (showNYMNOpenLine and time == NYMNOpenTime and showIndicator) // Only draw the NY Midnight line once at 00:00 - FOR INDICES (Workaround by adding 1 day in milliseconds) NYMN_line_open:= line.new(x1=NYMNOpenTime, y1=open, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=open, color=i_NYMNOpenCol, style=linestyle_level, width=i_lineWidthLevels) // NYMN Open line log_msg("New York Midnight Open Horizontal Price line CME", 'low') if showLabels NYMNOpenLabel := label.new(x=NYSessionEndTime, y=open, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(NYMNOpenLabel, "NY Midnight Open: " + str.tostring(open)) if showCaptions label.set_text(NYMNOpenLabel, "00:00 Open") // *** End of NY MN Level line // New York AM Open Price line if (showNYAMOpenLine and time == AMSessionTime and showIndicator) // Only draw the NY AM line once at 08.30 NYAM_line_open:= _hline(AMSessionTime, NYSessionEndTime, open, extend.none, i_NYAMOpenCol, linestyle_level, i_lineWidthLevels) // NYAM Open priceline log_msg("New York AM Open Horizontal Price line", 'low') if showLabels NYAMOpenLabel := label.new(x=NYSessionEndTime, y=open, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(NYAMOpenLabel, "NY AM Open: " + str.tostring(open)) if showCaptions label.set_text(NYAMOpenLabel, "NY AM Open") // *** End of NYAM Open Level line // CME Open Price line if (showCMEOpenLine and time == CMESessionTime and showIndicator) // Only draw the CME Open line once at 09.30 CME_line_open:= _hline(CMESessionTime, NYSessionEndTime, open, extend.none, i_CMEOpenCol, linestyle_level, i_lineWidthLevels) // CME Open priceline log_msg("CME Open Horizontal Price line", 'low') if showLabels CMEOpenLabel := label.new(x=NYSessionEndTime, y=open, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(CMEOpenLabel, "CME Open: " + str.tostring(open)) if showCaptions label.set_text(CMEOpenLabel, "CME Open") // *** End of CME Open Level line // New York PM Open Price line if (showNYPMOpenLine and time == PMSessionTime and showIndicator) // Only draw the NY PM line once at 13.00 NYPM_line_open:= _hline(PMSessionTime, NYSessionEndTime, open, extend.none, i_NYPMOpenCol, linestyle_level, i_lineWidthLevels) // NYPM Open priceline log_msg("New York PM Open Horizontal Price line", 'low') if showLabels NYPMOpenLabel := label.new(x=NYSessionEndTime, y=open, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(NYPMOpenLabel, "NY PM Open: " + str.tostring(open)) if showCaptions label.set_text(NYPMOpenLabel, "NY PM Open") // *** End of NYPM Open Level line // END OF HORIZONTAL PRICE LINES // *** SESSION CODE *** // // Begin Asian Killzone Session Code var float Asian_hi = na // High for the Asian Session var float Asian_lo = na // Low for the Asian Session var Asian_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian High line var Asian_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_AsianLevelCol) // Asian Low line var AsianHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var AsianLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var AsianSessionStart = time // To register the timestap when the Asian Session begins on the previous day if sessionBegins(i_AsianSession) and showIndicator // When a new Asian Killzone Session is started log_msg("Asian Killzone Session Start", 'low') AsianSessionStart := time // Store the Session Starting timestamp if NYSessionEndTime < AsianSessionStart // If the NYSessionEndTime is in the past, then add 1 day if dayofweek == dayofweek.sunday and (syminfo.type == "futures" or syminfo.type == "cfd" or syminfo.type == "stock" or syminfo.type == "index" or syminfo.type == "forex") NYSessionEndTime := NYSessionEndTime+(2*86400000) // Add 2 days, so level lines will be drawn to the right like they should else NYSessionEndTime := NYSessionEndTime+(86400000) // Add 1 day, so level lines will be drawn to the right like they should. For crypto and 24hr markets // We are entering Asian Session hours; reset hi/lo. Asian_hi := high Asian_lo := low // Initialize the drawings for today if showLevel_Asian Asian_line_hi := line.new(x1=AsianSessionStart, y1=Asian_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Asian_hi, color=i_AsianLevelCol, width=i_lineWidthLevels, style=linestyle_level) // Asian High line Asian_line_lo := line.new(x1=AsianSessionStart, y1=Asian_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Asian_lo, color=i_AsianLevelCol, width=i_lineWidthLevels, style=linestyle_level) // Asian Low line if showLabels AsianHighLabel := label.new(x=AsianSessionStart, y=Asian_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) AsianLowLabel := label.new(x=AsianSessionStart, y=Asian_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(AsianHighLabel, "Asian High: " + str.tostring(Asian_hi)) if showCaptions label.set_text(AsianHighLabel, "Asian High") label.set_tooltip(AsianLowLabel, "Asian Low: " + str.tostring(Asian_lo)) if showCaptions label.set_text(AsianLowLabel, "Asian Low") else if AsianSession // We are in allowed AsianSession hours; track hi/lo. log_msg("Asian Killzone: Tracking Highs and Lows", 'low') Asian_hi := math.max(high, Asian_hi) Asian_lo := math.min(low, Asian_lo) if (Asian_hi > Asian_hi[1]) log_msg("Asian Killzone: New High found", 'low') if showLevel_Asian line.set_xy1(id=Asian_line_hi, x=time, y=Asian_hi) line.set_xy2(id=Asian_line_hi, x=NYSessionEndTime, y=Asian_hi) if showLabels label.set_xy(id=AsianHighLabel, x=NYSessionEndTime, y=Asian_hi) label.set_xy(id=AsianLowLabel, x=NYSessionEndTime, y=Asian_lo) label.set_tooltip(AsianHighLabel, "Asian High: " + str.tostring(Asian_hi)) label.set_tooltip(AsianLowLabel, "Asian Low: " + str.tostring(Asian_lo)) if (Asian_lo < Asian_lo[1]) log_msg("Asian Killzone: New Low found", 'low') if showLevel_Asian line.set_xy1(id=Asian_line_lo, x=time, y=Asian_lo) line.set_xy2(id=Asian_line_lo, x=NYSessionEndTime, y=Asian_lo) if showLabels label.set_xy(id=AsianHighLabel, x=NYSessionEndTime, y=Asian_hi) label.set_xy(id=AsianLowLabel, x=NYSessionEndTime, y=Asian_lo) label.set_tooltip(AsianHighLabel, "Asian High: " + str.tostring(Asian_hi)) label.set_tooltip(AsianLowLabel, "Asian Low: " + str.tostring(Asian_lo)) // END Asian Session Code // *** // Begin London Killzone Session Code var float London_hi = na // High for the London Session var float London_lo = na // Low for the London Session var London_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London High line var London_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_LondonLevelCol) // London Low line var LondonHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var LondonLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var LondonSessionStart = time // To register the timestap when the London Session begins if (time == LondonSessionTime and showIndicator) // When a new London Killzone Session is started log_msg("London Killzone Session Start", 'low') LondonSessionStart := time // Store the Session Starting timestamp // We are entering London Session hours; reset hi/lo. London_hi := high London_lo := low // Initialize the drawings for today if showLevel_London London_line_hi := line.new(x1=LondonSessionStart, y1=London_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=London_hi, color=i_LondonLevelCol, width=i_lineWidthLevels, style=linestyle_level) // London High line London_line_lo := line.new(x1=LondonSessionStart, y1=London_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=London_lo, color=i_LondonLevelCol, width=i_lineWidthLevels, style=linestyle_level) // London Low line if showLabels LondonHighLabel := label.new(x=LondonSessionStart, y=London_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(LondonHighLabel, "London High: " + str.tostring(London_hi)) if showCaptions label.set_text(LondonHighLabel, "LKZ High") LondonLowLabel := label.new(x=LondonSessionStart, y=London_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(LondonLowLabel, "London Low: " + str.tostring(London_lo)) if showCaptions label.set_text(LondonLowLabel, "LKZ Low") else if (time > LondonSessionTime and time <= LondonSessionEndTime) // We are in allowed LondonSession hours; track hi/lo. London_hi := math.max(high, London_hi) London_lo := math.min(low, London_lo) if (London_hi > London_hi[1]) if showLevel_London line.set_xy1(id=London_line_hi, x=time, y=London_hi) line.set_xy2(id=London_line_hi, x=NYSessionEndTime, y=London_hi) if showLabels label.set_xy(id=LondonHighLabel, x=NYSessionEndTime, y=London_hi) label.set_xy(id=LondonLowLabel, x=NYSessionEndTime, y=London_lo) label.set_tooltip(LondonHighLabel, "London High: " + str.tostring(London_hi)) label.set_tooltip(LondonLowLabel, "London Low: " + str.tostring(London_lo)) if (London_lo < London_lo[1]) if showLevel_London line.set_xy1(id=London_line_lo, x=time, y=London_lo) line.set_xy2(id=London_line_lo, x=NYSessionEndTime, y=London_lo) if showLabels label.set_xy(id=LondonHighLabel, x=NYSessionEndTime, y=London_hi) label.set_xy(id=LondonLowLabel, x=NYSessionEndTime, y=London_lo) label.set_tooltip(LondonHighLabel, "London High: " + str.tostring(London_hi)) label.set_tooltip(LondonLowLabel, "London Low: " + str.tostring(London_lo)) // END London Session Code // *** // // Begin Globex Session Code if sessionBegins(i_GlobexSession) and showIndicator // When a new Globex Session is started log_msg("Globex Session Start", 'low') GlobexSessionStart := time // Store the Session Starting timestamp if NYSessionEndTime < GlobexSessionStart // If the NYSessionEndTime is in the past, then add 1 day NYSessionEndTime := NYSessionEndTime+86400000 // Add 1 day, so level lines will be drawn to the right like they should if dayofweek == dayofweek.sunday and (syminfo.type == "futures" or syminfo.type == "cfd" or syminfo.type == "stock" or syminfo.type == "index" or syminfo.type == "forex") NYSessionEndTime := NYSessionEndTime+(2*86400000) // Add another day, so level lines will be drawn to the right like they should // We are entering Globex Session hours; reset hi/lo. Globex_open := open log_msg("Globex Open: " + str.tostring(Globex_open), 'low') Globex_hi := high Globex_lo := low // Initialize the drawings for today if showGlobex // Draw the Globex Open Vertical Line Globex_line := vline(GlobexSessionStart, i_GlobexSessionCol, linestyle, i_lineWidth) if showGlobexDrawings // Create new objects for today if showGlobexOpenLine // Only paints once. Globex_line_open:= line.new(x1=GlobexSessionStart, y1=Globex_open, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Globex_open, color=i_GlobexOpenCol, style=linestyle_level, width=i_lineWidthLevels) // Globex Open line if showLabels GlobexOpenLabel := label.new(x=NYSessionEndTime, y=Globex_open, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(GlobexOpenLabel, "Globex Open: " + str.tostring(Globex_open)) if showCaptions label.set_text(GlobexOpenLabel, "Globex Open") Globex_line_hi := line.new(x1=GlobexSessionStart, y1=Globex_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Globex_hi, color=i_GlobexLevelCol, width=i_lineWidthLevels, style=linestyle_level) // Globex High line Globex_line_lo := line.new(x1=GlobexSessionStart, y1=Globex_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=Globex_lo, color=i_GlobexLevelCol, width=i_lineWidthLevels, style=linestyle_level) // Globex Low line if showLabels GlobexHighLabel := label.new(x=NYSessionEndTime, y=Globex_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) GlobexLowLabel := label.new(x=NYSessionEndTime, y=Globex_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(GlobexHighLabel, "Globex High: " + str.tostring(Globex_hi)) label.set_tooltip(GlobexLowLabel, "Globex Low: " + str.tostring(Globex_lo)) if showCaptions label.set_text(GlobexHighLabel, "Globex High") if showCaptions label.set_text(GlobexLowLabel, "Globex Low") else if GlobexSession // We are in allowed GlobexSession hours; track hi/lo. Globex_hi := math.max(high, Globex_hi) Globex_lo := math.min(low, Globex_lo) if (Globex_hi > Globex_hi[1]) if showGlobexDrawings line.set_xy1(id=Globex_line_hi, x=time, y=Globex_hi) line.set_xy2(id=Globex_line_hi, x=NYSessionEndTime, y=Globex_hi) if showLabels label.set_xy(id=GlobexHighLabel, x=NYSessionEndTime, y=Globex_hi) label.set_xy(id=GlobexLowLabel, x=NYSessionEndTime, y=Globex_lo) label.set_tooltip(GlobexHighLabel, "Globex High: " + str.tostring(Globex_hi)) label.set_tooltip(GlobexLowLabel, "Globex Low: " + str.tostring(Globex_lo)) if (Globex_lo < Globex_lo[1]) if showGlobexDrawings line.set_xy1(id=Globex_line_lo, x=time, y=Globex_lo) line.set_xy2(id=Globex_line_lo, x=NYSessionEndTime, y=Globex_lo) if showLabels label.set_xy(id=GlobexHighLabel, x=NYSessionEndTime, y=Globex_hi) label.set_xy(id=GlobexLowLabel, x=NYSessionEndTime, y=Globex_lo) label.set_tooltip(GlobexHighLabel, "Globex High: " + str.tostring(Globex_hi)) label.set_tooltip(GlobexLowLabel, "Globex Low: " + str.tostring(Globex_lo)) // END Globex Session Code // Begin NYKZ Killzone Session Code var float NYKZ_hi = na // High for the NYKZ Session var float NYKZ_lo = na // Low for the NYKZ Session var NYKZ_line_hi = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYKZLevelCol) // NYKZ High line var NYKZ_line_lo = line.new(x1=na, y1=na, x2=na, xloc=xloc.bar_time, y2=close, color=i_NYKZLevelCol) // NYKZ Low line var NYKZHighLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var NYKZLowLabel = label.new(x=na, y=na, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) var NYKZSessionStart = time // To register the timestap when the NYKZ Session begins if (time == NYKZSessionTime and showIndicator) // When a new NYKZ Killzone Session is started log_msg("NY Killzone Session Start", 'low') NYKZSessionStart := time // Store the Session Starting timestamp // We are entering NYKZ Session hours; reset hi/lo. NYKZ_hi := high NYKZ_lo := low // Initialize the drawings for today if showLevel_NYKZ NYKZ_line_hi := line.new(x1=NYKZSessionStart, y1=NYKZ_hi, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=NYKZ_hi, color=i_NYKZLevelCol, width=i_lineWidthLevels, style=linestyle_level) // NYKZ High line NYKZ_line_lo := line.new(x1=NYKZSessionStart, y1=NYKZ_lo, x2=NYSessionEndTime, xloc=xloc.bar_time, y2=NYKZ_lo, color=i_NYKZLevelCol, width=i_lineWidthLevels, style=linestyle_level) // NYKZ Low line if showLabels NYKZHighLabel := label.new(x=NYKZSessionStart, y=NYKZ_hi, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) NYKZLowLabel := label.new(x=NYKZSessionStart, y=NYKZ_lo, xloc=xloc.bar_time, color=i_LabelCol, textcolor=i_LabelTextcol, style=label.style_label_left, size=size.small) label.set_tooltip(NYKZHighLabel, "NYKZ High: " + str.tostring(NYKZ_hi)) label.set_tooltip(NYKZLowLabel, "NYKZ Low: " + str.tostring(NYKZ_lo)) if showCaptions label.set_text(NYKZHighLabel, "NYKZ High") if showCaptions label.set_text(NYKZLowLabel, "NYKZ Low") else if (time > NYKZSessionTime and time <= NYKZSessionEndTime) // We are in allowed NYKZSession hours; track hi/lo. NYKZ_hi := math.max(high, NYKZ_hi) NYKZ_lo := math.min(low, NYKZ_lo) if (NYKZ_hi > NYKZ_hi[1]) if showLevel_NYKZ line.set_xy1(id=NYKZ_line_hi, x=time, y=NYKZ_hi) line.set_xy2(id=NYKZ_line_hi, x=NYSessionEndTime, y=NYKZ_hi) if showLabels label.set_xy(id=NYKZHighLabel, x=NYSessionEndTime, y=NYKZ_hi) label.set_xy(id=NYKZLowLabel, x=NYSessionEndTime, y=NYKZ_lo) label.set_tooltip(NYKZHighLabel, "NYKZ High: " + str.tostring(NYKZ_hi)) label.set_tooltip(NYKZLowLabel, "NYKZ Low: " + str.tostring(NYKZ_lo)) if (NYKZ_lo < NYKZ_lo[1]) if showLevel_NYKZ line.set_xy1(id=NYKZ_line_lo, x=time, y=NYKZ_lo) line.set_xy2(id=NYKZ_line_lo, x=NYSessionEndTime, y=NYKZ_lo) if showLabels label.set_xy(id=NYKZHighLabel, x=NYSessionEndTime, y=NYKZ_hi) label.set_xy(id=NYKZLowLabel, x=NYSessionEndTime, y=NYKZ_lo) label.set_tooltip(NYKZHighLabel, "NYKZ High: " + str.tostring(NYKZ_hi)) label.set_tooltip(NYKZLowLabel, "NYKZ Low: " + str.tostring(NYKZ_lo)) // END NYKZ Session Code // *** // Create and fill log table // var log_tbl = table.new(position.bottom_left, 3, log_show_msg + 2, border_width = 1) if (barstate.isconfirmed and showDebug) table.merge_cells(log_tbl, 0, 0, 2, 0) table.cell(log_tbl, 0, 0, 'Debug Logging', text_size=size.normal, text_color=color.black, bgcolor = color.gray, text_halign=text.align_center) table.cell(log_tbl, 0, 1, "Bar #", bgcolor = color.gray, text_size = size.small) table.cell(log_tbl, 1, 1, "Time", bgcolor = color.gray, text_size = size.small) table.cell(log_tbl, 2, 1, "Message", bgcolor = color.gray, text_size = size.small) for i = 1 to log_show_msg arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset if (arr_i < 0) break type = array.get(type_arr, arr_i) msg_color = type == 'low' ? #cccccc : type == 'medium' ? #F5AC4E : type == 'high' ? #DD4224 : na table.cell(log_tbl, 0, i+1, str.tostring(array.get(bar_arr, arr_i)), bgcolor = msg_color, text_size = size.small) table.cell(log_tbl, 1, i+1, array.get(time_arr, arr_i), bgcolor = msg_color, text_size = size.small) table.cell(log_tbl, 2, i+1, array.get(msg_arr, arr_i), bgcolor = msg_color, text_size = size.small) /////////////////////////////// // Testing area //log_msg(str.format("NYMNOpenTime: {0,date, y-MM-d'.' hh:mm:ss}" ,NYMNOpenTime), "low") //log_msg("TodayStart Timestamp: " + str.tostring(TodayStart), 'low') // Start Plotting plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.monday : false, offset=0, style=shape.diamond, text="Monday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.tuesday : false, offset=0, style=shape.diamond, text="Tuesday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.wednesday : false, offset=0, style=shape.diamond, text="Wednesday", color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.thursday : false, offset=0, style=shape.diamond, text="Thursday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.friday : false, offset=0, style=shape.diamond, text="Friday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.saturday : false, offset=0, style=shape.diamond, text="Saturday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) plotshape(showDOW and showIndicator ? hour == 4 and minute == 0 and dayofweek == dayofweek.sunday : false, offset=0, style=shape.diamond, text="Sunday" , color=color.new(i_DOWCol, 0), location = location.bottom, textcolor=color.new(i_DOWCol, 0)) // Do housekeeping of old objects - remove everything before the number of days set housekeeping(i_showDaysDraw)
[_ParkF]Linreg & Trendlines
https://www.tradingview.com/script/Qc2KFagE/
ParkF
https://www.tradingview.com/u/ParkF/
943
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © ParkF //@version=5 indicator("[_ParkF]Linreg & Trendlines", overlay=true) // LINEAR REGRESSION // input group1 = "LINEAR REGRESSION SETTING" lengthInput = input.int(100, title="Length", minval = 1, maxval = 5000, group=group1) sourceInput = input.source(close, title="Source", group=group1) group2 = "LINEAR REGRESSION SWITCH" useDev1Input = input.bool(true, title="Large LinReg On / Off", group=group2) useDev2Input = input.bool(true, title="Medium LinReg On / Off", group=group2) useDev3Input = input.bool(true, title="Small LinReg On / Off", group=group2) useUpperDevInput = true upperMultInput = 3.0 useLowerDevInput = true lowerMultInput = 3.0 useUpperDevInput2 = true upperMultInput2 = 2.0 useLowerDevInput2 = true lowerMultInput2 = 2.0 useUpperDevInput3 = true upperMultInput3 = 1.0 useLowerDevInput3 = true lowerMultInput3 = 1.0 group3 = "LINEAR REGRESSION EXTEND LINES" extendLeftInput = input.bool(false, "Extend Lines Left", group=group3) extendRightInput = input.bool(true, "Extend Lines Right", group=group3) extendStyle = switch extendLeftInput and extendRightInput => extend.both extendLeftInput => extend.left extendRightInput => extend.right => extend.none group4 = "LINEAR REGRESSION WIDTH" a_lwidth = input.int(2, title='Large LinReg Width', minval=0, maxval=10, group=group4) b_lwidth = input.int(1, title='Medium LinReg Width', minval=0, maxval=10, group=group4) c_lwidth = input.int(1, title='Small LinReg Width', minval=0, maxval=10, group=group4) d_lwidth = input.int(2, title='Base Line LinReg Width', minval=0, maxval=10, group=group4) group5 = "LINEAR REGRESSION STYLE" A_LineStyle_Type = input.string(title='Large LinReg Type', defval='Dotted', options=['Dashed', 'Dotted', 'Solid'], group=group5) A_Line_Type = A_LineStyle_Type == 'Dashed' ? line.style_dashed : A_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid B_LineStyle_Type = input.string(title='Medium LinReg Type', defval='Solid', options=['Dashed', 'Dotted', 'Solid'], group=group5) B_Line_Type = B_LineStyle_Type == 'Dashed' ? line.style_dashed : B_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid C_LineStyle_Type = input.string(title='Small LinReg Type', defval='Dashed', options=['Dashed', 'Dotted', 'Solid'], group=group5) C_Line_Type = C_LineStyle_Type == 'Dashed' ? line.style_dashed : C_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid D_LineStyle_Type = input.string(title='Base Line LinReg Type', defval='Solid', options=['Dashed', 'Dotted', 'Solid'], group=group5) D_Line_Type = D_LineStyle_Type == 'Dashed' ? line.style_dashed : D_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid group6 = "LINEAR REGRESSION COLOR" colorLarge = input.color(color.new(#0c3299, 0), "Large Linreg", inline=group6, group=group6) colorMedium = input.color(color.new(#0c3299, 0), "Medium Linreg", inline=group6, group=group6) colorSmall = input.color(color.new(#0c3299, 0), "Small Linreg", inline=group6, group=group6) colorBase = input.color(color.new(#0c3299, 0), "Base Line", inline=group6, group=group6) // function calcSlope(source, length) => max_bars_back(source, 5000) if not barstate.islast or length <= 1 [float(na), float(na), float(na)] else sumX = 0.0 sumY = 0.0 sumXSqr = 0.0 sumXY = 0.0 for i = 0 to length - 1 by 1 val = source[i] per = i + 1.0 sumX += per sumY += val sumXSqr += per * per sumXY += val * per slope = (length * sumXY - sumX * sumY) / (length * sumXSqr - sumX * sumX) average = sumY / length intercept = average - slope * sumX / length + slope [slope, average, intercept] [s, a, i] = calcSlope(sourceInput, lengthInput) // linreg base function startPrice = i + s * (lengthInput - 1) endPrice = i var line baseLine = na if na(baseLine) and not na(startPrice) baseLine := line.new(bar_index - lengthInput + 1, startPrice, bar_index, endPrice, width=d_lwidth, style=D_Line_Type, extend=extendStyle, color=colorBase) else line.set_xy1(baseLine, bar_index - lengthInput + 1, startPrice) line.set_xy2(baseLine, bar_index, endPrice) na calcDev(source, length, slope, average, intercept) => upDev = 0.0 dnDev = 0.0 stdDevAcc = 0.0 dsxx = 0.0 dsyy = 0.0 dsxy = 0.0 periods = length - 1 daY = intercept + slope * periods / 2 val = intercept for j = 0 to periods by 1 price = high[j] - val if price > upDev upDev := price price := val - low[j] if price > dnDev dnDev := price price := source[j] dxt = price - average dyt = val - daY price -= val stdDevAcc += price * price dsxx += dxt * dxt dsyy += dyt * dyt dsxy += dxt * dyt val += slope stdDev = math.sqrt(stdDevAcc / (periods == 0 ? 1 : periods)) pearsonR = dsxx == 0 or dsyy == 0 ? 0 : dsxy / math.sqrt(dsxx * dsyy) [stdDev, pearsonR, upDev, dnDev] [stdDev, pearsonR, upDev, dnDev] = calcDev(sourceInput, lengthInput, s, a, i) // large linreg function upperStartPrice = startPrice + (useUpperDevInput ? upperMultInput * stdDev : upDev) upperEndPrice = endPrice + (useUpperDevInput ? upperMultInput * stdDev : upDev) var line upper = na lowerStartPrice = startPrice + (useLowerDevInput ? -lowerMultInput * stdDev : -dnDev) lowerEndPrice = endPrice + (useLowerDevInput ? -lowerMultInput * stdDev : -dnDev) var line lower = na if na(upper) and not na(upperStartPrice) upper := useDev1Input ? line.new(bar_index - lengthInput + 1, upperStartPrice, bar_index, upperEndPrice, width=a_lwidth, style=A_Line_Type, extend=extendStyle, color=colorLarge) : na else line.set_xy1(upper, bar_index - lengthInput + 1, upperStartPrice) line.set_xy2(upper, bar_index, upperEndPrice) na if na(lower) and not na(lowerStartPrice) lower := useDev1Input ? line.new(bar_index - lengthInput + 1, lowerStartPrice, bar_index, lowerEndPrice, width=a_lwidth, style=A_Line_Type, extend=extendStyle, color=colorLarge) : na else line.set_xy1(lower, bar_index - lengthInput + 1, lowerStartPrice) line.set_xy2(lower, bar_index, lowerEndPrice) na // medium linreg function upperStartPrice2 = startPrice + (useUpperDevInput2 ? upperMultInput2 * stdDev : upDev) upperEndPrice2 = endPrice + (useUpperDevInput2 ? upperMultInput2 * stdDev : upDev) var line upper2 = na lowerStartPrice2 = startPrice + (useLowerDevInput2 ? -lowerMultInput2 * stdDev : -dnDev) lowerEndPrice2 = endPrice + (useLowerDevInput2 ? -lowerMultInput2 * stdDev : -dnDev) var line lower2 = na if na(upper2) and not na(upperStartPrice2) upper2 := useDev2Input ? line.new(bar_index - lengthInput + 1, upperStartPrice2, bar_index, upperEndPrice2, width=b_lwidth, style=B_Line_Type, extend=extendStyle, color=colorMedium) : na else line.set_xy1(upper2, bar_index - lengthInput + 1, upperStartPrice2) line.set_xy2(upper2, bar_index, upperEndPrice2) na if na(lower2) and not na(lowerStartPrice2) lower2 := useDev2Input ? line.new(bar_index - lengthInput + 1, lowerStartPrice2, bar_index, lowerEndPrice2, width=b_lwidth, style=B_Line_Type, extend=extendStyle, color=colorMedium) : na else line.set_xy1(lower2, bar_index - lengthInput + 1, lowerStartPrice2) line.set_xy2(lower2, bar_index, lowerEndPrice2) na // small linreg fuction upperStartPrice3 = startPrice + (useUpperDevInput3 ? upperMultInput3 * stdDev : upDev) upperEndPrice3 = endPrice + (useUpperDevInput3 ? upperMultInput3 * stdDev : upDev) var line upper3 = na lowerStartPrice3 = startPrice + (useLowerDevInput3 ? -lowerMultInput3 * stdDev : -dnDev) lowerEndPrice3 = endPrice + (useLowerDevInput3 ? -lowerMultInput3 * stdDev : -dnDev) var line lower3 = na if na(upper3) and not na(upperStartPrice3) upper3 := useDev3Input ? line.new(bar_index - lengthInput + 1, upperStartPrice3, bar_index, upperEndPrice3, width=c_lwidth, style=C_Line_Type, extend=extendStyle, color=colorSmall) : na else line.set_xy1(upper3, bar_index - lengthInput + 1, upperStartPrice3) line.set_xy2(upper3, bar_index, upperEndPrice3) na if na(lower3) and not na(lowerStartPrice3) lower3 := useDev3Input ? line.new(bar_index - lengthInput + 1, lowerStartPrice3, bar_index, lowerEndPrice3, width=c_lwidth, style=C_Line_Type, extend=extendStyle, color=colorSmall) : na else line.set_xy1(lower3, bar_index - lengthInput + 1, lowerStartPrice3) line.set_xy2(lower3, bar_index, lowerEndPrice3) na // TRENDLINES // input group7 = 'TRENDLINES' o = open[1] h = high l = low c = close log_chart = input(true, title='Use Log Chart', group=group1) a_Color_Type = input.string(defval='Monochrome', title='Use Trendlines Color Scheme', options=['Colored', 'Monochrome'], group=group7) group8 = 'PRIMARY TRENDLINES' a_Show_Primary = input(true, title='Primary Trendlines On / Off', group=group8) a_len = input(25, title='Primary Lookback Length', group=group8) a_Extensions = input.string(title='Primary Trendlines Extensions', defval='50', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group8) a_width = input.int(2, title='Primary Line Width', minval=0, maxval=10, group=group8) a_LineStyle_Type = input.string(title='Primary Line Type', defval='Solid', options=['Dashed', 'Dotted', 'Solid'], group=group8) a_Line_Type = a_LineStyle_Type == 'Dashed' ? line.style_dashed : a_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid a_Rising_Upper_Falling_Lower = false group9 = 'SECONDARY TRENDLINES' b_Show_Secondary = input(true, title='Secondary Trendlines On / Off', group=group9) b_len = input(10, title='Secondary Lookback Length', group=group9) b_Extensions = input.string(title='Secondary Trendlines Extensions', defval='25', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group9) b_LineStyle_Type = input.string(title='Secondary Line Type', defval='Dashed', options=['Dashed', 'Dotted', 'Solid'], group=group9) b_Line_Type = b_LineStyle_Type == 'Dashed' ? line.style_dashed : b_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid b_width = input.int(2, title='Secondary Line Width', minval=0, maxval=10, group=group9) b_Rising_Upper_Falling_Lower = false group10 = 'TRENDLINES COLOR' a_Line_Color = input.color(#ffffff, title="Primary Trendline Color", group=group10) b_Line_Color = input.color(#ffffff, title="Secondary Trendline Color", group=group10) a_bar_time = time - time[1] b_bar_time = time - time[1] //primary trendline // trendline extension a_Extension_Multiplier= a_Extensions=="25"? 1 : a_Extensions=="50"? 2 : a_Extensions=="75"? 3 : a_Extensions=="100"? 4 : a_Extensions=="150"? 6 : a_Extensions=="200"? 8 : a_Extensions=="300"? 12 : a_Extensions=="400"? 16 : a_Extensions=="500"? 20 : a_Extensions=="750"? 30 : a_Extensions=="1000"? 40 : a_Extensions=="Infinate"? 0 : na // trendline function a_f_trendline(a__input_function, a__delay, a__only_up, a__extend) => var int a_Ax = 1 var int a_Bx = 1 var float a_By = 0 var float a_slope = 0 a_Ay = fixnan(a__input_function) if ta.change(a_Ay) != 0 a_Ax := time[a__delay] a_By := a_Ay[1] a_Bx := a_Ax[1] a_slope := log_chart ? (math.log(a_Ay) - math.log(a_By)) / (a_Ax - a_Bx) : (a_Ay - a_By) / (a_Ax - a_Bx) a_slope else a_Ax := a_Ax[1] a_Bx := a_Bx[1] a_By := a_By[1] a_By // draw trendline var line a_trendline = na var int a_Axbis = 0 var float a_Aybis = 0 var bool a__xtend = true a_extension_time = a_Extension_Multiplier * a_bar_time * 25 a_Axbis := a_Ax + a_extension_time a_Aybis := log_chart ? a_Ay * math.exp(a_extension_time * a_slope) : a_Ay + a_extension_time * a_slope if a_Extension_Multiplier != 0 a__xtend := false a__xtend if ta.change(a_Ay) != 0 a_line_color_Rising_Falling = a_slope * time < 0 ? a__only_up ? a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na a_line_color_Not_Rising_Falling = a_slope * time < 0 ? a__only_up ? na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : na a_line_color = a_Show_Primary and not a_Rising_Upper_Falling_Lower ? a_line_color_Not_Rising_Falling : a_Show_Primary and a_Rising_Upper_Falling_Lower ? a_line_color_Rising_Falling : na if not na(a_line_color) a_trendline := line.new(a_Bx, a_By, a_Axbis, a_Aybis, xloc.bar_time, extend=a__xtend ? extend.right : extend.none, color=a_Line_Color, style=a_Line_Type, width=a_width) a_trendline [a_Bx, a_By, a_Axbis, a_Aybis, a_slope] // calc pivot points a_high_point = ta.pivothigh(c > o ? h : l, a_len, a_len / 2) a_low_point = ta.pivotlow(c > o ? l : h, a_len, a_len / 2) // call trendline function [a_phx1, a_phy1, a_phx2, a_phy2, a_slope_high] = a_f_trendline(a_high_point, a_len / 2, false, true) [a_plx1, a_ply1, a_plx2, a_ply2, a_slope_low] = a_f_trendline(a_low_point, a_len / 2, true, true) // secondary trendline // trendline extension b_Extension_Multiplier= b_Extensions=="25"? 1 : b_Extensions=="50"? 2 : b_Extensions=="75"? 3 : b_Extensions=="100"? 4 : b_Extensions=="150"? 6 : b_Extensions=="200"? 8 : b_Extensions=="300"? 12 : b_Extensions=="400"? 16 : b_Extensions=="500"? 20 : b_Extensions=="750"? 30 : b_Extensions=="1000"? 40 : b_Extensions=="Infinate"? 0 : na // trendline function b_f_trendline(b__input_function, b__delay, b__only_up, b__extend) => var int b_Ax = 1 var int b_Bx = 1 var float b_By = 0 var float b_slope = 0 b_Ay = fixnan(b__input_function) if ta.change(b_Ay) != 0 b_Ax := time[b__delay] b_By := b_Ay[1] b_Bx := b_Ax[1] b_slope := log_chart ? (math.log(b_Ay) - math.log(b_By)) / (b_Ax - b_Bx) : (b_Ay - b_By) / (b_Ax - b_Bx) b_slope else b_Ax := b_Ax[1] b_Bx := b_Bx[1] b_By := b_By[1] b_By // draw trendlines var line b_trendline = na var int b_Axbis = 0 var float b_Aybis = 0 var bool b__xtend = true b_extension_time = b_Extension_Multiplier * b_bar_time * 25 b_Axbis := b_Ax + b_extension_time b_Aybis := log_chart ? b_Ay * math.exp(b_extension_time * b_slope) : b_Ay + b_extension_time * b_slope if b_Extension_Multiplier != 0 b__xtend := false b__xtend if ta.change(b_Ay) != 0 b_line_color_Rising_Falling = b_slope * time < 0 ? b__only_up ? b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na b_line_color_Not_Rising_Falling = b_slope * time < 0 ? b__only_up ? na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : na b_line_color = b_Show_Secondary and not b_Rising_Upper_Falling_Lower ? b_line_color_Not_Rising_Falling : b_Show_Secondary and b_Rising_Upper_Falling_Lower ? b_line_color_Rising_Falling : na if not na(b_line_color) b_trendline := line.new(b_Bx, b_By, b_Axbis, b_Aybis, xloc.bar_time, extend=b__xtend ? extend.right : extend.none, color=b_Line_Color, style=b_Line_Type, width=b_width) b_trendline [b_Bx, b_By, b_Axbis, b_Aybis, b_slope] // calc pivot points b_high_point = ta.pivothigh(c > o ? h : l, b_len, b_len / 2) b_low_point = ta.pivotlow(c > o ? l : h, b_len, b_len / 2) // call trendline function [b_phx1, b_phy1, b_phx2, b_phy2, b_slope_high] = b_f_trendline(b_high_point, b_len / 2, false, true) [b_plx1, b_ply1, b_plx2, b_ply2, b_slope_low] = b_f_trendline(b_low_point, b_len / 2, true, true) // plot b_color_high = b_slope_high * time < 0 ? color.green : na b_color_low = b_slope_low * time > 0 ? color.red : na
Bitcoin Spot Premium
https://www.tradingview.com/script/wFYxVeN2-Bitcoin-Spot-Premium/
ImaWrknMan
https://www.tradingview.com/u/ImaWrknMan/
63
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/ // // Description // ----------- // Plots the difference between the Bitcoin Spot price and the average of 7 Futures prices. //@version=5 indicator(title="Bitcoin Spot Premium", shorttitle = "BTC Spot Premium", overlay = false) spotSymbol = input(defval = "COINBASE:BTCUSD", title = "Spot Symbol") src = input(defval = hlc3, title = "Source") inclFut1 = input(defval = true, title = "", inline = "fut1", group = "Futures Symbols") fut1Symbol = input(defval = "BYBIT:BTCUSDT.P", title = "Symbol 1", inline = "fut1", group = "Futures Symbols") inclFut2 = input(defval = true, title = "", inline = "fut2", group = "Futures Symbols") fut2Symbol = input(defval = "BITFINEX:BTCUSD", title = "Symbol 2", inline = "fut2", group = "Futures Symbols") inclFut3 = input(defval = true, title = "", inline = "fut3", group = "Futures Symbols") fut3Symbol = input(defval = "BITSTAMP:BTCUSD", title = "Symbol 3", inline = "fut3", group = "Futures Symbols") inclFut4 = input(defval = true, title = "", inline = "fut4", group = "Futures Symbols") fut4Symbol = input(defval = "BITMEX:XBTUSDT.P", title = "Symbol 4", inline = "fut4", group = "Futures Symbols") inclFut5 = input(defval = true, title = "", inline = "fut5", group = "Futures Symbols") fut5Symbol = input(defval = "PHEMEX:BTCUSDT.P", title = "Symbol 5", inline = "fut5", group = "Futures Symbols") inclFut6 = input(defval = true, title = "", inline = "fut6", group = "Futures Symbols") fut6Symbol = input(defval = "BINANCE:BTCUSDT.P", title = "Symbol 6", inline = "fut6", group = "Futures Symbols") inclFut7 = input(defval = true, title = "", inline = "fut7", group = "Futures Symbols") fut7Symbol = input(defval = "OKX:BTCUSDT.P", title = "Symbol 7", inline = "fut7", group = "Futures Symbols") // Spot spot = request.security(spotSymbol, timeframe.period, src) // Futures fut = array.new_float(0, 0) fut1 = request.security(fut1Symbol, timeframe.period, src) fut2 = request.security(fut2Symbol, timeframe.period, src) fut3 = request.security(fut3Symbol, timeframe.period, src) fut4 = request.security(fut4Symbol, timeframe.period, src) fut5 = request.security(fut5Symbol, timeframe.period, src) fut6 = request.security(fut6Symbol, timeframe.period, src) fut7 = request.security(fut7Symbol, timeframe.period, src) if inclFut1 array.push(fut, fut1) if inclFut2 array.push(fut, fut2) if inclFut3 array.push(fut, fut3) if inclFut4 array.push(fut, fut4) if inclFut5 array.push(fut, fut5) if inclFut6 array.push(fut, fut6) if inclFut7 array.push(fut, fut7) // Average all Futures futAvg = array.avg(fut) // Premium prem = spot - futAvg // Plot color transp = prem >= -10 and prem <= 10 ? 80 : prem >= -20 and prem <= 20 ? 65 : prem >= -30 and prem <= 30 ? 50 : prem >= -40 and prem <= 40 ? 35 : prem >= -50 and prem <= 50 ? 20 : 0 plotClr = prem > 0 ? color.rgb(102, 187, 106, transp) : color.rgb(247, 82, 95, transp) hline(0) plot(prem, color = plotClr, style = plot.style_area)
ETH Gravity Oscillator
https://www.tradingview.com/script/rLI0jakf-ETH-Gravity-Oscillator/
nickolassteel
https://www.tradingview.com/u/nickolassteel/
21
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/ // © nickolassteel //@version=5 indicator(title='ETH Gravity Oscillator', format=format.price, precision=1) //Variables ETH = request.security('ETHUSD', 'W', close) //COG ETHcog = ((ta.cog(ETH, 20)) + 12) * (10/6) fx = math.pow(math.e, -1 * ((bar_index - 250)* 0.01)) + 6.9 ETHadj = (((ETHcog / fx) * 10) + 0.9) * (10/11) //Graph c_grad = color.from_gradient(ETHadj, 0, 10, color.rgb(0, 500, 0, 25), color.rgb(500, 0, 0, 0)) plot(ETHadj, linewidth=2, color=c_grad) hline(5)
SuperTrend Optimizer
https://www.tradingview.com/script/aH7Vwm5C-SuperTrend-Optimizer/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
1,735
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 //@version=5 // ________________________________________________ // | | // | --------------------------------- | // | | K̲ i̲ o̲ s̲ e̲ f̲ f̲ T̲ r̲ a̲ d̲ i̲ n̲ g | | // | | | | // | | ƃ u ᴉ p ɐ ɹ ꓕ ⅎ ⅎ ǝ s o ᴉ ꓘ | | // | -------------------------------- | // | | // |_______________________________________________| indicator("SuperTrend Optimizer", shorttitle = "SuperTrend Optimizer [Kioseff Trading]", overlay = true, max_lines_count = 500, max_boxes_count = 500) factor = input.float(3.0, "SuperTrend Factor", step = 0.01, minval = 0.0001, group = "Set Lower Threshold for Parameter Optimization Range", tooltip = "Changes to This Parameter Shifts the Tested Factor Range. For Instance, Increasing the Factor Measure From 3.00 to 3.01 (+0.01) Will Remove 3.00 From the Tested Range - This Setting Controls the Lower Threshold of the Range. The Upper Threshold, in All Instances, Is This Setting + 3.3 (I.e 3.0[Lower] - 6.3[Upper], 4.0[Lower] - 7.3[Upper], 2.5[Lower], - 5.8[Upper])") atr = input.int(10, "SuperTrend ATR Length", step = 1, minval = 1, tooltip = "Changes to This Parameter Shifts the Tested ATR Period Range. For Instance, Increasing the ATR Measure From 10 to 1 (+1) Will Remove 10 From the Tested Range - This Setting Controls the Lower Threshold of the Range. The Upper Threshold, in All Instances, Is This Setting + 2 (I.e 10[Lower] - 12[Upper], 11[Lower] - 13[Upper], 9[Lower], - 11[Upper])") select = input.string("Best", title = "Best Performers ? Worst Performers", options = ["Best", "Worst"], group = "Table Config") inst = input.string("No", title = "Instructions?", options = ["No", "Yes"]) tab = input.string("All", title = "Show Performers", options = ["Top Three", "All"]) lab = input.string("On", title = '"Parameters Tested" Label ?', options = ["On", "Off"]) ovr = input.string("Off", title = "Plot Override SuperTrend (Plot Your Own Instead of Auto Plot Best Performer)", options = ["Off", "On"] , group = 'Plot Supertrend With Your Parameters (This Overrides the Automatic Plot of the Best Performing Parameters) Selecting "On" Does NOT Affect the Parameter Combination Testing Range!') ovrF = input.float(3.0, "Override SuperTrend Factor", step = 0.01, minval = 0.0001) ovrA = input.int(10, "SuperTrend ATR Length", step = 1, minval = 1) light = input.string(defval = "Off", title = "Light Mode?", options = ["Off", "On"]) // _______________________________________________________ // // Override ST // _______________________________________________________ [s, d] = ta.supertrend(ovrF, ovrA) // // _______________________________________________________ // // Combination Parameters for Array // _______________________________________________________ [s1, d1] = ta.supertrend(factor , atr) [s2, d2] = ta.supertrend(factor + 0.1, atr) [s3, d3] = ta.supertrend(factor + 0.2, atr) [s4, d4] = ta.supertrend(factor + 0.3, atr) [s5, d5] = ta.supertrend(factor + 0.4, atr) [s6, d6] = ta.supertrend(factor + 0.5, atr) [s7, d7] = ta.supertrend(factor + 0.6, atr) [s8, d8] = ta.supertrend(factor + 0.7, atr) [s9, d9] = ta.supertrend(factor + 0.8, atr) [s10, d10] = ta.supertrend(factor + 0.9, atr) [s11, d11] = ta.supertrend(factor + 1.0, atr) [s12, d12] = ta.supertrend(factor + 1.1, atr) [s13, d13] = ta.supertrend(factor + 1.2, atr) [s14, d14] = ta.supertrend(factor + 1.3, atr) [s15, d15] = ta.supertrend(factor + 1.4, atr) [s16, d16] = ta.supertrend(factor + 1.5, atr) [s17, d17] = ta.supertrend(factor + 1.6, atr) [s18, d18] = ta.supertrend(factor + 1.7, atr) [s19, d19] = ta.supertrend(factor + 1.8, atr) [s20, d20] = ta.supertrend(factor + 1.9, atr) [s21, d21] = ta.supertrend(factor + 2.0, atr) [s22, d22] = ta.supertrend(factor + 2.1, atr) [s23, d23] = ta.supertrend(factor + 2.2, atr) [s24, d24] = ta.supertrend(factor + 2.3, atr) [s25, d25] = ta.supertrend(factor + 2.4, atr) [s26, d26] = ta.supertrend(factor + 2.5, atr) [s27, d27] = ta.supertrend(factor + 2.6, atr) [s28, d28] = ta.supertrend(factor + 2.7, atr) [s29, d29] = ta.supertrend(factor + 2.8, atr) [s30, d30] = ta.supertrend(factor + 2.9, atr) [s31, d31] = ta.supertrend(factor + 3.0, atr) [s32, d32] = ta.supertrend(factor + 3.1, atr) [s33, d33] = ta.supertrend(factor + 3.2, atr) [s34, d34] = ta.supertrend(factor + 3.3, atr) [sB1, dB1] = ta.supertrend(factor , atr + 1) [sB2, dB2] = ta.supertrend(factor + 0.1, atr + 1) [sB3, dB3] = ta.supertrend(factor + 0.2, atr + 1) [sB4, dB4] = ta.supertrend(factor + 0.3, atr + 1) [sB5, dB5] = ta.supertrend(factor + 0.4, atr + 1) [sB6, dB6] = ta.supertrend(factor + 0.5, atr + 1) [sB7, dB7] = ta.supertrend(factor + 0.6, atr + 1) [sB8, dB8] = ta.supertrend(factor + 0.7, atr + 1) [sB9, dB9] = ta.supertrend(factor + 0.8, atr + 1) [sB10, dB10] = ta.supertrend(factor + 0.9, atr + 1) [sB11, dB11] = ta.supertrend(factor + 1.0, atr + 1) [sB12, dB12] = ta.supertrend(factor + 1.1, atr + 1) [sB13, dB13] = ta.supertrend(factor + 1.2, atr + 1) [sB14, dB14] = ta.supertrend(factor + 1.3, atr + 1) [sB15, dB15] = ta.supertrend(factor + 1.4, atr + 1) [sB16, dB16] = ta.supertrend(factor + 1.5, atr + 1) [sB17, dB17] = ta.supertrend(factor + 1.6, atr + 1) [sB18, dB18] = ta.supertrend(factor + 1.7, atr + 1) [sB19, dB19] = ta.supertrend(factor + 1.8, atr + 1) [sB20, dB20] = ta.supertrend(factor + 1.9, atr + 1) [sB21, dB21] = ta.supertrend(factor + 2.0, atr + 1) [sB22, dB22] = ta.supertrend(factor + 2.1, atr + 1) [sB23, dB23] = ta.supertrend(factor + 2.2, atr + 1) [sB24, dB24] = ta.supertrend(factor + 2.3, atr + 1) [sB25, dB25] = ta.supertrend(factor + 2.4, atr + 1) [sB26, dB26] = ta.supertrend(factor + 2.5, atr + 1) [sB27, dB27] = ta.supertrend(factor + 2.6, atr + 1) [sB28, dB28] = ta.supertrend(factor + 2.7, atr + 1) [sB29, dB29] = ta.supertrend(factor + 2.8, atr + 1) [sB30, dB30] = ta.supertrend(factor + 2.9, atr + 1) [sB31, dB31] = ta.supertrend(factor + 3.0, atr + 1) [sB32, dB32] = ta.supertrend(factor + 3.1, atr + 1) [sB33, dB33] = ta.supertrend(factor + 3.2, atr + 1) [sB34, dB34] = ta.supertrend(factor + 3.3, atr + 1) [sC1, dC1] = ta.supertrend(factor , atr + 2) [sC2, dC2] = ta.supertrend(factor + 0.1, atr + 2) [sC3, dC3] = ta.supertrend(factor + 0.2, atr + 2) [sC4, dC4] = ta.supertrend(factor + 0.3, atr + 2) [sC5, dC5] = ta.supertrend(factor + 0.4, atr + 2) [sC6, dC6] = ta.supertrend(factor + 0.5, atr + 2) [sC7, dC7] = ta.supertrend(factor + 0.6, atr + 2) [sC8, dC8] = ta.supertrend(factor + 0.7, atr + 2) [sC9, dC9] = ta.supertrend(factor + 0.8, atr + 2) [sC10, dC10] = ta.supertrend(factor + 0.9, atr + 2) [sC11, dC11] = ta.supertrend(factor + 1.0, atr + 2) [sC12, dC12] = ta.supertrend(factor + 1.1, atr + 2) [sC13, dC13] = ta.supertrend(factor + 1.2, atr + 2) [sC14, dC14] = ta.supertrend(factor + 1.3, atr + 2) [sC15, dC15] = ta.supertrend(factor + 1.4, atr + 2) [sC16, dC16] = ta.supertrend(factor + 1.5, atr + 2) [sC17, dC17] = ta.supertrend(factor + 1.6, atr + 2) [sC18, dC18] = ta.supertrend(factor + 1.7, atr + 2) [sC19, dC19] = ta.supertrend(factor + 1.8, atr + 2) [sC20, dC20] = ta.supertrend(factor + 1.9, atr + 2) [sC21, dC21] = ta.supertrend(factor + 2.0, atr + 2) [sC22, dC22] = ta.supertrend(factor + 2.1, atr + 2) [sC23, dC23] = ta.supertrend(factor + 2.2, atr + 2) [sC24, dC24] = ta.supertrend(factor + 2.3, atr + 2) [sC25, dC25] = ta.supertrend(factor + 2.4, atr + 2) [sC26, dC26] = ta.supertrend(factor + 2.5, atr + 2) [sC27, dC27] = ta.supertrend(factor + 2.6, atr + 2) [sC28, dC28] = ta.supertrend(factor + 2.7, atr + 2) [sC29, dC29] = ta.supertrend(factor + 2.8, atr + 2) [sC30, dC30] = ta.supertrend(factor + 2.9, atr + 2) [sC31, dC31] = ta.supertrend(factor + 3.0, atr + 2) [sC32, dC32] = ta.supertrend(factor + 3.1, atr + 2) [sC33, dC33] = ta.supertrend(factor + 3.2, atr + 2) [sC34, dC34] = ta.supertrend(factor + 3.3, atr + 2) var float x = 0 var float x1 = 0 var float x2 = 0 var float x3 = 0 var float x4 = 0 var float x5 = 0 var float x6 = 0 var float x7 = 0 var float x8 = 0 var float x9 = 0 var float x10 = 0 var float x11 = 0 var float x12 = 0 var float x13 = 0 var float x14 = 0 var float x15 = 0 var float x16 = 0 var float x17 = 0 var float x18 = 0 var float x19 = 0 var float x20 = 0 var float x21 = 0 var float x22 = 0 var float x23 = 0 var float x24 = 0 var float x25 = 0 var float x26 = 0 var float x27 = 0 var float x28 = 0 var float x29 = 0 var float x30 = 0 var float x31 = 0 var float x32 = 0 var float x33 = 0 var float x34 = 0 var float x35 = 0 var float x36 = 0 var float x37 = 0 var float x38 = 0 var float x39 = 0 var float x40 = 0 var float x41 = 0 var float x42 = 0 var float x43 = 0 var float x44 = 0 var float x45 = 0 var float x46 = 0 var float x47 = 0 var float x48 = 0 var float x49 = 0 var float x50 = 0 var float x51 = 0 var float x52 = 0 var float x53 = 0 var float x54 = 0 var float x55 = 0 var float x56 = 0 var float x57 = 0 var float x58 = 0 var float x59 = 0 var float x60 = 0 var float x61 = 0 var float x62 = 0 var float x63 = 0 var float x64 = 0 var float x65 = 0 var float x66 = 0 var float x67 = 0 var float x68 = 0 var float x69 = 0 var float x70 = 0 var float x71 = 0 var float x72 = 0 var float x73 = 0 var float x74 = 0 var float x75 = 0 var float x76 = 0 var float x77 = 0 var float x78 = 0 var float x79 = 0 var float x80 = 0 var float x81 = 0 var float x82 = 0 var float x83 = 0 var float x84 = 0 var float x85 = 0 var float x86 = 0 var float x87 = 0 var float x88 = 0 var float x89 = 0 var float x90 = 0 var float x91 = 0 var float x92 = 0 var float x93 = 0 var float x94 = 0 var float x95 = 0 var float x96 = 0 var float x97 = 0 var float x98 = 0 var float x99 = 0 var float x100 = 0 var float x101 = 0 var float x102 = 0 var float x103 = 0 var float x104 = 0 var float x105 = 0 var float x106 = 0 var float x107 = 0 var float x108 = 0 var float x109 = 0 var float x110 = 0 var float x111 = 0 var float x112 = 0 var float x113 = 0 var float x114 = 0 var float x115 = 0 var float x116 = 0 var float x117 = 0 var float x118 = 0 var float x119 = 0 var float x120 = 0 var float x121 = 0 var float x122 = 0 var float x123 = 0 var float x124 = 0 var float x125 = 0 var float x126 = 0 var float x127 = 0 var float x128 = 0 var float x129 = 0 var float x130 = 0 var float x131 = 0 var float x132 = 0 var float x133 = 0 var float x134 = 0 var float x135 = 0 var float x136 = 0 var float xC69 = 0 var float xC70 = 0 var float xC71 = 0 var float xC72 = 0 var float xC73 = 0 var float xC74 = 0 var float xC75 = 0 var float xC76 = 0 var float xC77 = 0 var float xC78 = 0 var float xC79 = 0 var float xC80 = 0 var float xC81 = 0 var float xC82 = 0 var float xC83 = 0 var float xC84 = 0 var float xC85 = 0 var float xC86 = 0 var float xC87 = 0 var float xC88 = 0 var float xC89 = 0 var float xC90 = 0 var float xC91 = 0 var float xC92 = 0 var float xC93 = 0 var float xC94 = 0 var float xC95 = 0 var float xC96 = 0 var float xC97 = 0 var float xC98 = 0 var float xC99 = 0 var float xC100 = 0 var float xC101 = 0 var float xC102 = 0 var float xC103 = 0 var float xC104 = 0 var float xC105 = 0 var float xC106 = 0 var float xC107 = 0 var float xC108 = 0 var float xC109 = 0 var float xC110 = 0 var float xC111 = 0 var float xC112 = 0 var float xC113 = 0 var float xC114 = 0 var float xC115 = 0 var float xC116 = 0 var float xC117 = 0 var float xC118 = 0 var float xC119 = 0 var float xC120 = 0 var float xC121 = 0 var float xC122 = 0 var float xC123 = 0 var float xC124 = 0 var float xC125 = 0 var float xC126 = 0 var float xC127 = 0 var float xC128 = 0 var float xC129 = 0 var float xC130 = 0 var float xC131 = 0 var float xC132 = 0 var float xC133 = 0 var float xC134 = 0 var float xC135 = 0 var float xC136 = 0 var float k = 0 var float k1 = 0 var float k2 = 0 var float k3 = 0 var float k4 = 0 var float k5 = 0 var float k6 = 0 var float k7 = 0 var float k8 = 0 var float k9 = 0 var float k10 = 0 var float k11 = 0 var float k12 = 0 var float k13 = 0 var float k14 = 0 var float k15 = 0 var float k16 = 0 var float k17 = 0 var float k18 = 0 var float k19 = 0 var float k20 = 0 var float k21 = 0 var float k22 = 0 var float k23 = 0 var float k24 = 0 var float k25 = 0 var float k26 = 0 var float k27 = 0 var float k28 = 0 var float k29 = 0 var float k30 = 0 var float k31 = 0 var float k32 = 0 var float k33 = 0 var float k34 = 0 var float k35 = 0 var float k36 = 0 var float k37 = 0 var float k38 = 0 var float k39 = 0 var float k40 = 0 var float k41 = 0 var float k42 = 0 var float k43 = 0 var float k44 = 0 var float k45 = 0 var float k46 = 0 var float k47 = 0 var float k48 = 0 var float k49 = 0 var float k50 = 0 var float k51 = 0 var float k52 = 0 var float k53 = 0 var float k54 = 0 var float k55 = 0 var float k56 = 0 var float k57 = 0 var float k58 = 0 var float k59 = 0 var float k60 = 0 var float k61 = 0 var float k62 = 0 var float k63 = 0 var float k64 = 0 var float k65 = 0 var float k66 = 0 var float k67 = 0 var float kx34 = 0 var float kx35 = 0 var float kx36 = 0 var float kx37 = 0 var float kx38 = 0 var float kx39 = 0 var float kx40 = 0 var float kx41 = 0 var float kx42 = 0 var float kx43 = 0 var float kx44 = 0 var float kx45 = 0 var float kx46 = 0 var float kx47 = 0 var float kx48 = 0 var float kx49 = 0 var float kx50 = 0 var float kx51 = 0 var float kx52 = 0 var float kx53 = 0 var float kx54 = 0 var float kx55 = 0 var float kx56 = 0 var float kx57 = 0 var float kx58 = 0 var float kx59 = 0 var float kx60 = 0 var float kx61 = 0 var float kx62 = 0 var float kx63 = 0 var float kx64 = 0 var float kx65 = 0 var float kx66 = 0 var float kx67 = 0 var float j = 0 var float j1 = 0 var float j2 = 0 var float j3 = 0 var float j4 = 0 var float j5 = 0 var float j6 = 0 var float j7 = 0 var float j8 = 0 var float j9 = 0 var float j10 = 0 var float j11 = 0 var float j12 = 0 var float j13 = 0 var float j14 = 0 var float j15 = 0 var float j16 = 0 var float j17 = 0 var float j18 = 0 var float j19 = 0 var float j20 = 0 var float j21 = 0 var float j22 = 0 var float j23 = 0 var float j24 = 0 var float j25 = 0 var float j26 = 0 var float j27 = 0 var float j28 = 0 var float j29 = 0 var float j30 = 0 var float j31 = 0 var float j32 = 0 var float j33 = 0 var float j34 = 0 var float j35 = 0 var float j36 = 0 var float j37 = 0 var float j38 = 0 var float j39 = 0 var float j40 = 0 var float j41 = 0 var float j42 = 0 var float j43 = 0 var float j44 = 0 var float j45 = 0 var float j46 = 0 var float j47 = 0 var float j48 = 0 var float j49 = 0 var float j50 = 0 var float j51 = 0 var float j52 = 0 var float j53 = 0 var float j54 = 0 var float j55 = 0 var float j56 = 0 var float j57 = 0 var float j58 = 0 var float j59 = 0 var float j60 = 0 var float j61 = 0 var float j62 = 0 var float j63 = 0 var float j64 = 0 var float j65 = 0 var float j66 = 0 var float j67 = 0 var float jx34 = 0 var float jx35 = 0 var float jx36 = 0 var float jx37 = 0 var float jx38 = 0 var float jx39 = 0 var float jx40 = 0 var float jx41 = 0 var float jx42 = 0 var float jx43 = 0 var float jx44 = 0 var float jx45 = 0 var float jx46 = 0 var float jx47 = 0 var float jx48 = 0 var float jx49 = 0 var float jx50 = 0 var float jx51 = 0 var float jx52 = 0 var float jx53 = 0 var float jx54 = 0 var float jx55 = 0 var float jx56 = 0 var float jx57 = 0 var float jx58 = 0 var float jx59 = 0 var float jx60 = 0 var float jx61 = 0 var float jx62 = 0 var float jx63 = 0 var float jx64 = 0 var float jx65 = 0 var float jx66 = 0 var float jx67 = 0 // _______________________________________________________ // // Combination Parameter Calculations for Array // _______________________________________________________ if d1[1] == 1 and d1 == -1 and j == 0 x := close j := 1 if d1[1] == -1 and d1 == 1 and j == 1 x2 := ((close / x) - 1) * 100 x2 := x2[1] + x2 k += 1 j := 0 if d2[1] == 1 and d2 == -1 and j1 == 0 x3 := close j1 := 1 if d2[1] == -1 and d2 == 1 and j1 == 1 x4 := ((close / x3) - 1) * 100 x4 := x4[1] + x4 k1 += 1 j1 := 0 if d3[1] == 1 and d3 == -1 and j2 == 0 x5 := close j2 := 1 if d13[1] == -1 and d3 == 1 and j2 == 1 x6 := ((close / x5) - 1) * 100 x6 := x6[1] + x6 k2 += 1 j2 := 0 if d4[1] == 1 and d4 == -1 and j3 == 0 x7 := close j3 := 1 if d4[1] == -1 and d4 == 1 and j3 == 1 x8 := ((close / x7) - 1) * 100 x8 := x8[1] + x8 k3 += 1 j3 := 0 if d5[1] == 1 and d5 == -1 and j4 == 0 x9 := close j4 := 1 if d5[1] == -1 and d5 == 1 and j4 == 1 x10 := ((close / x9) - 1) * 100 x10 := x10[1] + x10 k4 += 1 j4 := 0 if d6[1] == 1 and d6 == -1 and j5 == 0 x11 := close j5 := 1 if d6[1] == -1 and d6 == 1 and j5 == 1 x12 := ((close / x11) - 1) * 100 x12 := x12[1] + x12 k5 += 1 j5 := 0 if d7[1] == 1 and d7 == -1 and j6 == 0 x13 := close j6 := 1 if d7[1] == -1 and d7 == 1 and j6 == 1 x14 := ((close / x13) - 1) * 100 x14 := x14[1] + x14 k6 += 1 j6 := 0 if d8[1] == 1 and d8 == -1 and j7 == 0 x15 := close j7 := 1 if d8[1] == -1 and d8 == 1 and j7 == 1 x16 := ((close / x15) - 1) * 100 x16 := x16[1] + x16 k7 += 1 j7 := 0 if d9[1] == 1 and d9 == -1 and j8 == 0 x17 := close j8 := 1 if d9[1] == -1 and d9 == 1 and j8 == 1 x18 := ((close / x17) - 1) * 100 x18 := x18[1] + x18 k8 += 1 j8 := 0 if d10[1] == 1 and d10 == -1 and j9 == 0 x19 := close j9 := 1 if d10[1] == -1 and d10 == 1 and j9 == 1 x20 := ((close / x19) - 1) * 100 x20 := x20[1] + x20 k9 += 1 j9 := 0 if d11[1] == 1 and d11 == -1 and j10 == 0 x21 := close j10 := 1 if d11[1] == -1 and d11 == 1 and j10 == 1 x22 := ((close / x21) - 1) * 100 x22 := x22[1] + x22 k10 += 1 j10 := 0 if d12[1] == 1 and d12 == -1 and j11 == 0 x23 := close j11 := 1 if d12[1] == -1 and d12 == 1 and j11 == 1 x24 := ((close / x23) - 1) * 100 x24 := x24[1] + x24 k11 += 1 j11 := 0 if d13[1] == 1 and d13 == -1 and j12 == 0 x25 := close j12 := 1 if d13[1] == -1 and d13 == 1 and j12 == 1 x26 := ((close / x25) - 1) * 100 x26 := x26[1] + x26 k12 += 1 j12 := 0 if d14[1] == 1 and d14 == -1 and j13 == 0 x27 := close j13 := 1 if d14[1] == -1 and d14 == 1 and j13 == 1 x28 := ((close / x27) - 1) * 100 x28 := x28[1] + x28 k13 += 1 j13 := 0 if d15[1] == 1 and d15 == -1 and j14 == 0 x29 := close j14 := 1 if d15[1] == -1 and d15 == 1 and j14 == 1 x30 := ((close / x29) - 1) * 100 x30 := x30[1] + x30 k14 += 1 j14 := 0 if d16[1] == 1 and d16 == -1 and j15 == 0 x31 := close j15 := 1 if d16[1] == -1 and d16 == 1 and j15 == 1 x32 := ((close / x31) - 1) * 100 x32 := x32[1] + x32 k15 += 1 j15 := 0 if d17[1] == 1 and d17 == -1 and j16 == 0 x33 := close j16 := 1 if d17[1] == -1 and d17 == 1 and j16 == 1 x34 := ((close / x33) - 1) * 100 x34 := x34[1] + x34 k16 += 1 j16 := 0 if d18[1] == 1 and d18 == -1 and j17 == 0 x35 := close j17 := 1 if d18[1] == -1 and d18 == 1 and j17 == 1 x36 := ((close / x35) - 1) * 100 x36 := x36[1] + x36 k17 += 1 j17 := 0 if d19[1] == 1 and d19 == -1 and j18 == 0 x37 := close j18 := 1 if d19[1] == -1 and d19 == 1 and j18 == 1 x38 := ((close / x37) - 1) * 100 x38 := x38[1] + x38 k18 += 1 j18 := 0 if d20[1] == 1 and d20 == -1 and j19 == 0 x39 := close j19 := 1 if d20[1] == -1 and d20 == 1 and j19 == 1 x40 := ((close / x39) - 1) * 100 x40 := x40[1] + x40 k19 += 1 j19 := 0 if d21[1] == 1 and d21 == -1 and j20 == 0 x41 := close j20 := 1 if d21[1] == -1 and d21 == 1 and j20 == 1 x42 := ((close / x41) - 1) * 100 x42 := x42[1] + x42 k20 += 1 j20 := 0 if d22[1] == 1 and d22 == -1 and j21 == 0 x43 := close j21 := 1 if d22[1] == -1 and d22 == 1 and j21 == 1 x44 := ((close / x43) - 1) * 100 x44 := x44[1] + x44 k21 += 1 j21 := 0 if d23[1] == 1 and d23 == -1 and j22 == 0 x45 := close j22 := 1 if d23[1] == -1 and d23 == 1 and j22 == 1 x46 := ((close / x45) - 1) * 100 x46 := x46[1] + x46 k22 += 1 j22 := 0 if d24[1] == 1 and d24 == -1 and j23 == 0 x47 := close j23 := 1 if d24[1] == -1 and d24 == 1 and j23 == 1 x48 := ((close / x47) - 1) * 100 x48 := x48[1] + x48 k23 += 1 j23 := 0 if d25[1] == 1 and d25 == -1 and j24 == 0 x49 := close j24 := 1 if d25[1] == -1 and d25 == 1 and j24 == 1 x50 := ((close / x49) - 1) * 100 x50 := x50[1] + x50 k24 += 1 j24 := 0 if d26[1] == 1 and d26 == -1 and j25 == 0 x51 := close j25 := 1 if d26[1] == -1 and d26 == 1 and j25 == 1 x52 := ((close / x51) - 1) * 100 x52 := x52[1] + x52 k25 += 1 j25 := 0 if d27[1] == 1 and d27 == -1 and j26 == 0 x53 := close j26 := 1 if d27[1] == -1 and d27 == 1 and j26 == 1 x54 := ((close / x53) - 1) * 100 x54 := x54[1] + x54 k26 += 1 j26 := 0 if d28[1] == 1 and d28 == -1 and j27 == 0 x55 := close j27 := 1 if d28[1] == -1 and d28 == 1 and j27 == 1 x56 := ((close / x55) - 1) * 100 x56 := x56[1] + x56 k27 += 1 j27 := 0 if d29[1] == 1 and d29 == -1 and j28 == 0 x57 := close j28 := 1 if d29[1] == -1 and d29 == 1 and j28 == 1 x58 := ((close / x57) - 1) * 100 x58 := x58[1] + x58 k28 += 1 j28 := 0 if d30[1] == 1 and d30 == -1 and j29 == 0 x59 := close j29 := 1 if d30[1] == -1 and d30 == 1 and j29 == 1 x60 := ((close / x59) - 1) * 100 x60 := x60[1] + x60 k29 += 1 j29 := 0 if d31[1] == 1 and d31 == -1 and j30 == 0 x61 := close j30 := 1 if d31[1] == -1 and d31 == 1 and j30 == 1 x62 := ((close / x61) - 1) * 100 x62 := x62[1] + x62 k30 += 1 j30 := 0 if d32[1] == 1 and d32 == -1 and j31 == 0 x63 := close j31 := 1 if d32[1] == -1 and d32 == 1 and j31 == 1 x64 := ((close / x63) - 1) * 100 x64 := x64[1] + x64 k31 += 1 j31 := 0 if d33[1] == 1 and d33 == -1 and j32 == 0 x65 := close j32 := 1 if d33[1] == -1 and d33 == 1 and j32 == 1 x66 := ((close / x65) - 1) * 100 x66 := x66[1] + x66 k32 += 1 j32 := 0 if d34[1] == 1 and d34 == -1 and j33 == 0 x67 := close j33 := 1 if d34[1] == -1 and d34 == 1 and j33 == 1 x68 := ((close / x67) - 1) * 100 x68 := x68[1] + x68 k33 += 1 j33 := 0 if dB1[1] == 1 and dB1 == -1 and j34 == 0 x69 := close j34 := 1 if dB1[1] == -1 and dB1 == 1 and j34 == 1 x70 := ((close / x69) - 1) * 100 x70 := x70[1] + x70 k34 += 1 j34 := 0 if dB2[1] == 1 and dB2 == -1 and j35 == 0 x71 := close j35 := 1 if dB2[1] == -1 and dB2 == 1 and j35 == 1 x72 := ((close / x71) - 1) * 100 x72 := x72[1] + x72 k35 += 1 j35 := 0 if dB3[1] == 1 and dB3 == -1 and j36 == 0 x73 := close j36 := 1 if dB13[1] == -1 and dB3 == 1 and j36 == 1 x74 := ((close / x73) - 1) * 100 x74 := x74[1] + x74 k36 += 1 j36 := 0 if dB4[1] == 1 and dB4 == -1 and j37 == 0 x75 := close j37 := 1 if dB4[1] == -1 and dB4 == 1 and j37 == 1 x76 := ((close / x75) - 1) * 100 x76 := x76[1] + x76 k37 += 1 j37 := 0 if dB5[1] == 1 and dB5 == -1 and j38 == 0 x77 := close j38 := 1 if dB5[1] == -1 and dB5 == 1 and j38 == 1 x78 := ((close / x77) - 1) * 100 x78 := x78[1] + x78 k38 += 1 j38 := 0 if dB6[1] == 1 and dB6 == -1 and j39 == 0 x79 := close j39 := 1 if dB6[1] == -1 and dB6 == 1 and j39 == 1 x80 := ((close / x79) - 1) * 100 x80 := x80[1] + x80 k39 += 1 j39 := 0 if dB7[1] == 1 and dB7 == -1 and j40 == 0 x81 := close j40 := 1 if dB7[1] == -1 and dB7 == 1 and j40 == 1 x82 := ((close / x81) - 1) * 100 x82 := x82[1] + x82 k40 += 1 j40 := 0 if dB8[1] == 1 and dB8 == -1 and j41 == 0 x83 := close j41 := 1 if dB8[1] == -1 and dB8 == 1 and j41 == 1 x84 := ((close / x83) - 1) * 100 x84 := x84[1] + x84 k41 += 1 j41 := 0 if dB9[1] == 1 and dB9 == -1 and j42 == 0 x85 := close j42 := 1 if dB9[1] == -1 and dB9 == 1 and j42 == 1 x86 := ((close / x85) - 1) * 100 x86 := x86[1] + x86 k42 += 1 j42 := 0 if dB10[1] == 1 and dB10 == -1 and j43 == 0 x87 := close j43 := 1 if dB10[1] == -1 and dB10 == 1 and j43 == 1 x88 := ((close / x87) - 1) * 100 x88 := x88[1] + x88 k43 += 1 j43 := 0 if dB11[1] == 1 and dB11 == -1 and j44 == 0 x89 := close j44 := 1 if dB11[1] == -1 and dB11 == 1 and j44 == 1 x90 := ((close / x89) - 1) * 100 x90 := x90[1] + x90 k44 += 1 j44 := 0 if dB12[1] == 1 and dB12 == -1 and j45 == 0 x91 := close j45 := 1 if dB12[1] == -1 and dB12 == 1 and j45 == 1 x92 := ((close / x91) - 1) * 100 x92 := x92[1] + x92 k45 += 1 j45 := 0 if dB13[1] == 1 and dB13 == -1 and j46 == 0 x93 := close j46 := 1 if dB13[1] == -1 and dB13 == 1 and j46 == 1 x94 := ((close / x93) - 1) * 100 x94 := x94[1] + x94 k46 += 1 j46 := 0 if dB14[1] == 1 and dB14 == -1 and j47 == 0 x95 := close j47 := 1 if dB14[1] == -1 and dB14 == 1 and j47 == 1 x96 := ((close / x95) - 1) * 100 x96 := x96[1] + x96 k47 += 1 j47 := 0 if dB15[1] == 1 and dB15 == -1 and j48 == 0 x97 := close j48 := 1 if dB15[1] == -1 and dB15 == 1 and j48 == 1 x98 := ((close / x97) - 1) * 100 x98 := x98[1] + x98 k48 += 1 j48 := 0 if dB16[1] == 1 and dB16 == -1 and j49 == 0 x99 := close j49 := 1 if dB16[1] == -1 and dB16 == 1 and j49 == 1 x100 := ((close / x99) - 1) * 100 x100 := x100[1] + x100 k49 += 1 j49 := 0 if dB17[1] == 1 and dB17 == -1 and j50 == 0 x101 := close j50 := 1 if dB17[1] == -1 and dB17 == 1 and j50 == 1 x102 := ((close / x101) - 1) * 100 x102 := x102[1] + x102 k50 += 1 j50 := 0 if dB18[1] == 1 and dB18 == -1 and j51 == 0 x103 := close j51 := 1 if dB18[1] == -1 and dB18 == 1 and j51 == 1 x104 := ((close / x103) - 1) * 100 x104 := x104[1] + x104 k51 += 1 j51 := 0 if dB19[1] == 1 and dB19 == -1 and j52 == 0 x105 := close j52 := 1 if dB19[1] == -1 and dB19 == 1 and j52 == 1 x106 := ((close / x105) - 1) * 100 x106 := x106[1] + x106 k52 += 1 j52 := 0 if dB20[1] == 1 and dB20 == -1 and j53 == 0 x107 := close j53 := 1 if dB20[1] == -1 and dB20 == 1 and j53 == 1 x108 := ((close / x107) - 1) * 100 x108 := x108[1] + x108 k53 += 1 j53 := 0 if dB21[1] == 1 and dB21 == -1 and j54 == 0 x109 := close j54 := 1 if dB21[1] == -1 and dB21 == 1 and j54 == 1 x110 := ((close / x109) - 1) * 100 x110 := x110[1] + x110 k54 += 1 j54 := 0 if dB22[1] == 1 and dB22 == -1 and j55 == 0 x111 := close j55 := 1 if dB22[1] == -1 and dB22 == 1 and j55 == 1 x112 := ((close / x111) - 1) * 100 x112 := x112[1] + x112 k55 += 1 j55 := 0 if dB23[1] == 1 and dB23 == -1 and j56 == 0 x113 := close j56 := 1 if dB23[1] == -1 and dB23 == 1 and j56 == 1 x114 := ((close / x113) - 1) * 100 x114 := x114[1] + x114 k56 += 1 j56 := 0 if dB24[1] == 1 and dB24 == -1 and j57 == 0 x115 := close j57 := 1 if dB24[1] == -1 and dB24 == 1 and j57 == 1 x116 := ((close / x115) - 1) * 100 x116 := x116[1] + x116 k57 += 1 j57 := 0 if dB25[1] == 1 and dB25 == -1 and j58 == 0 x117 := close j58 := 1 if dB25[1] == -1 and dB25 == 1 and j58 == 1 x118 := ((close / x117) - 1) * 100 x118 := x118[1] + x118 k58 += 1 j58 := 0 if dB26[1] == 1 and dB26 == -1 and j59 == 0 x119 := close j59 := 1 if dB26[1] == -1 and dB26 == 1 and j59 == 1 x120 := ((close / x119) - 1) * 100 x120 := x120[1] + x120 k59 += 1 j59 := 0 if dB27[1] == 1 and dB27 == -1 and j60 == 0 x121 := close j60 := 1 if dB27[1] == -1 and dB27 == 1 and j60 == 1 x122 := ((close / x121) - 1) * 100 x122 := x122[1] + x122 k60 += 1 j60 := 0 if dB28[1] == 1 and dB28 == -1 and j61 == 0 x123 := close j61 := 1 if dB28[1] == -1 and dB28 == 1 and j61 == 1 x124 := ((close / x123) - 1) * 100 x124 := x124[1] + x124 k61 += 1 j61 := 0 if dB29[1] == 1 and dB29 == -1 and j62 == 0 x125 := close j62 := 1 if dB29[1] == -1 and dB29 == 1 and j62 == 1 x126 := ((close / x125) - 1) * 100 x126 := x126[1] + x126 k62 += 1 j62 := 0 if dB30[1] == 1 and dB30 == -1 and j63 == 0 x127 := close j63 := 1 if dB30[1] == -1 and dB30 == 1 and j63 == 1 x128 := ((close / x127) - 1) * 100 x128 := x128[1] + x128 k63 += 1 j63 := 0 if dB31[1] == 1 and dB31 == -1 and j64 == 0 x129 := close j64 := 1 if dB31[1] == -1 and dB31 == 1 and j64 == 1 x130 := ((close / x129) - 1) * 100 x130 := x130[1] + x130 k64 += 1 j64 := 0 if dB32[1] == 1 and dB32 == -1 and j65 == 0 x131 := close j65 := 1 if dB32[1] == -1 and dB32 == 1 and j65 == 1 x132 := ((close / x131) - 1) * 100 x132 := x132[1] + x132 k65 += 1 j65 := 0 if dB33[1] == 1 and dB33 == -1 and j66 == 0 x133 := close j66 := 1 if dB33[1] == -1 and dB33 == 1 and j66 == 1 x134 := ((close / x133) - 1) * 100 x134 := x134[1] + x134 k66 += 1 j66 := 0 if dB34[1] == 1 and dB34 == -1 and j67 == 0 x135 := close j67 := 1 if dB34[1] == -1 and dB34 == 1 and j67 == 1 x136 := ((close / x135) - 1) * 100 x136 := x136[1] + x136 k67 += 1 j67 := 0 if dC1[1] == 1 and dC1 == -1 and jx34 == 0 xC69 := close jx34 := 1 if dC1[1] == -1 and dC1 == 1 and jx34 == 1 xC70 := ((close / xC69) - 1) * 100 xC70 := xC70[1] + xC70 kx34 += 1 jx34 := 0 if dC2[1] == 1 and dC2 == -1 and jx35 == 0 xC71 := close jx35 := 1 if dC2[1] == -1 and dC2 == 1 and jx35 == 1 xC72 := ((close / xC71) - 1) * 100 xC72 := xC72[1] + xC72 kx35 += 1 jx35 := 0 if dC3[1] == 1 and dC3 == -1 and jx36 == 0 xC73 := close jx36 := 1 if dC13[1] == -1 and dC3 == 1 and jx36 == 1 xC74 := ((close / xC73) - 1) * 100 xC74 := xC74[1] + xC74 kx36 += 1 jx36 := 0 if dC4[1] == 1 and dC4 == -1 and jx37 == 0 xC75 := close jx37 := 1 if dC4[1] == -1 and dC4 == 1 and jx37 == 1 xC76 := ((close / xC75) - 1) * 100 xC76 := xC76[1] + xC76 kx37 += 1 jx37 := 0 if dC5[1] == 1 and dC5 == -1 and jx38 == 0 xC77 := close jx38 := 1 if dC5[1] == -1 and dC5 == 1 and jx38 == 1 xC78 := ((close / xC77) - 1) * 100 xC78 := xC78[1] + xC78 kx38 += 1 jx38 := 0 if dC6[1] == 1 and dC6 == -1 and jx39 == 0 xC79 := close jx39 := 1 if dC6[1] == -1 and dC6 == 1 and jx39 == 1 xC80 := ((close / xC79) - 1) * 100 xC80 := xC80[1] + xC80 kx39 += 1 jx39 := 0 if dC7[1] == 1 and dC7 == -1 and jx40 == 0 xC81 := close jx40 := 1 if dC7[1] == -1 and dC7 == 1 and jx40 == 1 xC82 := ((close / xC81) - 1) * 100 xC82 := xC82[1] + xC82 kx40 += 1 jx40 := 0 if dC8[1] == 1 and dC8 == -1 and jx41 == 0 xC83 := close jx41 := 1 if dC8[1] == -1 and dC8 == 1 and jx41 == 1 xC84 := ((close / xC83) - 1) * 100 xC84 := xC84[1] + xC84 kx41 += 1 jx41 := 0 if dC9[1] == 1 and dC9 == -1 and jx42 == 0 xC85 := close jx42 := 1 if dC9[1] == -1 and dC9 == 1 and jx42 == 1 xC86 := ((close / xC85) - 1) * 100 xC86 := xC86[1] + xC86 kx42 += 1 jx42 := 0 if dC10[1] == 1 and dC10 == -1 and jx43 == 0 xC87 := close jx43 := 1 if dC10[1] == -1 and dC10 == 1 and jx43 == 1 xC88 := ((close / xC87) - 1) * 100 xC88 := xC88[1] + xC88 kx43 += 1 jx43 := 0 if dC11[1] == 1 and dC11 == -1 and jx44 == 0 xC89 := close jx44 := 1 if dC11[1] == -1 and dC11 == 1 and jx44 == 1 xC90 := ((close / xC89) - 1) * 100 xC90 := xC90[1] + xC90 kx44 += 1 jx44 := 0 if dC12[1] == 1 and dC12 == -1 and jx45 == 0 xC91 := close jx45 := 1 if dC12[1] == -1 and dC12 == 1 and jx45 == 1 xC92 := ((close / xC91) - 1) * 100 xC92 := xC92[1] + xC92 kx45 += 1 jx45 := 0 if dC13[1] == 1 and dC13 == -1 and jx46 == 0 xC93 := close jx46 := 1 if dC13[1] == -1 and dC13 == 1 and jx46 == 1 xC94 := ((close / xC93) - 1) * 100 xC94 := xC94[1] + xC94 kx46 += 1 jx46 := 0 if dC14[1] == 1 and dC14 == -1 and jx47 == 0 xC95 := close jx47 := 1 if dC14[1] == -1 and dC14 == 1 and jx47 == 1 xC96 := ((close / xC95) - 1) * 100 xC96 := xC96[1] + xC96 kx47 += 1 jx47 := 0 if dC15[1] == 1 and dC15 == -1 and jx48 == 0 xC97 := close jx48 := 1 if dC15[1] == -1 and dC15 == 1 and jx48 == 1 xC98 := ((close / xC97) - 1) * 100 xC98 := xC98[1] + xC98 kx48 += 1 jx48 := 0 if dC16[1] == 1 and dC16 == -1 and jx49 == 0 xC99 := close jx49 := 1 if dC16[1] == -1 and dC16 == 1 and jx49 == 1 xC100 := ((close / xC99) - 1) * 100 xC100 := xC100[1] + xC100 kx49 += 1 jx49 := 0 if dC17[1] == 1 and dC17 == -1 and jx50 == 0 xC101 := close jx50 := 1 if dC17[1] == -1 and dC17 == 1 and jx50 == 1 xC102 := ((close / xC101) - 1) * 100 xC102 := xC102[1] + xC102 kx50 += 1 jx50 := 0 if dC18[1] == 1 and dC18 == -1 and jx51 == 0 xC103 := close jx51 := 1 if dC18[1] == -1 and dC18 == 1 and jx51 == 1 xC104 := ((close / xC103) - 1) * 100 xC104 := xC104[1] + xC104 kx51 += 1 jx51 := 0 if dC19[1] == 1 and dC19 == -1 and jx52 == 0 xC105 := close jx52 := 1 if dC19[1] == -1 and dC19 == 1 and jx52 == 1 xC106 := ((close / xC105) - 1) * 100 xC106 := xC106[1] + xC106 kx52 += 1 jx52 := 0 if dC20[1] == 1 and dC20 == -1 and jx53 == 0 xC107 := close jx53 := 1 if dC20[1] == -1 and dC20 == 1 and jx53 == 1 xC108 := ((close / xC107) - 1) * 100 xC108 := xC108[1] + xC108 kx53 += 1 jx53 := 0 if dC21[1] == 1 and dC21 == -1 and jx54 == 0 xC109 := close jx54 := 1 if dC21[1] == -1 and dC21 == 1 and jx54 == 1 xC110 := ((close / xC109) - 1) * 100 xC110 := xC110[1] + xC110 kx54 += 1 jx54 := 0 if dC22[1] == 1 and dC22 == -1 and jx55 == 0 xC111 := close jx55 := 1 if dC22[1] == -1 and dC22 == 1 and jx55 == 1 xC112 := ((close / xC111) - 1) * 100 xC112 := xC112[1] + xC112 kx55 += 1 jx55 := 0 if dC23[1] == 1 and dC23 == -1 and jx56 == 0 xC113 := close jx56 := 1 if dC23[1] == -1 and dC23 == 1 and jx56 == 1 xC114 := ((close / xC113) - 1) * 100 xC114 := xC114[1] + xC114 kx56 += 1 jx56 := 0 if dC24[1] == 1 and dC24 == -1 and jx57 == 0 xC115 := close jx57 := 1 if dC24[1] == -1 and dC24 == 1 and jx57 == 1 xC116 := ((close / xC115) - 1) * 100 xC116 := xC116[1] + xC116 kx57 += 1 jx57 := 0 if dC25[1] == 1 and dC25 == -1 and jx58 == 0 xC117 := close jx58 := 1 if dC25[1] == -1 and dC25 == 1 and jx58 == 1 xC118 := ((close / xC117) - 1) * 100 xC118 := xC118[1] + xC118 kx58 += 1 jx58 := 0 if dC26[1] == 1 and dC26 == -1 and jx59 == 0 xC119 := close jx59 := 1 if dC26[1] == -1 and dC26 == 1 and jx59 == 1 xC120 := ((close / xC119) - 1) * 100 xC120 := xC120[1] + xC120 kx59 += 1 jx59 := 0 if dC27[1] == 1 and dC27 == -1 and jx60 == 0 xC121 := close jx60 := 1 if dC27[1] == -1 and dC27 == 1 and jx60 == 1 xC122 := ((close / xC121) - 1) * 100 xC122 := xC122[1] + xC122 kx60 += 1 jx60 := 0 if dC28[1] == 1 and dC28 == -1 and jx61 == 0 xC123 := close jx61 := 1 if dC28[1] == -1 and dC28 == 1 and jx61 == 1 xC124 := ((close / xC123) - 1) * 100 xC124 := xC124[1] + xC124 kx61 += 1 jx61 := 0 if dC29[1] == 1 and dC29 == -1 and jx62 == 0 xC125 := close jx62 := 1 if dC29[1] == -1 and dC29 == 1 and jx62 == 1 xC126 := ((close / xC125) - 1) * 100 xC126 := xC126[1] + xC126 kx62 += 1 jx62 := 0 if dC30[1] == 1 and dC30 == -1 and jx63 == 0 xC127 := close jx63 := 1 if dC30[1] == -1 and dC30 == 1 and jx63 == 1 xC128 := ((close / xC127) - 1) * 100 xC128 := xC128[1] + xC128 kx63 += 1 jx63 := 0 if dC31[1] == 1 and dC31 == -1 and jx64 == 0 xC129 := close jx64 := 1 if dC31[1] == -1 and dC31 == 1 and jx64 == 1 xC130 := ((close / xC129) - 1) * 100 xC130 := xC130[1] + xC130 kx64 += 1 jx64 := 0 if dC32[1] == 1 and dC32 == -1 and jx65 == 0 xC131 := close jx65 := 1 if dC32[1] == -1 and dC32 == 1 and jx65 == 1 xC132 := ((close / xC131) - 1) * 100 xC132 := xC132[1] + xC132 kx65 += 1 jx65 := 0 if dC33[1] == 1 and dC33 == -1 and jx66 == 0 xC133 := close jx66 := 1 if dC33[1] == -1 and dC33 == 1 and jx66 == 1 xC134 := ((close / xC133) - 1) * 100 xC134 := xC134[1] + xC134 kx66 += 1 jx66 := 0 if dC34[1] == 1 and dC34 == -1 and jx67 == 0 xC135 := close jx67 := 1 if dC34[1] == -1 and dC34 == 1 and jx67 == 1 xC136 := ((close / xC135) - 1) * 100 xC136 := xC136[1] + xC136 kx67 += 1 jx67 := 0 // Thank you Dyuck https://www.tradingview.com/v/Mzc4dmq7/ f_sort_by_array(_array1, _array2, _ascending) => _array1_size = array.size(_array1) _array1_sorted = array.new_string(_array1_size) _array2_sorted = array.copy(_array2) if _array1_size == array.size(_array2) array.sort(_array2_sorted, _ascending ? order.ascending : 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) array.set(_array1_sorted, i, _unsorted_value) [_array1_sorted, _array2_sorted] // Thank you Dyuck https://www.tradingview.com/v/Mzc4dmq7/ // _______________________________________________________ // // Performance Array Set // _______________________________________________________ best = array.new_float(102) array.set(best, 0, x2) array.set(best, 1, x4) array.set(best, 2, x6) array.set(best, 3, x8) array.set(best, 4, x10) array.set(best, 5, x12) array.set(best, 6, x14) array.set(best, 7, x16) array.set(best, 8, x18) array.set(best, 9, x20) array.set(best, 10, x22) array.set(best, 11, x24) array.set(best, 12, x26) array.set(best, 13, x28) array.set(best, 14, x30) array.set(best, 15, x32) array.set(best, 16, x34) array.set(best, 17, x36) array.set(best, 18, x38) array.set(best, 19, x40) array.set(best, 20, x42) array.set(best, 21, x44) array.set(best, 22, x46) array.set(best, 23, x48) array.set(best, 24, x50) array.set(best, 25, x52) array.set(best, 26, x54) array.set(best, 27, x56) array.set(best, 28, x58) array.set(best, 29, x60) array.set(best, 30, x62) array.set(best, 31, x64) array.set(best, 32, x66) array.set(best, 33, x68) array.set(best, 34, x70) array.set(best, 35, x72) array.set(best, 36, x74) array.set(best, 37, x76) array.set(best, 38, x78) array.set(best, 39, x80) array.set(best, 40, x82) array.set(best, 41, x84) array.set(best, 42, x86) array.set(best, 43, x88) array.set(best, 44, x90) array.set(best, 45, x92) array.set(best, 46, x94) array.set(best, 47, x96) array.set(best, 48, x98) array.set(best, 49, x100) array.set(best, 50, x102) array.set(best, 51, x104) array.set(best, 52, x106) array.set(best, 53, x108) array.set(best, 54, x110) array.set(best, 55, x112) array.set(best, 56, x114) array.set(best, 57, x116) array.set(best, 58, x118) array.set(best, 59, x120) array.set(best, 60, x122) array.set(best, 61, x124) array.set(best, 62, x126) array.set(best, 63, x128) array.set(best, 64, x130) array.set(best, 65, x132) array.set(best, 66, x134) array.set(best, 67, x136) array.set(best, 68, xC70) array.set(best, 69, xC72) array.set(best, 70, xC74) array.set(best, 71, xC76) array.set(best, 72, xC78) array.set(best, 73, xC80) array.set(best, 74, xC82) array.set(best, 75, xC84) array.set(best, 76, xC86) array.set(best, 77, xC88) array.set(best, 78, xC90) array.set(best, 79, xC92) array.set(best, 80, xC94) array.set(best, 81, xC96) array.set(best, 82, xC98) array.set(best, 83, xC100) array.set(best, 84, xC102) array.set(best, 85, xC104) array.set(best, 86, xC106) array.set(best, 87, xC108) array.set(best, 88, xC110) array.set(best, 89, xC112) array.set(best, 90, xC114) array.set(best, 91, xC116) array.set(best, 92, xC118) array.set(best, 93, xC120) array.set(best, 94, xC122) array.set(best, 95, xC124) array.set(best, 96, xC126) array.set(best, 97, xC128) array.set(best, 98, xC130) array.set(best, 99, xC132) array.set(best, 100, xC134) array.set(best, 101, xC136) // _______________________________________________________ // // String Array Set // _______________________________________________________ best1 = array.new_string(102) array.set(best1, 0, "SuperTrend: " + "[" +str.tostring(factor, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 1, "SuperTrend: " + "[" +str.tostring(factor + 0.1, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 2, "SuperTrend: " + "[" +str.tostring(factor + 0.2, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 3, "SuperTrend: " + "[" +str.tostring(factor + 0.3, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 4, "SuperTrend: " + "[" +str.tostring(factor + 0.4, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 5, "SuperTrend: " + "[" +str.tostring(factor + 0.5, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 6, "SuperTrend: " + "[" +str.tostring(factor + 0.6, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 7, "SuperTrend: " + "[" +str.tostring(factor + 0.7, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 8, "SuperTrend: " + "[" +str.tostring(factor + 0.8, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 9, "SuperTrend: " + "[" +str.tostring(factor + 0.9, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 10, "SuperTrend: " + "[" +str.tostring(factor + 1.0, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 11, "SuperTrend: " + "[" +str.tostring(factor + 1.1, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 12, "SuperTrend: " + "[" +str.tostring(factor + 1.2, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 13, "SuperTrend: " + "[" +str.tostring(factor + 1.3, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 14, "SuperTrend: " + "[" +str.tostring(factor + 1.4, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 15, "SuperTrend: " + "[" +str.tostring(factor + 1.5, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 16, "SuperTrend: " + "[" +str.tostring(factor + 1.6, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 17, "SuperTrend: " + "[" +str.tostring(factor + 1.7, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 18, "SuperTrend: " + "[" +str.tostring(factor + 1.8, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 19, "SuperTrend: " + "[" +str.tostring(factor + 1.9, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 20, "SuperTrend: " + "[" +str.tostring(factor + 2.0, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 21, "SuperTrend: " + "[" +str.tostring(factor + 2.1, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 22, "SuperTrend: " + "[" +str.tostring(factor + 2.2, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 23, "SuperTrend: " + "[" +str.tostring(factor + 2.3, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 24, "SuperTrend: " + "[" +str.tostring(factor + 2.4, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 25, "SuperTrend: " + "[" +str.tostring(factor + 2.5, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 26, "SuperTrend: " + "[" +str.tostring(factor + 2.6, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 27, "SuperTrend: " + "[" +str.tostring(factor + 2.7, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 28, "SuperTrend: " + "[" +str.tostring(factor + 2.8, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 29, "SuperTrend: " + "[" +str.tostring(factor + 2.9, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 30, "SuperTrend: " + "[" +str.tostring(factor + 3.0, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 31, "SuperTrend: " + "[" +str.tostring(factor + 3.1, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 32, "SuperTrend: " + "[" +str.tostring(factor + 3.2, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 33, "SuperTrend: " + "[" +str.tostring(factor + 3.3, format.mintick) + ", " + str.tostring(atr + 0, "#") + "] ") array.set(best1, 34, "SuperTrend: " + "[" +str.tostring(factor, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 35, "SuperTrend: " + "[" +str.tostring(factor + 0.1, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 36, "SuperTrend: " + "[" +str.tostring(factor + 0.2, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 37, "SuperTrend: " + "[" +str.tostring(factor + 0.3, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 38, "SuperTrend: " + "[" +str.tostring(factor + 0.4, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 39, "SuperTrend: " + "[" +str.tostring(factor + 0.5, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 40, "SuperTrend: " + "[" +str.tostring(factor + 0.6, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 41, "SuperTrend: " + "[" +str.tostring(factor + 0.7, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 42, "SuperTrend: " + "[" +str.tostring(factor + 0.8, format.mintick)+ ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 43, "SuperTrend: " + "[" +str.tostring(factor + 0.9, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 44, "SuperTrend: " + "[" +str.tostring(factor + 1.0, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 45, "SuperTrend: " + "[" +str.tostring(factor + 1.1, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 46, "SuperTrend: " + "[" +str.tostring(factor + 1.2, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 47, "SuperTrend: " + "[" +str.tostring(factor + 1.3, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 48, "SuperTrend: " + "[" +str.tostring(factor + 1.4, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 49, "SuperTrend: " + "[" +str.tostring(factor + 1.5, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 50, "SuperTrend: " + "[" +str.tostring(factor + 1.6, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 51, "SuperTrend: " + "[" +str.tostring(factor + 1.7, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 52, "SuperTrend: " + "[" +str.tostring(factor + 1.8, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 53, "SuperTrend: " + "[" +str.tostring(factor + 1.9, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 54, "SuperTrend: " + "[" +str.tostring(factor + 2.0, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 55, "SuperTrend: " + "[" +str.tostring(factor + 2.1, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 56, "SuperTrend: " + "[" +str.tostring(factor + 2.2, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 57, "SuperTrend: " + "[" +str.tostring(factor + 2.3, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 58, "SuperTrend: " + "[" +str.tostring(factor + 2.4, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 59, "SuperTrend: " + "[" +str.tostring(factor + 2.5, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 60, "SuperTrend: " + "[" +str.tostring(factor + 2.6, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 61, "SuperTrend: " + "[" +str.tostring(factor + 2.7, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 62, "SuperTrend: " + "[" +str.tostring(factor + 2.8, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 63, "SuperTrend: " + "[" +str.tostring(factor + 2.9, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 64, "SuperTrend: " + "[" +str.tostring(factor + 3.0, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 65, "SuperTrend: " + "[" +str.tostring(factor + 3.1, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 66, "SuperTrend: " + "[" +str.tostring(factor + 3.2, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 67, "SuperTrend: " + "[" +str.tostring(factor + 3.3, format.mintick) + ", " + str.tostring(atr + 1, "#") + "] ") array.set(best1, 68, "SuperTrend: " + "[" +str.tostring(factor, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 69, "SuperTrend: " + "[" +str.tostring(factor + 0.1, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 70, "SuperTrend: " + "[" +str.tostring(factor + 0.2, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 71, "SuperTrend: " + "[" +str.tostring(factor + 0.3, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 72, "SuperTrend: " + "[" +str.tostring(factor + 0.4, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 73, "SuperTrend: " + "[" +str.tostring(factor + 0.5, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 74, "SuperTrend: " + "[" +str.tostring(factor + 0.6, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 75, "SuperTrend: " + "[" +str.tostring(factor + 0.7, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 76, "SuperTrend: " + "[" +str.tostring(factor + 0.8, format.mintick)+ ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 77, "SuperTrend: " + "[" +str.tostring(factor + 0.9, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 78, "SuperTrend: " + "[" +str.tostring(factor + 1.0, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 79, "SuperTrend: " + "[" +str.tostring(factor + 1.1, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 80, "SuperTrend: " + "[" +str.tostring(factor + 1.2, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 81, "SuperTrend: " + "[" +str.tostring(factor + 1.3, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 82, "SuperTrend: " + "[" +str.tostring(factor + 1.4, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 83, "SuperTrend: " + "[" +str.tostring(factor + 1.5, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 84, "SuperTrend: " + "[" +str.tostring(factor + 1.6, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 85, "SuperTrend: " + "[" +str.tostring(factor + 1.7, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 86, "SuperTrend: " + "[" +str.tostring(factor + 1.8, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 87, "SuperTrend: " + "[" +str.tostring(factor + 1.9, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 88, "SuperTrend: " + "[" +str.tostring(factor + 2.0, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 89, "SuperTrend: " + "[" +str.tostring(factor + 2.1, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 90, "SuperTrend: " + "[" +str.tostring(factor + 2.2, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 91, "SuperTrend: " + "[" +str.tostring(factor + 2.3, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 92, "SuperTrend: " + "[" +str.tostring(factor + 2.4, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 93, "SuperTrend: " + "[" +str.tostring(factor + 2.5, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 94, "SuperTrend: " + "[" +str.tostring(factor + 2.6, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 95, "SuperTrend: " + "[" +str.tostring(factor + 2.7, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 96, "SuperTrend: " + "[" +str.tostring(factor + 2.8, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 97, "SuperTrend: " + "[" +str.tostring(factor + 2.9, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 98, "SuperTrend: " + "[" +str.tostring(factor + 3.0, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 99, "SuperTrend: " + "[" +str.tostring(factor + 3.1, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 100, "SuperTrend: " + "[" +str.tostring(factor + 3.2, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") array.set(best1, 101, "SuperTrend: " + "[" +str.tostring(factor + 3.3, format.mintick) + ", " + str.tostring(atr + 2, "#") + "] ") [cumulativePerformanceNameSorted, cumulativePerformanceSorted] = f_sort_by_array(best1, best, false) // _______________________________________________________ // // Attaching an Identifier to Optimized Parameters // _______________________________________________________ o = array.get(cumulativePerformanceSorted, 0) var p = 0.0 var t = 0.0 if o == x2 p := s1 t := d1 else if o == x4 p := s2 t := d2 else if o == x6 p := s3 t := d3 else if o == x8 p := s4 t := d4 else if o == x10 p := s5 t := d5 else if o == x12 p := s6 t := d6 else if o == x14 p := s7 t := d7 else if o == x16 p := s8 t := d8 else if o == x18 p := s9 t := d9 else if o == x20 p := s10 t := d10 else if o == x22 p := s11 t := d11 else if o == x24 p := s12 t := d12 else if o == x26 p := s13 t := d13 else if o == x28 p := s14 t := d14 else if o == x30 p := s15 t := d15 else if o == x32 p := s16 t := d16 else if o == x34 p := s17 t := d17 else if o == x36 p := s18 t := d18 else if o == x38 p := s19 t := d19 else if o == x40 p := s20 t := d20 else if o == x42 p := s21 t := d21 else if o == x44 p := s22 t := d22 else if o == x46 p := s23 t := d23 else if o == x48 p := s24 t := d24 else if o == x50 p := s25 t := d25 else if o == x52 p := s26 t := d26 else if o == x54 p := s27 t := d27 else if o == x56 p := s28 t := d28 else if o == x58 p := s29 t := d29 else if o == x60 p := s30 t := d30 else if o == x62 p := s31 t := d31 else if o == x64 p := s32 t := d32 else if o == x66 p := s33 t := d33 else if o == x68 p := s34 t := d34 else if o == x70 p := sB1 t := dB1 else if o == x72 p := sB2 t := dB2 else if o == x74 p := sB3 t := dB3 else if o == x76 p := sB4 t := dB4 else if o == x78 p := sB5 t := dB5 else if o == x80 p := sB6 t := dB6 else if o == x82 p := sB7 t := dB7 else if o == x84 p := sB8 t := dB8 else if o == x86 p := sB9 t := dB9 else if o == x88 p := sB10 t := dB10 else if o == x90 p := sB11 t := dB11 else if o == x92 p := sB12 t := dB12 else if o == x94 p := sB13 t := dB13 else if o == x96 p := sB14 t := dB14 else if o == x98 p := sB15 t := dB15 else if o == x100 p := sB16 t := dB16 else if o == x102 p := sB17 t := dB17 else if o == x104 p := sB18 t := dB18 else if o == x106 p := sB19 t := dB19 else if o == x108 p := sB20 t := dB20 else if o == x110 p := sB21 t := dB21 else if o == x112 p := sB22 t := dB22 else if o == x114 p := sB23 t := dB23 else if o == x116 p := sB24 t := dB24 else if o == x118 p := sB25 t := dB25 else if o == x120 p := sB26 t := dB26 else if o == x122 p := sB27 t := dB27 else if o == x124 p := sB28 t := dB28 else if o == x126 p := sB29 t := dB29 else if o == x128 p := sB30 t := dB30 else if o == x130 p := sB31 t := dB31 else if o == x132 p := sB32 t := dB32 else if o == x134 p := sB33 t := dB33 else if o == x136 p := sB34 t := dB34 else if o == xC70 p := sC1 t := dC1 else if o == xC72 p := sC2 t := dC2 else if o == xC74 p := sC3 t := dC3 else if o == xC76 p := sC4 t := dC4 else if o == xC78 p := sC5 t := dC5 else if o == xC80 p := sC6 t := dC6 else if o == xC82 p := sC7 t := dC7 else if o == xC84 p := sC8 t := dC8 else if o == xC86 p := sC9 t := dC9 else if o == xC88 p := sC10 t := dC10 else if o == xC90 p := sC11 t := dC11 else if o == xC92 p := sC12 t := dC12 else if o == xC94 p := sC13 t := dC13 else if o == xC96 p := sC14 t := dC14 else if o == xC98 p := sC15 t := dC15 else if o == xC100 p := sC16 t := dC16 else if o == xC102 p := sC17 t := dC17 else if o == xC104 p := sC18 t := dC18 else if o == xC106 p := sC19 t := dC19 else if o == xC108 p := sC20 t := dC20 else if o == xC110 p := sC21 t := dC21 else if o == xC112 p := sC22 t := dC22 else if o == xC114 p := sC23 t := dC23 else if o == xC116 p := sC24 t := dC24 else if o == xC118 p := sC25 t := dC25 else if o == xC120 p := sC26 t := dC26 else if o == xC122 p := sC27 t := dC27 else if o == xC124 p := sC28 t := dC28 else if o == xC126 p := sC29 t := dC29 else if o == xC128 p := sC30 t := dC30 else if o == xC130 p := sC31 t := dC31 else if o == xC132 p := sC32 t := dC32 else if o == xC134 p := sC33 t := dC33 else if o == xC136 p := sC34 t := dC34 // _______________________________________________________ // // Plot Optimized Parameters.. Or Override ST // _______________________________________________________ midS = plot((open + close) / 2, display=display.none, title = "[(Open + Close) / 2] Average Price") upS = plot(ovr == "Off" and t < 0 ? p : na, "Up Trend", color = #02ff00, style=plot.style_linebr) downS = plot(ovr == "Off" and t > 0 ? p : na, "Down Trend", color = #ff0500, style=plot.style_linebr) fill(midS, upS, ovr == "Off" ? color.new(#ffffff, 90) : na, fillgaps=false, title = "Uptrend Fill") fill(midS, downS, ovr == "Off" ? color.new(#000000, 90) : na, fillgaps=false, title = "Downtrend Fill") upO = plot(ovr == "On" and d < 0 ? s : na, "Up Trend (OVERRIDE ST)", color = color.blue, style=plot.style_linebr) downO = plot(ovr == "On" and d > 0 ? s : na, "Down Trend (OVERRIDE ST)", color = color.orange, style=plot.style_linebr) var label [] buy = array.new_label(1) if t[1] == 1 and t == -1 and ovr == "Off" array.push(buy, label.new(bar_index, p * .99, style = label.style_label_up, textcolor = color.green, color = color.new(color.black,50), text = "Long")) else if d[1] == 1 and d == -1 and ovr == "On" array.push(buy, label.new(bar_index, s * .99, style = label.style_label_up, textcolor = color.orange, color = color.new(color.black,50), text = "Long")) // _______________________________________________________ // // Performance Table // _______________________________________________________ arrayText = "" allText = "" allText2 = "" var table tablePerformance = na if barstate.islast tablePerformance := table.new(position.bottom_right, 10, 10, bgcolor = color.new(color.white, 100)) if select == "Best" and tab == "Top Three" for i = 0 to 2 arrayText := arrayText + array.get(cumulativePerformanceNameSorted, i) + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) +"\n\n" else if select == "Worst" array.reverse(cumulativePerformanceSorted) array.reverse(cumulativePerformanceNameSorted) if tab == "Top Three" for i = 0 to 2 arrayText := arrayText + array.get(cumulativePerformanceNameSorted, i) + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) +"\n\n" if tab == "All" for i = 0 to 33 arrayText := arrayText + array.get(cumulativePerformanceNameSorted, i) + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) +"\n\n" for i = 34 to 67 allText := allText + array.get(cumulativePerformanceNameSorted, i) + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) +"\n\n" for i = 68 to 101 allText2 := allText2 + array.get(cumulativePerformanceNameSorted, i) + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) +"\n\n" table.cell(tablePerformance, 2, 2, text = allText, text_color = color.blue, text_size = size.tiny, bgcolor = color.new(color.black, 50)) table.cell(tablePerformance, 3, 2, text = allText2, text_color = light == "Off" ? color.red : color.blue, text_size = size.tiny, bgcolor = color.new(color.black, 50)) if tab == "Top Three" if lab == "On" table.cell(tablePerformance, 1,0, text = "Best Performing ST is Automatically Plotted" ,text_color = color.white, text_size = tab == "All" ? size.tiny : size.normal, bgcolor = na) table.cell(tablePerformance, 1,1, text = "Parameters : Performance" ,text_color = light == "Off" ? color.green : color.blue, text_size = tab == "All" ? size.tiny : size.normal, bgcolor = color.new(color.black, 50)) table.cell(tablePerformance, 1,2, text = arrayText ,text_color = light == "Off" ? color.green : color.blue, text_size = tab == "All" ? size.tiny : size.normal, bgcolor = color.new(color.black, 50)) if lab == "On" table.cell(tablePerformance, tab == "All" ? 2 : 1, tab == "All" ? 0 : 3, text = "Parameters Tested: \n\n" + "Factor [" + str.tostring(factor, format.mintick) + " to " + str.tostring(factor + 3.3, format.mintick) + "]" + "\n\nATR Period " + "[" + str.tostring(atr, "#.0") + " to " + str.tostring(atr + 2, "#.0") + "]", text_color = light == "Off" ? color.white : color.blue, text_size = tab == "All" ? size.small : size.normal) if inst == "Yes" table.cell(tablePerformance, 0,4, text_size = size.small, text_color = light == "Off" ? color.white : color.blue, text = "Hello! This indicator attempts to optimize Supertrend parameters. To achieve this, 102 parameter combinations are tested \nconcurrently - the top three performers are \nlisted in descending order. Parameters, \nFactor: Changes to this parameter shifts the tested factor range. \nFor instance, increasing the factor measure from 3.00 to 3. 01 (+0. 01 ) \nwill remove 3.00 from the tested range - this setting controls \nthe lower threshold of the range. The upper threshold, in all instances, is the \nlower Factor threshold + 3.3 (i.e. 3.0(lower) - 6.3(upper), 4.0(lower) - 7.3(upper), 2.5(lower) - 5.8(upper)) \nATR period: Changes to this parameter shifts the tested ATR period range. For instance, increasing \nthe ATR measure from 10 to 11 (+1) will remove 10\n from the tested range - this setting controls the lower threshold of the \nrange. The upper threshold, in all instances, is the lower threshold + 2 \n(i.e. 10(lower) - 12(upper), 11(lower) - 13(upper), 9(lower), - 11(upper)) The Factor \nparameter is modifiable to any positive decimal number; the ATR parameter is modifiable to any positive integer. \nChanging either parameter shifts the tested parameter combination range. \nBoth parameters can be changed in the settings, to which you control the lower threshold \nof the range. If, for instance, you were to change the Factor measurement from 3.0 to 4.1 \n(+1.1) the 4.0 Factor measurement, and all Factor measures less than 4.0, \nwill be excluded from the performance test. Consequently, \na Supertrend test will be performed with a Factor of 4.1 \nand an ATR period of 10 (default). This test repeats at \n0.1 Factor intervals and 1.0 ATR intervals. Therefore, assume you modify the Factor \nlower threshold to 3.1 and the ATR lower threshold to 10. The indicator will test three Supertrend \nsystems with a Factor of 3.1 and an ATR period of 10.. then 11.. 12, then three systems \nwith a Factor of 3.2 and an ATR period of 10.. then 11.. 12... \nuntil (lower Factor threshold + 3.3) and (lower ATR threshold + 2) are tested... \nwhich in this example is... a Factor of 6.4 and an ATR period of 12. The tested Factor \nrange and ATR range are displayed in a bottom right table alongside \nthe top performing parameter combinations. Of course, you can change \nthe the lower thresholds, which means you can test numerous Supertrend \nparameter combinations! However, no greater than 102 parameter combinations\n will be tested simultaneously; the best performing Supertrend parameters are plotted \non the chart automatically. The indicator tests LONG positions ONLY! Traditional Supertrend sell signals are \nconsidered LONG EXIT signals - \nwhich are calculated for profit/loss. Performance calculations are predicated on CUMULATIVE \ngains, not average gain/loss! Also, it's good to be prudent with an indicator \nlike this! Automated optimization can lead to \nover optimization!") // _______________________________________________________ // // FUN // _______________________________________________________ // _______________________________________________________ // // Raining Candlesticks (Rocketship?) // _______________________________________________________ var line [] n = array.new_line(1) var line [] n1 = array.new_line(1) var linefill [] b = array.new_linefill(1) var line[] c = array.new_line(1) var line [] c1 = array.new_line(1) var line [] l = array.new_line(1) var line [] l1 = array.new_line(1) var line [] l2 = array.new_line(1) var line [] l3 = array.new_line(1) var box[] bo = array.new_box(1) var box[] bo1 = array.new_box(1) var box[] bo2 = array.new_box(1) var box[] bo3 = array.new_box(1) var label [] btc = array.new_label(1) var label [] eth = array.new_label(1) var label [] zCash = array.new_label(1) var label[] doge = array.new_label(1) var label [] rocket = array.new_label(1) [mid, up, lo] = ta.bb(ohlc4, 20, 2.0) emalo = ta.sma(lo, 200) emahi = ta.ema(up, 2) var int counter = 0 var int counter1 = 0 if counter < 30 counter += 1 if counter == 30 counter := 0 if counter1 < 50 counter1 += 1 if counter1 == 50 counter1 := 0 h = ta.highest(high, 250) rain = input.string(defval = "Sunny Day", title = 'Raining ?', options = ["Candles", "Crypto", "Sunny Day", "Rocketship?"], group = 'Leave on "Sunny Day" for the chart to remain unaffected; changing the settings below does not affect script calculations. If you want to try these with Bar Replay, be sure to change the "Show Performers" tab to "Top Three" to increase chart space!') if barstate.islast if rain != "Sunny Day" and rain != "Rocketship?" array.push(n, line.new(bar_index + 150, emahi[1], bar_index + 151, emahi, color = color.gray)) array.push(n1, line.new(bar_index + 150, emalo[1], bar_index + 151, emalo, color = color.gray)) array.push(b, linefill.new(array.get(n, array.size(n) - 1), array.get(n1, array.size(n1) - 1), color.new(color.gray,50))) array.push(c, line.new(bar_index + 101, emahi[50], bar_index + 101, emalo[50], color = color.gray)) array.push(c1, line.new(bar_index + 151, emahi, bar_index + 151, emalo, color = color.gray)) if rain == "Candles" array.push(bo, box.new(bar_index + 110, emalo[40] - counter[5], bar_index + 112, emalo[40] - counter, bgcolor = counter > 5 and close[5] > open[5] ? color.green : counter > 5 and close[5] < open[5] ? color.red : na, border_color = counter > 5 and close[5] > open[5] ? color.green : counter > 5 and close[5] < open[5] ? color.red : na)) array.push(bo1, box.new(bar_index + 130, emalo[20] - counter[5], bar_index + 132, emalo[20] - counter, bgcolor = counter > 8 and close[3] > open[3] ? color.green : counter > 8 and close[3] < open[3] ? color.red : na, border_color = counter > 8 and close[3] > open[3] ? color.green : counter > 8 and close[3] < open[3] ? color.red : na)) array.push(bo2, box.new(bar_index + 120, emalo[30] - counter[5], bar_index + 122, emalo[30] - counter, bgcolor = counter > 11 and close[4] > open[4] ? color.green : counter > 11 and close[4] < open[4] ? color.red : na, border_color = counter > 11 and close[4] > open[4] ? color.green : counter > 14 and close[4] < open[4] ? color.red : na)) array.push(bo3, box.new(bar_index + 140, emalo[10] - counter[5], bar_index + 142, emalo[10] - counter, bgcolor = counter > 14 and close[2] > open[2] ? color.green : counter > 14 and close[2] < open[2] ? color.red : na, border_color = counter > 14 and close[2] > open[2] ? color.green : counter > 18 and close[2] < open[2] ? color.red : na)) array.push(l, line.new(bar_index + 111, box.get_top(array.get(bo, 0)) * 1.01, bar_index + 111, box.get_bottom(array.get(bo, 0)) * .99, color = counter > 5 and close[5] > open[5] ? color.green : counter > 5 and close[5] < open[5] ? color.red : na)) array.push(l1, line.new(bar_index + 121, box.get_top(array.get(bo1, 0)) * 1.01, bar_index + 121, box.get_bottom(array.get(bo1, 0)) * .99, color = counter > 11 and close[4] > open[4] ? color.green : counter > 11 and close[4] < open[4] ? color.red : na)) array.push(l2, line.new(bar_index + 131, box.get_top(array.get(bo2, 0)), bar_index + 131, box.get_bottom(array.get(bo2, 0)) * .98, color = counter > 8 and close[3] > open[3] ? color.green : counter > 8 and close[3] < open[3] ? color.red : na)) array.push(l3, line.new(bar_index + 141, box.get_top(array.get(bo3, 0)) * 1.02, bar_index + 141, box.get_bottom(array.get(bo3, 0)) * .98, color = counter > 14 and close[2] > open[2] ? color.green : counter > 14 and close[2] < open[2] ? color.red : na)) if rain == "Crypto" array.push(btc, label.new(bar_index + 111, emalo[40] - counter1[5], text = "₿", color = na, textcolor = counter1 > 5 ? color.yellow : na, size = size.large)) array.push(eth, label.new(bar_index + 121, emalo[30] - counter1[5], text = "⟠", color = na, textcolor = counter1 > 14 ? color.blue : na, size = size.huge)) array.push(zCash, label.new(bar_index + 131, emalo[20] - counter1[5], text = "ⓩ", color = na, textcolor = counter1 > 11? color.red : na, size = size.normal)) array.push(doge, label.new(bar_index + 141, emalo[10] - counter1[5], text = "🐶", color = na, textcolor = counter1 > 18 ? color.black : na, size = size.normal)) if rain == "Rocketship?" array.push(rocket, label.new(bar_index + bar_index % 200, h + bar_index % 200, text = "🚀", color = na)) if array.size(n) > 50 if rain != "Sunny Day" line.delete(array.shift(n)) line.delete(array.shift(n1)) linefill.delete(array.shift(b)) if array.size(c) > 1 line.delete(array.shift(c)) line.delete(array.shift(c1)) if array.size(l) > 1 and rain == "Candles" line.delete(array.shift(l)) line.delete(array.shift(l1)) line.delete(array.shift(l2)) line.delete(array.shift(l3)) box.delete(array.shift(bo)) box.delete(array.shift(bo1)) box.delete(array.shift(bo2)) box.delete(array.shift(bo3)) if rain == "Crypto" and array.size(btc) > 1 label.delete(array.shift(btc)) label.delete(array.shift(eth)) label.delete(array.shift(zCash)) label.delete(array.shift(doge)) var table tt = na if barstate.islast tt := table.new(position.top_right, 5, 5) if rain == "Rocketship?" and array.size(rocket) > 1 label.delete(array.shift(rocket)) table.cell(tt,0, 0, text = "🌕", text_size = size.huge)
Muyyu oscillator
https://www.tradingview.com/script/BvN0BNlM-Muyyu-oscillator/
Dnshzlkfli
https://www.tradingview.com/u/Dnshzlkfli/
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/ // © Dnshzlkfli //@version=5 indicator(title = "Muyyu oscillator", shorttitle = "Muyyu oscillator", format=format.price, precision=2, timeframe="", timeframe_gaps=true) lengthMO = input.int(title = "MO line",defval =21, minval=1) src = input(close, title="Source") mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev") basis = ta.sma(src, lengthMO) dev = mult * ta.stdev(src, lengthMO) upper = basis + dev lower = basis - dev mor = ((src - lower)/(upper - lower)) plot(mor, "muyyu oscillator", color.blue , linewidth = 2) band1 = hline(0.8, "Overbought", color=#787B86, linestyle=hline.style_dashed) band0 = hline(0.2, "Oversold", color=#787B86, linestyle=hline.style_dashed) band2 = hline(1, "Overbought", color=#787B86, linestyle=hline.style_dashed) band3 = hline(0, "Oversold", color=#787B86, linestyle=hline.style_dashed) fill(band1, band0,color.rgb(38, 166, 154, 95) ) length = input.int(21, 'length', minval=1) K1 = (2 * close - high - low) K2 = high != low ? high - low : 1 INT = (K1 / K2)*volume INTSUM = math.sum(INT, length) coloff = INTSUM > 0 ? color.rgb(38, 166, 154, 70) : color.red //color bullColor = input.color(color.rgb(38, 166, 154, 70), inline = "1") bearColor = input.color(color.red, inline = "1") backgroundColor = if INTSUM >= 0 color.from_gradient(INTSUM, 0, 1000, color.new(bullColor, 75), bullColor) else color.from_gradient(INTSUM, -1000, 0, bearColor, color.new(bearColor, 75)) bgcolor(backgroundColor)
Aryangel_MACD+RSI
https://www.tradingview.com/script/IKT4X7Nd-Aryangel-MACD-RSI/
sachinjadhav4686
https://www.tradingview.com/u/sachinjadhav4686/
13
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © sachinjadhav4686 //@version=5 indicator(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) rsiLengthInput = input.int(25, minval=1, title="RSI Length", group="RSI Settings") rsiLengthInput2 = input.int(100, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings") up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) up2 = ta.rma(math.max(ta.change(rsiSourceInput), 1), rsiLengthInput2) down2 = ta.rma(-math.min(ta.change(rsiSourceInput), 1), rsiLengthInput2) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2)) rsiMA = ma(rsi, maLengthInput, maTypeInput) rsiMA2 = ma(rsi, maLengthInput, maTypeInput) isBB = maTypeInput == "Bollinger Bands" plot(rsi, "RSI", color=#33855d) plot(rsi2, "RSI2", color=#cd0000) rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86) hline(50, "RSI Middle Band", color=color.new(#787B86, 50)) rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86) fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill") bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green) bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green) fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill") fast_length = input(title="Fast Length", defval=12) slow_length = input(title="Slow Length", defval=26) src = input(title="Source", defval=close) signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9) sma_source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"]) sma_signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"]) // Plot colors col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD") col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal") col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above") col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above") col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below") col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below") // Calculating fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length) slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length) hist = macd - signal plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below))) plot(macd, title="MACD", color=col_macd) plot(signal, title="Signal", color=col_signal)
CryptoMettle - Crypto Market Support Band
https://www.tradingview.com/script/kSmsdWcg-CryptoMettle-Crypto-Market-Support-Band/
CryptoMettle
https://www.tradingview.com/u/CryptoMettle/
2
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © vikaskumrai //@version=5 indicator("Vikas_MBM",overlay=true) a=ta.sma(close,20) b=ta.ema(close,21) one=plot(a,title= "SMA", color=color.new(color.red,0)) two=plot(b,title= "EMA", color=color.new(color.green,0)) fill(one,two,color=color.new(color.yellow,90))
CryptoMettle - Crypto Market Support Band
https://www.tradingview.com/script/GUArfOKR-CryptoMettle-Crypto-Market-Support-Band/
CryptoMettle
https://www.tradingview.com/u/CryptoMettle/
14
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © vikaskumrai //@version=5 indicator("CryptoMettle",overlay=true) a=ta.sma(close,20) b=ta.ema(close,21) one=plot(a,title= "SMA", color=color.new(color.white,0)) two=plot(b,title= "EMA", color=color.new(color.orange,0)) fill(one,two,color=color.new(color.yellow,80))
Mike, MA20,50,200
https://www.tradingview.com/script/YKkIil0J-Mike-MA20-50-200/
micormat
https://www.tradingview.com/u/micormat/
9
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/ // © micormat //@version=4 study(title="Mike, MA20,50,200", shorttitle="Mike,MA20,50,200", overlay=true, resolution="") out20 = sma(close, 20) plot(out20, color=color.green, title="MA20", offset=0) out50 = sma(close, 50) plot(out50, color=color.purple, title="MA50", offset=0) out200 = sma(close, 200) plot(out200, color=color.orange, title="MA200", offset=0)
Aryangel RSI+MACD
https://www.tradingview.com/script/1Tv28mzo-Aryangel-RSI-MACD/
sachinjadhav4686
https://www.tradingview.com/u/sachinjadhav4686/
33
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/ // © sachinjadhav4686 //@version=5 indicator(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) rsiLengthInput = input.int(25, minval=1, title="RSI Length", group="RSI Settings") rsiLengthInput2 = input.int(100, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings") up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) up2 = ta.rma(math.max(ta.change(rsiSourceInput), 1), rsiLengthInput2) down2 = ta.rma(-math.min(ta.change(rsiSourceInput), 1), rsiLengthInput2) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2)) rsiMA = ma(rsi, maLengthInput, maTypeInput) rsiMA2 = ma(rsi, maLengthInput, maTypeInput) isBB = maTypeInput == "Bollinger Bands" plot(rsi, "RSI", color=#33855d) plot(rsi2, "RSI2", color=#cd0000) rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86) hline(50, "RSI Middle Band", color=color.new(#787B86, 50)) rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86) fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill") bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green) bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green) fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill")
ema_gks
https://www.tradingview.com/script/OC0WNIUL-ema-gks/
workrisewr
https://www.tradingview.com/u/workrisewr/
7
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © workrisewr //@version=5 indicator("ema gks", overlay=true) r = ta.ema(close, 9) shortema = ta.ema(close, 9) longema = ta.ema(close, 13) xUp = ta.crossover(shortema, longema) xDn = ta.crossunder(shortema, longema) if xUp alert("Go long (EMA is " + str.tostring(r, "#.00)")) else if xDn alert("Go short (RSI is " + str.tostring(r, "#.00)")) plotchar(xUp, "Go Long", "▲", location.belowbar , color.lime, size = size.tiny) plotchar(xDn, "Go Short", "▼", location.abovebar, color.red, size = size.tiny) plot (shortema) plot (longema, color=color.green)
Triple EMA
https://www.tradingview.com/script/jIUZhHEW-Triple-EMA/
bhu1tyagi
https://www.tradingview.com/u/bhu1tyagi/
5
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/ // © bhu1tyagi //@version=4 study(title="Triple EMA", shorttitle="TEMA 15 min", overlay = true) Length = input(13, minval=1) Length2 = input(50, minval=1) Length3 = input(200, minval=1) xPrice = close xEMA1 = ema(xPrice, Length) xEMA2 = ema(xPrice, Length2) xEMA3 = ema(xPrice, Length3) plot (xEMA1, color = #2196F3, title="TEMA1") plot (xEMA2, color = #FF5252, title="TEMA2") plot (xEMA3, color = #4CAF50, title="TEMA3")
Double RSI & SMA
https://www.tradingview.com/script/5BXjfnqP-double-rsi-sma/
Evgenyc111
https://www.tradingview.com/u/Evgenyc111/
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/ // © Evgenyc111 // Double RSI for trend detection //@version=5 indicator("Double RSI & SMA", "Double RSI&SMA", false) period1 = input(25, "First RSI lenght") period2 = input(100, "Second RSI lenght") period3 = input(150, "First RSI SMA lenght") th = input(1.5, "Signal treshold") day = input(true, "Day theme?") showLabels = input(true, "Show buy/sell labels?") data = input(close, "Данные") h1 = hline(70) h2 = hline(30) labelcolor = color.gray buy = ta.crossover(ta.rsi(data, period1), math.min(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))+th) strongbuy = ta.crossover(ta.rsi(data, period1), math.max(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))+th) sell = ta.crossunder(ta.rsi(data, period1), math.max(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))-th) strongsell = ta.crossunder(ta.rsi(data, period1), math.min(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))-th) plot(ta.rsi(data, period1), title="RSI1", color = (day?color.orange:color.red), linewidth=2) plot(ta.rsi(data, period2), title="RSI2", color = (day?color.navy:color.yellow), linewidth=2) plot(ta.sma(ta.rsi(data, period1),period3), title="SMA1", color = color.blue, linewidth=2) graph = ta.rsi(data, period1) plotshape((buy or strongbuy) and showLabels ? graph-5 : na, title="StrongBuy/Buy Label", text="B", location=location.absolute, style=shape.labelup, size=size.tiny, color=strongbuy?color.green:labelcolor, textcolor=color.white) plotshape((sell or strongsell) and showLabels ? graph+5 : na, title="StrongSell/Sell Label", text="S", location=location.absolute, style=shape.labeldown, size=size.tiny, color=strongsell?color.red:labelcolor, textcolor=color.white) fill(h1,h2, color = color.new(color.purple, 90)) alertcondition(buy or strongbuy, title="Alert: RSI Buy", message="Double RSI Buy!") alertcondition(sell or strongsell, title="Alert: RSI Sell", message="Double RSI Sell!") alertcondition(buy or sell or strongbuy or strongsell, title="Alert: RSI Signal", message="Double RSI Signal!")
Bubbles BB futures
https://www.tradingview.com/script/CKMv2AAx/
JHavez
https://www.tradingview.com/u/JHavez/
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/ // © JHavez //@version=5 indicator("Bulle BB futures", overlay=true, explicit_plot_zorder=true) var UpperArrow = -5 //BB calculation [Middle, Upper, Lower] = ta.bb(close,20,2) //plot arrow plotshape(open > Middle and open >= Upper and close >= Upper ? UpperArrow : na, "Fleche2", shape.triangledown, location.abovebar, color.orange, size = size.small) plotshape(close < Middle and open <= Lower and close <= Lower ? UpperArrow : na, "Fleche2", shape.triangleup, location.belowbar, color.orange, size = size.small)
CPR
https://www.tradingview.com/script/r89PxP9d-CPR/
mortal_glitch
https://www.tradingview.com/u/mortal_glitch/
113
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/ // © mortal_glitch //@version=5 indicator("CPR",overlay=true) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////Central Pivot Range///////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// AUTO = "Auto" DAILY = "Daily" WEEKLY = "Weekly" MONTHLY = "Monthly" QUARTERLY = "Quarterly" YEARLY = "Yearly" BIYEARLY = "Biyearly" TRIYEARLY = "Triyearly" QUINQUENNIALLY = "Quinquennially" DECENNIALLY = "Decennially" TRADITIONAL = "Traditional" FIBONACCI = "Fibonacci" WOODIE = "Woodie" CLASSIC = "Classic" DEMARK = "DM" CAMARILLA = "Camarilla" kind = input.string(title="Type", defval="Traditional", options=[TRADITIONAL, FIBONACCI, WOODIE, CLASSIC, DEMARK, CAMARILLA]) pivot_time_frame = input.string(title="Pivots Timeframe", defval=AUTO, options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY, QUINQUENNIALLY, DECENNIALLY]) look_back = input.int(title="Number of Pivots Back", defval=15, minval=1, maxval=5000) is_daily_based = input.bool(title="Use Daily-based Values", defval=true, tooltip="When this option is unchecked, Pivot Points will use intraday data while calculating on intraday charts. If Extended Hours are displayed on the chart, they will be taken into account during the pivot level calculation. If intraday OHLC values are different from daily-based values (normal for stocks), the pivot levels will also differ.") show_labels = input.bool(title="Show Labels", defval=false, group="labels") show_prices = input.bool(title="Show Prices", defval=false, group="labels") position_labels = input.string("Left", "Labels Position", options=["Left", "Right"], group="labels") line_width = input.int(title="Line Width", defval=1, minval=1, maxval=100, group="levels") var DEF_COLOR = #FB8C00 var arr_time = array.new_int() var p = array.new_float() var bc = array.new_float() var tc = array.new_float() p_color = input.color(color.white, "P‏ ‏ ‏", inline="P", group="levels") p_show = input.bool(true, "", inline="P", group="levels") var r1 = array.new_float() var s1 = array.new_float() s1_color = input.color(DEF_COLOR, "S1", inline="S1/R1" , group="levels") s1_show = input.bool(true, "", inline="S1/R1", group="levels") r1_color = input.color(DEF_COLOR, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R1", inline="S1/R1", group="levels") r1_show = input.bool(true, "", inline="S1/R1", group="levels") var r2 = array.new_float() var s2 = array.new_float() s2_color = input.color(DEF_COLOR, "S2", inline="S2/R2", group="levels") s2_show = input.bool(true, "", inline="S2/R2", group="levels") r2_color = input.color(DEF_COLOR, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R2", inline="S2/R2", group="levels") r2_show = input.bool(true, "", inline="S2/R2", group="levels") var r3 = array.new_float() var s3 = array.new_float() s3_color = input.color(DEF_COLOR, "S3", inline="S3/R3", group="levels") s3_show = input.bool(true, "", inline="S3/R3", group="levels") r3_color = input.color(DEF_COLOR, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R3", inline="S3/R3", group="levels") r3_show = input.bool(true, "", inline="S3/R3", group="levels") var r4 = array.new_float() var s4 = array.new_float() s4_color = input.color(DEF_COLOR, "S4", inline="S4/R4", group="levels") s4_show = input.bool(false, "", inline="S4/R4", group="levels") r4_color = input.color(DEF_COLOR, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R4", inline="S4/R4", group="levels") r4_show = input.bool(false, "", inline="S4/R4", group="levels") var r5 = array.new_float() var s5 = array.new_float() s5_color = input.color(DEF_COLOR, "S5", inline="S5/R5", group="levels") s5_show = input.bool(false, "", inline="S5/R5", group="levels") r5_color = input.color(DEF_COLOR, "‏ ‏ ‏ ‏ ‏ ‏ ‏ ‏R5", inline="S5/R5", group="levels") r5_show = input.bool(false, "", inline="S5/R5", group="levels") pivotX_open = float(na) pivotX_open := nz(pivotX_open[1], open) pivotX_high = float(na) pivotX_high := nz(pivotX_high[1], high) pivotX_low = float(na) pivotX_low := nz(pivotX_low[1], low) pivotX_prev_open = float(na) pivotX_prev_open := nz(pivotX_prev_open[1]) pivotX_prev_high = float(na) pivotX_prev_high := nz(pivotX_prev_high[1]) pivotX_prev_low = float(na) pivotX_prev_low := nz(pivotX_prev_low[1]) pivotX_prev_close = float(na) pivotX_prev_close := nz(pivotX_prev_close[1]) get_pivot_resolution() => resolution = "M" if pivot_time_frame == AUTO if timeframe.isintraday resolution := timeframe.multiplier <= 30 ? "D" : "W" else if timeframe.isweekly or timeframe.ismonthly resolution := "12M" else if pivot_time_frame == DAILY resolution := "D" else if pivot_time_frame == WEEKLY resolution := "W" else if pivot_time_frame == MONTHLY resolution := "M" else if pivot_time_frame == QUARTERLY resolution := "3M" else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or pivot_time_frame == DECENNIALLY resolution := "12M" resolution var lines = array.new_line() var labels = array.new_label() draw_line(i, pivot, col,transp,sty) => if array.size(arr_time) > 1 array.push(lines, line.new(array.get(arr_time, i), array.get(pivot, i), array.get(arr_time, i + 1), array.get(pivot, i), color=color.new(col,transp) ,xloc=xloc.bar_time, width=line_width,style=sty)) sol=line.style_solid das=line.style_dashed calc_pivot() => pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3 pivotBC=(pivotX_prev_high+pivotX_prev_low)/2 array.push(p, pivotX_Median) array.push(bc, pivotBC) array.push(tc, pivotX_Median-pivotBC+ pivotX_Median ) array.push(r1, (pivotX_Median * 2) - pivotX_prev_low) array.push(s1, (pivotX_Median * 2) - pivotX_prev_high) array.push(r2, pivotX_Median + (1 * (pivotX_prev_high - pivotX_prev_low))) array.push(s2, pivotX_Median - (1 * (pivotX_prev_high - pivotX_prev_low))) array.push(r3, (pivotX_Median * 2) + (pivotX_prev_high - 2 * pivotX_prev_low)) array.push(s3, (pivotX_Median * 2) - (2 * pivotX_prev_high - pivotX_prev_low)) array.push(r4, (pivotX_Median * 3) + (pivotX_prev_high - 3 * pivotX_prev_low)) array.push(s4, (pivotX_Median * 3) - (3 * pivotX_prev_high - pivotX_prev_low)) array.push(r5, (pivotX_Median * 4) + (pivotX_prev_high - 4 * pivotX_prev_low)) array.push(s5, (pivotX_Median * 4) - (4 * pivotX_prev_high - pivotX_prev_low)) //calc_pivot() => // if kind == TRADITIONAL // traditional() resolution = get_pivot_resolution() SIMPLE_DIVISOR = -1 custom_years_divisor = switch pivot_time_frame BIYEARLY => 2 TRIYEARLY => 3 QUINQUENNIALLY => 5 DECENNIALLY => 10 => SIMPLE_DIVISOR calc_high(prev, curr) => if na(prev) or na(curr) nz(prev, nz(curr, na)) else math.max(prev, curr) calc_low(prev, curr) => if not na(prev) and not na(curr) math.min(prev, curr) else nz(prev, nz(curr, na)) calc_OHLC_for_pivot(custom_years_divisor) => if custom_years_divisor == SIMPLE_DIVISOR [open, high, low, open[1], high[1], low[1], close[1], time[1]] else var prev_sec_open = float(na) var prev_sec_high = float(na) var prev_sec_low = float(na) var prev_sec_close = float(na) var prev_sec_time = int(na) var curr_sec_open = float(na) var curr_sec_high = float(na) var curr_sec_low = float(na) if year % custom_years_divisor == 0 curr_sec_open := open curr_sec_high := high curr_sec_low := low prev_sec_high := high[1] prev_sec_low := low[1] prev_sec_close := close[1] prev_sec_time := time[1] for i = 2 to custom_years_divisor prev_sec_open := nz(open[i], prev_sec_open) prev_sec_high := calc_high(prev_sec_high, high[i]) prev_sec_low := calc_low(prev_sec_low, low[i]) prev_sec_time := nz(time[i], prev_sec_time) [curr_sec_open, curr_sec_high, curr_sec_low, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time] [sec_open, sec_high, sec_low, prev_sec_open, prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time] = request.security(syminfo.tickerid, resolution, calc_OHLC_for_pivot(custom_years_divisor), lookahead = barmerge.lookahead_on) sec_open_gaps_on = request.security(syminfo.tickerid, resolution, open, gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on) is_change_years = custom_years_divisor > 0 and ta.change(time(resolution)) and year % custom_years_divisor == 0 var is_change = false var uses_current_bar = timeframe.isintraday and kind == WOODIE var change_time = int(na) is_time_change = (ta.change(time(resolution)) and custom_years_divisor == SIMPLE_DIVISOR) or is_change_years if is_time_change change_time := time var start_time = time without_time_change = barstate.islast and array.size(arr_time) == 0 is_can_calc_pivot = (not uses_current_bar and is_time_change) or (uses_current_bar and not na(sec_open_gaps_on)) or without_time_change enough_bars_for_calculate = prev_sec_time >= start_time or is_daily_based if is_can_calc_pivot and enough_bars_for_calculate if array.size(arr_time) == 0 and is_daily_based pivotX_prev_open := prev_sec_open[1] pivotX_prev_high := prev_sec_high[1] pivotX_prev_low := prev_sec_low[1] pivotX_prev_close := prev_sec_close[1] pivotX_open := sec_open[1] pivotX_high := sec_high[1] pivotX_low := sec_low[1] array.push(arr_time, start_time) calc_pivot() if is_daily_based pivotX_prev_open := prev_sec_open pivotX_prev_high := prev_sec_high pivotX_prev_low := prev_sec_low pivotX_prev_close := prev_sec_close pivotX_open := sec_open pivotX_high := sec_high pivotX_low := sec_low else pivotX_prev_high := pivotX_high pivotX_prev_low := pivotX_low pivotX_prev_open := pivotX_open pivotX_prev_close := close[1] pivotX_open := open pivotX_high := high pivotX_low := low if barstate.islast and not is_change and array.size(arr_time) > 0 and not without_time_change array.set(arr_time, array.size(arr_time) - 1, change_time) else if without_time_change array.push(arr_time, start_time) else array.push(arr_time, nz(change_time, time)) calc_pivot() if array.size(arr_time) > look_back if array.size(arr_time) > 0 array.shift(arr_time) if array.size(p) > 0 and p_show array.shift(p) if array.size(bc) > 0 and p_show array.shift(bc) if array.size(tc) > 0 and p_show array.shift(tc) if array.size(r1) > 0 and r1_show array.shift(r1) if array.size(s1) > 0 and s1_show array.shift(s1) if array.size(r2) > 0 and r2_show array.shift(r2) if array.size(s2) > 0 and s2_show array.shift(s2) if array.size(r3) > 0 and r3_show array.shift(r3) if array.size(s3) > 0 and s3_show array.shift(s3) if array.size(r4) > 0 and r4_show array.shift(r4) if array.size(s4) > 0 and s4_show array.shift(s4) if array.size(r5) > 0 and r5_show array.shift(r5) if array.size(s5) > 0 and s5_show array.shift(s5) is_change := true else if not is_daily_based pivotX_high := math.max(pivotX_high, high) pivotX_low := math.min(pivotX_low, low) if barstate.islast and not is_daily_based and array.size(arr_time) == 0 runtime.error("Not enough intraday data to calculate Pivot Points. Lower the Pivots Timeframe or turn on the 'Use Daily-based Values' option in the indicator settings.") if barstate.islast and array.size(arr_time) > 0 and is_change is_change := false if custom_years_divisor > 0 last_pivot_time = array.get(arr_time, array.size(arr_time) - 1) pivot_timeframe = str.tostring(12 * custom_years_divisor) + "M" estimate_pivot_time = last_pivot_time + timeframe.in_seconds(pivot_timeframe) * 1000 array.push(arr_time, estimate_pivot_time) else array.push(arr_time, time_close(resolution)) for i = 0 to array.size(lines) - 1 if array.size(lines) > 0 line.delete(array.shift(lines)) for i = 0 to array.size(arr_time) - 2 if array.size(p) > 0 and p_show draw_line(i, p, p_color,0,sol) if array.size(r1) > 0 and r1_show draw_line(i, r1, r1_color,40,sol) if array.size(s1) > 0 and s1_show draw_line(i, s1, s1_color,40,sol) if array.size(r2) > 0 and r2_show draw_line(i, r2, r2_color,60,sol) if array.size(s2) > 0 and s2_show draw_line(i, s2, s2_color,60,sol) if array.size(r3) > 0 and r3_show draw_line(i, r3, r3_color,80,sol) if array.size(s3) > 0 and s3_show draw_line(i, s3, s3_color,80,sol) if array.size(bc) > 0 and p_show draw_line(i, bc, p_color,20,das) if array.size(tc) > 0 and p_show draw_line(i, tc, p_color,20,das)
Parabolic RSI
https://www.tradingview.com/script/2ql2Smor-Parabolic-RSI/
Sofien-Kaabar
https://www.tradingview.com/u/Sofien-Kaabar/
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/ // © Sofien-Kaabar //@version=5 indicator("Parabolic RSI", overlay = false) parabolic = ta.sar(0.02, 0.02, 0.2) rsi_parabolic = ta.rsi(parabolic, 21) plot(rsi_parabolic) hline(80) hline(20)
Multi-Timeframe RSI Grid
https://www.tradingview.com/script/PGQ2G7fe-Multi-Timeframe-RSI-Grid/
jmosullivan
https://www.tradingview.com/u/jmosullivan/
119
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/ // © jmosullivan // @version=5 // Created By jmosullivan // MTF RSI Grid // The relative strength index (RSI) is a momentum indicator that measures the magnitude of recent price changes to evaluate // overbought or oversold conditions. The RSI is normally displayed as an oscillator separately from price and can have a // reading from 0 to 100. This indicator displays the current RSI levels at up to 6 timeframes (of your choosing) in a grid. // If the RSI levels reach overbought (above 70) or oversold (below 30) conditions, it changes the color to help you see that // RSI has reached extreme levels. Note that in tradingview, when the chart is on a higher timeframe, the lower timeframe RSI // levels don't calculate properly, so this indicator will hide those values in the grid. If none of your selected values are // available, it hides the table completely. indicator(title='MM RSI Grid', overlay=true) import jmosullivan/Table/1 import jmosullivan/Utils/3 // Constants SPACE = "   " // Configuration grp = "Appearance" showTitle = input.bool(group=grp, defval=true, title='Show "RSI" Heading') friendlyTextSize = input.string(group=grp, defval="Tiny", title="Size / Position  ", options=["Tiny", "Small", "Normal", "Large", "Huge"], inline="position and size") textSize = Utils.getSizeFromString(friendlyTextSize) friendlyPosition = input.string(group=grp, defval="Top Right", title="", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], inline="position and size") position = Utils.getPositionFromString(friendlyPosition) verticalOffset = input.int(group=grp, defval=0, title="Vertical Offset", minval=0, maxval=3, step=1, tooltip="The number of row-sized spaces to place the table away from the top or bottom (depending on the position chosen).") colorHelp = "Background and text color pairs for moderate and extreme RSI levels, respectively." colorModerate = input.color(group=grp, defval=color.rgb(40, 98, 255), title="Colors", inline="colors") colorModerateText = input.color(group=grp, defval=color.white, title="", inline="colors") colorExtreme = input.color(group=grp, defval=color.rgb(235, 46, 175), title="", inline="colors") colorExtremeText = input.color(group=grp, defval=color.white, title="", inline="colors", tooltip=colorHelp) grp2 = "Timeframes" show1 = input.bool(defval=true, title="", inline="tf1", group=grp2) show2 = input.bool(defval=true, title="", inline="tf2", group=grp2) show3 = input.bool(defval=true, title="", inline="tf3", group=grp2) show4 = input.bool(defval=true, title="", inline="tf4", group=grp2) show5 = input.bool(defval=true, title="", inline="tf5", group=grp2) show6 = input.bool(defval=true, title="", inline="tf6", group=grp2) friendlyTimeframe1 = input.timeframe(defval="5m", title="", inline="tf1", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) friendlyTimeframe2 = input.timeframe(defval="15m", title="", inline="tf2", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) friendlyTimeframe3 = input.timeframe(defval="1h", title="", inline="tf3", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) friendlyTimeframe4 = input.timeframe(defval="4h", title="", inline="tf4", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) friendlyTimeframe5 = input.timeframe(defval="1D", title="", inline="tf5", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) friendlyTimeframe6 = input.timeframe(defval="1W", title="", inline="tf6", group=grp2, options=["1m", "2m", "5m", "15m", "30m", "45m", "1h", "2h", "3h", "4h", "12h", "1D", "1W", "1M"]) grp3 = "Superstack Alerts" ssToolTip = "Superstack alerts are triggered when 3 or more consecutive timeframes (starting from the first one) reach oversold or overbought together. " // showSuperstackBreadcrumbs = input.bool(defval=false, title="Show arrow icon breadcrumbs on chart when superstack conditions are met.", tooltip=ssToolTip + "Breadcrumbs are a bit messy, cluttering up the chart, but they are useful for seeing when things began and ended on the chart historically.", group=grp3) showSuperstackLabels = input.bool(defval=true, title="Show label on chart when superstack conditions are met.", tooltip=ssToolTip + " The labels only appear when a superstack is active and disappear when it is finished.", group=grp3) length = input.int(group="Advanced", defval=14, title="RSI Length") // Functions getTimeframePeriodFromFriendlyString(friendlyString) => switch friendlyString "1m" => "1" "2m" => "2" "5m" => "5" "15m" => "15" "30m" => "30" "45m" => "45" "1h" => "60" "2h" => "120" "3h" => "180" "4h" => "240" "12h" => "1440" "1D" => "D" "1W" => "W" "1M" => "M" => "5" requestSecurityProxy(_tickerid, _timeframe, _expression) => request.security(_tickerid, _timeframe, _expression, lookahead=barmerge.lookahead_on) requestSecurityLower(tickerid, timeframe, expression) => _timeframe = timeframe.in_seconds('') < timeframe.in_seconds(timeframe) ? '' : timeframe array<float> lowerTimeframeArray = request.security_lower_tf(syminfo.tickerid, _timeframe, expression) array.size(lowerTimeframeArray) > 0 ? array.get(lowerTimeframeArray, array.size(lowerTimeframeArray) - 1) : na requestSecurity(tickerid, timeframe, expression) => timeframe.in_seconds('') <= timeframe.in_seconds(timeframe) ? requestSecurityProxy(tickerid, timeframe, expression) : requestSecurityLower(tickerid, timeframe, expression) addTimeframe(timeframe, rsi, show, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) => if (show) overbought = rsi >= 70 oversold = rsi <= 30 bgColor = oversold or overbought ? colorExtreme : colorModerate textColor = oversold or overbought ? colorExtremeText : colorModerateText array.push(superstackTFArray, timeframe) array.push(superstackOBArray, overbought) array.push(superstackOSArray, oversold) array.push(dataArray, Table.Cell.new( str.format(" {0} \n {1,number,#} ", timeframe, rsi), bgColor, textColor )) drawLabel(ssLevel) => if (barstate.islast and showSuperstackLabels) ssBreak = ssLevel == 0 yloc = ssBreak ? close : ssLevel > 0 ? high : low txt = str.format("Superstack {0}: {1}", ssLevel > 0 ? "Overbought" : "Oversold", math.abs(ssLevel)) clr = ssLevel > 0 ? color.red : color.green style = ssLevel > 0 ? label.style_label_lower_left : label.style_label_upper_left, l = label.new(x=bar_index[0]+1, y=yloc, text=txt, style=style, color=clr, textcolor=color.white, size=size.small) // Delete older labels (only have the latest one on the last candle) label.delete(l[1]) // Delete the current one if there's no stairstep and no break if (ssLevel == 0) label.delete(l[0]) getConsecutiveTrueCount(boolArray) => count = int(0) i = int(0) isTrue = true boolSize = array.size(boolArray) while i < boolSize and isTrue == true isTrue := array.get(boolArray, i) == true count += isTrue ? 1 : 0 i += 1 count // Indicator Logic // Convert the configured "friendly" timeframe strings back to the ones expected by TradingView timeframe1 = getTimeframePeriodFromFriendlyString(friendlyTimeframe1) timeframe2 = getTimeframePeriodFromFriendlyString(friendlyTimeframe2) timeframe3 = getTimeframePeriodFromFriendlyString(friendlyTimeframe3) timeframe4 = getTimeframePeriodFromFriendlyString(friendlyTimeframe4) timeframe5 = getTimeframePeriodFromFriendlyString(friendlyTimeframe5) timeframe6 = getTimeframePeriodFromFriendlyString(friendlyTimeframe6) // Arrays to be built up by the indicator dataArray = array.new<Table.Cell>() superstackTFArray = array.new<string>() superstackOBArray = array.new<bool>() superstackOSArray = array.new<bool>() // Fetch the RSI levels from the chosen timeframes rsi = ta.rsi(close, length) rsi1 = requestSecurity(syminfo.tickerid, timeframe1, rsi) rsi2 = requestSecurity(syminfo.tickerid, timeframe2, rsi) rsi3 = requestSecurity(syminfo.tickerid, timeframe3, rsi) rsi4 = requestSecurity(syminfo.tickerid, timeframe4, rsi) rsi5 = requestSecurity(syminfo.tickerid, timeframe5, rsi) rsi6 = requestSecurity(syminfo.tickerid, timeframe6, rsi) if barstate.islast // Build up the array to be rendered if (showTitle) array.push(dataArray, Table.Cell.new(" RSI ", colorExtreme, colorExtremeText)) addTimeframe(friendlyTimeframe1, rsi1, show1, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) addTimeframe(friendlyTimeframe2, rsi2, show2, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) addTimeframe(friendlyTimeframe3, rsi3, show3, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) addTimeframe(friendlyTimeframe4, rsi4, show4, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) addTimeframe(friendlyTimeframe5, rsi5, show5, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) addTimeframe(friendlyTimeframe6, rsi6, show6, superstackTFArray, superstackOBArray, superstackOSArray, dataArray) int dataSize = array.size(dataArray) if (showTitle) dataSize -= 1 if dataSize > 0 Table.fromArray(dataArray, position, verticalOffset, false, textSize, 2, "\n") // Alert Conditions obLevel = getConsecutiveTrueCount(superstackOBArray) osLevel = getConsecutiveTrueCount(superstackOSArray) ssLevel = obLevel > 2 ? obLevel : osLevel > 2 ? -osLevel : 0 superstackOb3 = obLevel >= 3 superstackOb4 = obLevel >= 4 superstackOb5 = obLevel >= 5 superstackOb6 = obLevel >= 6 superstackOs3 = osLevel >= 3 superstackOs4 = osLevel >= 4 superstackOs5 = osLevel >= 5 superstackOs6 = osLevel >= 6 // Alerts alertcondition(superstackOb3, title="Superstack: 3 Overbought", message="{{ticker}} Superstack: 3 timeframes overbought") alertcondition(superstackOb4, title="Superstack: 4 Overbought", message="{{ticker}} Superstack: 4 timeframes overbought") alertcondition(superstackOb5, title="Superstack: 5 Overbought", message="{{ticker}} Superstack: 5 timeframes overbought") alertcondition(superstackOb6, title="Superstack: 6 Overbought", message="{{ticker}} Superstack: 6 timeframes overbought") alertcondition(superstackOs3, title="Superstack: 3 Oversold", message="{{ticker}} Superstack: 3 timeframes oversold") alertcondition(superstackOs4, title="Superstack: 4 Oversold", message="{{ticker}} Superstack: 4 timeframes oversold") alertcondition(superstackOs5, title="Superstack: 5 Oversold", message="{{ticker}} Superstack: 5 timeframes oversold") alertcondition(superstackOs6, title="Superstack: 6 Oversold", message="{{ticker}} Superstack: 6 timeframes oversold") alertcondition(superstackOb3 or superstackOs3, title="Superstack: 3 Overbought/Oversold", message="{{ticker}} Superstack: 3 timeframes overbought or oversold") alertcondition(superstackOb4 or superstackOs4, title="Superstack: 4 Overbought/Oversold", message="{{ticker}} Superstack: 4 timeframes overbought or oversold") alertcondition(superstackOb5 or superstackOs5, title="Superstack: 5 Overbought/Oversold", message="{{ticker}} Superstack: 5 timeframes overbought or oversold") alertcondition(superstackOb6 or superstackOs6, title="Superstack: 6 Overbought/Oversold", message="{{ticker}} Superstack: 6 timeframes overbought or oversold") drawLabel(ssLevel)
ADX Color Coded Bar
https://www.tradingview.com/script/THO37KYs-ADX-Color-Coded-Bar/
christofferka
https://www.tradingview.com/u/christofferka/
34
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © christofferka //@version=5 indicator("ADX Color Coded Bar", timeframe='',timeframe_gaps =false) adxlen = input.int(14, minval=1, title="ADX Smoothing") dilen = input.int(14, minval=1, title="DI Length") 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) sig = adx(dilen, adxlen) ADXColorthreshhold = input.int(25, minval=1, title="ADX Color Threshold",tooltip="Green = Confident moves are more likely to happen. Red = More likely to be fakeouts, choppy and consolidating market conditions. Keep in mind that confident moves can happen in the red zone and that this is a lagging indicator.) ") ADXColorGreen = sig > ADXColorthreshhold ? color.green :color.red // ADX BAR ADXBarTopLine = plot(sig ? -41 : na, title = 'ADX Bar TOP Line', transp = 100) ADXBarBottomLine = plot(sig ? -45 : na, title = 'ADX Bar BOTTOM Line', transp = 100) fill(ADXBarTopLine, ADXBarBottomLine, title = 'ADX Bar Colors', color = ADXColorGreen, transp = 35)
Multi-Time Period Charts V2
https://www.tradingview.com/script/QG99Ufe5-Multi-Time-Period-Charts-V2/
Vollchaot
https://www.tradingview.com/u/Vollchaot/
210
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/ // © Tradingview //@version=5 indicator("Multi-Time Period Charts", "MTPC", overlay=true, max_boxes_count=500) AUTO_TIMEFRAME_TOOLTIP = "When the Auto option is selected, the timeframe of the indicator is chosen automatically based on the chart timeframe. The Timeframe dropdown is ignored. The automated timeframes are: \n '1 day' for any chart timeframes below '1 day' \n '1 week' for any timeframes starting from '1 day' up to '1 week' \n '1 month' for any timeframes starting from '1 week' up to '1 month' \n '3 months' for any timeframes starting from '1 month' up to '3 months' \n '12 months' for any timeframes above '3 months'" HLR = "High/Low Range" TR = "True Range" HAR = "Heikin Ashi Range" DEFAULT_RESOLUTION = "1M" DEFAULT_COLOR_GROWTH = color.rgb(0, 150, 136, 80) DEFAULT_COLOR_FALL = color.rgb(244, 67, 54, 80) DEFAULT_CALCULATION_METHOD = HLR DEFAULT_AUTO_RESOLUTION = true var prevBarIndex = bar_index drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, borderGrowth, borderFall) => drawnBox = box.new(left, top, right, bottom) if diff < 0 box.set_border_color(drawnBox, borderFall) box.set_bgcolor(drawnBox, fallColorInput) else box.set_border_color(drawnBox, borderGrowth) box.set_bgcolor(drawnBox, growthColorInput) drawnBox selectAutoTimeframe() => timeframe.isseconds ? '120': timeframe.isminutes ? '1440': timeframe.isdaily ? 'W': timeframe.isweekly ? 'M': timeframe.ismonthly and timeframe.multiplier < 3 ? '3M': '12M' autoTimeframeInput = input(DEFAULT_AUTO_RESOLUTION, title="AutoTimeframe", tooltip=AUTO_TIMEFRAME_TOOLTIP) timeframeInput = input.timeframe(DEFAULT_RESOLUTION, title="Timeframe") timeframe = autoTimeframeInput ? selectAutoTimeframe() : timeframeInput calculationMethodInput = input.string(DEFAULT_CALCULATION_METHOD, "Calculation", options = [HLR, TR, HAR]) trackPriceInput = input(true, "Show dashed lines") growthColorInput = input(DEFAULT_COLOR_GROWTH, title="",inline="Body") fallColorInput = input(DEFAULT_COLOR_FALL, title="Body", inline="Body") growthBorderColor = input(color.new(DEFAULT_COLOR_GROWTH, 0), title="", inline="Outline") fallBorderColor = input(color.new(DEFAULT_COLOR_FALL, 0), title="Outline", inline="Outline") [previousHigh, previousLow, previousClose, previousOpen, prePreviousClose] = request.security(syminfo.tickerid, timeframe, [high[1], low[1], close[1], open[1], close[2]], lookahead=barmerge.lookahead_on) [currentHigh, currentLow, currentClose, currentOpen, prevClose] = request.security(syminfo.tickerid, timeframe, [high, low, close, open, close[1]]) isNewPeriod = ta.change(time(timeframe)) drawCurrent = barstate.islast and not isNewPeriod secHigh = drawCurrent ? currentHigh : previousHigh secPrevClose = drawCurrent ? prevClose : prePreviousClose secLow = drawCurrent ? currentLow : previousLow diff = drawCurrent ? currentClose - currentOpen : previousClose - previousOpen left = prevBarIndex right = drawCurrent ? bar_index : bar_index[1] [ashiHigh, ashiLow] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, [high, low]) float top = na float bottom = na if calculationMethodInput == HLR top := secHigh bottom := secLow else if calculationMethodInput == TR top := math.max(secHigh, secPrevClose) bottom := math.min(secLow, secPrevClose) else if calculationMethodInput == HAR top := ashiHigh bottom := ashiLow if isNewPeriod prevBarIndex := bar_index drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, growthBorderColor, fallBorderColor) var box prevBox = na if barstate.islast if isNewPeriod prevBox := na else box.delete(prevBox) prevBox := drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, growthBorderColor, fallBorderColor) var box prevBox1 = na var float prevTop = na var float prevBottom = na if array.size(box.all) > 1 prevBox1 := array.get(box.all, array.size(box.all) - 1) prevTop := box.get_top(prevBox1) prevBottom := box.get_bottom(prevBox1) // box.delete(prevBox1) plot(prevTop, "Prev Top", color=color.new(color.blue, trackPriceInput ? 0 : 100), trackprice = trackPriceInput, show_last = 1) plot(prevBottom, "Prev Bot", color=color.new(color.blue, trackPriceInput ? 0 : 100), trackprice = trackPriceInput, show_last = 1)
Pivot Trend Levels
https://www.tradingview.com/script/uRCjLoPJ-Pivot-Trend-Levels/
AliSignals
https://www.tradingview.com/u/AliSignals/
89
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © alipeikani // I have to thank stackoverflow for the help //@version=5 indicator('pivot trend levels', overlay=true) bars = input(3) checkbox = input.bool(title= "color chenging by trend", defval=true) ph = ta.pivothigh(high, bars, bars) pl = ta.pivotlow(low, bars, bars) //INIT VARIABLES var int ph_uptrend_flag = 0 var float ph_valid1 = 0 var float ph_valid2 = 0 var float ph_valid3 = 0 var float ph_valid4 = 0 var float ph_valid5 = 0 var float pl_valid1 = 0 var float pl_valid2 = 0 var float pl_valid3 = 0 var float pl_valid4 = 0 var float pl_valid5 = 0 var float ph_valid_old = 2 var float pl_valid_old = 0 // non meaningful number here for initialization only ph_non_na = nz(ph, 0) pl_non_na = nz(pl, 0) // stores 0's instead of na's for non-pivot-pointed bars // re-calculate uptrend every time a new pivot comes in, otherwise keep last known value for uptrend flag if ph_non_na != 0 ph_valid5 := ph_valid4 ph_valid4 := ph_valid3 ph_valid3 := ph_valid2 ph_valid2 := ph_valid1 ph_valid1 := ph_non_na ph_valid_old := ph_valid1 ph_valid_old else ph_valid1 := ph_valid1 ph_valid_old := ph_valid_old ph_valid_old if pl_non_na != 0 pl_valid5 := pl_valid4 pl_valid4 := pl_valid3 pl_valid3 := pl_valid2 pl_valid2 := pl_valid1 pl_valid1 := pl_non_na pl_valid_old := pl_valid1 pl_valid_old else pl_valid1 := pl_valid1 pl_valid_old := pl_valid_old pl_valid_old max = math.max(ph_valid2, ph_valid1) //lph = math.min(ph_valid2, ph_valid1) // lower pivots of highs //hpl = math.max(pl_valid2, pl_valid1) // higher pivots of lows min = math.min(pl_valid2, pl_valid1) avg = math.avg(ph_valid2, ph_valid1,pl_valid2, pl_valid1) /// I need help here!!! I tried to build a trend detection system based on which if the last move of the "max" and the "min" upwards, Trend will change to Bullish and if their last move is downward trend will change bearish. // If the direction of their movement is not consistent, trend will not change //float maxup = 0 //float minup = 0 //if max > max[1] // maxup := 1 // //else // if max < max[1] // maxup := -1 // else // // maxup := maxup[1] //if min > min[1] // minup := 1 //else // if min < min[1] // minup := -1 // else // minup := minup[1] //xup = if max == max[1] // na //else // maxup //nup = if min == min[1] // na //else // minup //v = if close > open // 1 //else // if open > close // open // else // na //clrchecked = if Trendup == 1 // color.lime //else // if Trendup == -1 // color.red // else // color.white plot(max, title = "High level", color=color.lime) plot(min, title = "Low level", color=color.lime) plot(avg, title = "Mid level", color=color.yellow )
Bull Market Support Band Divergency
https://www.tradingview.com/script/qYdebr4p-Bull-Market-Support-Band-Divergency/
delrioo
https://www.tradingview.com/u/delrioo/
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/ // © delrioo //@version=4 study("Bull Market Support Band Divergency") a = ema(close,21) b = sma(close,20) c = 100*(a-b)/close d = rsi(close,20) aux = a-b e = c*(d/100) desv = dev(close,20) f = (a-b)*desv/close outSma = security(syminfo.tickerid, "W", b) outEma = security(syminfo.tickerid, "W", a) outDiv = security(syminfo.tickerid, "W", c) outDer = security(syminfo.tickerid, "W", e) plot(outDiv, color = color.lime) plot(outDer, color = color.orange)
VIX Cheat Sheet
https://www.tradingview.com/script/68Z68uZZ-VIX-Cheat-Sheet/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
884
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 //@version=5 indicator("VIX Cheat Sheet [Kioseff Trading]", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500) // _______________________________________________________ // // Input Box // _______________________________________________________ select = input.string("VIX", title = "VIX (Generally Stocks) or VixFix (Works Anywhere) ?", options = ["VIX", "VixFix"]) vixTV = input.string("No", title = "Turn Off Tradingview TV?", options = ["No", "Yes", "Unplug"], group = "Utility Inputs") tvCol = input.string("On", title = 'VIX Box Color Fills ("Color Commentary")', options = ["On", "Off"]) labelSize = input.string("Tiny", title = "Label Size", options = ["Tiny", "Small", "Auto"]) labelCount = input.int(defval = 500, title = "Label Count", maxval = 500, minval = 0) lossBox = input.string("On", title = "Show Average Loss Boxes", options = ["On", "Off"]) hide = input.string(defval = "No", title = 'Send "Color Commentary" to a Table? \n(Select "Yes" When VIX is Fluctuating Wildly)', options = ["No", "Yes"], group = "Nonutility inputs") BaW = input.string(defval = "Color", title = "Color TV? Black and White?", options = ["Color", "Black and White"]) // _______________________________________________________ // // Data Request // _______________________________________________________ vix() => [close, open, high, low] [vClose, vOpen, vHigh, vLow] = request.security("VIX", "D", vix()) vFix = (ta.highest(close, 22) - low) / (ta.highest(close, 22)) * 100 spx = request.security("PCSPX", "D", close) ratioSMA = ta.sma(spx, 50) VorVFclose = select == "VIX" ? vClose : vFix // _______________________________________________________ // // Standard Deviation and Correlation // _______________________________________________________ [mid, upper, lower] = ta.bb(VorVFclose, 20, 2.0) corr = ta.correlation(close, vClose, 200) // _______________________________________________________ // // One-Time Initialization Variables // _______________________________________________________ var float assetClose = 0.0 var float tenSessionCalcCumulative = 0.0 var float fiveSessionCalcCumulative = 0.0 var float sessionCalc = 0.0 var float fiveSessionLowest = 0.0 var float sessionCalc1 = 0.0 var float fiveSessionCalc = 0.0 var float tenSessionCalc = 0.0 var float tenSessionLowest = 0.0 var int fiveSessionCounter = 0 var int tenSessionCounter = 0 var int counter = 0 var int vixCounter = 0 var int sessionCounter = 0 var int indexCounter = 0 var label labelX = na var label labelX1 = na var label labelX3 = na var label labelX4 = na var line lineF = na var line lineF1 = na var line lineF2 = na var line lineF3 = na var linefill lineF4 = na var line lineF5 = na var line lineF6 = na var line lineF7 = na var box lossBox5 = na var box lossBox10 = na var label vixLabel = na var box vixBox = na var line vixLine3 = na var linefill vixLineFill = na var float fixedHigh = 0.0 var int fixedHighCounter = 0 var line red = na var line green = na var line yellow = na var line blue = na var line purple = na var line orange = na var linefill redx = na var linefill greenx = na var linefill yellowx = na var linefill bluex = na var linefill purplex = na var linefill orangex = na var label TV = na var label x = na var label x1 = na var label x2 = na var label x3 = na var label x4 = na var label x5 = na var label x6 = na var label x7 = na var label x8 = na var label x9 = na var label x10 = na var label x11 = na var label x12 = na var label x13 = na var label x14 = na var color r2 = na var color g2 = na var color ye2 = na var color b2 = na var color p2 = na var color o2 = na var float y = 0.0 var float y1 = 0.0 var float y2 = 0.0 var float y3 = 0.0 var int y4 = -1 var int y5 = 0 var int y6 = 0 var line j = na var line j1 = na var line j2 = na var line j3 = na var linefill j4 = na var label n = na var label n1 = na var label n2 = na var label n4 = na var line nx = na var line nx1 = na var line nx2 = na var line nx3 = na var label saveLabel = na var line [] vA = array.new_line() var line [] lowerA = array.new_line() var line [] upperA = array.new_line() var linefill [] aFill = array.new_linefill() var float[] trackLow = array.new_float() var float[] trackHigh = array.new_float() var color[] colorChange = array.new_color() var color[] colorChange2 = array.new_color() // _______________________________________________________ // // Initial Performance Calculations // _______________________________________________________ vixLow = ta.lowest(close, bar_index + 1 - indexCounter) if bar_index - indexCounter > 5000 indexCounter := bar_index if VorVFclose > upper and counter == 0 assetClose := close counter := 1 indexCounter := bar_index if counter == 1 vixCounter += 1 if counter == 1 and vixCounter == 11 counter := 0 tenSessionCalc := ((close / assetClose) - 1) * 100 tenSessionCalcCumulative :=((close / assetClose) - 1) * 100 tenSessionCalcCumulative := tenSessionCalcCumulative[1] + tenSessionCalcCumulative tenSessionCounter += 1 vixCounter := 0 tenSessionLowest := ((vixLow / assetClose) - 1) * 100 tenSessionLowest := tenSessionLowest[1] + tenSessionLowest if counter == 1 and vixCounter == 6 fiveSessionCounter += 1 fiveSessionCalc := ((close / assetClose) - 1) * 100 fiveSessionCalcCumulative := ((close / assetClose) - 1) * 100 fiveSessionCalcCumulative := fiveSessionCalcCumulative[1] + fiveSessionCalcCumulative fiveSessionLowest := ((vixLow / assetClose) - 1) * 100 fiveSessionLowest := fiveSessionLowest[1] + fiveSessionLowest if counter == 1 and vixCounter == 2 sessionCalc := ((close / assetClose) - 1) * 100 sessionCalc1 := ((close / assetClose) - 1) * 100 sessionCalc1 := sessionCalc1[1] + sessionCalc1 sessionCounter += 1 // _______________________________________________________ // // Plot Calculations // _______________________________________________________ vgl = ((vClose / vClose[1] - 1) * 100) vfgl = ((vFix / vFix[1] - 1) * 100) vixGainLossString = vgl > 0.0 ? " (Gain)" : vgl < 0.0 ? " (Loss)" : " (No Gain/Loss)" vixFixGainLossString = vfgl > 0.0 ? " (Gain)" : vfgl < 0.0 ? " (Loss)" : " (No Gain/Loss)" vixVixFixGainLossString = select == "VIX " ? "VIX " : "VixFix " pcString = spx == 1.00 ? "(Equal Puts/Calls)" : spx < 1.00 ? "(More Calls Than Puts)" : "(More Puts Than Calls)" // Used for Box Plot Smoothing highestHigh = ta.highest(high, 500) lowestLow = ta.lowest(low, 500) highestHigh1 = ta.highest(high, 200) lowestLow1 = ta.lowest(low, 200) highestSmooth = ta.sma(math.avg(highestHigh, highestHigh1, lowestLow1, ohlc4), 100) mult = input.float(2.5, title = "TV Size (Decrease for Low Price Assets) (Default is 2.5x)", step = 0.1) // Exaggerating VIX/VixFix Price Flucuations vixPlotCalc = select == "VIX" ? VorVFclose * mult * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252)) * .003) + math.abs(close / close[1])) : VorVFclose * (mult) * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252))* .003) + math.abs(close / close[1])) upperPlotCalc = select == "VIX" ? upper * mult * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252)) * .003)+ math.abs(close / close[1])) : upper * (mult) * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252)) * .003)+ math.abs(close / close[1])) lowerPlotCalc = select == "VIX" ? lower * mult * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252)) * .003) + math.abs(close / close[1])): lower * (mult) * ((math.avg(ta.highest(high, 252), ta.lowest(low, 252)) * .003)+ math.abs(close / close[1])) // _______________________________________________________ // // Final Performance Calculations // _______________________________________________________ finVix10 = tenSessionCalcCumulative / tenSessionCounter finVix5 = fiveSessionCalcCumulative / fiveSessionCounter finVix = sessionCalc1 / sessionCounter vixLowest = fiveSessionLowest / fiveSessionCounter vixLowestTen = tenSessionLowest / tenSessionCounter runningVIX = ((close / assetClose) - 1) * 100 lPlot = ta.lowest(low, 5)[5] // _______________________________________________________ // // Lines & Lables // _______________________________________________________ if bar_index > bar_index[1] and vixCounter == 0 label.delete(labelX1[1]) line.delete(lineF1[1]) lineF1 := line.new(bar_index, close, bar_index + 5, close * .96, color = color.white, style = line.style_dashed) labelX1 := label.new(bar_index + 5, close* .96, text = select == "VIX" ? "VIX/" + str.tostring(syminfo.ticker) + " Correlation Coeffecient: " + str.tostring(corr, format.mintick) + "\n_______________________________________\n" + "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent) , color = select == "VIX" ? color.new(color.yellow, 50) : color.new(color.orange, 50), textcolor = color.white, style = label.style_label_left, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto) if bar_index > bar_index[1] and vixCounter == 1 label.delete(labelX1[1]) line.delete(lineF1[1]) lineF1 := line.new(bar_index, close, bar_index + 5, close * .96, color = color.white, style = line.style_dashed) labelX1 := label.new(bar_index + 5, close * .96, text = select == "VIX" ? "VIX Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVIX Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VIX Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) : "VixFix Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVixFix Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VixFix Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent), color = select == "VIX" ? color.new(color.red, 50) : color.new(color.red, 50), textcolor = color.white, style = label.style_label_left, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) if lossBox == "On" lossBox5 := box.new(indexCounter, assetClose * (1 + (vixLowest/100)), bar_index, (assetClose * (1 + (vixLowest/100) ) * 1.005), bgcolor = color.new(color.orange, 75), border_color = color.new(color.orange, 75),text = "Average Greatest 5-Session % Loss", text_color = color.white) lossBox10 := box.new(indexCounter, assetClose * (1 + (vixLowestTen/100)), bar_index, (assetClose * (1 + (vixLowestTen/100) ) * 1.005), bgcolor = color.new(color.white, 25), border_color = color.new(color.black, 0), text = "Average Greatest 10-Session % Loss", text_color = color.black) labelX := label.new(bar_index, high * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band" : "VixFix Closed Above Upper Band", color = select == "VIX" ? color.new(color.blue, 50) : color.new(color.purple, 50), textcolor = color.white, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) lineF := line.new(bar_index, high * 1.05, bar_index, high, style = line.style_dashed, color = color.white) if bar_index > bar_index[1] and vixCounter > 1 and vixCounter <= 5 label.delete(labelX1[1]) line.delete(lineF1[1]) label.delete(labelX[1]) line.delete(lineF[1]) lineF1 := line.new(bar_index, close, bar_index+ 5, close * .96, color = color.white, style = line.style_dashed) labelX1 := label.new(bar_index + 5, close * .96, text = select == "VIX" ? "VIX Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVIX Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VIX Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) : "VixFix Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVixFix Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VixFix Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) , color = select == "VIX" ? color.new(color.red, 50) : color.new(color.red, 50), textcolor = color.white, style = label.style_label_left, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) if lossBox == "On" box.delete(lossBox5[1]) lossBox5 := box.new(indexCounter, assetClose * (1 + (vixLowest/100)), bar_index, (assetClose * (1 + (vixLowest/100) ) * 1.005), bgcolor = color.new(color.orange, 75), border_color = color.new(color.orange, 75),text = "Average Greatest 5-Session % Loss", text_color = color.white) box.delete(lossBox10[1]) lossBox10 := box.new(indexCounter, assetClose * (1 + (vixLowestTen/100)), bar_index, (assetClose * (1 + (vixLowestTen/100) ) * 1.005), bgcolor = color.new(color.white, 25), border_color = color.new(color.black, 0), text = "Average Greatest 10-Session % Loss", text_color = color.black) labelX := label.new(bar_index, high * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band" : "VixFix Closed Above Upper Band", color = select == "VIX" ? color.new(color.blue, 50) : color.new(color.purple, 50), textcolor = color.white, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) lineF := line.new(bar_index, high * 1.05, bar_index, high, style = line.style_dashed, color = color.white) if bar_index > bar_index[1] and vixCounter > 5 and vixCounter < 10 label.delete(labelX1[1]) line.delete(lineF1[1]) label.delete(labelX[1]) line.delete(lineF[1]) lineF1 := line.new(bar_index, close, bar_index + 5, close * .96, color = color.white, style = line.style_dashed) labelX1 := label.new(bar_index + 5, close * .96, text = select == "VIX" ? "VIX Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVIX Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VIX Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) : "VixFix Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVixFix Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VixFix Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) ,color = select == "VIX" ? color.new(color.red, 50) : color.new(color.red, 50), textcolor = color.white, style = label.style_label_left, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) if lossBox == "On" box.delete(lossBox5[1]) lossBox5 := box.new(indexCounter, assetClose * (1 + (vixLowest/100)), bar_index, (assetClose * (1 + (vixLowest/100) ) * 1.005), bgcolor = color.new(color.orange, 75), border_color = color.new(color.orange, 75),text = "Average Greatest 5-Session % Loss", text_color = color.white) box.delete(lossBox10[1]) lossBox10 := box.new(indexCounter, assetClose * (1 + (vixLowestTen/100)), bar_index, (assetClose * (1 + (vixLowestTen/100) ) * 1.005), bgcolor = color.new(color.white, 25), border_color = color.new(color.black, 0), text = "Average Greatest 10-Session % Loss", text_color = color.black) labelX := label.new(bar_index, high * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band" : "VixFix Closed Above Upper Band", color = select == "VIX" ? color.new(color.blue, 50) : color.new(color.purple, 50), textcolor = color.white, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) lineF := line.new(bar_index, high * 1.05, bar_index, high, style = line.style_dashed, color = color.white) if bar_index > bar_index[1] and vixCounter >= 11 label.delete(labelX1[1]) line.delete(lineF1[1]) lineF1 := line.new(bar_index , close, bar_index + 5, close * .96, color = color.white, style = line.style_dashed) labelX1 := label.new(bar_index + 5, close * .96, text = select == "VIX" ? "VIX Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVIX Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VIX Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(tenSessionCalc, format.percent) : "VixFix Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVixFix Upper Band Price: $" + str.tostring(upper, format.mintick) + "\n\nFollowing a VixFix Close Above Upper Band, " + "\n\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(tenSessionCalc, format.percent) , color = select == "VIX" ? color.new(color.red, 50) : color.new(color.red, 50), textcolor = color.white, style = label.style_label_left, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) label.delete(labelX[1]) line.delete(lineF[1]) lineF := line.new(bar_index - 9, high * 1.05, bar_index - 9, high, style = line.style_dashed, color = color.white) labelX := label.new(bar_index - 9, high * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band" : "VixFix Closed Above Upper Band", color = color.new(color.blue, 75), textcolor = color.white, tooltip = str.tostring(year(time)) + "/" + str.tostring(month(time)) + "/" + str.tostring(dayofmonth(time)) + "\nNext Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\10-Session %Gain/Loss: " + str.tostring(tenSessionCalc, format.percent)) if lossBox == "On" box.delete(lossBox5[1]) lossBox5 := box.new(indexCounter, assetClose * (1 + (vixLowest/100)), bar_index, (assetClose * (1 + (vixLowest/100) ) * 1.005), bgcolor = color.new(color.orange, 75), border_color = color.new(color.orange, 75),text = "Average Greatest 5-Session % Loss", text_color = color.white) box.delete(lossBox10[1]) lossBox10 := box.new(indexCounter, assetClose * (1 + (vixLowestTen/100)), bar_index, (assetClose * (1 + (vixLowestTen/100) ) * 1.005), bgcolor = color.new(color.white, 25), border_color = color.new(color.black, 0), text = "Average Greatest 10-Session % Loss", text_color = color.black) if bar_index > bar_index[1] and vixCounter > 0 and vixCounter < 10 line.delete(lineF2[1]) line.delete(lineF3[1]) lineF2 := line.new(indexCounter, assetClose * 1.10, bar_index, assetClose * 1.10, color = na) lineF3 := line.new(indexCounter, assetClose * .90, bar_index, assetClose * .90, color = na) lineF4 := linefill.new(lineF2, lineF3, color = color.new(color.red, 90)) if vixCounter == 0 line.delete(lineF3) line.delete(lineF2) linefill.delete(lineF4) if VorVFclose > upper and vixCounter == 0 labelX := label.new(bar_index, high * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band" : "VixFix Closed Above Upper Band", color = select == "VIX" ? color.new(color.blue, 50) : color.new(color.purple, 50), textcolor = color.white, tooltip = select == "VIX" ? "Average 5-Session Greatest % Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VIX Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VIX Close Above the Upper Band: " + str.tostring(finVix10, format.percent) : "Average 5-Session Greatest % Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(vixLowest, format.percent) + "\n_______________________________________\nAverage Next Session Close-to-Close Gain/Loss \nFollowing a VixFix Close Above the Upper Band: " + str.tostring(finVix, format.percent) + "\n_______________________________________\nAverage 5-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix5, format.percent) + "\n_______________________________________\nAverage 10-Session Gain/Loss Following\na VixFix Close Above the Upper Band: " + str.tostring(finVix10, format.percent)) lineF := line.new(bar_index, high * 1.05, bar_index, high, style = line.style_dashed, color = color.white) if vixCounter == 10 label.delete(labelX) labelX := label.new(indexCounter, high[bar_index - indexCounter] * 1.05, text = select == "VIX" ? "VIX Closed Above Upper Band\n" + str.tostring(year(time[bar_index - indexCounter])) + "/" + str.tostring(month(time[bar_index - indexCounter])) + "/" + str.tostring(dayofmonth(time[bar_index - indexCounter])) + "\n_______________________________________\n" + "Next Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent) : "VixFix Closed Above Upper Band\n" + str.tostring(year(time[bar_index - indexCounter])) + "/" + str.tostring(month(time[bar_index - indexCounter])) + "/" + str.tostring(dayofmonth(time[bar_index - indexCounter])) + "\n_______________________________________\n" + "Next Session %Gain/Loss: " + str.tostring(sessionCalc, format.percent) + "\n5-Session %Gain/Loss: " + str.tostring(fiveSessionCalc, format.percent) + "\n10-Session %Gain/Loss: " + str.tostring(runningVIX, format.percent), color = select == "VIX" ? color.new(color.blue, 50) : color.new(color.purple, 50), textcolor = color.white, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto) line.delete(lineF) lineF := line.new(indexCounter, high[bar_index - indexCounter] * 1.05, indexCounter, high[bar_index - indexCounter], style = line.style_dashed, color = color.white) // _______________________________________________________ // // VIX Box Plot and Color Cycle // _______________________________________________________ // Color Array Cycle if barstate.isfirst array.push(colorChange, BaW == "Color" ? color.new(color.red, 87) : color.new(color.white, 90)) array.push(colorChange, BaW == "Color" ?color.new(color.green, 87): color.new(color.gray, 90)) array.push(colorChange,BaW == "Color" ? color.new(color.yellow, 87): color.new(color.black, 90)) array.push(colorChange,BaW == "Color" ?color.new(color.blue, 87): color.new(color.white, 90)) array.push(colorChange,BaW == "Color" ?color.new(color.purple, 87): color.new(color.gray, 90)) array.push(colorChange, BaW == "Color" ?color.new(color.orange, 87): color.new(color.black, 90)) array.push(colorChange2,BaW == "Color" ?color.new(color.red, 25): color.new(color.white, 90)) array.push(colorChange2,BaW == "Color" ?color.new(color.green, 25): color.new(color.gray, 90)) array.push(colorChange2, BaW == "Color" ?color.new(color.yellow, 25): color.new(color.black, 90)) array.push(colorChange2,BaW == "Color" ?color.new(color.blue, 25): color.new(color.white, 90)) array.push(colorChange2,BaW == "Color" ?color.new(color.purple, 25): color.new(color.gray, 90)) array.push(colorChange2, BaW == "Color" ?color.new(color.orange, 25): color.new(color.black, 90)) // Cycles Colors aGet = array.get(colorChange, bar_index % array.size(colorChange)) aGet2 = array.get(colorChange2, bar_index % array.size(colorChange2)) // Plots Color Commentary if bar_index > bar_index[1] line.delete(red[1]) line.delete(green[1]) line.delete(yellow[1]) line.delete(blue[1]) line.delete(purple[1]) line.delete(orange[1]) line.delete(lineF5[1]) line.delete(lineF6[1]) line.delete(lineF7[1]) label.delete(TV[1]) linefill.delete(redx[1]) linefill.delete(greenx[1]) linefill.delete(yellowx[1]) linefill.delete(bluex[1]) linefill.delete(purplex[1]) linefill.delete(orangex[1]) red := line.new(bar_index + 100, box.get_bottom(vixBox), bar_index + 100, label.get_y(labelX3) * .85, color = na) green := line.new(bar_index + 112, box.get_bottom(vixBox), bar_index + 112, label.get_y(labelX3) * .85, color = na) yellow := line.new(bar_index + 125, box.get_bottom(vixBox), bar_index + 125, label.get_y(labelX3) * .85, color = na) blue := line.new(bar_index + 137, box.get_bottom(vixBox), bar_index + 137, label.get_y(labelX3) * .85, color = na) purple := line.new(bar_index + 150, box.get_bottom(vixBox), bar_index + 150, label.get_y(labelX3) * .85, color = na) orange := line.new(bar_index + 162, box.get_bottom(vixBox), bar_index + 162, label.get_y(labelX3) * .85, color = na) redx := linefill.new(red, green, color = tvCol == "On" ? aGet : na) greenx := linefill.new(green, yellow, color = tvCol == "On" ? aGet[1] : na) yellowx := linefill.new(yellow, blue, color = tvCol == "On" ? aGet[2] : na) bluex := linefill.new(blue, purple, color = tvCol == "On" ? aGet[3] : na) purplex := linefill.new(purple, orange, color = tvCol == "On" ? aGet[4] : na) lineF6 := line.new(bar_index + 100, box.get_bottom(vixBox), bar_index + 100, label.get_y(labelX3) * .85, color = color.white, style = line.style_dashed) lineF5 := line.new(bar_index + 175, box.get_bottom(vixBox), bar_index + 175, label.get_y(labelX3) * .85, color = color.white, style = line.style_dashed) lineF7 := line.new(bar_index + 100, line.get_y2(lineF6), bar_index + 175, line.get_y2(lineF5), color = color.white, style = line.style_dashed) orangex := linefill.new(orange, lineF5, color = tvCol == "On" ? aGet[5] : na) // Plots VIX/VixFix TV if bar_index > bar_index[1] if vixTV == "No" or vixTV == "Yes" array.push(vA, line.new(bar_index + 150, highestSmooth + vixPlotCalc[1] + (highestSmooth[1] - highestSmooth), bar_index + 151, highestSmooth + vixPlotCalc , color = VorVFclose >= upper and select == "VIX" and BaW == "Color" ? color.red : VorVFclose >= upper and select == "VixFix" and BaW == "Color" ? color.blue : select == "VIX" and VorVFclose < upper and BaW == "Color" ? color.green : select == "VixFix" and VorVFclose < upper and BaW == "Color" ? color.green : BaW == "Black and White" ? color.white : color.green)) array.push(lowerA, line.new(bar_index + 150, highestSmooth + lowerPlotCalc[1] + (highestSmooth[1] - highestSmooth), bar_index + 151, highestSmooth + lowerPlotCalc , color = select == "VIX" and BaW == "Color" ? color.blue : select == "VixFix" and BaW == "Color" ? color.red : BaW == "Black and White" ? color.gray : color.blue)) array.push(upperA, line.new(bar_index + 150, highestSmooth + upperPlotCalc[1] + (highestSmooth[1] - highestSmooth), bar_index + 151, highestSmooth + upperPlotCalc , color = select == "VIX" and BaW == "Color" ? color.blue : select == "VixFix" and BaW == "Color" ? color.red : BaW == "Black and White" ? color.gray : color.blue)) array.push(aFill, linefill.new(array.get(lowerA, array.size(lowerA) - 1), array.get(upperA, array.size(upperA) - 1), select == "VIX" and BaW == "Color"? color.new(color.blue,75) : select == "VixFix" and BaW == "Color" ? color.new(color.red, 75) : BaW == "Black and White" ? color.new(color.gray, 75) : color.new(color.blue, 75))) array.push(trackLow, math.min(highestSmooth + vixPlotCalc[1] + (highestSmooth[1] - highestSmooth), highestSmooth + lowerPlotCalc[1] + (highestSmooth[1] - highestSmooth))) array.push(trackHigh, math.max(highestSmooth + vixPlotCalc[1] + (highestSmooth[1] - highestSmooth), highestSmooth + upperPlotCalc[1] + (highestSmooth[1] - highestSmooth))) if array.size(vA) > 50 line.delete(array.shift(vA)) line.delete(array.shift(lowerA)) line.delete(array.shift(upperA)) linefill.delete(array.shift(aFill)) array.shift(trackLow) array.shift(trackHigh) // Advisory when VIX/VixFix is Pushing Statistics off Chart if bar_index > bar_index[1] and vClose > 50 and hide == "No" label.delete(saveLabel[1]) saveLabel := label.new(bar_index + 115, array.max(trackHigh) * .98, color = na, text = "Try Putting the Color Commentary \nin a Table (User Input Tab Option)", textcolor = color.red, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto) if vClose < 50 label.delete(saveLabel[1]) // VIX Box Plot if bar_index > bar_index[1] and vixTV == "No" vixBox := box.new(bar_index + 100, array.max(trackHigh) * 1.01, bar_index + 175, array.min(trackLow) * .99, border_width = 1, border_style = line.style_solid, border_color = color.white) // Plot VIX Statistics if bar_index > bar_index[1] and vixTV == "No" label.delete(vixLabel[1]) box.delete(vixBox[1]) vixLabel := label.new(bar_index + 151, box.get_top(vixBox) * 1.01, color = select == "VIX" ? color.new(color.purple, 50) : color.new(#000000, 50), text = select == "VIX" ? "VIX Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVIX Upper Band Price: $" + str.tostring(upper, format.mintick) : "VixFix Current Close Price: $" + str.tostring(VorVFclose, format.mintick) + "\nVixFix Upper Band Price: $" + str.tostring(upper, format.mintick) , textcolor = color.white) if vixTV == "No" and hide == "No" line.delete(vixLine3[1]) label.delete(labelX3[1]) label.delete(x[1]) label.delete(x1[1]) label.delete(x2[1]) label.delete(x3[1]) label.delete(x4[1]) label.delete(x5[1]) label.delete(x6[1]) label.delete(x7[1]) label.delete(x8[1]) label.delete(x9[1]) label.delete(x10[1]) label.delete(x11[1]) label.delete(x12[1]) label.delete(x13[1]) label.delete(x14[1]) vixLine3 := line.new(bar_index + 151, box.get_top(vixBox) , bar_index + 151, label.get_y(vixLabel), style =line.style_dashed, color = color.white) // Plots "Color Commentary" if BaW == "Color" x := label.new(bar_index + 122, array.min(trackLow) * .965, text = "C", color = na, textcolor = tvCol == "On" ? aGet2 : na) x1 := label.new(bar_index + 124, array.min(trackLow) * .965, text = "o", color = na, textcolor = tvCol == "On" ? aGet2[1] : na) x2 := label.new(bar_index + 126, array.min(trackLow) * .965, text = "l", color = na, textcolor = tvCol == "On" ? aGet2[2] : na) x3 := label.new(bar_index + 128, array.min(trackLow) * .965, text = "o", color = na, textcolor = tvCol == "On" ? aGet2[3] : na) x4 := label.new(bar_index + 130, array.min(trackLow) * .965, text = "r", color = na, textcolor = tvCol == "On" ? aGet2[4] : na) x5 := label.new(bar_index + 132, array.min(trackLow) * .965, text = " C", color = na, textcolor = tvCol == "On" ? aGet2[5] : na) x6 := label.new(bar_index + 134, array.min(trackLow) * .965, text = "o", color = na, textcolor = tvCol == "On" ? aGet2[0] : na) x7 := label.new(bar_index + 136, array.min(trackLow) * .965, text = "m", color = na, textcolor = tvCol == "On" ? aGet2[1] : na) x8 := label.new(bar_index + 138, array.min(trackLow) * .965, text = " m", color = na, textcolor = tvCol == "On" ? aGet2[2] : na) x9 := label.new(bar_index + 140, array.min(trackLow) * .965, text = " e", color = na, textcolor = tvCol == "On" ? aGet2[3] : na) x10 := label.new(bar_index + 142, array.min(trackLow) * .965, text = " n", color = na, textcolor = tvCol == "On" ? aGet2[4] : na) x11 := label.new(bar_index + 144, array.min(trackLow) * .965, text = " t", color = na, textcolor = tvCol == "On" ? aGet2[5] : na) x12 := label.new(bar_index + 146, array.min(trackLow) * .965, text = " a", color = na, textcolor = tvCol == "On" ? aGet2[0] : na) x13 := label.new(bar_index + 148, array.min(trackLow) * .965, text = " r", color = na, textcolor = tvCol == "On" ? aGet2[1] : na) x14 := label.new(bar_index + 150, array.min(trackLow) * .965, text = " y", color = na, textcolor = tvCol == "On" ? aGet2[2] : na) // Plots Additional VIX Statistics labelX3 := label.new(bar_index + 136, array.min(trackLow) * .85, text = "VIX Gain/loss: " + str.tostring(vgl, format.percent) + vixGainLossString + "\n\nVixFix Gain/Loss: " + str.tostring(vfgl, format.percent) + vixFixGainLossString + "\n\nS&P 500 Put/Call Ratio: " + str.tostring(spx, format.mintick) + "\n" + pcString + "\n\n50-Session Average \nS&P 500 Put/Call Ratio: " + str.tostring(ratioSMA, format.mintick) , style = label.style_label_center, color = color.new(color.white, 100), textcolor = color.white) label.delete(labelX4[1]) labelX4 := label.new(bar_index + 136, label.get_y(labelX3) * .75, text = vClose > 30 ? "VIX IS PRICED AT $" + str.tostring(vClose, format.mintick) + " \n(STAY ALERT)" : na, color = na, textcolor = color.red) // Plots "Tradingview TV" Label if bar_index > bar_index[1] and vixTV == "No" TV := label.new(bar_index + 117, box.get_top(vixBox), text = select == "VIX" ? "Tradingview TV: VIX" : "Tradingview TV: VixFix", color = na, textcolor = color.white, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto) // Colors Bars Where VIX/VixFix Closed Above Upper Band box.set_bgcolor(vixBox, color.new(#000000, 0)) // _______________________________________________________ // // VIX > 40 Box Plot // _______________________________________________________ lowYaxis = ta.lowest(low, 50) lowYaxis1 = ta.lowest((year(time) > timestamp(1989, 12, 31) ? bar_index - y4 : 1)) if bar_index - y4 > 5000 y4 := bar_index if ta.crossover(vClose, 40) and y5 == 0 y1 := high y4 := bar_index y5 := 1 y3 := close j := line.new(y4, y1, y4, high) j1 := line.new(y4, y1, y4, lowYaxis) j2 := line.new(y4, lowYaxis , bar_index, lowYaxis) j3 := line.new(bar_index + 1, high, bar_index + 1, lowYaxis) j4 := linefill.new(j2, j3, color.new(color.blue, 75)) y6 += 1 nx := line.new(y4, lowYaxis, y4 - 1, line.get_y2(j2) * .98, color = color.white, style = line.style_dashed) nx1 := line.new(y4, lowYaxis, y4, line.get_y2(j2) * .98, color = color.white, style = line.style_dashed) n := label.new(y4 - 1, line.get_y2(j2) * .98, text = "VIX > 40", color= color.new(color.blue, 50), size = size.auto, style = label.style_label_up, textcolor = color.white) n1 := label.new(bar_index, line.get_y2(j2) * .98, text = close <= y3 ? "Loss: " + str.tostring(((close /y3) - 1) * 100, format.percent) : "Gain: " + str.tostring(((close /y3) - 1) * 100, format.percent), color= color.new(color.blue, 50), textcolor = color.white, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto, style = label.style_label_up) if y5 == 1 and y5[1] == 1 line.delete(j[1]) line.delete(j1[1]) line.delete(j2[1]) line.delete(j3[1]) linefill.delete(j4[1]) line.delete(nx[1]) line.delete(nx1) label.delete(n[1]) label.delete(n1[1]) j2 := line.new(y4, lowYaxis, bar_index + 1, lowYaxis) j1 := line.new(y4, y1, y4, lowYaxis) j := line.new(y4, y1, bar_index + 1, high) j3 := line.new(bar_index + 1, high, bar_index + 1, lowYaxis) j4 := linefill.new(j1, j3, color.new(color.blue, 75)) nx := line.new(y4, lowYaxis, y4 - 1, line.get_y2(j2) * .98, color = color.white, style = line.style_dashed) nx1 := line.new(bar_index, lowYaxis, bar_index, line.get_y2(j2) * .98, color = color.white, style = line.style_dashed) n := label.new(y4 - 1, line.get_y2(j2) * .98, text = "VIX > 40", color= color.new(color.blue, 50), size = size.auto, style = label.style_label_up, textcolor = color.white) n1 := label.new(bar_index, line.get_y2(j2) * .98, text = close <= y3 ? "Loss: " + str.tostring(((close /y3) - 1) * 100, format.percent) : "Gain: " + str.tostring(((close /y3) - 1) * 100, format.percent), color= color.new(color.blue, 50), textcolor = color.white, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto, style = label.style_label_up) y6 += 1 if ta.crossunder(vClose, 40) and y5 == 1 label.delete(n1) line.delete(nx1) nx2 := line.new(bar_index + 1, lowYaxis, bar_index + 2, line.get_y2(j2) * .98, color = color.white, style = line.style_dashed) n4 := label.new(math.round(math.avg(y4, bar_index)), line.get_y2(j2) * .95, text = close <= y3 ? "Greatest Loss: " + str.tostring(((lowYaxis1 / y3) - 1) * 100, format.percent) : na, color= color.new(color.blue, 50), textcolor = color.white, size = labelSize == "Tiny" ? size.tiny : labelSize == "Small" ? size.small : size.auto, style = label.style_label_up) nx3 := line.new(math.round(math.avg(y4, bar_index)), line.get_y2(j2),math.round(math.avg(y4, bar_index)), line.get_y2(j2) * .95 , color = color.white, style = line.style_dashed) n2 := label.new(bar_index + 2, line.get_y2(nx2), text = "VIX < 40", color = color.new(color.blue, 50), textcolor = color.white, size = size.auto, style = label.style_label_up) y5 := 0 y6 := 0 if y6 == 0 and y6[1] < 10 line.delete(j) line.delete(j1) line.delete(j2) line.delete(j3) linefill.delete(j4) line.delete(nx) line.delete(nx1) line.delete(nx2) label.delete(n) label.delete(n1) label.delete(n2) label.delete(n4) line.delete(nx3) if y6 == 0 line.delete(nx1) // _______________________________________________________ // // Array Delete // _______________________________________________________ if array.size(label.all) > labelCount label.delete(array.get(label.all, 0)) int(na) // _______________________________________________________ // // Barcolor // _______________________________________________________ col1 = input.color(#0020ff, title = "VIX Closed Above Upper Band Bar Color") col2 = input.color(#5d00ff, title = "VixFix Closed Above Upper Band Bar Color") barcolor(VorVFclose > upper and select == "VIX" ? col1 : VorVFclose > upper and select == "VixFix" ? col2 : na, title = "VIX and VixFix > Upper Band Bar Color") // _______________________________________________________ // // Table (Optional) // _______________________________________________________ table1 = hide == "Yes" ? table.new(position.bottom_right, 10, 10) : na if hide == "Yes" table.cell(table1, 0, 0, text = "VIX Gain/loss: " + str.tostring(vgl, format.percent) + vixGainLossString + "\n\nVixFix Gain/Loss: " + str.tostring(vfgl, format.percent) + vixFixGainLossString + "\n\nS&P 500 Put/Call Ratio: " + str.tostring(spx, format.mintick) + "\n" + pcString + "\n\n50-Session Average \nS&P 500 Put/Call Ratio: " + str.tostring(ratioSMA, format.mintick), text_color = color.white) else if hide == "No" na
End Point Moving Average [EPMA]
https://www.tradingview.com/script/MzpgcIYP-End-Point-Moving-Average-EPMA/
crypteisfuture
https://www.tradingview.com/u/crypteisfuture/
63
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/ // © crypteisfuture //@version=5 indicator("End Point Moving Average [EPMA]", overlay = true) Get_EPMA(epma_source, epma_length) => epma = ( epma_length * math.sum( ta.cum( 1 ) * epma_source, epma_length ) - math.sum( ta.cum( 1 ), epma_length) * math.sum( epma_source, epma_length) ) / (epma_length * math.sum( math.pow( ta.cum( 1 ), 2), epma_length ) - math.pow( math.sum( ta.cum( 1 ), epma_length ), 2 ) ) * ta.cum( 1 ) + (ta.ema(epma_source, epma_length) - ta.ema( ta.cum( 1 ), epma_length) * (epma_length * math.sum( ta.cum( 1 ) * epma_source, epma_length) - math.sum( ta.cum( 1 ), epma_length ) * math.sum( epma_source, epma_length) ) / (epma_length * math.sum( math.pow( ta.cum( 1 ), 2 ), epma_length) - math.pow( math.sum( ta.cum( 1 ), epma_length ), 2 ) ) ) Get_EPMA_Average(epma) => epma_average = math.avg(epma[0], epma[1], epma[3], epma[5], epma[8], epma[13]) epma_source = input.source(close, title = 'EPMA Source') epma_length = input.int(20, title = 'EPMA Length') epma = Get_EPMA(epma_source, epma_length) epma_avg = Get_EPMA_Average(epma) show_high_low_epma = input.bool(false, 'Show high/low EPMA only?') epma_high_length = input.int(50, title = 'High EPMA Length') epma_high = Get_EPMA(high, epma_high_length) epma_high_avg = Get_EPMA_Average(epma_high) epma_low_length = input.int(14, title = 'Low EPMA Length') epma_low = Get_EPMA(low, epma_low_length) epma_low_avg = Get_EPMA_Average(epma_low) is_epma_underprice = epma_avg > close downtrend_color = color.red uptrend_color = color.lime epma_color = is_epma_underprice ? downtrend_color : uptrend_color plot(show_high_low_epma ? na : epma_avg, color = color.new(epma_color, 0), linewidth = 2) plot(show_high_low_epma ? na : epma_avg[1], color = color.new(epma_color, 50), linewidth = 2) plot(show_high_low_epma ? na : epma_avg[2], color = color.new(epma_color, 60), linewidth = 2) plot(show_high_low_epma ? na : epma_avg[3], color = color.new(epma_color, 70), linewidth = 2) plot(show_high_low_epma ? na : epma_avg[4], color = color.new(epma_color, 80), linewidth = 2) plot(show_high_low_epma ? na : epma_avg[5], color = color.new(epma_color, 90), linewidth = 2) plot(show_high_low_epma ? epma_high_avg : na, color = color.new(epma_color, 0), linewidth = 2) plot(show_high_low_epma ? epma_high_avg[1] : na, color = color.new(epma_color, 50), linewidth = 2) plot(show_high_low_epma ? epma_high_avg[2] : na, color = color.new(epma_color, 60), linewidth = 2) plot(show_high_low_epma ? epma_high_avg[3] : na, color = color.new(epma_color, 70), linewidth = 2) plot(show_high_low_epma ? epma_high_avg[4] : na, color = color.new(epma_color, 80), linewidth = 2) plot(show_high_low_epma ? epma_high_avg[5] : na, color = color.new(epma_color, 90), linewidth = 2) plot(show_high_low_epma ? epma_low_avg : na, color = color.new(epma_color, 0), linewidth = 2) plot(show_high_low_epma ? epma_low_avg[1] : na, color = color.new(epma_color, 50), linewidth = 2) plot(show_high_low_epma ? epma_low_avg[2] : na, color = color.new(epma_color, 60), linewidth = 2) plot(show_high_low_epma ? epma_low_avg[3] : na, color = color.new(epma_color, 70), linewidth = 2) plot(show_high_low_epma ? epma_low_avg[4] : na, color = color.new(epma_color, 80), linewidth = 2) plot(show_high_low_epma ? epma_low_avg[5] : na, color = color.new(epma_color, 90), linewidth = 2)
Donchian Channels (Close)
https://www.tradingview.com/script/b0qcfZCX-Donchian-Channels-Close/
danilogalisteu
https://www.tradingview.com/u/danilogalisteu/
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/ // © danilogalisteu //@version=5 indicator("Donchian Channels (Close)", "DCC", overlay=true) name1 = "Period 1" period1 = input.int(10, "Period", minval=1, group=name1, inline=name1) offset1 = input.int(0, "Box offset", minval=0, group=name1, inline=name1) color1 = input.color(color.yellow, "Color", group=name1, inline=name1) showl1 = input.bool(true, "Show line", group=name1, inline=name1+"line2") showb1 = input.bool(true, "Show box", group=name1, inline=name1+"line2") showc1 = input.bool(false, "Show channel", group=name1, inline=name1+"line2") showm1 = input.bool(false, "Show momentum change level", group=name1, inline=name1+"line3") name2 = "Period 2" period2 = input.int(15, "Period", minval=1, group=name2, inline=name2) offset2 = input.int(0, "Box offset", minval=0, group=name2, inline=name2) color2 = input.color(color.red, "Color", group=name2, inline=name2) showl2 = input.bool(true, "Show line", group=name2, inline=name2+"line2") showb2 = input.bool(true, "Show box", group=name2, inline=name2+"line2") showc2 = input.bool(false, "Show channel", group=name2, inline=name2+"line2") showm2 = input.bool(false, "Show momentum change level", group=name2, inline=name2+"line3") name3 = "Period 3" period3 = input.int(21, "Period", minval=1, group=name3, inline=name3) offset3 = input.int(0, "Box offset", minval=0, group=name3, inline=name3) color3 = input.color(color.purple, "Color", group=name3, inline=name3) showl3 = input.bool(true, "Show line", group=name3, inline=name3+"line2") showb3 = input.bool(true, "Show box", group=name3, inline=name3+"line2") showc3 = input.bool(false, "Show channel", group=name3, inline=name3+"line2") showm3 = input.bool(true, "Show momentum change level", group=name3, inline=name3+"line3") name4 = "Period 4" period4 = input.int(63, "Period", minval=1, group=name4, inline=name4) offset4 = input.int(0, "Box offset", minval=0, group=name4, inline=name4) color4 = input.color(color.blue, "Color", group=name4, inline=name4) showl4 = input.bool(true, "Show line", group=name4, inline=name4+"line2") showb4 = input.bool(true, "Show box", group=name4, inline=name4+"line2") showc4 = input.bool(false, "Show channel", group=name4, inline=name4+"line2") showm4 = input.bool(true, "Show momentum change level", group=name4, inline=name4+"line3") get_channel_levels(period, show, tcolor, offset=0) => up = ta.highest(close, period) dn = ta.lowest(close, period) md = 0.5 * (dn + up) bb = box(na) ll = line(na) if show and barstate.islast bb := box.new(bar_index[period+offset-1], up[offset], bar_index[offset], dn[offset], border_color=tcolor, bgcolor=color.new(tcolor, 95)) ll := line.new(bar_index[period+offset-1], md[offset], bar_index[offset], md[offset], color=tcolor) box.delete(bb[1]) line.delete(ll[1]) [dn, md, up] [dn1, md1, up1] = get_channel_levels(period1, showb1, color1, offset1) [dn2, md2, up2] = get_channel_levels(period2, showb2, color2, offset2) [dn3, md3, up3] = get_channel_levels(period3, showb3, color3, offset3) [dn4, md4, up4] = get_channel_levels(period4, showb4, color4, offset4) display_noplot = display.data_window+display.price_scale+display.status_line plot(md1, "Box 1 center", color=color1, linewidth=2, display=showl1 ? display.all : display_noplot) plot(up1, "Box 1 top", color=color1, linewidth=1, display=showc1 ? display.all : display_noplot) plot(dn1, "Box 1 bottom", color=color1, linewidth=1, display=showc1 ? display.all : display_noplot) plot(close, "Box 1 momentum change level", color=color1, linewidth=1, offset=period1-1, display=showm1 ? display.all : display_noplot) plot(md2, "Box 2 center", color=color2, linewidth=2, display=showl2 ? display.all : display_noplot) plot(up2, "Box 2 top", color=color2, linewidth=1, display=showc2 ? display.all : display_noplot) plot(dn2, "Box 2 bottom", color=color2, linewidth=1, display=showc2 ? display.all : display_noplot) plot(close, "Box 2 momentum change level", color=color2, linewidth=1, offset=period2-1, display=showm2 ? display.all : display_noplot) plot(md3, "Box 3 center", color=color3, linewidth=2, display=showl3 ? display.all : display_noplot) plot(up3, "Box 3 top", color=color3, linewidth=1, display=showc3 ? display.all : display_noplot) plot(dn3, "Box 3 bottom", color=color3, linewidth=1, display=showc3 ? display.all : display_noplot) plot(close, "Box 3 momentum change level", color=color3, linewidth=1, offset=period3-1, display=showm3 ? display.all : display_noplot) plot(md4, "Box 4 center", color=color4, linewidth=2, display=showl4 ? display.all : display_noplot) plot(up4, "Box 4 top", color=color4, linewidth=1, display=showc4 ? display.all : display_noplot) plot(dn4, "Box 4 bottom", color=color4, linewidth=1, display=showc4 ? display.all : display_noplot) plot(close, "Box 4 momentum change level", color=color4, linewidth=1, offset=period4-1, display=showm4 ? display.all : display_noplot)
Wedge and Flag Finder (Multi - zigzag)
https://www.tradingview.com/script/n3g6JvoB-Wedge-and-Flag-Finder-Multi-zigzag/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
5,310
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("Wedge and Flag Finder (Multi - zigzag)", max_lines_count=500, max_labels_count=500, overlay=true, max_bars_back = 2000) import HeWhoMustNotBeNamed/zigzag/14 as zg import HeWhoMustNotBeNamed/arrays/1 as pa import HeWhoMustNotBeNamed/utils/1 as utils maxBarsBack = 2000 max_bars_back(open, maxBarsBack) max_bars_back(high, maxBarsBack) max_bars_back(low, maxBarsBack) max_bars_back(close, maxBarsBack) wedgeSize = input.int(5, 'Wedge Length', options=[5,6], group='Generic', tooltip='Defines how many pivots a wedge should comply. Options are 5 and 6 with 5 being default') theme = input.string('Dark', title='Theme', options=['Light', 'Dark'], group='Generic', tooltip='Chart theme settings. Line and label colors are generted based on the theme settings. If dark theme is selected, '+ 'lighter colors are used and if light theme is selected, darker colors are used.') avoidOverlap = input.bool(true, 'Suppress Overlap', group='Generic', tooltip='Avoids plotting wedge if there is an existing wedge at starting point. This does not avoid nesting wedges (Wedge within wedge)') drawZigzag = input.bool(true, 'Draw Zigzag', group='Generic', tooltip='Draw zigzag lines and mark pivots within wedge') showZigZag1 = input.bool(true, title='L1', group='Zigzag', inline='z1') zigzag1Length = input.int(5, step=5, minval=3, title='', group='Zigzag', inline='z1') showZigZag2 = input.bool(true, title='L2', group='Zigzag', inline='z1') zigzag2Length = input.int(8, step=5, minval=3, title='', group='Zigzag', inline='z1') showZigZag3 = input.bool(true, title='L3', group='Zigzag', inline='z2') zigzag3Length = input.int(13, step=5, minval=3, title='', group='Zigzag', inline='z2') showZigZag4 = input.bool(true, title='L4', group='Zigzag', inline='z2') zigzag4Length = input.int(21, step=5, minval=3, title='', group='Zigzag', inline='z2') applyAngleDiff = input.bool(false, 'Angle Difference', inline='ad', group='Angles') minAngleDiff = input.int(5, '', minval=0, maxval=10, inline='ad', step=5, group='Angles') maxAngleDiff = input.int(20, '', minval=10, maxval=90, inline='ad', step=5, group='Angles', tooltip='Show patterns where angle between trend lines falls under the selected range') applyAngleLimit = input.bool(false, 'Angle Range    ', inline='ar', group='Angles') minAngleRange = input.int(10, '', minval=0, maxval=20, inline='ar', step=5, group='Angles') maxAngleRange = input.int(60, '', minval=20, maxval=90, inline='ar', step=5, group='Angles', tooltip='Show patterns where at least one of the trend line is within the given angle range') var themeColors = theme=="Dark"? array.from( color.rgb(251, 244, 109), color.rgb(141, 186, 81), color.rgb(74, 159, 245), color.rgb(255, 153, 140), color.rgb(255, 149, 0), color.rgb(0, 234, 211), color.rgb(167, 153, 183), color.rgb(255, 210, 113), color.rgb(119, 217, 112), color.rgb(95, 129, 228), color.rgb(235, 146, 190), color.rgb(198, 139, 89), color.rgb(200, 149, 149), color.rgb(196, 182, 182), color.rgb(255, 190, 15), color.rgb(192, 226, 24), color.rgb(153, 140, 235), color.rgb(206, 31, 107), color.rgb(251, 54, 64), color.rgb(194, 255, 217), color.rgb(255, 219, 197), color.rgb(121, 180, 183) ) : array.from( color.rgb(61, 86, 178), color.rgb(57, 163, 136), color.rgb(250, 30, 14), color.rgb(169, 51, 58), color.rgb(225, 87, 138), color.rgb(62, 124, 23), color.rgb(244, 164, 66), color.rgb(134, 72, 121), color.rgb(113, 159, 176), color.rgb(170, 46, 230), color.rgb(161, 37, 104), color.rgb(189, 32, 0), color.rgb(16, 86, 82), color.rgb(200, 92, 92), color.rgb(63, 51, 81), color.rgb(114, 106, 149), color.rgb(171, 109, 35), color.rgb(247, 136, 18), color.rgb(51, 71, 86), color.rgb(12, 123, 147), color.rgb(195, 43, 173) ) maxPatternsReference = 10 var aBarArray = array.new_int() var bBarArray = array.new_int() var cBarArray = array.new_int() var dBarArray = array.new_int() var eBarArray = array.new_int() var fBarArray = array.new_int() var xBarArray = array.new_int() f_angle(a, b, loopback) => rad2degree = 180 / math.pi ang = rad2degree * math.atan((a - b)/(2*math.sum(ta.tr, loopback+1)/(loopback+1))) ang add_new_wedge(a,b,c,d,e,f,aBar,bBar,cBar,dBar,eBar,fBar,l1Angle, l2Angle, zgColor, wedgeSize=5)=> dir = a>b? 1: -1 pa.unshift(fBarArray, fBar, maxPatternsReference) pa.unshift(aBarArray, aBar, maxPatternsReference) pa.unshift(bBarArray, bBar, maxPatternsReference) pa.unshift(cBarArray, cBar, maxPatternsReference) pa.unshift(dBarArray, dBar, maxPatternsReference) pa.unshift(eBarArray, eBar, maxPatternsReference) if(drawZigzag) ab = line.new(bBar, b, aBar, a) bc = line.new(cBar, c, bBar, b) cd = line.new(dBar, d, cBar, c) de = line.new(eBar, e, dBar, d) aLbl = label.new(aBar, a, '5', style=label.style_none, yloc=dir>0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) bLbl = label.new(bBar, b, '4', style=label.style_none, yloc=dir<0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) cLbl = label.new(cBar, c, '3', style=label.style_none, yloc=dir>0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) dLbl = label.new(dBar, d, '2', style=label.style_none, yloc=dir<0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) eLbl = label.new(eBar, e, '1', style=label.style_none, yloc=dir>0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) if(wedgeSize == 6) ef = line.new(fBar, f, eBar, e) fLbl = label.new(fBar, f, '0', style=label.style_none, yloc=dir<0?yloc.abovebar:yloc.belowbar, textcolor=zgColor) wedgeLine(l1StartX, l1StartY, l1EndX, l1EndY, l2StartX, l2StartY, l2EndX, l2EndY, zgColor)=> l1t = line.new(l1StartX, l1StartY, l1EndX, l1EndY, color=zgColor, extend=extend.both) l2t = line.new(l2StartX, l2StartY, l2EndX, l2EndY, color=zgColor, extend=extend.both) startBar = math.min(l2StartX, l1StartX) endBar = l1EndX l1Start = line.get_price(l1t, startBar) l1End = line.get_price(l1t, endBar) l2Start = line.get_price(l2t,startBar) l2End = line.get_price(l2t, endBar) line.set_extend(l1t, extend.none) line.set_extend(l2t, extend.none) line.set_x1(l1t, startBar) line.set_y1(l1t, l1Start) line.set_x2(l1t, endBar) line.set_y2(l1t, l1End) line.set_x1(l2t, startBar) line.set_y1(l2t, l2Start) line.set_x2(l2t, endBar) line.set_y2(l2t, l2End) l1Angle = f_angle(l1End, l1Start, endBar-startBar) l2Angle = f_angle(l2End, l2Start, endBar-startBar) l1Diff = math.abs(l1Start-l1End) l2Diff = math.abs(l2Start-l2End) [l1t, l2t, l1Angle, l2Angle, l1Diff, l2Diff] find_wedge(a,b,c,d,e,f,aBar,bBar,cBar,dBar,eBar,fBar,zigzagpivots, zigzagpivotbars, fIndex, wedgeSize=6)=> existingPattern = false lastPivot = wedgeSize == 6? f : e lastPivotBar = wedgeSize == 6? fBar : eBar llastPivot = wedgeSize == 6? e : d for i=0 to array.size(aBarArray)==0? na: array.size(aBarArray)-1 commonPivots = (array.get(aBarArray, i) == aBar ? 1 : 0) + (array.get(bBarArray, i) == bBar ? 1 : 0) + (array.get(cBarArray, i) == cBar ? 1 : 0) + (array.get(dBarArray, i) == dBar ? 1 : 0) + (array.get(eBarArray, i) == eBar ? 1 : 0) + (wedgeSize == 6 and array.get(fBarArray, i) == fBar ? 1 : 0) if(commonPivots >=2) or (avoidOverlap and lastPivotBar < array.get(aBarArray,i) and lastPivotBar > array.get(fBarArray, i)) existingPattern := true break if(not existingPattern) aRatio = math.abs(a-b)/math.abs(b-c) bRatio = math.abs(b-c)/math.abs(c-d) cRatio = math.abs(c-d)/math.abs(d-e) dRatio = math.abs(d-e)/math.abs(e-f) zgColor = array.pop(themeColors) [l1t, l2t, l1Angle, l2Angle, l1Diff, l2Diff] = wedgeLine(eBar, e, aBar, a, wedgeSize == 6?fBar:dBar, wedgeSize == 6?f:d, bBar, b, zgColor) isType1Wedge = aRatio >=1 and bRatio < 1 and cRatio >= 1 and (dRatio < 1 or wedgeSize==5) and l1Diff < l2Diff isType2Wedge = aRatio <1 and bRatio >= 1 and cRatio < 1 and (dRatio >=1 or wedgeSize==5) and l1Diff > l2Diff angleDiff = math.abs(l1Angle-l2Angle) angleDiffInRange = (angleDiff >= minAngleDiff and angleDiff <= maxAngleDiff) or not applyAngleDiff angleInRange = (math.max(math.abs(l1Angle), math.abs(l2Angle)) >= minAngleRange and math.min(math.abs(l1Angle), math.abs(l2Angle)) <= maxAngleRange) or not applyAngleLimit isWedge = (isType1Wedge or isType2Wedge) and angleDiffInRange and angleInRange if(isWedge) for i = aBar to lastPivotBar l = low[bar_index-i] h = high[bar_index-i] l1Price = line.get_price(l1t, i) l2Price = line.get_price(l2t, i) if(h < math.min(l1Price, l2Price) or l > math.max(l1Price, l2Price)) isWedge := false break if(i == cBar and (l1Price > h or l1Price < l)) isWedge := false break if(i == dBar and (l2Price > h or l2Price < l)) isWedge := false break if isWedge wedgeType = isType1Wedge? 1 : 2 add_new_wedge(a,b,c,d,e,f,aBar,bBar,cBar,dBar,eBar,fBar,l1Angle, l2Angle, zgColor, wedgeSize) length = array.size(zigzagpivots) xIndexes = utils.get_trend_series(zigzagpivots, fIndex, length) isFlag = false for i=array.size(xIndexes)-1 to 0 xIndex = array.get(xIndexes, i) x = array.get(zigzagpivots, xIndex) xBar = array.get(zigzagpivotbars, xIndex) flagRatio = math.abs(lastPivot-line.get_price(wedgeSize == 6?l1t:l2t, lastPivotBar))/math.abs(x-lastPivot) isFlag := flagRatio < 0.618 and (lastPivot-x)/math.abs(lastPivot-x) == (lastPivot-(wedgeSize == 6?b:a))/math.abs(lastPivot-(wedgeSize == 6?b:a)) if(isFlag) lFlag = line.new(xBar, x, lastPivotBar, lastPivot, color=zgColor, extend=extend.none) dir = x > lastPivot? 1 : -1 label.new(xBar, x, 'Flag', style=dir>0?label.style_label_down:label.style_label_up, yloc=yloc.price, color=zgColor, textcolor=color.black) break if(not isFlag) dir = lastPivot > llastPivot? 1 : -1 label.new(fBar, f, 'Wedge', style=dir>0?label.style_label_down:label.style_label_up, yloc=yloc.price, color=zgColor, textcolor=color.black) alert('New '+(isFlag?'Flag':'Wedge')+' pattern found') array.unshift(themeColors, zgColor) true else line.delete(l1t) line.delete(l2t) array.push(themeColors, zgColor) false scan_patterns(startIndex, newPivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar)=> length = array.size(zigzagpivots) numberOfPivots=5 newLastABar = lastABar if(length >= startIndex+numberOfPivots+1 and newPivot) a = array.get(zigzagpivots, startIndex) aBar = array.get(zigzagpivotbars, startIndex) aIndex = startIndex lastDir = array.get(zigzagpivotdirs, startIndex) if(aBar!=lastABar) newLastABar := aBar b = array.get(zigzagpivots, startIndex+1) bBar = array.get(zigzagpivotbars, startIndex+1) c = array.get(zigzagpivots, startIndex+2) cBar = array.get(zigzagpivotbars, startIndex+2) d = array.get(zigzagpivots, startIndex+3) dBar = array.get(zigzagpivotbars, startIndex+3) e = array.get(zigzagpivots, startIndex+4) eBar = array.get(zigzagpivotbars, startIndex+4) f = e fBar = eBar if(wedgeSize == 6) f := array.get(zigzagpivots, startIndex+5) fBar := array.get(zigzagpivotbars, startIndex+5) find_wedge(a,b,c,d,e,f,aBar,bBar,cBar,dBar,eBar,fBar,zigzagpivots, zigzagpivotbars, startIndex+wedgeSize-1,wedgeSize) newLastABar startIndex = 0 if(showZigZag1) [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagpivotratios, _, _, _, _, _, newPivot, doublePivot] = zg.czigzag(zigzag1Length) var lastABar = 0 lastABar := scan_patterns(startIndex+1, doublePivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) lastABar := scan_patterns(startIndex, newPivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) if(showZigZag2) [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagpivotratios, _, _, _, _, _, newPivot, doublePivot] = zg.czigzag(zigzag2Length) var lastABar = 0 lastABar := scan_patterns(startIndex+1, doublePivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) lastABar := scan_patterns(startIndex, newPivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) if(showZigZag3) [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagpivotratios, _, _, _, _, _, newPivot, doublePivot] = zg.czigzag(zigzag3Length) var lastABar = 0 lastABar := scan_patterns(startIndex+1, doublePivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) lastABar := scan_patterns(startIndex, newPivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) if(showZigZag4) [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagpivotratios, _, _, _, _, _, newPivot, doublePivot] = zg.czigzag(zigzag4Length) var lastABar = 0 lastABar := scan_patterns(startIndex+1, doublePivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar) lastABar := scan_patterns(startIndex, newPivot, zigzagpivots, zigzagpivotbars, zigzagpivotratios, zigzagpivotdirs, lastABar)
Relative Strength Index with divergence signal
https://www.tradingview.com/script/aNnGz78R-Relative-Strength-Index-with-divergence-signal/
shariffyaseen
https://www.tradingview.com/u/shariffyaseen/
16
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © shariffyaseen //@version=5 //@version=5 indicator(title="Relative Strength Index",overlay = false, shorttitle="RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA 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)) rsiMA = ma(rsi, maLengthInput, maTypeInput) isBB = maTypeInput == "Bollinger Bands" //plot(rsi, "RSI", color=#7E57C2) plot(rsiMA, "RSI-based MA", color=color.yellow) //rsiUpperBand = hline(60, "RSI Upper Band", color=#787B86) //hline(50, "RSI Middle Band", color=color.new(#787B86, 50)) //rsiLowerBand = hline(40, "RSI Lower Band", color=#787B86) //fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill") //bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green) //bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green) //fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill") len = input.int(title="RSI Period", minval=1, defval=14) src = input(title="RSI Source", defval=close) lbR = input(title="Pivot Lookback Right", defval=5) lbL = input(title="Pivot Lookback Left", defval=5) rangeUpper = input(title="Max of Lookback Range", defval=60) rangeLower = input(title="Min of Lookback Range", defval=5) plotBull = input(title="Plot Bullish", defval=true) plotHiddenBull = input(title="Plot Hidden Bullish", defval=false) plotBear = input(title="Plot Bearish", defval=true) plotHiddenBear = input(title="Plot Hidden Bearish", defval=false) bearColor = color.red bullColor = color.green hiddenBullColor = color.new(color.green, 80) hiddenBearColor = color.new(color.red, 80) textColor = color.white noneColor = color.new(color.white, 100) osc = ta.rsi(src, len) plot(osc, title="RSI", linewidth=2, color=#2962FF) hline(50, title="Middle Line", color=#787B86, linestyle=hline.style_dotted) obLevel = hline(60, title="Overbought", color=#787B86, linestyle=hline.style_dotted) osLevel = hline(40, title="Oversold", color=#787B86, linestyle=hline.style_dotted) fill(obLevel, osLevel, title="Background", color=color.rgb(33, 150, 243, 90)) plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Lower Low priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=2, color=(bullCond ? bullColor : noneColor) ) plotshape( bullCond ? osc[lbR] : na, offset=-lbR, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor ) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) // Price: Higher Low priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound plot( plFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond ? hiddenBullColor : noneColor) ) plotshape( hiddenBullCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text=" H Bull ", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor ) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1) bearCond = plotBear and priceHH and oscLH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? bearColor : noneColor) ) plotshape( bearCond ? osc[lbR] : na, offset=-lbR, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor ) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) // Price: Lower High priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound plot( phFound ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? hiddenBearColor : noneColor) ) plotshape( hiddenBearCond ? osc[lbR] : na, offset=-lbR, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=bearColor, textcolor=textColor )
Tesla Coil ML
https://www.tradingview.com/script/K30TplAH-Tesla-Coil-ML/
jdehorty
https://www.tradingview.com/u/jdehorty/
664
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/ // © jdehorty, based on work by DasanC, veryfid, and John Ehlers // @version=5 // This is a re-implementation of @veryfid's wonderful Tesla Coil indicator to leverage basic Machine Learning Algorithms to help classify coil crossovers. // The original Tesla Coil indicator requires extensive training and practice for the user to develop adequate intuition to interpret coil crossovers. // The goal for this version is to help the user understand the underlying logic of the Tesla Coil indicator and provide a more intuitive way to interpret the indicator. // The signals should be interpreted as suggestions rather than as a hard-coded set of rules. // NOTE: Please do NOT trade off the signals blindly. Always try to use your own intuition for understanding the coils and check for confluence with other indicators before initiating a trade. indicator(title='Tesla Coil ML [2.2]', overlay=false) // Chart Settings series = input(title='Source Series', defval=close, group="Chart Settings", tooltip="Source series to use for Tesla Coil calculations.") show_ml_signals = input(true, title="Show ML Signals", group="Chart Settings", tooltip="Show ML signals on the chart.") signal_size = input(2, title="Signal Size", group="Chart Settings", tooltip="Size of the signal dots. 1 = small, 2 = medium, 3 = large.") show_mesa = input(true, title="Show MESA Baseline", group="Chart Settings", tooltip="Show MESA baseline to provide additional color-coded context for the dominant cycle.") mesa_size = input(1, title="MESA Line Thickness", group="Chart Settings", tooltip="Thickness of the MESA line. 1 = thin, 2 = medium, 3 = thick.") scanning_range = input(title='Scanning Range', defval=100, group="Chart Settings", tooltip="Number of bars to scan for a cycle.") // MESA Spectrum Dominant Cycle // Based on previous work by Franklin Moormann and John Ehlers import Duyck/Matrix_Functions_Lib_JD/1 as matrix src = series inp = src res = input.timeframe(title='Resolution', defval='') rep = false bar = true lowerLength = 12 upperLength = 54 coefLength = 10 a1 = math.exp(-1.414 * math.pi / upperLength) b1 = 2 * a1 * math.cos(1.414 * math.pi / upperLength) c2 = b1 c3 = -a1 * a1 c1 = (1 + c2 - c3) / 4 a = math.exp(-1.414 * math.pi / lowerLength) coef2 = 2 * a * math.cos(1.414 * math.pi / lowerLength) coef3 = -a * a coef1 = 1 - coef2 - coef3 _p = array.new_float(500, 0.0) bb1 = array.new_float(500, 0.0) bb2 = array.new_float(500, 0.0) coef = array.new_float(500, 0.0) coefA = array.new_float(500, 0.0) hCoef = array.new_float(500, 0.0) wave = array.new_float(500, 0.0) nWave = array.new_float(500, 0.0) cycle = array.new_float(500, 0.0) coef2A = matrix.init(500, lowerLength, 0.0) hp = 0.0 hp := bar_index < 4 ? 0 : c1 * (src - 2 * nz(src[1]) + nz(src[2])) + c2 * nz(hp[1]) + c3 * nz(hp[2]) ssf = 0.0 ssf := bar_index < 3 ? hp : coef1 * ((hp + nz(hp[1])) / 2) + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) pwr = 0.0 for int i = 0 to upperLength - 1 by 1 pwr := pwr + math.pow(nz(ssf[i]), 2) pwr := pwr / upperLength array.set(bb1, 1, ssf) array.set(bb2, upperLength - 1, nz(ssf[upperLength - 1])) for int i = 2 to upperLength - 1 by 1 array.set(bb1, i, nz(ssf[i - 1])) array.set(bb2, i - 1, nz(ssf[i - 1])) num = 0.0 denom = 0.0 for int i = 1 to upperLength - 1 by 1 num := num + array.get(bb1, i) * array.get(bb2, i) denom := denom + math.pow(array.get(bb1, i), 2) + math.pow(array.get(bb2, i), 2) array.set(coef, 1, denom != 0 ? 2 * num / denom : 0) array.set(_p, 1, pwr * (1 - math.pow(array.get(coef, 1), 2))) for int i = 2 to coefLength by 1 for int j = 1 to i - 1 by 1 array.set(coefA, j, array.get(coef, j)) for int j = 1 to upperLength - i by 1 array.set(bb1, j, array.get(bb1, j) - (array.get(coefA, i - 1) * array.get(bb2, j))) array.set(bb2, j, array.get(bb2, j + 1) - (array.get(coefA, i - 1) * array.get(bb1, j + 1))) num1 = 0.0, denom1 = 0.0 for int j = 1 to upperLength - i by 1 num1 := num1 + (array.get(bb1, j) * array.get(bb2, j)) denom1 := denom1 + (math.pow(array.get(bb1, j), 2) + math.pow(array.get(bb2, j), 2)) array.set(coef, i, denom1 != 0 ? 2 * num1 / denom1 : 0) array.set(_p, i, array.get(_p, i - 1) * (1 - math.pow(array.get(coef, i), 2))) for int j = 1 to i - 1 by 1 array.set(coef, j, array.get(coefA, j) - (array.get(coef, i) * array.get(coefA, i - j))) for int i = 1 to coefLength matrix.set(coef2A, i, 1, array.get(coef, i)) for int j = lowerLength to 2 matrix.set(coef2A, i, j, matrix.get(coef2A, i, j - 1)) for int i = 1 to coefLength array.set(hCoef, i, 0) cc = 0.0 for int j = 1 to lowerLength cos = 1 - math.cos(2 * math.pi * j / (lowerLength + 1)) array.set(hCoef, i, array.get(hCoef, i) + (cos * matrix.get(coef2A, i, j))) cc := cc + cos array.set(hCoef, i, cc != 0 ? array.get(hCoef, i) / cc : 0) for int i = lowerLength to upperLength denReal = 0.0, denImag = 0.0 for int j = 1 to coefLength denReal := denReal + (array.get(hCoef, j) * math.cos(2 * math.pi * j / i)) denImag := denImag - (array.get(hCoef, j) * math.sin(2 * math.pi * j / i)) wav = math.pow(1 - denReal, 2) + math.pow(denImag, 2) array.set(wave, i, wav != 0 ? array.get(_p, coefLength) / wav : 0) maxWave = array.get(wave, lowerLength) for int i = lowerLength to upperLength maxWave := array.get(wave, i) > maxWave ? array.get(wave, i) : maxWave for int i = lowerLength to upperLength array.set(nWave, i, maxWave != 0 ? -array.get(wave, i)/maxWave : 0) maxCycle = array.get(cycle, lowerLength), domCycle = 0.0 for int i = lowerLength to upperLength if array.get(nWave, i) > maxCycle maxCycle := array.get(nWave, i) domCycle := i slo = ssf - nz(ssf[1]) sig = slo > 0 ? slo > nz(slo[1]) ? 2 : 1 : slo < 0 ? slo < nz(slo[1]) ? -2 : -1 : 0 strong_buy = ta.crossover(sig, 1) strong_sell = ta.crossunder(sig, -1) buy = ta.crossover(sig, 0) sell = ta.crossunder(sig, 0) msdcColor = sig > 2 ? color.new(color.green, 55) : sig > 0 ? color.new(color.green, 0) : sig < -2 ? color.new(color.red, 0) : sig < 0 ? color.new(color.red, 50) : color.black plot(domCycle + 20, title='MESA Cycle', color=show_mesa ? msdcColor : color.new(color.black, 100), linewidth=mesa_size) // Cycle Settings mirror = true purple_cycle_offset = input(40, title="Purple Cycle Offset", group="Cycle Settings", tooltip="Adjusts the overlap between the purple cycle and its mirror.") blue_cycle_offset = input(40, title="Blue Cycle Offset", group="Cycle Settings", tooltip="Adjusts the overlap between the blue cycle and its mirror.") white_cycle_offset = input(40, title="White Cycle Offset", group="Cycle Settings", tooltip="Adjusts the overlap between the white cycle and its mirror.") // Machine Learning Settings ptype = 'Close' reso = input.timeframe('', 'Timeframe/Sensitivity', group="Machine Learning Settings", tooltip="Timeframe for Machine Learning Algorithm. Lower values will result in more crossover signals.") lookback = input.int(3, 'Lookback Window Size [2..n]', minval=2, tooltip='The number of bars to look back.', group="Machine Learning Settings") nlbk = input.int(2, 'Normalization Lookback [2..240]', minval=2, maxval=240, tooltip='The number of bars to use for normalization.', group="Machine Learning Settings") lrate = input.float(0.0009, 'Learning Rate [0.0001..0.01]', minval=0.0001, maxval=0.01, step=0.0001, group="Machine Learning Settings", tooltip='The learning rate is the amount of change that the model will make in the direction of the gradient. The higher the learning rate, the more the model will change in the direction of the gradient. The lower the learning rate, the less the model will change in the direction of the gradient.') iterations = input.int(1000, 'Training Iterations [50..20000]', minval=50, group="Machine Learning Settings", tooltip='The number of iterations is the number of times the model will be trained. The higher the number of iterations, the more accurate the model will be. The lower the number of iterations, the faster the model will be.') ftype = input.string('None', 'Signals Filter', options=['Volatility', 'Volume', 'Both', 'None'], group="Machine Learning Settings", tooltip='The Signals Filter option allows you to filter signals by either the Volatility, Volume, Both, or None. The Volatility filter will filter signals by the volatility of the asset. The Volume filter will filter signals by the volume of the asset. The Both filter will filter signals by both the volatility and volume of the asset. The "None" filter will not filter signals.') curves = false easteregg = true useprice = true holding_p = input.int(5, 'Holding Period [1..n]', minval=1, tooltip='The holding period is the number of bars that the model will wait before signaling a trade.', group="Machine Learning Settings") // The Cosine IFM (Instantaneous Frequency Measurement) - Method #1 // Reference: "MEASURING CYCLES" paper by John Ehlers getCosIFM(series) => // red pi = math.pi s2 = 0.0 s3 = 0.0 delta1 = 0.0 instant = 0.0 ifm = 0.0 value1 = 0.0 value2 = 0.0 value4 = 0.0 value1 := series - series[7] s2 := 0.2 * (value1[1] + value1) * (value1[1] + value1) + 0.8 * nz(s2[1]) s3 := 0.2 * (value1[1] - value1) * (value1[1] - value1) + 0.8 * nz(s3[1]) if s2 != 0 value2 := math.sqrt(s3 / s2) value2 if s3 != 0 delta1 := 2 * math.atan(value2) delta1 for i = 0 to scanning_range by 1 value4 += delta1[i] if value4 > 2 * pi and instant == 0.0 instant := i - 1 instant if instant == 0.0 instant := instant[1] instant ifm := 0.25 * instant + 0.75 * nz(ifm[1]) ifm // Robust Cycle Measurement Function (I-Q Principles) - Method #2 // Reference: unknown getRCM(series) => // green price = series alpha = 0.1 pi = math.pi cycle = 0.0 q1 = 0.0 i1 = 0.0 i2 = 0.0 q2 = 0.0 delta1 = 0.0 delta1Phase = 0.0 medianDelta = 0.0 dc = 0.0 instPeriod = 0.0 period = 0.0 smooth = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6 cycle := (1 - 0.5 * alpha) * (1 - 0.5 * alpha) * (smooth - 2 * smooth[1] + smooth[2]) + 2 * (1 - alpha) * nz(cycle[1]) - (1 - alpha) * (1 - alpha) * nz(cycle[2]) if bar_index < 7 cycle := (price - 2 * price[1] + price[2]) / 4 cycle q1 := (0.0962 * cycle + 0.5769 * cycle[2] - 0.5769 * cycle[4] - 0.0962 * cycle[6]) * (0.5 + 0.08 * instPeriod[1]) i1 := cycle[3] if q1 != 0 and q1[1] != 0 delta1Phase := (i1 / q1 - i1[1] / q1[1]) / (1 + i1 * i1[1] / (q1 * q1[1])) delta1Phase if delta1Phase < 0.1 delta1Phase := 0.1 delta1Phase if delta1Phase > 1.1 delta1Phase := 1.1 delta1Phase medianDelta := ta.percentile_nearest_rank(delta1Phase, 5, 50) if medianDelta == 0 dc := 15 dc else dc := 6.28318 / medianDelta + 0.5 dc instPeriod := 0.33 * dc + 0.67 * nz(instPeriod[1]) period := 0.15 * instPeriod + 0.85 * nz(period[1]) period := math.round(period) period // In-Phase & Quadrature Instantaneous Frequency Measurements (IFM) - Method #2 in the Paper getIPQ(series) => // blue pi = math.pi imult = 0.635 qmult = 0.338 inphase = 0.0 quadrature = 0.0 re = 0.0 im = 0.0 inst = 0.0 delta1 = 0.0 dominant_cycle = 0.0 V = 0.0 P = series - series[7] inphase := 1.25 * (P[4] - imult * P[2]) + imult * nz(inphase[3]) quadrature := P[2] - qmult * P + qmult * nz(quadrature[2]) re := 0.2 * (inphase * inphase[1] + quadrature * quadrature[1]) + 0.8 * nz(re[1]) im := 0.2 * (inphase * quadrature[1] - inphase[1] * quadrature) + 0.8 * nz(im[1]) if re != 0.0 delta1 := math.atan(im / re) delta1 for i = 0 to 100 by 1 V += delta1[i] if V > 2 * pi and inst == 0.0 inst := i inst if inst == 0.0 inst := nz(inst[1]) inst dominant_cycle := 0.25 * inst + 0.75 * nz(dominant_cycle[1]) // Core ML Logic // Reference and further reading: "Machine Learning for Algorithmic Trading" by Stefan Jansen // Also influenced by previous pinescript implementations of Jansen's algorithms by @capcissmo volumeBreak(thres) => rsivol = ta.rsi(volume, 14) osc = ta.hma(rsivol, 10) osc > thres volatilityBreak(volmin, volmax) => ta.atr(volmin) > ta.atr(volmax) dot(v, w, p) => // dot product math.sum(v * w, p) sigmoid(z) => 1.0 / (1.0 + math.exp(-z)) logistic_regression(X, Y, p, lr, iterations) => w = 0.0 loss = 0.0 for i = 1 to iterations by 1 hypothesis = sigmoid(dot(X, 0.0, p)) loss := -1.0 / p * dot(dot(Y, math.log(hypothesis) + 1.0 - Y, p), math.log(1.0 - hypothesis), p) gradient = 1.0 / p * dot(X, hypothesis - Y, p) w -= lr * gradient w [loss, sigmoid(dot(X, w, p))] minimax(ds, p, min, max) => hi = ta.highest(ds, p) lo = ta.lowest(ds, p) (max - min) * (ds - lo) / (hi - lo) + min get_log_reg_predictions() => var BUY = 1 var SELL = -1 var HOLD = 0 var signal = HOLD var hp_counter = 0 ds = ptype == 'Open' ? open : ptype == 'High' ? high : ptype == 'Low' ? low : ptype == 'Close' ? close : ptype == 'HL2' ? (high + low) / 2 : ptype == 'OC2' ? (open + close) / 2 : ptype == 'OHL3' ? (open + high + low) / 3 : ptype == 'HLC3' ? (high + low + close) / 3 : (open + high + low + close) / 4 base_ds = request.security('', reso, ds[barstate.ishistory ? 0 : 1]) synth_ds = math.log(math.abs(math.pow(base_ds, 2) - 1) + .5) base = easteregg ? time : base_ds synth = easteregg ? base_ds : synth_ds [loss, prediction] = logistic_regression(base, synth, lookback, lrate, iterations) scaled_loss = minimax(loss, nlbk, ta.lowest(base_ds, nlbk), ta.highest(base_ds, nlbk)) scaled_prediction = minimax(prediction, nlbk, ta.lowest(base_ds, nlbk), ta.highest(base_ds, nlbk)) filter = ftype == 'Volatility' ? volatilityBreak(1, 10) : ftype == 'Volume' ? volumeBreak(49) : ftype == 'Both' ? volatilityBreak(1, 10) and volumeBreak(49) : true signal := useprice ? base_ds < scaled_loss ? SELL : base_ds > scaled_loss ? BUY : nz(signal[1]) : ta.crossunder(scaled_loss, scaled_prediction) ? SELL : ta.crossover(scaled_loss, scaled_prediction) and filter ? BUY : nz(signal[1]) changed = ta.change(signal) hp_counter := changed ? 0 : hp_counter + 1 hp_filter = hp_counter < 3 startLongTrade = changed and signal == BUY startShortTrade = changed and signal == SELL [startLongTrade, startShortTrade] [startLongTrade, startShortTrade] = get_log_reg_predictions() // Get all cycles and their average ipq = getIPQ(series) // (same as original called "len") cifm = getCosIFM(series) // (originally len1 * 3) rcm = getRCM(series) // (not graphed, included in average) average = math.avg(cifm * 3, rcm, ipq) scaled_cifm = cifm * 3 // scaled rcm_mirror = rcm * -1 + blue_cycle_offset ipq_mirror = ipq * -1 + blue_cycle_offset average_mirror = average * -1 + purple_cycle_offset scaled_cifm_mirror = scaled_cifm * -1 + white_cycle_offset w = scaled_cifm w_ = scaled_cifm_mirror b = ipq b_ = ipq_mirror p = average p_ = average_mirror // Same Color Crosses ww_1 = ta.crossover(w, w_) ww_2 = ta.crossunder(w, w_) white_cross = ww_1 or ww_2 bb_1 = ta.crossover(b, b_) bb_2 = ta.crossunder(b, b_) blue_cross = bb_1 or bb_2 pp_1 = ta.crossover(p, p_) pp_2 = ta.crossunder(p, p_) purple_cross = pp_1 or pp_2 // White-Blue Crosses wb1 = ta.crossover(w, b) wb2 = ta.crossunder(w, b) wb_1 = ta.crossover(w, b_) wb_2 = ta.crossunder(w, b_) w_b_1 = ta.crossover(w_, b_) w_b_2 = ta.crossunder(w_, b_) w_b1 = ta.crossover(w_, b) w_b2 = ta.crossunder(w_, b) wb_cross = wb1 or wb2 or wb_1 or wb_2 or w_b_1 or w_b_2 or w_b1 or w_b2 // White-Purple Crosses wp1 = ta.crossover(w, p) wp2 = ta.crossunder(w, p) wp_1 = ta.crossover(w, p_) wp_2 = ta.crossunder(w, p_) w_p_1 = ta.crossover(w_, p_) w_p_2 = ta.crossunder(w_, p_) w_p1 = ta.crossover(w_, p) w_p2 = ta.crossunder(w_, p) wp_cross = wp1 or wp2 or wp_1 or wp_2 or w_p_1 or w_p_2 or w_p1 or w_p2 // Blue-Purple Crosses bp1 = ta.crossover(b, p) bp2 = ta.crossunder(b, p) bp_1 = ta.crossover(b, p_) bp_2 = ta.crossunder(b, p_) b_p_1 = ta.crossover(b_, p_) b_p_2 = ta.crossunder(b_, p_) b_p1 = ta.crossover(b_, p) b_p2 = ta.crossunder(b_, p) bp_cross = bp1 or bp2 or bp_1 or bp_2 or b_p_1 or b_p_2 or b_p1 or b_p2 // Combination Crosses by Category any_self_cross = white_cross or blue_cross or purple_cross any_different_cross = wb_cross or wp_cross or bp_cross any_cross = any_different_cross or any_self_cross blue_cross_all = blue_cross or bp_cross or wb_cross white_cross_all = white_cross or wp_cross or wb_cross purple_cross_all = purple_cross or wp_cross or bp_cross // Transparency Definitions tr_fig = 20 tr_white = w > w_ ? 50 : 0 tr_blue = b <= b_ ? 85 : 45 tr_purple = p > p_ ? 70 : 0 // Color Definitions cola = color.new(#2196f3, tr_blue) colb = color.new(#bbd9fb, tr_white) colc = color.new(#9575cd, tr_purple) // Main Cycles plot(b, "Blue", color=cola) plot(w, "White", color=colb) plot(p, "Purple", color=colc) // Mirror Cycles plot(b_, "Blue Mirror", color=cola) plot(w_, "White Mirror", color=colb) plot(p_, "Purple Mirror", color=colc) buy_condition = startLongTrade sell_condition = startShortTrade green_signal = show_ml_signals ? color.new(color.green, 60) : color.new(color.green, 100) red_signal = show_ml_signals ? color.new(color.red, 60) : color.new(color.red, 100) // Purple Crosses plot(purple_cross_all and buy_condition ? p : na, title="Purple Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(purple_cross_all and buy_condition ? p : na, title="Purple Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(purple_cross_all and sell_condition ? p : na, title="Purple Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(purple_cross_all and sell_condition ? p : na, title="Purple Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(purple_cross_all and buy_condition ? p_ : na, title="Purple Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(purple_cross_all and buy_condition ? p_ : na, title="Purple Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(purple_cross_all and sell_condition ? p_ : na, title="Purple Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(purple_cross_all and sell_condition ? p_ : na, title="Purple Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) // Blue Crosses plot(blue_cross_all and buy_condition ? b : na, title="Blue Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(blue_cross_all and buy_condition ? b : na, title="Blue Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(blue_cross_all and sell_condition ? b : na, title="Blue Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(blue_cross_all and sell_condition ? b : na, title="Blue Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(blue_cross_all and buy_condition ? b_ : na, title="Blue Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(blue_cross_all and buy_condition ? b_ : na, title="Blue Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(blue_cross_all and sell_condition ? b_ : na, title="Blue Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(blue_cross_all and sell_condition ? b_ : na, title="Blue Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) // White Crosses plot(white_cross_all and buy_condition ? w : na, title="White Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(white_cross_all and buy_condition ? w : na, title="White Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(white_cross_all and sell_condition ? w : na, title="White Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(white_cross_all and sell_condition ? w : na, title="White Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(white_cross_all and buy_condition ? w_ : na, title="White Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(white_cross_all and buy_condition ? w_ : na, title="White Mirror Cross Buy", style=plot.style_circles, linewidth=signal_size, color=green_signal) plot(white_cross_all and sell_condition ? w_ : na, title="White Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) plot(white_cross_all and sell_condition ? w_ : na, title="White Mirror Cross Sell", style=plot.style_circles, linewidth=signal_size, color=red_signal) // Backtesting as a strategy: // longCondition = white_cross // strategy.entry("Backtest", strategy.long, when=white_cross) // opened_order = strategy.position_size[0] != strategy.position_size[1] and strategy.position_size[0] != 0 // bars = ta.barssince(opened_order) + 1 // strategy.close_all(when=(bars==2))
Lankou VS BTC all
https://www.tradingview.com/script/fZ9Hc1fP-Lankou-VS-BTC-all/
lankou
https://www.tradingview.com/u/lankou/
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/ // © lankou //@version=5 // AUTO // compare with BTC indicator('Lankou VS any', overlay=true, precision=10) divisor = input.symbol("BTCUSDT", 'divisor') the_string_btc = syminfo.ticker + '/' + divisor // UNUSED symOpen_btc = security(the_string_btc, timeframe.period, open) ha_open = request.security(the_string_btc, timeframe.period, open) ha_high = request.security(the_string_btc, timeframe.period, high) ha_low = request.security(the_string_btc, timeframe.period, low) ha_close = request.security(the_string_btc, timeframe.period, close) _transp = 45 red = color.rgb(200, 0, 70, _transp) green = color.rgb(0, 200, 70, _transp) palette = ha_close >= ha_open ? green : red plotcandle(ha_open, ha_high, ha_low, ha_close, color=palette, wickcolor=palette, bordercolor=palette)
Bond Yeild Curve
https://www.tradingview.com/script/9xMPt3dv-Bond-Yeild-Curve/
morzor61
https://www.tradingview.com/u/morzor61/
50
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 // Reference : // # ⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑ // # Purpose : // # // # History : // # Rev 3 : 128 // # Rev 4 : from 128 》 // # - Add 2-10 Spread. // # - Change to User Defined Type. // # // # Reference : // # - 10-2 Year Treasury Yield Spread by zdmre : https://www.tradingview.com/v/JN82lVEA/ // # - Historical US Bond Yield Curve, BarefootJoey : https://www.tradingview.com/script/faurpTxW-Historical-US-Bond-Yield-Curve/ // # // # ⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑⁑ //@version=5 indicator("Treasury Yield") //#region User Defined Type type Yields float TTM03MY float TTM01Y float TTM02Y float TTM03Y float TTM05Y float TTM07Y float TTM10Y float TTM20Y //---------------------------------------------------------------------------------------- //#region Constant ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― // Country // SEA THAILAND = 'Thailand' ,VIETNAM = 'Vietnam' ,INDONESIA = 'Indonesia' ,MALAYSIA = 'Malaysia' , PHILIPPINES = 'Philippines' ,SINGAPORE = 'Singapore' // ASIA JAPAN = 'Japan' ,CHINA = 'China' ,SOUTH_KOREA = 'South Korea' ,INDIA = 'India', TAIWAN = 'Taiwan' // EAST ASIA // AMERICA USA = 'US' ,CANADA = 'Canada' // SOUTH AMERIA BRAZIL = 'Brazil' // EU UK = 'UK' ,GERMANY = 'Germany' ,FRANCE = 'France' ,RUSSIA = 'Russia' , AUSTRALIA = 'Australia' ,EU = 'EU' // TTM [TTM_03MY, TTM_06MY, TTM_01Y, TTM_02Y, TTM_03Y, TTM_05Y, TTM_07Y, TTM_10Y, TTM_15Y, TTM_20Y] TTM_03MY = '03MY' , TTM_01Y = '01Y' ,TTM_02Y = '02Y', TTM_03Y = '03Y', TTM_05Y = '05Y' ,TTM_07Y = '07Y', TTM_10Y = '10Y', TTM_20Y = '20Y' //#endregion //-------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------- //#region INPUT MAIN_GROUP = "Base" MAIN_GROUP_PERIOD = "Time" COMPARE_GROUP = 'COMPARE BY COUNTRY' ALL_TTM = "Line Chart for All TTM" , COMPARE_BY_PERIOD = "Compare by time", COMPARE_BY_COUNTRY = "Compare by country", SPREAD_02_10 = "2-10 Spread" data_type = input.string(title = "Data Type", defval = COMPARE_BY_PERIOD, options = [ COMPARE_BY_PERIOD, COMPARE_BY_COUNTRY, ALL_TTM, SPREAD_02_10]) country01 = input.string(USA, 'Base Country', options = [ '--- AMERICA ---', USA, CANADA, '--- EUROPE ----', UK, GERMANY, FRANCE, RUSSIA, AUSTRALIA, EU, '--- ASIA ------', JAPAN, CHINA, SOUTH_KOREA, INDIA, TAIWAN, '--- SEA -------', THAILAND, VIETNAM, INDONESIA, MALAYSIA, PHILIPPINES, SINGAPORE], inline="Base Country", group = MAIN_GROUP) compare_period_01 = input.int(title = "Compare Period", defval = 30, inline = MAIN_GROUP_PERIOD, group = MAIN_GROUP) compare_period_02 = input.int(title = "", defval = 252, inline = MAIN_GROUP_PERIOD, group = MAIN_GROUP) country02 = input.string(CHINA, 'Compare Country', options = [ '--- AMERICA ---', USA, CANADA, '--- EUROPE ----', UK, GERMANY, FRANCE, RUSSIA, AUSTRALIA, EU, '--- ASIA ------', JAPAN, CHINA, SOUTH_KOREA, INDIA, TAIWAN, '--- SEA -------', THAILAND, VIETNAM, INDONESIA, MALAYSIA, PHILIPPINES, SINGAPORE], inline=COMPARE_GROUP, group = COMPARE_GROUP) country03 = input.string(UK, '', options = [ '--- AMERICA ---', USA, CANADA, '--- EUROPE ----', UK, GERMANY, FRANCE, RUSSIA, AUSTRALIA, EU, '--- ASIA ------', JAPAN, CHINA, SOUTH_KOREA, INDIA, TAIWAN, '--- SEA -------', THAILAND, VIETNAM, INDONESIA, MALAYSIA, PHILIPPINES, SINGAPORE], inline=COMPARE_GROUP, group = COMPARE_GROUP) locFactor = input.int(defval = 40, title = "Location Factor", minval = 1, step = 5) //#endregion //#region FUNCTION ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― get_bond_ticker(_country, _ttm)=> // Function : Get ticker of treasury bond from each country from TVC. // param : _country ==> Country // param : _per ==> Time to maturity of treasury bond // country_code = '' country_code = switch _country // SEA THAILAND => 'TH' VIETNAM => 'VN' INDONESIA => 'ID' MALAYSIA => 'MY' 'Philippines' => 'PH' 'Singapore' => 'SG' // Asia JAPAN => 'JP' CHINA => 'CN' 'S Korea' => 'KR' INDIA => 'IN' 'Taiwan' => 'TW' // East Asia // America USA => 'US' 'Canada' => 'CA' // South America 'Brazil' => 'BR' // 'Argentina' => // EU UK => 'GB' GERMANY => 'DE' 'France' => 'FR' 'Russia' => 'RU' 'Australia' => 'AU' 'EU' => 'EU' // Not show => '' // Bond Ticker based on selected country and TTM bond_ticker = 'TVC:' + country_code + _ttm bond_ticker // get_ttm(country, ttm)=> tickerSymbol = get_bond_ticker(country, ttm) yield = nz(request.security(tickerSymbol, timeframe.period, close, ignore_invalid_symbol = true)) get_all_ttm(country)=> ttm_03my = get_ttm(country, TTM_03MY) ttm_01y = get_ttm(country, TTM_01Y ) ttm_02y = get_ttm(country, TTM_02Y ) ttm_03y = get_ttm(country, TTM_03Y ) ttm_05y = get_ttm(country, TTM_05Y ) ttm_07y = get_ttm(country, TTM_07Y ) ttm_10y = get_ttm(country, TTM_10Y ) ttm_20y = get_ttm(country, TTM_20Y ) data = Yields.new(ttm_03my, ttm_01y, ttm_02y, ttm_03y, ttm_05y, ttm_07y, ttm_10y, ttm_20y) line_position(x)=> int number_of_ttm = 8 factor = (number_of_ttm-x) * locFactor x_position = bar_index - (x == 9 ? factor + 7 : factor ) draw_label(x, y, txt, label_order)=> var label ttm_label = na lable_style = x==9 ? label.style_label_left: label.style_label_up label.delete(ttm_label) txt_color = label_order == 1 ? color.rgb(255, 136, 0) : label_order == 2 ? color.new(#5eff00, 0) :color.new(#3bf2ff, 0) ttm_label := label.new( line_position(x), y, text= txt, color=color.new(#35a4ff, 100), textcolor = txt_color, style=lable_style) // @function Draw line of yield. // ___ // #### Usage // ``` // draw_line(x1, y1, x2, y2, line_order) // ``` // ___ // @param y1 start location value // @param x1 start location // @returns `Line plot of 2 locatoin` draw_line(x1, y1, x2, y2, line_order)=> var color line_color = na var string line_style = na var int line_width = na if line_order == 1 line_color := color.rgb(255, 136, 0) line_style := line.style_solid line_width := 3 else if line_order == 2 line_color := color.new(#5eff00, 0) line_style := line.style_dotted line_width := 2 else line_style := line.style_dotted line_color := color.new(#3bf2ff, 0) line_width := 1 var line value_line = na line.delete(value_line) value_line := line.new( line_position(x1), y1, line_position(x2), y2, width=line_width, color = line_color) value_line //#endregion //#region CALCULATION ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――v c1Data = get_all_ttm(country01) c2Data = get_all_ttm(country02) c3Data = get_all_ttm(country03) if data_type == COMPARE_BY_COUNTRY draw_line(1, c1Data.TTM03MY, 2, c1Data.TTM01Y , 2) draw_line(2, c1Data.TTM01Y, 3, c1Data.TTM02Y , 2) draw_line(3, c1Data.TTM02Y, 4, c1Data.TTM03Y , 2) draw_line(4, c1Data.TTM03Y, 5, c1Data.TTM05Y , 2) draw_line(5, c1Data.TTM05Y, 6, c1Data.TTM07Y , 2) draw_line(6, c1Data.TTM07Y, 7, c1Data.TTM10Y , 2) draw_line(7, c1Data.TTM10Y, 8, c1Data.TTM20Y , 2) draw_label(9, c1Data.TTM20Y, str.tostring(country01), 1) draw_line(1, c2Data.TTM03MY, 2, c2Data.TTM01Y, 1) draw_line(2, c2Data.TTM01Y, 3, c2Data.TTM02Y, 1) draw_line(3, c2Data.TTM02Y, 4, c2Data.TTM03Y, 1) draw_line(4, c2Data.TTM03Y, 5, c2Data.TTM05Y, 1) draw_line(5, c2Data.TTM05Y, 6, c2Data.TTM07Y, 1) draw_line(6, c2Data.TTM07Y, 7, c2Data.TTM10Y, 1) draw_line(7, c2Data.TTM10Y, 8, c2Data.TTM20Y, 1) draw_label(9, c2Data.TTM20Y, str.tostring(country02), 2) draw_line(1, c3Data.TTM03MY, 2, c3Data.TTM01Y , 3) draw_line(2, c3Data.TTM01Y, 3, c3Data.TTM02Y , 3) draw_line(3, c3Data.TTM02Y, 4, c3Data.TTM03Y , 3) draw_line(4, c3Data.TTM03Y, 5, c3Data.TTM05Y , 3) draw_line(5, c3Data.TTM05Y, 6, c3Data.TTM07Y , 3) draw_line(6, c3Data.TTM07Y, 7, c3Data.TTM10Y , 3) draw_line(7, c3Data.TTM10Y, 8, c3Data.TTM20Y , 3) draw_label(9, c3Data.TTM20Y, str.tostring(country03), 3) draw_label(1, c1Data.TTM03MY , '3M' , 1) draw_label(2, c1Data.TTM01Y , '1Y' , 1) draw_label(3, c1Data.TTM02Y , '2Y' , 1) draw_label(4, c1Data.TTM03Y , '3Y' , 1) draw_label(5, c1Data.TTM05Y , '5Y' , 1) draw_label(6, c1Data.TTM07Y , '7Y' , 1) draw_label(7, c1Data.TTM10Y , '10Y', 1) draw_label(8, c1Data.TTM20Y , '20Y', 1) draw_label(9, c1Data.TTM20Y, data_type == COMPARE_BY_PERIOD ? 'Current' : country01, 1) if data_type == COMPARE_BY_PERIOD draw_line(1, c1Data.TTM03MY , 2, c1Data.TTM01Y, 1) draw_line(2, c1Data.TTM01Y , 3, c1Data.TTM02Y, 1) draw_line(3, c1Data.TTM02Y , 4, c1Data.TTM03Y, 1) draw_line(4, c1Data.TTM03Y , 5, c1Data.TTM05Y, 1) draw_line(5, c1Data.TTM05Y , 6, c1Data.TTM07Y, 1) draw_line(6, c1Data.TTM07Y , 7, c1Data.TTM10Y, 1) draw_line(7, c1Data.TTM10Y , 8, c1Data.TTM20Y, 1) draw_line(1, c1Data.TTM03MY[compare_period_01], 2, c1Data.TTM01Y[compare_period_01], 2) draw_line(2, c1Data.TTM01Y[compare_period_01], 3, c1Data.TTM02Y[compare_period_01], 2) draw_line(3, c1Data.TTM02Y[compare_period_01], 4, c1Data.TTM03Y[compare_period_01], 2) draw_line(4, c1Data.TTM03Y[compare_period_01], 5, c1Data.TTM05Y[compare_period_01], 2) draw_line(5, c1Data.TTM05Y[compare_period_01], 6, c1Data.TTM07Y[compare_period_01], 2) draw_line(6, c1Data.TTM07Y[compare_period_01], 7, c1Data.TTM10Y[compare_period_01], 2) draw_line(7, c1Data.TTM10Y[compare_period_01], 8, c1Data.TTM20Y[compare_period_01], 2) draw_line(1, c1Data.TTM03MY[compare_period_02], 2, c1Data.TTM01Y[compare_period_02], 3) draw_line(2, c1Data.TTM01Y[compare_period_02], 3, c1Data.TTM02Y[compare_period_02], 3) draw_line(3, c1Data.TTM02Y[compare_period_02], 4, c1Data.TTM03Y[compare_period_02], 3) draw_line(4, c1Data.TTM03Y[compare_period_02], 5, c1Data.TTM05Y[compare_period_02], 3) draw_line(5, c1Data.TTM05Y[compare_period_02], 6, c1Data.TTM07Y[compare_period_02], 3) draw_line(6, c1Data.TTM07Y[compare_period_02], 7, c1Data.TTM10Y[compare_period_02], 3) draw_line(7, c1Data.TTM10Y[compare_period_02], 8, c1Data.TTM20Y[compare_period_02], 3) _suffix = timeframe.period == "D" ? " days ago" : timeframe.period == "W" ? " weeks ago" : timeframe.period == "M" ? " month ago" : na draw_label(9, c1Data.TTM20Y, 'Current', 1) draw_label(9, c1Data.TTM20Y[compare_period_01], str.tostring(compare_period_01)+_suffix, 2) draw_label(9, c1Data.TTM20Y[compare_period_02], str.tostring(compare_period_02)+_suffix, 3) draw_label(1, c1Data.TTM03MY , '3M' , 1) draw_label(2, c1Data.TTM01Y , '1Y' , 1) draw_label(3, c1Data.TTM02Y , '2Y' , 1) draw_label(4, c1Data.TTM03Y , '3Y' , 1) draw_label(5, c1Data.TTM05Y , '5Y' , 1) draw_label(6, c1Data.TTM07Y , '7Y' , 1) draw_label(7, c1Data.TTM10Y , '10Y', 1) draw_label(8, c1Data.TTM20Y , '20Y', 1) // float spread = na if data_type == SPREAD_02_10 spread := c1Data.TTM10Y - c1Data.TTM02Y bearish = ta.cross(spread, 0) == 1 and spread < 0 bullish = ta.cross(spread, 2.6) == 1 and spread > 2.6 if bearish label1 = label.new(bar_index, 0 , text='|\n'+ str.format("{0,date, y\nMMM-d}", time), style=label.style_label_up, color=color.new(color.red,100)) label.set_size(label1, size.small) label.set_textcolor(label1, color.red) if bullish label2 = label.new(bar_index, 2.6 , text=str.format("{0,date, y\nMMM-d\n}", time)+'|', style=label.style_label_down, color=color.new(color.green,100)) label.set_size(label2, size.small) label.set_textcolor(label2, color.green) plot(data_type == SPREAD_02_10 ? spread : na, title = "2-10 Spread", color = color.orange) upperBand = hline(data_type == SPREAD_02_10 ? 2.6 : na , title = 'Upper Band') centerBand = hline(data_type == SPREAD_02_10 ? 1.3 : na , title = 'Center Band') lowerBand = hline(data_type == SPREAD_02_10 ? 0 : na , title = 'Lower Band') fill(upperBand, lowerBand, color=color.rgb(126, 87, 194, 90), title="Background") // data_type == All ttm. plot(series = data_type == ALL_TTM ? c1Data.TTM03MY : na, title = "3M", color = color.rgb(75, 75, 75), linewidth = 1) plot(series = data_type == ALL_TTM ? c1Data.TTM01Y : na, title = "1Y", color = color.rgb(75, 75, 75), linewidth = 1) plot(series = data_type == ALL_TTM ? c1Data.TTM02Y : na, title = "2Y", color = color.rgb(50, 248, 0), linewidth = 2) plot(series = data_type == ALL_TTM ? c1Data.TTM03Y : na, title = "3Y", color = color.rgb(75, 75, 75), linewidth = 1) plot(series = data_type == ALL_TTM ? c1Data.TTM05Y : na, title = "5Y", color = color.rgb(255, 6, 201), linewidth = 2) plot(series = data_type == ALL_TTM ? c1Data.TTM07Y : na, title = "7Y", color = color.rgb(75, 75, 75), linewidth = 1) plot(series = data_type == ALL_TTM ? c1Data.TTM10Y : na, title = "10Y", color = color.rgb(253, 0, 0), linewidth = 2) plot(series = data_type == ALL_TTM ? c1Data.TTM20Y : na, title = "20Y", color = color.rgb(75, 75, 75), linewidth = 1) //
Settlement price
https://www.tradingview.com/script/LuYMi8j8-Settlement-price/
konidtaly88
https://www.tradingview.com/u/konidtaly88/
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/ // © konidtaly88 //@version=5 indicator("Settlement price",overlay=true) i_res = input.timeframe('D', "Resolution", options=['D', 'W', 'M']) daily_settlement_price = request.security(syminfo.tickerid, "D", close[1], barmerge.gaps_off, barmerge.lookahead_on) daily_index = request.security(syminfo.tickerid, "D", bar_index[1], barmerge.gaps_off, barmerge.lookahead_on) weekly_settlement_price = request.security(syminfo.tickerid, "W", close[1], barmerge.gaps_off, barmerge.lookahead_on) weekly_index = request.security(syminfo.tickerid, "W", bar_index[1], barmerge.gaps_off, barmerge.lookahead_on) monthly_settlement_price = request.security(syminfo.tickerid, "M", close[1], barmerge.gaps_off, barmerge.lookahead_on) monthly_index = request.security(syminfo.tickerid, "M", bar_index[1], barmerge.gaps_off, barmerge.lookahead_on) var today = daily_index var this_week = weekly_index var this_month = monthly_index settlement_price = switch i_res 'D' => today == daily_index? daily_settlement_price:na 'W' => this_week == weekly_index? weekly_settlement_price:na 'M' => this_month == monthly_index? monthly_settlement_price:na => na plot(timeframe.isintraday?settlement_price:na, style=plot.style_linebr, color=color.new(color.blue, 25), offset=-1) today := daily_index this_week := weekly_index this_month := monthly_index
Volume Variation Index Indicator
https://www.tradingview.com/script/ZfAEZqOJ-Volume-Variation-Index-Indicator/
thequantscience
https://www.tradingview.com/u/thequantscience/
33
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/ // © thequantscience //@version=5 indicator("VolumeVariationIndex", overlay = false) //-----------VolumeVariationIndex--------------{ //Measures the change in trading volume. //Green columns indicate increasing volume trades. //Red columns indicate decreasing volume trades. //You can check the average of the variations. //You can active volume variation avarage from UI. //You can setting avarage variation period from UI. //---------} // Calculate volume var VolumeVariation = volume[1] - volume GreenVolume = if VolumeVariation > 0 VolumeVariation else 0 RedVolume = if VolumeVariation < 0 VolumeVariation else 0 plot(GreenVolume, title = "VolumeIncrease", style = plot.style_columns, color = color.green) plot(RedVolume, title = "VolumeDecrease", style = plot.style_columns, color = color.red) // Calculate volume var avarage ActiveAvarage = input.string("NO", title="ActiveAvarageVariation", options=["NO", "YES"]) == "YES" AvaragePeriod = input(10) AvarageVolumeVariation = ta.sma(VolumeVariation, AvaragePeriod) Avarage = if AvarageVolumeVariation and ActiveAvarage AvarageVolumeVariation else 0 plot(Avarage, color = color.blue)
3rd day breakout
https://www.tradingview.com/script/b8GdweuL-3rd-day-breakout/
aforanand22
https://www.tradingview.com/u/aforanand22/
23
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © aforanand22 //@version=4 study(title = "3rd day breakout", overlay = true) Inside_Bar = high <= high[1] and low >= low[1] plotshape(Inside_Bar, style=shape.arrowdown, location=location.abovebar, color= color.yellow) Inside_Bar_Bullish = high[1] <= high[2] and low[1] >= low[2] and close >= high[2] plotshape(Inside_Bar_Bullish, style=shape.arrowup, location=location.belowbar,color= color.green) Inside_Bar_Bearish = high[1] <= high[2] and low[1] >= low[2] and close <= low[2] plotshape(Inside_Bar_Bearish, style=shape.arrowdown, location=location.abovebar, color= color.red)
S&P 500 Earnings Yield Spread
https://www.tradingview.com/script/ay9aOPJU-S-P-500-Earnings-Yield-Spread/
alexjnelson
https://www.tradingview.com/u/alexjnelson/
177
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/ // © alexjnelson //@version=4 study("S&P 500 Yield Spread") overbought = input(3.16, "Overbought Level") oversold = input(-3.97, "Oversold Level") // Color Coding - Credit to The_Caretaker; this spectrum was adapted from his Bollinger Bands Width Percentile indicator max_val = input(4.44, "Max Expected Value", tooltip="By default this is the maximum since 1960 as of Feb 2 2022 (4.44%)") min_val = input(-5.82, "Max Expected Value", tooltip="By default this is the minimum since 1960 as of Feb 2 2022 (-5.82%)") color_type = input ( "Spectrum", "Color Type", input.string, options = [ "Spectrum", "Solid" ], inline = "1", group = "BBWP Plot Settings" ) spec_type = input ( "Blue Green Red", "Spectrum", input.string, options = [ "Blue Red", "Blue Green Red"], inline = "1", group = "BBWP Plot Settings" ) is_solid = input ( #FFFF00, "Solid", input.color, inline = "1", group = "BBWP Plot Settings" ) var c_prcntSpctrm1 = array.new_color ( na ) if barstate.isfirst array.push ( c_prcntSpctrm1, #0000FF ), array.push ( c_prcntSpctrm1, #000AFF ), array.push ( c_prcntSpctrm1, #0014FF ), array.push ( c_prcntSpctrm1, #001FFF ), array.push ( c_prcntSpctrm1, #0029FF ), array.push ( c_prcntSpctrm1, #0033FF ), array.push ( c_prcntSpctrm1, #003DFF ), array.push ( c_prcntSpctrm1, #0047FF ), array.push ( c_prcntSpctrm1, #0052FF ), array.push ( c_prcntSpctrm1, #005CFF ), array.push ( c_prcntSpctrm1, #0066FF ), array.push ( c_prcntSpctrm1, #0070FF ), array.push ( c_prcntSpctrm1, #007AFF ), array.push ( c_prcntSpctrm1, #0085FF ), array.push ( c_prcntSpctrm1, #008FFF ), array.push ( c_prcntSpctrm1, #0099FF ), array.push ( c_prcntSpctrm1, #00A3FF ), array.push ( c_prcntSpctrm1, #00ADFF ), array.push ( c_prcntSpctrm1, #00B8FF ), array.push ( c_prcntSpctrm1, #00C2FF ), array.push ( c_prcntSpctrm1, #00CCFF ), array.push ( c_prcntSpctrm1, #00D6FF ), array.push ( c_prcntSpctrm1, #00E0FF ), array.push ( c_prcntSpctrm1, #00EBFF ), array.push ( c_prcntSpctrm1, #00F5FF ), array.push ( c_prcntSpctrm1, #00FFFF ), array.push ( c_prcntSpctrm1, #00FFF5 ), array.push ( c_prcntSpctrm1, #00FFEB ), array.push ( c_prcntSpctrm1, #00FFE0 ), array.push ( c_prcntSpctrm1, #00FFD6 ), array.push ( c_prcntSpctrm1, #00FFCC ), array.push ( c_prcntSpctrm1, #00FFC2 ), array.push ( c_prcntSpctrm1, #00FFB8 ), array.push ( c_prcntSpctrm1, #00FFAD ), array.push ( c_prcntSpctrm1, #00FFA3 ), array.push ( c_prcntSpctrm1, #00FF99 ), array.push ( c_prcntSpctrm1, #00FF8F ), array.push ( c_prcntSpctrm1, #00FF85 ), array.push ( c_prcntSpctrm1, #00FF7A ), array.push ( c_prcntSpctrm1, #00FF70 ), array.push ( c_prcntSpctrm1, #00FF66 ), array.push ( c_prcntSpctrm1, #00FF5C ), array.push ( c_prcntSpctrm1, #00FF52 ), array.push ( c_prcntSpctrm1, #00FF47 ), array.push ( c_prcntSpctrm1, #00FF3D ), array.push ( c_prcntSpctrm1, #00FF33 ), array.push ( c_prcntSpctrm1, #00FF29 ), array.push ( c_prcntSpctrm1, #00FF1F ), array.push ( c_prcntSpctrm1, #00FF14 ), array.push ( c_prcntSpctrm1, #00FF0A ), array.push ( c_prcntSpctrm1, #00FF00 ), array.push ( c_prcntSpctrm1, #0AFF00 ), array.push ( c_prcntSpctrm1, #14FF00 ), array.push ( c_prcntSpctrm1, #1FFF00 ), array.push ( c_prcntSpctrm1, #29FF00 ), array.push ( c_prcntSpctrm1, #33FF00 ), array.push ( c_prcntSpctrm1, #3DFF00 ), array.push ( c_prcntSpctrm1, #47FF00 ), array.push ( c_prcntSpctrm1, #52FF00 ), array.push ( c_prcntSpctrm1, #5CFF00 ), array.push ( c_prcntSpctrm1, #66FF00 ), array.push ( c_prcntSpctrm1, #70FF00 ), array.push ( c_prcntSpctrm1, #7AFF00 ), array.push ( c_prcntSpctrm1, #85FF00 ), array.push ( c_prcntSpctrm1, #8FFF00 ), array.push ( c_prcntSpctrm1, #99FF00 ), array.push ( c_prcntSpctrm1, #A3FF00 ), array.push ( c_prcntSpctrm1, #ADFF00 ), array.push ( c_prcntSpctrm1, #B8FF00 ), array.push ( c_prcntSpctrm1, #C2FF00 ), array.push ( c_prcntSpctrm1, #CCFF00 ), array.push ( c_prcntSpctrm1, #D6FF00 ), array.push ( c_prcntSpctrm1, #E0FF00 ), array.push ( c_prcntSpctrm1, #EBFF00 ), array.push ( c_prcntSpctrm1, #F5FF00 ), array.push ( c_prcntSpctrm1, #FFFF00 ), array.push ( c_prcntSpctrm1, #FFF500 ), array.push ( c_prcntSpctrm1, #FFEB00 ), array.push ( c_prcntSpctrm1, #FFE000 ), array.push ( c_prcntSpctrm1, #FFD600 ), array.push ( c_prcntSpctrm1, #FFCC00 ), array.push ( c_prcntSpctrm1, #FFC200 ), array.push ( c_prcntSpctrm1, #FFB800 ), array.push ( c_prcntSpctrm1, #FFAD00 ), array.push ( c_prcntSpctrm1, #FFA300 ), array.push ( c_prcntSpctrm1, #FF9900 ), array.push ( c_prcntSpctrm1, #FF8F00 ), array.push ( c_prcntSpctrm1, #FF8500 ), array.push ( c_prcntSpctrm1, #FF7A00 ), array.push ( c_prcntSpctrm1, #FF7000 ), array.push ( c_prcntSpctrm1, #FF6600 ), array.push ( c_prcntSpctrm1, #FF5C00 ), array.push ( c_prcntSpctrm1, #FF5200 ), array.push ( c_prcntSpctrm1, #FF4700 ), array.push ( c_prcntSpctrm1, #FF3D00 ), array.push ( c_prcntSpctrm1, #FF3300 ), array.push ( c_prcntSpctrm1, #FF2900 ), array.push ( c_prcntSpctrm1, #FF1F00 ), array.push ( c_prcntSpctrm1, #FF1400 ), array.push ( c_prcntSpctrm1, #FF0000 ), array.push ( c_prcntSpctrm1, #FF0000 ) var c_prcntSpctrm2 = array.new_color ( na ) if barstate.isfirst array.push ( c_prcntSpctrm2, #0000FF ), array.push ( c_prcntSpctrm2, #0200FC ), array.push ( c_prcntSpctrm2, #0500F9 ), array.push ( c_prcntSpctrm2, #0700F7 ), array.push ( c_prcntSpctrm2, #0A00F4 ), array.push ( c_prcntSpctrm2, #0C00F2 ), array.push ( c_prcntSpctrm2, #0F00EF ), array.push ( c_prcntSpctrm2, #1100ED ), array.push ( c_prcntSpctrm2, #1400EA ), array.push ( c_prcntSpctrm2, #1600E8 ), array.push ( c_prcntSpctrm2, #1900E5 ), array.push ( c_prcntSpctrm2, #1C00E2 ), array.push ( c_prcntSpctrm2, #1E00E0 ), array.push ( c_prcntSpctrm2, #2100DD ), array.push ( c_prcntSpctrm2, #2300DB ), array.push ( c_prcntSpctrm2, #2600D8 ), array.push ( c_prcntSpctrm2, #2800D6 ), array.push ( c_prcntSpctrm2, #2B00D3 ), array.push ( c_prcntSpctrm2, #2D00D1 ), array.push ( c_prcntSpctrm2, #3000CE ), array.push ( c_prcntSpctrm2, #3300CC ), array.push ( c_prcntSpctrm2, #3500C9 ), array.push ( c_prcntSpctrm2, #3800C6 ), array.push ( c_prcntSpctrm2, #3A00C4 ), array.push ( c_prcntSpctrm2, #3D00C1 ), array.push ( c_prcntSpctrm2, #3F00BF ), array.push ( c_prcntSpctrm2, #4200BC ), array.push ( c_prcntSpctrm2, #4400BA ), array.push ( c_prcntSpctrm2, #4700B7 ), array.push ( c_prcntSpctrm2, #4900B5 ), array.push ( c_prcntSpctrm2, #4C00B2 ), array.push ( c_prcntSpctrm2, #4F00AF ), array.push ( c_prcntSpctrm2, #5100AD ), array.push ( c_prcntSpctrm2, #5400AA ), array.push ( c_prcntSpctrm2, #5600A8 ), array.push ( c_prcntSpctrm2, #5900A5 ), array.push ( c_prcntSpctrm2, #5B00A3 ), array.push ( c_prcntSpctrm2, #5E00A0 ), array.push ( c_prcntSpctrm2, #60009E ), array.push ( c_prcntSpctrm2, #63009B ), array.push ( c_prcntSpctrm2, #660099 ), array.push ( c_prcntSpctrm2, #680096 ), array.push ( c_prcntSpctrm2, #6B0093 ), array.push ( c_prcntSpctrm2, #6D0091 ), array.push ( c_prcntSpctrm2, #70008E ), array.push ( c_prcntSpctrm2, #72008C ), array.push ( c_prcntSpctrm2, #750089 ), array.push ( c_prcntSpctrm2, #770087 ), array.push ( c_prcntSpctrm2, #7A0084 ), array.push ( c_prcntSpctrm2, #7C0082 ), array.push ( c_prcntSpctrm2, #7F007F ), array.push ( c_prcntSpctrm2, #82007C ), array.push ( c_prcntSpctrm2, #84007A ), array.push ( c_prcntSpctrm2, #870077 ), array.push ( c_prcntSpctrm2, #890075 ), array.push ( c_prcntSpctrm2, #8C0072 ), array.push ( c_prcntSpctrm2, #8E0070 ), array.push ( c_prcntSpctrm2, #91006D ), array.push ( c_prcntSpctrm2, #93006B ), array.push ( c_prcntSpctrm2, #960068 ), array.push ( c_prcntSpctrm2, #990066 ), array.push ( c_prcntSpctrm2, #9B0063 ), array.push ( c_prcntSpctrm2, #9E0060 ), array.push ( c_prcntSpctrm2, #A0005E ), array.push ( c_prcntSpctrm2, #A3005B ), array.push ( c_prcntSpctrm2, #A50059 ), array.push ( c_prcntSpctrm2, #A80056 ), array.push ( c_prcntSpctrm2, #AA0054 ), array.push ( c_prcntSpctrm2, #AD0051 ), array.push ( c_prcntSpctrm2, #AF004F ), array.push ( c_prcntSpctrm2, #B2004C ), array.push ( c_prcntSpctrm2, #B50049 ), array.push ( c_prcntSpctrm2, #B70047 ), array.push ( c_prcntSpctrm2, #BA0044 ), array.push ( c_prcntSpctrm2, #BC0042 ), array.push ( c_prcntSpctrm2, #BF003F ), array.push ( c_prcntSpctrm2, #C1003D ), array.push ( c_prcntSpctrm2, #C4003A ), array.push ( c_prcntSpctrm2, #C60038 ), array.push ( c_prcntSpctrm2, #C90035 ), array.push ( c_prcntSpctrm2, #CC0033 ), array.push ( c_prcntSpctrm2, #CE0030 ), array.push ( c_prcntSpctrm2, #D1002D ), array.push ( c_prcntSpctrm2, #D3002B ), array.push ( c_prcntSpctrm2, #D60028 ), array.push ( c_prcntSpctrm2, #D80026 ), array.push ( c_prcntSpctrm2, #DB0023 ), array.push ( c_prcntSpctrm2, #DD0021 ), array.push ( c_prcntSpctrm2, #E0001E ), array.push ( c_prcntSpctrm2, #E2001C ), array.push ( c_prcntSpctrm2, #E50019 ), array.push ( c_prcntSpctrm2, #E80016 ), array.push ( c_prcntSpctrm2, #EA0014 ), array.push ( c_prcntSpctrm2, #ED0011 ), array.push ( c_prcntSpctrm2, #EF000F ), array.push ( c_prcntSpctrm2, #F2000C ), array.push ( c_prcntSpctrm2, #F4000A ), array.push ( c_prcntSpctrm2, #F70007 ), array.push ( c_prcntSpctrm2, #F90005 ), array.push ( c_prcntSpctrm2, #FC0002 ), array.push ( c_prcntSpctrm2, #FF0000 ) f_clrSlct ( percent, select, type, solid, array1, array2 ) => select == "Solid" ? solid : array.get ( type == "Blue Green Red" ? array1 : array2, round ( percent ) ) // get the % distance between the max and min val, but ensure that a number is not being used beyond the min or max get_pct (val) => 100 * (min(max(val, min_val), max_val) - min_val) / (max_val - min_val) // actual code treasury_10y = security("US10Y", "M", close) sp500_earnings = security("QUANDL:MULTPL/SP500_EARNINGS_YIELD_MONTH", "M", close) spread = treasury_10y - sp500_earnings color_spec = f_clrSlct ( get_pct(spread), color_type, spec_type, is_solid, c_prcntSpctrm1, c_prcntSpctrm2 ) plot(spread, color=color_spec) hline(overbought, color=color.red, title="Overbought") hline(oversold, color=color.green, title="Oversold")
SuperTrendS
https://www.tradingview.com/script/tM7CSlio-SuperTrendS/
lucidreamer15
https://www.tradingview.com/u/lucidreamer15/
307
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/ // © lucidreamer15, Youtube -> lucidreamer Crypto //Special Thanks To; //@Kivanc Ozbilgic for Supertrend //@LonesomeTheBlue for Pivot Point Supertrend //@everget for Jurik RSX //@version=4 study("SuperTrendS", overlay = true, format=format.price, precision=2) //RSX length = input(title="RSX Length", type=input.integer, defval=14, group='RSX') src1 = input(title="RSX Source", type=input.source, defval=hlc3, group='RSX') obLevel = input(title="RSX OB Level", type=input.integer, defval=70, group='RSX') osLevel = input(title="RSX OS Level", type=input.integer, defval=30, group='RSX') f8 = 100 * src1 f10 = nz(f8[1]) v8 = f8 - f10 f18 = 3 / (length + 2) f20 = 1 - f18 f28 = 0.0 f28 := f20 * nz(f28[1]) + f18 * v8 f30 = 0.0 f30 := f18 * f28 + f20 * nz(f30[1]) vC = f28 * 1.5 - f30 * 0.5 f38 = 0.0 f38 := f20 * nz(f38[1]) + f18 * vC f40 = 0.0 f40 := f18 * f38 + f20 * nz(f40[1]) v10 = f38 * 1.5 - f40 * 0.5 f48 = 0.0 f48 := f20 * nz(f48[1]) + f18 * v10 f50 = 0.0 f50 := f18 * f48 + f20 * nz(f50[1]) v14 = f48 * 1.5 - f50 * 0.5 f58 = 0.0 f58 := f20 * nz(f58[1]) + f18 * abs(v8) f60 = 0.0 f60 := f18 * f58 + f20 * nz(f60[1]) v18 = f58 * 1.5 - f60 * 0.5 f68 = 0.0 f68 := f20 * nz(f68[1]) + f18 * v18 f70 = 0.0 f70 := f18 * f68 + f20 * nz(f70[1]) v1C = f68 * 1.5 - f70 * 0.5 f78 = 0.0 f78 := f20 * nz(f78[1]) + f18 * v1C f80 = 0.0 f80 := f18 * f78 + f20 * nz(f80[1]) v20 = f78 * 1.5 - f80 * 0.5 f88_ = 0.0 f90_ = 0.0 f88 = 0.0 f90_ := nz(f90_[1]) == 0 ? 1 : nz(f88[1]) <= nz(f90_[1]) ? nz(f88[1]) + 1 : nz(f90_[1]) + 1 f88 := nz(f90_[1]) == 0 and (length - 1 >= 5) ? length - 1 : 5 f0 = f88 >= f90_ and f8 != f10 ? 1 : 0 f90 = f88 == f90_ and f0 == 0 ? 0 : f90_ v4_ = f88 < f90 and v20 > 0 ? (v14 / v20 + 1) * 50 : 50 rsx = v4_ > 100 ? 100 : v4_ < 0 ? 0 : v4_ rsxob = rsx > obLevel rsxos = rsx < osLevel rsxobos = (rsx > obLevel or rsx < osLevel) regularst = input(title='Use Regular ST?', defval=true,group='ST Preference') ppst= input(title='Use Pivot Point ST?', defval=false,group='ST Preference') zigzagst = input(title='Use ZigZag ST?', defval=false,group='ST Preference') //Regular ST Periods = input(title="ATR Period", type=input.integer, defval=10,group='Regular SuperTrend') src = input(hl2, title="Source",group='Regular SuperTrend') Multiplier = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0 ,group='Regular SuperTrend') changeATR= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true,group='Regular SuperTrend') 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 upPlot = plot(trend == 1 ? up : na, title="ST Up Trend", style=plot.style_linebr, linewidth=2, color= rsx < osLevel ? color.orange : color.lime ,transp=regularst ? 0 : 100) buySignal = trend == 1 and trend[1] == -1 plotshape(buySignal ? up : na, title="ST UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=regularst ? 0 : 100) dnPlot = plot(trend == 1 ? na : dn, title="ST Down Trend", style=plot.style_linebr, linewidth=2, color= rsx> obLevel ? color.fuchsia : color.red, transp=regularst ? 0 : 100) sellSignal = trend == -1 and trend[1] == 1 plotshape(sellSignal ? dn : na, title="ST DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=regularst ? 0 : 100) mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) changeCond = trend != trend[1] alertcondition(changeCond, title="Regular SuperTrend Direction Change", message="Regular SuperTrend has changed direction!") //Pivot Point Supertrend prd = input(defval = 2, title="Pivot Point Period", minval = 1, maxval = 50,group='Pivot Point SuperTrend') Factor=input(defval = 3, title = "ATR Factor", minval = 1, step = 0.1,group='Pivot Point SuperTrend') Pd=input(defval = 10, title = "ATR Period", minval=1,group='Pivot Point SuperTrend') showpivot = input(defval = false, title="Show Pivot Points",group='Pivot Point SuperTrend') showlabel = input(defval = true, title="Show Buy/Sell Labels",group='Pivot Point SuperTrend') showcl = input(defval = false, title="Show PP Center Line",group='Pivot Point SuperTrend') showsr = input(defval = false, title="Show Support/Resistance",group='Pivot Point SuperTrend') // get Pivot High/Low float ph = pivothigh(prd, prd) float pl = pivotlow(prd, prd) // drawl Pivot Points if "showpivot" is enabled plotshape(ph and showpivot, text="H", style=shape.labeldown, color=na, textcolor=color.red, location=location.abovebar, transp=0, offset = -prd) plotshape(pl and showpivot, text="L", style=shape.labeldown, color=na, textcolor=color.lime, location=location.belowbar, transp=0, offset = -prd) // calculate the Center line using pivot points var float center = na float lastpp = ph ? ph : pl ? pl : na if lastpp if na(center) center := lastpp else //weighted calculation center := (center * 2 + lastpp) / 3 // upper/lower bands calculation Up = center - (Factor * atr(Pd)) Dn = center + (Factor * atr(Pd)) // get the trend float TUp = na float TDown = na Trend = 0 TUp := close[1] > TUp[1] ? max(Up, TUp[1]) : Up TDown := close[1] < TDown[1] ? min(Dn, TDown[1]) : Dn Trend := close > TDown[1] ? 1: close < TUp[1]? -1: nz(Trend[1], 1) Trailingsl = Trend == 1 ? TUp : TDown // plot the trend linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.lime : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na plot(Trend == 1 ? TUp :na, color= rsx < osLevel ? color.orange : color.lime , style=plot.style_linebr, linewidth = 2, title = "PPST UpTrend",transp=ppst ? 0 : 100) plot(Trend == -1 ? TDown :na, color= rsx> obLevel ? color.fuchsia : color.red , style=plot.style_linebr, linewidth = 2, title = "PPST DownTrend",transp=ppst ? 0 : 100) plot(showcl ? center : na, color = showcl ? center < hl2 ? color.blue : color.red : na, transp=regularst ? 100 : 0) // check and plot the signals bsignal = Trend == 1 and Trend[1] == -1 ssignal = Trend == -1 and Trend[1] == 1 plotshape(bsignal and showlabel ? Trailingsl : na, title="Buy", text="Buy", location = location.absolute, style = shape.labelup, size = size.tiny, color = color.lime, textcolor = color.black, transp=ppst ? 0 : 100) plotshape(ssignal and showlabel ? Trailingsl : na, title="Sell", text="Sell", location = location.absolute, style = shape.labeldown, size = size.tiny, color = color.red, textcolor = color.white, transp=ppst ? 0 : 100) //get S/R levels using Pivot Points float resistance = na float support = na support := pl ? pl : support[1] resistance := ph ? ph : resistance[1] // if enabled then show S/R levels plot(showsr and support ? support : na, color = showsr and support ? color.lime : na, style = plot.style_circles, offset = -prd,transp=ppst ? 0 : 100) plot(showsr and resistance ? resistance : na, color = showsr and resistance ? color.red : na, style = plot.style_circles, offset = -prd,transp=ppst ? 0 : 100) // alerts alertcondition(Trend == 1 and Trend[1] == -1, title='PPST Buy Signal', message='PPST Buy Signal') alertcondition(Trend == -1 and Trend[1] == 1, title='PPST Sell Signal', message='PPST Sell Signal') alertcondition(change(Trend), title='PPST Trend Changed', message='PPST Trend Changed') //ZIGZAG source=input(close,group='ZigZag SuperTrend') Length = input(5, minval=0, step=5,group='ZigZag SuperTrend') DeviationThreshold = 0 history = input(2, step=1, minval=2,group='ZigZag SuperTrend') waitForConfirmation = input(true,group='ZigZag SuperTrend') waitForClose = input(true,group='ZigZag SuperTrend') atrPeriods = input(22, step=5,group='ZigZag SuperTrend') atrMult = input(1, step=0.5,group='ZigZag SuperTrend') var zigzaglines = array.new_line(0) var zigzagpivots = array.new_float(0) int max_array_size = history pivots(length, highSource, lowSource)=> float ph = highestbars(highSource, length) == 0 ? highSource : na float pl = lowestbars(lowSource, length) == 0 ? lowSource : na dir = 0 dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir[1])) [dir, ph, pl] get_edir(dir, y2)=> eDir = dir if(array.size(zigzaglines) > 0) lastLine = array.get(zigzaglines, 0) lastPivot = line.get_y1(lastLine) eDir := (dir*y2 > dir*lastPivot? 2 : 1) * dir eDir add_to_zigzaglines(x1, y1 , x2, y2, dir)=> eDir = get_edir(dir, y2) zgColor = color.new(#FFFFFF, 100) zline = line.new(x1=x1, y1=y1, x2 = x2, y2=y2, color=zgColor, width=2, style=line.style_solid) array.unshift(zigzaglines, zline) add_to_zigzag(dir, dirchanged, ph, pl, index, highSource, lowSource)=> value = (dir == 1? ph : pl) lowestVal = lowest(lowSource, Length) highestVal = highest(highSource, Length) lowestBar = lowestbars(lowSource, Length) highestBar = highestbars(highSource,Length) y1= dir == 1? lowestVal : highestVal x1 = bar_index + (dir == 1? lowestBar : highestBar) x2 = index y2 = value skip = false if(array.size(zigzaglines) > 0) lastLine = array.get(zigzaglines, 0) lastValue = line.get_y2(lastLine) lastIndex = line.get_x2(lastLine) if(not dirchanged) if(dir == 1 and value < lastValue) or (dir == -1 and value > lastValue) skip := true else line.delete(array.shift(zigzaglines)) skip := false if(array.size(zigzaglines) > 0) lastLine := array.get(zigzaglines, 0) lastValue := line.get_y2(lastLine) lastIndex := line.get_x2(lastLine) x1 := lastIndex y1 := lastValue outsideDeviationThreshold = ((abs(y1-y2)*100/y1) > DeviationThreshold) if(outsideDeviationThreshold and not skip) add_to_zigzaglines(x1, y1 , x2, y2, dir) if array.size(zigzaglines) > max_array_size line.delete(array.pop(zigzaglines)) zigzag(length, DeviationThreshold, highSource, lowSource)=> [dir, ph, pl] = pivots(length, highSource, lowSource) dirchanged = change(dir) if(ph or pl) add_to_zigzag(dir, dirchanged, ph, pl, bar_index, highSource, lowSource) get_high_low()=> array.clear(zigzagpivots) startIndex = waitForConfirmation? 1 : 0 if(array.size(zigzaglines) > startIndex) for i=startIndex to array.size(zigzaglines)-1 zgLine = array.get(zigzaglines, i) y1 = line.get_y1(zgLine) y2 = line.get_y2(zgLine) array.unshift(zigzagpivots,y1) array.unshift(zigzagpivots,y2) top = array.max(zigzagpivots) bottom = array.min(zigzagpivots) [top, bottom] supertrend_zg(top, bottom)=> dir = 1 prevDir = nz(dir[1], dir) atrDiff = atr(atrPeriods) * atrMult buyStop = bottom - atrDiff buyStopPrev = nz(buyStop[1], buyStop) sellStop = top + atrDiff sellStopPrev = nz(sellStop[1], sellStop) buyStop := prevDir == 1? max(buyStop, buyStopPrev) : buyStop sellStop := prevDir == -1? min(sellStop, sellStopPrev) : sellStop bullishCrossover = crossover(waitForClose? close : high, sellStopPrev) bearishCrossunder = crossunder(waitForClose? close : low, buyStopPrev) dir := (prevDir == 1 and bearishCrossunder)? -1 : (prevDir == -1 and bullishCrossover)? 1: prevDir [dir, buyStop, sellStop] highSource = source == close? high : source lowSource = source == close? low : source zigzag(Length, DeviationThreshold, highSource, lowSource) [top, bottom] = get_high_low() [dir, buyStop, sellStop] = supertrend_zg(top, bottom) plot(dir == 1? buyStop : na, color= rsx < osLevel ? color.orange : color.lime , title="BuyStop",linewidth=2, style=plot.style_linebr,transp=zigzagst ? 0 : 100) plot(dir == -1? sellStop : na, color= rsx> obLevel ? color.fuchsia : color.red , title="SellStop",linewidth=2, style=plot.style_linebr,transp=zigzagst ? 0 : 100) alertcondition(dir != dir[1], "ZigZag Supertrend direction update", "ZigZag Supertrend direction reversal observed")
15 percent movers
https://www.tradingview.com/script/cG8htfjl-15-percent-movers/
jamiesonpa
https://www.tradingview.com/u/jamiesonpa/
4
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © jamiesonpa //@version=5 indicator('15 percent movers', overlay=true) data = (close[1]-close[0])/close[0] condition1 = data > .14 condition2 = -data > .14 condition3 = condition1 or condition2 plotshape(condition3, style=shape.xcross, color= color.lime, size = size.small)
[_ParkF]RSI+
https://www.tradingview.com/script/0rmHC2M1/
ParkF
https://www.tradingview.com/u/ParkF/
541
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/ // © ParkF //@version=5 indicator('[_ParkF]RSI+', overlay=false, max_bars_back=1500) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // RSI // rsi configuration group1 = 'RSI' rsrc = input.source(close, 'RSI Source', group=group1) len = input.int(14, ' RSI Length', minval=1, group=group1) ad = true // rsi function pine_rsi(rsrc, len) => u = math.max(rsrc - rsrc[1], 0) d = math.max(rsrc[1] - rsrc, 0) rs = ta.rma(u, len) / ta.rma(d, len) res = 100 - 100 / (1 + rs) res pine_rma(rsrc, length) => b = 1 / length sum = 0.0 sum := na(sum[1]) ? ta.sma(rsrc, length) : b * rsrc + (1 - b) * nz(sum[1]) u = math.max(rsrc - rsrc[1], 0) d = math.max(rsrc[1] - rsrc, 0) b = 1 / len ruh = b * math.max(high - close[1], 0) + (1 - b) * ta.rma(u, len)[1] rdh = (1 - b) * ta.rma(d, len)[1] rul = (1 - b) * ta.rma(u, len)[1] rdl = b * math.max(close[1] - low, 0) + (1 - b) * ta.rma(d, len)[1] function(rsi, len) => f = -math.pow(math.abs(math.abs(rsi - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50 rsiadvanced = if rsi > 50 f + 50 else -f + 50 rsiadvanced rsiha = 100 - 100 / (1 + ruh / rdh) rsila = 100 - 100 / (1 + rul / rdl) rsia = ta.rsi(rsrc, len) rsih = if ad function(rsiha, len) else rsiha rsil = if ad function(rsila, len) else rsila // rsi bought & sold zone plot_bands = true sreb = hline(plot_bands ? 90 : na, 'Super Extreme Bought', color.new(#787b86, 0), linewidth=1, linestyle=hline.style_dashed) reb = hline(plot_bands ? 70 : na, 'Extreme Bought', color.new(#787b86, 0), linewidth=1, linestyle=hline.style_dashed) rmb = hline(plot_bands ? 50 : na, 'Middle Line', color.new(#c19f4c, 30), linewidth=3, linestyle=hline.style_solid) res = hline(plot_bands ? 30 : na, 'Extreme Sold', color.new(#787b86, 0), linewidth=1, linestyle=hline.style_dashed) sres = hline(plot_bands ? 10 : na, 'Super Extreme Sold', color.new(#787b86, 0), linewidth=1, linestyle=hline.style_dashed) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // RSI DIVERGENCE // input group2 = 'RSI DIV SETTING' divsw = input(true, 'Divergence On / Off Switch', group=group2) lb = input(15, 'Pivot Leftbars', group=group2) rb = input(2, 'Pivot Rightbars', group=group2) bear_src = input(close, 'Bearish Divs_Pivot Source', group=group2) bull_src = input(close, 'Bullish Divs_Pivot Source', group=group2) lvl = input.int(5, 'Lookback Level_Divs', options=[1, 2, 3, 4, 5], group=group2) // pivot bar = bar_index[rb] ph = ta.pivothigh(bear_src, lb, rb) pl = ta.pivotlow(bull_src, lb, rb) // div function hi0 = ta.valuewhen(ph, bear_src[rb], 0), hi1 = ta.valuewhen(ph, bear_src[rb], 1) hi2 = ta.valuewhen(ph, bear_src[rb], 2), hi3 = ta.valuewhen(ph, bear_src[rb], 3) hi4 = ta.valuewhen(ph, bear_src[rb], 4), hi5 = ta.valuewhen(ph, bear_src[rb], 5) lo0 = ta.valuewhen(pl, bull_src[rb], 0), lo1 = ta.valuewhen(pl, bull_src[rb], 1) lo2 = ta.valuewhen(pl, bull_src[rb], 2), lo3 = ta.valuewhen(pl, bull_src[rb], 3) lo4 = ta.valuewhen(pl, bull_src[rb], 4), lo5 = ta.valuewhen(pl, bull_src[rb], 5) dh0 = ta.valuewhen(ph, rsia[rb], 0), dh1 = ta.valuewhen(ph, rsia[rb], 1) dh2 = ta.valuewhen(ph, rsia[rb], 2), dh3 = ta.valuewhen(ph, rsia[rb], 3) dh4 = ta.valuewhen(ph, rsia[rb], 4), dh5 = ta.valuewhen(ph, rsia[rb], 5) dl0 = ta.valuewhen(pl, rsia[rb], 0), dl1 = ta.valuewhen(pl, rsia[rb], 1) dl2 = ta.valuewhen(pl, rsia[rb], 2), dl3 = ta.valuewhen(pl, rsia[rb], 3) dl4 = ta.valuewhen(pl, rsia[rb], 4), dl5 = ta.valuewhen(pl, rsia[rb], 5) bear_div1 = hi0 > hi1 and dh1 > dh0 bear_div2 = hi0 > hi1 and hi0 > hi2 and dh2 > dh0 and dh2 > dh1 and lvl >= 2 bear_div3 = hi0 > hi1 and hi0 > hi2 and hi0 > hi3 and dh3>dh0 and dh3>dh1 and dh3>dh2 and lvl >= 3 bear_div4 = hi0 > hi1 and hi0 > hi2 and hi0 > hi3 and hi0 > hi4 and dh4 > dh0 and dh4 > dh1 and dh4 > dh2 and dh4 > dh3 and lvl >= 4 bear_div5 = hi0>hi1 and hi0>hi2 and hi0>hi3 and hi0 > hi4 and hi0 > hi5 and dh5 > dh0 and dh5 > dh1 and dh5 > dh2 and dh5 > dh3 and dh5 > dh4 and lvl >= 5 bull_div1 = lo0 < lo1 and dl1 < dl0 bull_div2 = lo0<lo1 and lo0<lo2 and dl2 < dl0 and dl2 < dl1 and lvl >= 2 bull_div3 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and dl3 < dl0 and dl3 < dl1 and dl3 < dl2 and lvl >= 3 bull_div4 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and lo0 < lo4 and dl4 < dl0 and dl4 < dl1 and dl4 < dl2 and dl4 < dl3 and lvl >= 4 bull_div5 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and lo0 < lo4 and lo0 < lo5 and dl5 < dl0 and dl5 < dl1 and dl5 < dl2 and dl5 < dl3 and dl5 < dl4 and lvl >= 5 _bear1 = bear_div1 and not bear_div1[1], _bear2 = bear_div2 and not bear_div2[1] _bear3 = bear_div3 and not bear_div3[1], _bear4 = bear_div4 and not bear_div4[1] _bear5 = bear_div5 and not bear_div5[1] _bull1 = bull_div1 and not bull_div1[1], _bull2 = bull_div2 and not bull_div2[1] _bull3 = bull_div3 and not bull_div3[1], _bull4 = bull_div4 and not bull_div4[1] _bull5 = bull_div5 and not bull_div5[1] // plotshape plotshape(title='bear_div1', series=_bear1 and divsw ? 90 : na, style=shape.triangledown, color=#b22833, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div2', series=_bear2 and divsw ? 90 : na, style=shape.triangledown, color=#b22833, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div3', series=_bear3 and divsw ? 90 : na, style=shape.triangledown, color=#b22833, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div4', series=_bear4 and divsw ? 90 : na, style=shape.triangledown, color=#b22833, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div5', series=_bear5 and divsw ? 90 : na, style=shape.triangledown, color=#b22833, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div1', series=_bull1 and divsw ? 10 : na, style=shape.triangleup, color=#388e3c, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div2', series=_bull2 and divsw ? 10 : na, style=shape.triangleup, color=#388e3c, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div3', series=_bull3 and divsw ? 10 : na, style=shape.triangleup, color=#388e3c, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div4', series=_bull4 and divsw ? 10 : na, style=shape.triangleup, color=#388e3c, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div5', series=_bull5 and divsw ? 10 : na, style=shape.triangleup, color=#388e3c, location=location.absolute, size=size.tiny, offset=-2) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // linear regression // input lrg = 'Linear Regression' linreg1 = input(true, 'Longterm Linear Regression On / Off', group=lrg) linreg2 = input(true, 'Shorterm Linear Regression On / Off', group=lrg) periodTrend = input.int(100, 'Longterm Linear Regression Period', minval=4, group=lrg) periodTrend2 = input.int(25, 'Shorterm Linear Regression Period', minval=4, group=lrg) deviationsAmnt = input.float(2, 'Deviation', minval=0.1, step=0.1, group=lrg) estimatorType = input.string('Unbiased', 'Estimator', options=['Biased', 'Unbiased'], group=lrg) var extendType = input.string('Right', 'Extend', options=['Right', 'Segment'], group=lrg) == 'Right' ? extend.right : extend.none // drawline configuration drawLine(X1, Y1, X2, Y2, ExtendType, Color, LineStyle) => var line Line = na Line := linreg1 ? line.new(X1, Y1, X2, Y2, xloc.bar_index, ExtendType, Color, LineStyle, width=2) : na line.delete(Line[1]) drawLine2(X1, Y1, X2, Y2, ExtendType, Color, LineStyle) => var line Line = na Line := linreg2 ? line.new(X1, Y1, X2, Y2, xloc.bar_index, ExtendType, Color, LineStyle, width=2) : na line.delete(Line[1]) rsdcr2(PeriodMinusOne, Deviations, Estimate) => var period = PeriodMinusOne + 1 var devDenominator = Estimate == 'Unbiased' ? PeriodMinusOne : period Ex = 0.0 Ex2 = 0.0 Exy = 0.0 Ey = 0.0 for i = 0 to PeriodMinusOne by 1 closeI = nz(rsia[i]) Ex := Ex + i Ex2 := Ex2 + i * i Exy := Exy + closeI * i Ey := Ey + closeI Ey ExEx = Ex * Ex slope = Ex2 == ExEx ? 0.0 : (period * Exy - Ex * Ey) / (period * Ex2 - ExEx) linearRegression = (Ey - slope * Ex) / period intercept = linearRegression + bar_index * slope deviation = 0.0 for i = 0 to PeriodMinusOne by 1 deviation := deviation + math.pow(nz(rsia[i]) - (intercept - bar_index[i] * slope), 2.0) deviation deviation := Deviations * math.sqrt(deviation / devDenominator) correlate = ta.correlation(rsia, bar_index, period) r2 = math.pow(correlate, 2.0) [linearRegression, slope, deviation, correlate, r2] periodMinusOne = periodTrend - 1 [linReg, slope, deviation, correlate, r2] = rsdcr2(periodMinusOne, deviationsAmnt, estimatorType) endPointBar = bar_index - periodTrend + 1 endPointY = linReg + slope * periodMinusOne endPointBar2 = bar_index - periodTrend2 + 1 // drawline plot drawLine(endPointBar, endPointY + deviation, bar_index, linReg + deviation, extendType, #e91e63, line.style_solid) drawLine(endPointBar, endPointY, bar_index, linReg, extendType, #e91e63, line.style_dotted) drawLine(endPointBar, endPointY - deviation, bar_index, linReg - deviation, extendType, #e91e63, line.style_solid) drawLine2(endPointBar2, endPointY + deviation, bar_index, linReg + deviation, extendType, color.blue, line.style_solid) drawLine2(endPointBar2, endPointY, bar_index, linReg, extendType, color.blue, line.style_dotted) drawLine2(endPointBar2, endPointY - deviation, bar_index, linReg - deviation, extendType, color.blue, line.style_solid) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // TRENDLINES // input group3 = 'TREND LINES' o = rsia[1] h = rsih l = rsil c = rsia log_chart = input(true, title='Use Log Chart', group=group3) a_Color_Type = input.string(defval='Monochrome', title='Use Trendlines Color Scheme', options=['Colored', 'Monochrome'], group=group3) group4 = 'PRIMARY TRENDLINES' a_Show_Primary = input(false, title='Primary Trendlines On / Off', group=group4) a_len = input(20, title='Primary Lookback Length', group=group4) a_Extensions = input.string(title='Primary Trendlines Extensions', defval='25', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group4) a_width = input.int(2, title='Primary Line Width', minval=0, maxval=10, group=group4) a_LineStyle_Type = input.string(title='Primary Line Type', defval='Solid', options=['Dashed', 'Dotted', 'Solid'], group=group4) a_Line_Type = a_LineStyle_Type == 'Dashed' ? line.style_dashed : a_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid a_Rising_Upper_Falling_Lower = false group5 = 'SECONDARY TRENDLINES' b_Show_Secondary = input(false, title='Secondary Trendlines On / Off', group=group5) b_len = input(10, title='Secondary Lookback Length', group=group5) b_Extensions = input.string(title='Secondary Trendlines Extensions', defval='25', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group5) b_LineStyle_Type = input.string(title='Secondary Line Type', defval='Dashed', options=['Dashed', 'Dotted', 'Solid'], group=group5) b_Line_Type = b_LineStyle_Type == 'Dashed' ? line.style_dashed : b_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid b_width = input.int(1, title='Secondary Line Width', minval=0, maxval=10, group=group5) b_Rising_Upper_Falling_Lower = false group6 = 'TRENDLINES COLOR' a_Line_Color = input.color(#ffffff, title="Primary Trendline Color", group=group6) b_Line_Color = input.color(#ffffff, title="Secondary Trendline Color", group=group6) a_bar_time = time - time[1] b_bar_time = time - time[1] //primary trendline // trendline extension a_Extension_Multiplier= a_Extensions=="25"? 1 : a_Extensions=="50"? 2 : a_Extensions=="75"? 3 : a_Extensions=="100"? 4 : a_Extensions=="150"? 6 : a_Extensions=="200"? 8 : a_Extensions=="300"? 12 : a_Extensions=="400"? 16 : a_Extensions=="500"? 20 : a_Extensions=="750"? 30 : a_Extensions=="1000"? 40 : a_Extensions=="Infinate"? 0 : na // trendline function a_f_trendline(a__input_function, a__delay, a__only_up, a__extend) => var int a_Ax = 1 var int a_Bx = 1 var float a_By = 0 var float a_slope = 0 a_Ay = fixnan(a__input_function) if ta.change(a_Ay) != 0 a_Ax := time[a__delay] a_By := a_Ay[1] a_Bx := a_Ax[1] a_slope := log_chart ? (math.log(a_Ay) - math.log(a_By)) / (a_Ax - a_Bx) : (a_Ay - a_By) / (a_Ax - a_Bx) a_slope else a_Ax := a_Ax[1] a_Bx := a_Bx[1] a_By := a_By[1] a_By // draw trendline var line a_trendline = na var int a_Axbis = 0 var float a_Aybis = 0 var bool a__xtend = true a_extension_time = a_Extension_Multiplier * a_bar_time * 25 a_Axbis := a_Ax + a_extension_time a_Aybis := log_chart ? a_Ay * math.exp(a_extension_time * a_slope) : a_Ay + a_extension_time * a_slope if a_Extension_Multiplier != 0 a__xtend := false a__xtend if ta.change(a_Ay) != 0 a_line_color_Rising_Falling = a_slope * time < 0 ? a__only_up ? a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na a_line_color_Not_Rising_Falling = a_slope * time < 0 ? a__only_up ? na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : na a_line_color = a_Show_Primary and not a_Rising_Upper_Falling_Lower ? a_line_color_Not_Rising_Falling : a_Show_Primary and a_Rising_Upper_Falling_Lower ? a_line_color_Rising_Falling : na if not na(a_line_color) a_trendline := line.new(a_Bx, a_By, a_Axbis, a_Aybis, xloc.bar_time, extend=a__xtend ? extend.right : extend.none, color=a_Line_Color, style=a_Line_Type, width=a_width) a_trendline [a_Bx, a_By, a_Axbis, a_Aybis, a_slope] // calc pivot points a_high_point = ta.pivothigh(c > o ? h : l, a_len, a_len / 2) a_low_point = ta.pivotlow(c > o ? l : h, a_len, a_len / 2) // call trendline function [a_phx1, a_phy1, a_phx2, a_phy2, a_slope_high] = a_f_trendline(a_high_point, a_len / 2, false, true) [a_plx1, a_ply1, a_plx2, a_ply2, a_slope_low] = a_f_trendline(a_low_point, a_len / 2, true, true) // secondary trendline // trendline extension b_Extension_Multiplier= b_Extensions=="25"? 1 : b_Extensions=="50"? 2 : b_Extensions=="75"? 3 : b_Extensions=="100"? 4 : b_Extensions=="150"? 6 : b_Extensions=="200"? 8 : b_Extensions=="300"? 12 : b_Extensions=="400"? 16 : b_Extensions=="500"? 20 : b_Extensions=="750"? 30 : b_Extensions=="1000"? 40 : b_Extensions=="Infinate"? 0 : na // trendline function b_f_trendline(b__input_function, b__delay, b__only_up, b__extend) => var int b_Ax = 1 var int b_Bx = 1 var float b_By = 0 var float b_slope = 0 b_Ay = fixnan(b__input_function) if ta.change(b_Ay) != 0 b_Ax := time[b__delay] b_By := b_Ay[1] b_Bx := b_Ax[1] b_slope := log_chart ? (math.log(b_Ay) - math.log(b_By)) / (b_Ax - b_Bx) : (b_Ay - b_By) / (b_Ax - b_Bx) b_slope else b_Ax := b_Ax[1] b_Bx := b_Bx[1] b_By := b_By[1] b_By // draw trendlines var line b_trendline = na var int b_Axbis = 0 var float b_Aybis = 0 var bool b__xtend = true b_extension_time = b_Extension_Multiplier * b_bar_time * 25 b_Axbis := b_Ax + b_extension_time b_Aybis := log_chart ? b_Ay * math.exp(b_extension_time * b_slope) : b_Ay + b_extension_time * b_slope if b_Extension_Multiplier != 0 b__xtend := false b__xtend if ta.change(b_Ay) != 0 b_line_color_Rising_Falling = b_slope * time < 0 ? b__only_up ? b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na b_line_color_Not_Rising_Falling = b_slope * time < 0 ? b__only_up ? na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : na b_line_color = b_Show_Secondary and not b_Rising_Upper_Falling_Lower ? b_line_color_Not_Rising_Falling : b_Show_Secondary and b_Rising_Upper_Falling_Lower ? b_line_color_Rising_Falling : na if not na(b_line_color) b_trendline := line.new(b_Bx, b_By, b_Axbis, b_Aybis, xloc.bar_time, extend=b__xtend ? extend.right : extend.none, color=b_Line_Color, style=b_Line_Type, width=b_width) b_trendline [b_Bx, b_By, b_Axbis, b_Aybis, b_slope] // calc pivot points b_high_point = ta.pivothigh(c > o ? h : l, b_len, b_len / 2) b_low_point = ta.pivotlow(c > o ? l : h, b_len, b_len / 2) // call trendline function [b_phx1, b_phy1, b_phx2, b_phy2, b_slope_high] = b_f_trendline(b_high_point, b_len / 2, false, true) [b_plx1, b_ply1, b_plx2, b_ply2, b_slope_low] = b_f_trendline(b_low_point, b_len / 2, true, true) // plot b_color_high = b_slope_high * time < 0 ? color.green : na b_color_low = b_slope_low * time > 0 ? color.red : na // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // ICHIMOKU // input group7 = 'Ichimoku' ichi_sw = input(true, 'Ichimoku On / Off Switch', group=group7) conversionPeriods = input.int(13, minval=1, title='Conversion Line Periods', group=group7) basePeriods = input.int(33, minval=1, title='Base Line Periods', group=group7) laggingSpan2Periods = input.int(84, minval=1, title='Lagging Span 2 Periods', group=group7) displacement = input.int(33, minval=1, title='Displacement', group=group7) // calc donchian(len) => math.avg(ta.lowest(rsil, len), ta.highest(rsih, len)) conversionLine = donchian(conversionPeriods) baseLine = donchian(basePeriods) leadLine1 = math.avg(conversionLine, baseLine) leadLine2 = donchian(laggingSpan2Periods) // plot p1 = plot(ichi_sw ? leadLine1 : na, offset = displacement- 1, color=color.new(#1b5e20, 50), title="LeadLine A", linewidth=2) p2 = plot(ichi_sw ? leadLine2 : na, offset = displacement - 1, color=color.new(#801922, 50), title="LeadLine B", linewidth=2) fill(p1, p2, color = leadLine1 > leadLine2 ? color.new(#1b5e20, 80) : color.new(#801922, 80), title='Ichimoku Cloud') // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // MACD // input group8 = 'MACD' Histo_Switch_MACD = input(false, 'MACD Histogram On / Off Switch', group=group8) Fast_Len = input(title="Fast Length", defval=12, group=group8) Slow_Len = input(title="Slow Length", defval=26, group=group8) MACD_Source = input.source(close, 'MACD Source', group=group8) MACD_Signal_Len = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9, group=group8) SMA_Source = input.string(title="Oscillator MA Type", defval="EMA", options=["SMA", "EMA"], group=group8) SMA_Signal = input.string(title="Signal Line MA Type", defval="EMA", options=["SMA", "EMA"], group=group8) // calc Fast_MA = SMA_Source == "SMA" ? ta.sma(MACD_Source, Fast_Len) : ta.ema(MACD_Source, Fast_Len) Slow_MA = SMA_Source == "SMA" ? ta.sma(MACD_Source, Slow_Len) : ta.ema(MACD_Source, Slow_Len) MACD = Fast_MA - Slow_MA MACD_Signal = SMA_Signal == "SMA" ? ta.sma(MACD, MACD_Signal_Len) : ta.ema(MACD, MACD_Signal_Len) Histogram_MACD = MACD - MACD_Signal // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // TSI // input group9 = 'TSI' Histo_Switch_TSI = input(true, 'TSI Histogram On / Off Switch', group=group9) Short_Len = input(title="Short Period", defval=5, group=group9) Long_Len = input(title="Long Period", defval=20, group=group9) TSI_Signal_Len = input(title="Signal Line Period)", defval=5, group=group9) // calc TSI = ta.tsi(close, Short_Len, Long_Len) TSI_Signal = ta.ema(TSI, TSI_Signal_Len) Histogram_TSI = TSI - TSI_Signal // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // HISTOGRAM group10= 'HISTOGRAM COLOR' Color_Grow_Above = input(#2b4b46, "Above   Grow", inline="Above", group=group10) Color_Fall_Above = input(#8ca18d, "Fall", inline="Above", group=group10) Color_Grow_Below = input(#b49c79, "Below Grow", inline="Below", group=group10) Color_Fall_Below = input(#8b3d44, "Fall", inline="Below", group=group10) // plotshape histogram plotshape(Histogram_MACD and Histo_Switch_MACD ? 5 : na, title="MACD Histogram", style=shape.square, color=(Histogram_MACD>=0 ? (Histogram_MACD[1] < Histogram_MACD ? Color_Grow_Above : Color_Fall_Above) : (Histogram_MACD[1] < Histogram_MACD ? Color_Grow_Below : Color_Fall_Below)), location=location.absolute, size=size.tiny) plotshape(Histogram_TSI and Histo_Switch_TSI ? 5 : na, title="TSI Histogram", style=shape.square, color=(Histogram_TSI>=0 ? (Histogram_TSI[1] < Histogram_TSI ? Color_Grow_Above : Color_Fall_Above) : (Histogram_TSI[1] < Histogram_TSI ? Color_Grow_Below : Color_Fall_Below)), location=location.absolute, size=size.tiny) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // MULTI TIME FRAME RSI // input group11 = 'MTF_RSI' MTF_RSI = input(true, 'MTF_RSI On / Off Switch', group=group11) TF_Len_1 = input.int(14, 'Lookback 1H ', group=group11) TF_Len_2 = input.int(14, 'Lookback 4H', group=group11) TF_Len_3 = input.int(14, 'Lookback 1D', group=group11) // tf function TF_1 = input.timeframe(defval='60', title='1H', inline=group11, group=group11) TF_2 = input.timeframe(defval='240', title='4H', inline=group11, group=group11) TF_3 = input.timeframe(defval='D', title='1D', inline=group11, group=group11) S_1 = MTF_RSI ? request.security(syminfo.tickerid, TF_1, ta.rsi(rsrc, TF_Len_1)) : na S_2 = MTF_RSI ? request.security(syminfo.tickerid, TF_2, ta.rsi(rsrc, TF_Len_2)) : na S_3 = MTF_RSI ? request.security(syminfo.tickerid, TF_3, ta.rsi(rsrc, TF_Len_3)) : na // plot plot(series=S_1, title='TF_1H', color=color.new(#ffeb3b, 30), linewidth=4) plot(series=S_2, title='TF_4H', color=color.new(#ff9800, 40), linewidth=4) plot(series=S_3, title='TF_1D', color=color.new(#b22833, 50), linewidth=4) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // PLOT CANDLE(with wick), PLOT LINE color1 = color.new(color.white, 0) color2 = color.new(color.black, 0) wickcolor = color.new(color.black, 0) bordercolor = color.new(color.black, 0) plotcandle(rsia[1], rsih, rsil, rsia, 'RSI_Candle', color=ta.change(rsia) > 0 ? color1 : color2, wickcolor=wickcolor, bordercolor=bordercolor) plot(rsia, 'RSI_Line', color= ta.change(rsia) > 0 ? color.black : color.black, display=display.none, linewidth=2) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // alert and label alertcondition(_bear1 or _bear2 or _bear3 or _bear4 or _bear5, title='Bear', message='Bear') alertcondition(_bull1 or _bull2 or _bull3 or _bull4 or _bull5, title='Bull', message='Bull')
[_ParkF]MFI+
https://www.tradingview.com/script/CRidT2oU/
ParkF
https://www.tradingview.com/u/ParkF/
380
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/ // © ParkF //@version=5 indicator("[_ParkF]MFI+", max_bars_back=1500, overlay=false) // MFI // inpu mfig = 'MFI' len = input.int(title="Length", defval=14, minval=1, maxval=2000, group=mfig) msrc = hlc3 ad = true mf = ta.mfi(msrc, len) overbought=hline(80, title="Overbought", color=color.new(#b2b5be, 50), linestyle=hline.style_solid, linewidth=4) oversold=hline(20, title="Oversold", color=color.new(#b2b5be, 50), linestyle=hline.style_solid, linewidth=4) fill(overbought, oversold, color=color.rgb(126, 87, 194, 90), title="Background") // mfi function pine_mf(msrc, len) => u = math.max(msrc - msrc[1], 0) d = math.max(msrc[1] - msrc, 0) rs = ta.mfi(u, len) / ta.mfi(d, len) res = 100.0 - 100.0 / (1 + rs) res pine_mfi(msrc, len) => b = 1 / len sum = 0.0 sum := na(sum[1]) ? ta.sma(msrc, len) : b * msrc + (1 - b) * nz(sum[1]) u = math.max(msrc - msrc[1], 0) d = math.max(msrc[1] - msrc, 0) b = 1 / len muh = b * math.max(high - close[1], 0) + (1 - b) * ta.mfi(u, len)[1] mdh = (1 - b) * ta.mfi(d, len)[1] mul = (1 - b) * ta.mfi(u, len)[1] mdl = b * math.max(close[1] - low, 0) + (1 - b) * ta.mfi(d, len)[1] function(mf, len) => f = -math.pow(math.abs(math.abs(mf - 50) - 50), 1 + math.pow(len / 14, 0.618) - 1) / math.pow(50, math.pow(len / 14, 0.618) - 1) + 50 mfiadvanced = if mf > 50 f + 50 else -f + 50 mfiadvanced mfiha = 100.0 - 100.0 / (1 + muh / mdh) mfila = 100.0 - 100.0 / (1 + mul / mdl) mfia = ta.mfi(msrc, len) mfih = if ad function(mfiha, len) else mfiha mfil = if ad function(mfila, len) else mfila // candle plotcandle(mf[1], mfih, mfil, mf, 'MFI_Candle', color=ta.change(mf) > 0 ? #ffffff : #000000, wickcolor=#000000, bordercolor=#2a2e39, display=display.none) plot(mf, 'MFI_Line', color=ta.change(mf) > 0 ? color.black : color.black, linewidth=2) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // mfi divergence // input rb = input(2, 'Pivots Rightbars', group=mfig) lb = input(15, 'Pivots Leftbars for Pivots', group=mfig) sph = input(close, 'Bearish Divs_Pivot Source', group=mfig) spl = input(close, 'Bullish Divs_Pivot Source', group=mfig) lvl = input.int(5, 'Lookback Level_Divs', options=[1, 2, 3, 4, 5], group=mfig) div_col = input.color(color.orange, 'Divergence Line Color', group=mfig) // pivot ph = ta.pivothigh(sph, lb, rb) pl = ta.pivotlow(spl, lb, rb) hi0 = ta.valuewhen(ph, sph[rb], 0) hi1 = ta.valuewhen(ph, sph[rb], 1) hi2 = ta.valuewhen(ph, sph[rb], 2) hi3 = ta.valuewhen(ph, sph[rb], 3) hi4 = ta.valuewhen(ph, sph[rb], 4) hi5 = ta.valuewhen(ph, sph[rb], 5) lo0 = ta.valuewhen(pl, spl[rb], 0) lo1 = ta.valuewhen(pl, spl[rb], 1) lo2 = ta.valuewhen(pl, spl[rb], 2) lo3 = ta.valuewhen(pl, spl[rb], 3) lo4 = ta.valuewhen(pl, spl[rb], 4) lo5 = ta.valuewhen(pl, spl[rb], 5) lox0 = ta.valuewhen(pl, bar_index[rb], 0) lox1 = ta.valuewhen(pl, bar_index[rb], 1) lox2 = ta.valuewhen(pl, bar_index[rb], 2) lox3 = ta.valuewhen(pl, bar_index[rb], 3) lox4 = ta.valuewhen(pl, bar_index[rb], 4) lox5 = ta.valuewhen(pl, bar_index[rb], 5) hix0 = ta.valuewhen(ph, bar_index[rb], 0) hix1 = ta.valuewhen(ph, bar_index[rb], 1) hix2 = ta.valuewhen(ph, bar_index[rb], 2) hix3 = ta.valuewhen(ph, bar_index[rb], 3) hix4 = ta.valuewhen(ph, bar_index[rb], 4) hix5 = ta.valuewhen(ph, bar_index[rb], 5) mfi = ta.mfi(close, len) rh0 = ta.valuewhen(ph, mf[rb], 0) rh1 = ta.valuewhen(ph, mf[rb], 1) rh2 = ta.valuewhen(ph, mf[rb], 2) rh3 = ta.valuewhen(ph, mf[rb], 3) rh4 = ta.valuewhen(ph, mf[rb], 4) rh5 = ta.valuewhen(ph, mf[rb], 5) rl0 = ta.valuewhen(pl, mf[rb], 0) rl1 = ta.valuewhen(pl, mf[rb], 1) rl2 = ta.valuewhen(pl, mf[rb], 2) rl3 = ta.valuewhen(pl, mf[rb], 3) rl4 = ta.valuewhen(pl, mf[rb], 4) rl5 = ta.valuewhen(pl, mf[rb], 5) // bull & bear divergence logic bull_div_1= lo0<lo1 and rl1<rl0 bull_div_2= lo0<lo1 and lo0<lo2 and rl2<rl0 and rl2<rl1 and lvl>=2 bull_div_3= lo0<lo1 and lo0<lo2 and lo0<lo3 and rl3<rl0 and rl3<rl1 and rl3<rl2 and lvl>=3 bull_div_4= lo0<lo1 and lo0<lo2 and lo0<lo3 and lo0<lo4 and rl4<rl0 and rl4<rl1 and rl4<rl2 and rl4<rl3 and lvl>=4 bull_div_5= lo0<lo1 and lo0<lo2 and lo0<lo3 and lo0<lo4 and lo0<lo5 and rl5<rl0 and rl5<rl1 and rl5<rl2 and rl5<rl3 and rl5<rl4 and lvl>=5 bear_div_1= hi0>hi1 and rh1>rh0 bear_div_2= hi0>hi1 and hi0>hi2 and rh2>rh0 and rh2>rh1 and lvl>=2 bear_div_3= hi0>hi1 and hi0>hi2 and hi0>hi3 and rh3>rh0 and rh3>rh1 and rh3>rh2 and lvl>=3 bear_div_4= hi0>hi1 and hi0>hi2 and hi0>hi3 and hi0>hi4 and rh4>rh0 and rh4>rh1 and rh4>rh2 and rh4>rh3 and lvl>=4 bear_div_5= hi0>hi1 and hi0>hi2 and hi0>hi3 and hi0>hi4 and hi0>hi5 and rh5>rh0 and rh5>rh1 and rh5>rh2 and rh5>rh3 and rh5>rh4 and lvl>=5 new_bull1= bull_div_1 and not bull_div_1[1] new_bull2= bull_div_2 and not bull_div_2[1] new_bull3= bull_div_3 and not bull_div_3[1] new_bull4= bull_div_4 and not bull_div_4[1] new_bull5= bull_div_5 and not bull_div_5[1] new_bear1= bear_div_1 and not bear_div_1[1] new_bear2= bear_div_2 and not bear_div_2[1] new_bear3= bear_div_3 and not bear_div_3[1] new_bear4= bear_div_4 and not bear_div_4[1] new_bear5= bear_div_5 and not bear_div_5[1] recall(x) => ta.barssince(not na(x)) // bull divergence line plot rbull1 = line(na) rbull1 := new_bull1 and not new_bull2 and not new_bull3 and not new_bull4 and not new_bull5 ? line.new(lox0, rl0, lox1, rl1, color=div_col, width=2) : na rbull2 = line(na) rbull2 := new_bull2 and not new_bull3 and not new_bull4 and not new_bull5 ? line.new(lox0, rl0, lox2, rl2, color=div_col, width=2) : na rbull3 = line(na) rbull3 := new_bull3 and not new_bull4 and not new_bull5 ? line.new(lox0, rl0, lox3, rl3, color=div_col, width=2) : na rbull4 = line(na) rbull4 := new_bull4 and not new_bull5 ? line.new(lox0, rl0, lox4, rl4, color=div_col, width=2) : na rbull5 = line(na) rbull5 := new_bull5 ? line.new(lox0, rl0, lox5, rl5, color=div_col, width=2) : na xbull21 = ta.valuewhen(recall(rbull2) == 0, bar_index, 0) - ta.valuewhen(recall(rbull1) == 0, bar_index, 0) xbull31 = ta.valuewhen(recall(rbull3) == 0, bar_index, 0) - ta.valuewhen(recall(rbull1) == 0, bar_index, 0) xbull41 = ta.valuewhen(recall(rbull4) == 0, bar_index, 0) - ta.valuewhen(recall(rbull1) == 0, bar_index, 0) xbull51 = ta.valuewhen(recall(rbull5) == 0, bar_index, 0) - ta.valuewhen(recall(rbull1) == 0, bar_index, 0) xbull32 = ta.valuewhen(recall(rbull3) == 0, bar_index, 0) - ta.valuewhen(recall(rbull2) == 0, bar_index, 0) xbull42 = ta.valuewhen(recall(rbull4) == 0, bar_index, 0) - ta.valuewhen(recall(rbull2) == 0, bar_index, 0) xbull52 = ta.valuewhen(recall(rbull5) == 0, bar_index, 0) - ta.valuewhen(recall(rbull2) == 0, bar_index, 0) xbull43 = ta.valuewhen(recall(rbull4) == 0, bar_index, 0) - ta.valuewhen(recall(rbull3) == 0, bar_index, 0) xbull53 = ta.valuewhen(recall(rbull5) == 0, bar_index, 0) - ta.valuewhen(recall(rbull3) == 0, bar_index, 0) xbull54 = ta.valuewhen(recall(rbull5) == 0, bar_index, 0) - ta.valuewhen(recall(rbull4) == 0, bar_index, 0) if new_bull2 and lo2 == ta.valuewhen(new_bull1, lo1, 0) and xbull21 >= 0 line.delete(rbull1[xbull21]) if new_bull3 and lo3 == ta.valuewhen(new_bull1, lo1, 0) and xbull31 >= 0 line.delete(rbull1[xbull31]) if new_bull4 and lo4 == ta.valuewhen(new_bull1, lo1, 0) and xbull41 >= 0 line.delete(rbull1[xbull41]) if new_bull5 and lo5 == ta.valuewhen(new_bull1, lo1, 0) and xbull51 >= 0 line.delete(rbull1[xbull51]) if new_bull3 and lo3 == ta.valuewhen(new_bull2, lo2, 0) and xbull32 >= 0 line.delete(rbull2[xbull32]) if new_bull4 and lo4 == ta.valuewhen(new_bull2, lo2, 0) and xbull42 >= 0 line.delete(rbull2[xbull42]) if new_bull5 and lo5 == ta.valuewhen(new_bull2, lo2, 0) and xbull52 >= 0 line.delete(rbull2[xbull52]) if new_bull4 and lo4 == ta.valuewhen(new_bull3, lo3, 0) and xbull43 >= 0 line.delete(rbull3[xbull43]) if new_bull5 and lo5 == ta.valuewhen(new_bull3, lo3, 0) and xbull53 >= 0 line.delete(rbull3[xbull53]) if new_bull5 and lo5 == ta.valuewhen(new_bull4, lo4, 0) and xbull54 >= 0 line.delete(rbull4[xbull54]) // bear divergence line plot rbear1 = line(na) rbear1 := new_bear1 and not new_bear2 and not new_bear3 and not new_bear4 and not new_bear5 ? line.new(hix0, rh0, hix1, rh1, color=div_col, width=2) : na rbear2 = line(na) rbear2 := new_bear2 and not new_bear3 and not new_bear4 and not new_bear5 ? line.new(hix0, rh0, hix2, rh2, color=div_col, width=2) : na rbear3 = line(na) rbear3 := new_bear3 and not new_bear4 and not new_bear5 ? line.new(hix0, rh0, hix3, rh3, color=div_col, width=2) : na rbear4 = line(na) rbear4 := new_bear4 and not new_bear5 ? line.new(hix0, rh0, hix4, rh4, color=div_col, width=2) : na rbear5 = line(na) rbear5 := new_bear5 ? line.new(hix0, rh0, hix5, rh5, color=div_col, width=2) : na xbear21 = ta.valuewhen(recall(rbear2) == 0, bar_index, 0) - ta.valuewhen(recall(rbear1) == 0, bar_index, 0) xbear31 = ta.valuewhen(recall(rbear3) == 0, bar_index, 0) - ta.valuewhen(recall(rbear1) == 0, bar_index, 0) xbear41 = ta.valuewhen(recall(rbear4) == 0, bar_index, 0) - ta.valuewhen(recall(rbear1) == 0, bar_index, 0) xbear51 = ta.valuewhen(recall(rbear5) == 0, bar_index, 0) - ta.valuewhen(recall(rbear1) == 0, bar_index, 0) xbear32 = ta.valuewhen(recall(rbear3) == 0, bar_index, 0) - ta.valuewhen(recall(rbear2) == 0, bar_index, 0) xbear42 = ta.valuewhen(recall(rbear4) == 0, bar_index, 0) - ta.valuewhen(recall(rbear2) == 0, bar_index, 0) xbear52 = ta.valuewhen(recall(rbear5) == 0, bar_index, 0) - ta.valuewhen(recall(rbear2) == 0, bar_index, 0) xbear43 = ta.valuewhen(recall(rbear4) == 0, bar_index, 0) - ta.valuewhen(recall(rbear3) == 0, bar_index, 0) xbear53 = ta.valuewhen(recall(rbear5) == 0, bar_index, 0) - ta.valuewhen(recall(rbear3) == 0, bar_index, 0) xbear54 = ta.valuewhen(recall(rbear5) == 0, bar_index, 0) - ta.valuewhen(recall(rbear4) == 0, bar_index, 0) if new_bear2 and hi2 == ta.valuewhen(new_bear1, hi1, 0) and xbear21 >= 0 line.delete(rbear1[xbear21]) if new_bear3 and hi3 == ta.valuewhen(new_bear1, hi1, 0) and xbear31 >= 0 line.delete(rbear1[xbear31]) if new_bear4 and hi4 == ta.valuewhen(new_bear1, hi1, 0) and xbear41 >= 0 line.delete(rbear1[xbear41]) if new_bear5 and hi5 == ta.valuewhen(new_bear1, hi1, 0) and xbear51 >= 0 line.delete(rbear1[xbear51]) if new_bear3 and hi3 == ta.valuewhen(new_bear2, hi2, 0) and xbear32 >= 0 line.delete(rbear2[xbear32]) if new_bear4 and hi4 == ta.valuewhen(new_bear2, hi2, 0) and xbear42 >= 0 line.delete(rbear2[xbear42]) if new_bear5 and hi5 == ta.valuewhen(new_bear2, hi2, 0) and xbear52 >= 0 line.delete(rbear2[xbear52]) if new_bear4 and hi4 == ta.valuewhen(new_bear3, hi3, 0) and xbear43 >= 0 line.delete(rbear3[xbear43]) if new_bear5 and hi5 == ta.valuewhen(new_bear3, hi3, 0) and xbear53 >= 0 line.delete(rbear3[xbear53]) if new_bear5 and hi5 == ta.valuewhen(new_bear4, hi4, 0) and xbear54 >= 0 line.delete(rbear4[xbear54]) plotshape(title='bull_div_1', series=new_bull1 ? 13 : na, style=shape.triangleup, color=#089981, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div_2', series=new_bull2 ? 13 : na, style=shape.triangleup, color=#089981, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div_3', series=new_bull3 ? 13 : na, style=shape.triangleup, color=#089981, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div_4', series=new_bull4 ? 13 : na, style=shape.triangleup, color=#089981, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bull_div_5', series=new_bull5 ? 13 : na, style=shape.triangleup, color=#089981, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div_1', series=new_bear1 ? 87 : na, style=shape.triangledown, color=#f23645, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div_2', series=new_bear2 ? 87 : na, style=shape.triangledown, color=#f23645, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div_3', series=new_bear3 ? 87 : na, style=shape.triangledown, color=#f23645, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div_4', series=new_bear4 ? 87 : na, style=shape.triangledown, color=#f23645, location=location.absolute, size=size.tiny, offset=-2) plotshape(title='bear_div_5', series=new_bear5 ? 87 : na, style=shape.triangledown, color=#f23645, location=location.absolute, size=size.tiny, offset=-2) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // linear regression // input lrg = 'Linear Regression' linreg1 = input(true, 'Longterm Linear Regression On / Off', group=lrg) periodTrend = input.int(100, 'Longterm Linear Regression Period', minval=4, group=lrg) linreg2 = input(true, 'Shorterm Linear Regression On / Off', group=lrg) periodTrend2 = input.int(25, 'Shorterm Linear Regression Period', minval=4, group=lrg) deviationsAmnt = input.float(2, 'Deviation', minval=0.1, step=0.1, group=lrg) estimatorType = input.string('Unbiased', 'Estimator', options=['Biased', 'Unbiased'], group=lrg) var extendType = input.string('Right', 'Extend', options=['Right', 'Segment'], group=lrg) == 'Right' ? extend.right : extend.none // drawline configuration drawLine(X1, Y1, X2, Y2, ExtendType, Color, LineStyle) => var line Line = na Line := linreg1 ? line.new(X1, Y1, X2, Y2, xloc.bar_index, ExtendType, Color, LineStyle, width=2) : na line.delete(Line[1]) drawLine2(X1, Y1, X2, Y2, ExtendType, Color, LineStyle) => var line Line = na Line := linreg2 ? line.new(X1, Y1, X2, Y2, xloc.bar_index, ExtendType, Color, LineStyle, width=2) : na line.delete(Line[1]) rsdcr2(PeriodMinusOne, Deviations, Estimate) => var period = PeriodMinusOne + 1 var devDenominator = Estimate == 'Unbiased' ? PeriodMinusOne : period Ex = 0.0 Ex2 = 0.0 Exy = 0.0 Ey = 0.0 for i = 0 to PeriodMinusOne by 1 closeI = nz(mf[i]) Ex := Ex + i Ex2 := Ex2 + i * i Exy := Exy + closeI * i Ey := Ey + closeI Ey ExEx = Ex * Ex slope = Ex2 == ExEx ? 0.0 : (period * Exy - Ex * Ey) / (period * Ex2 - ExEx) linearRegression = (Ey - slope * Ex) / period intercept = linearRegression + bar_index * slope deviation = 0.0 for i = 0 to PeriodMinusOne by 1 deviation := deviation + math.pow(nz(mf[i]) - (intercept - bar_index[i] * slope), 2.0) deviation deviation := Deviations * math.sqrt(deviation / devDenominator) correlate = ta.correlation(mf, bar_index, period) r2 = math.pow(correlate, 2.0) [linearRegression, slope, deviation, correlate, r2] periodMinusOne = periodTrend - 1 [linReg, slope, deviation, correlate, r2] = rsdcr2(periodMinusOne, deviationsAmnt, estimatorType) endPointBar = bar_index - periodTrend + 1 endPointY = linReg + slope * periodMinusOne endPointBar2 = bar_index - periodTrend2 + 1 // drawline plot drawLine(endPointBar, endPointY + deviation, bar_index, linReg + deviation, extendType, #e91e63, line.style_solid) drawLine(endPointBar, endPointY, bar_index, linReg, extendType, #e91e63, line.style_dotted) drawLine(endPointBar, endPointY - deviation, bar_index, linReg - deviation, extendType, #e91e63, line.style_solid) drawLine2(endPointBar2, endPointY + deviation, bar_index, linReg + deviation, extendType, color.blue, line.style_solid) drawLine2(endPointBar2, endPointY, bar_index, linReg, extendType, color.blue, line.style_dotted) drawLine2(endPointBar2, endPointY - deviation, bar_index, linReg - deviation, extendType, color.blue, line.style_solid) // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // [_ParkF] // // TRENDLINES // input group3 = 'TREND LINES' o = mf[1] h = mfih l = mfil c = mf log_chart = input(true, title='Use Log Chart', group=group3) a_Color_Type = input.string(defval='Monochrome', title='Use Trendlines Color Scheme', options=['Colored', 'Monochrome'], group=group3) group4 = 'PRIMARY TRENDLINES' a_Show_Primary = input(true, title='Primary Trendlines On / Off', group=group4) a_len = input(20, title='Primary Lookback Length', group=group4) a_Extensions = input.string(title='Primary Trendlines Extensions', defval='25', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group4) a_width = input.int(2, title='Primary Line Width', minval=0, maxval=10, group=group4) a_LineStyle_Type = input.string(title='Primary Line Type', defval='Solid', options=['Dashed', 'Dotted', 'Solid'], group=group4) a_Line_Type = a_LineStyle_Type == 'Dashed' ? line.style_dashed : a_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid a_Rising_Upper_Falling_Lower = false group5 = 'SECONDARY TRENDLINES' b_Show_Secondary = input(true, title='Secondary Trendlines On / Off', group=group5) b_len = input(10, title='Secondary Lookback Length', group=group5) b_Extensions = input.string(title='Secondary Trendlines Extensions', defval='25', options=["Infinate", "25", "50", "75", "100", "150", "200", "300", "400", "500", "750", "1000"], group=group5) b_LineStyle_Type = input.string(title='Secondary Line Type', defval='Dashed', options=['Dashed', 'Dotted', 'Solid'], group=group5) b_Line_Type = b_LineStyle_Type == 'Dashed' ? line.style_dashed : b_LineStyle_Type == 'Dotted' ? line.style_dotted : line.style_solid b_width = input.int(1, title='Secondary Line Width', minval=0, maxval=10, group=group5) b_Rising_Upper_Falling_Lower = false group10 = 'TRENDLINES COLOR' a_Line_Color = input.color(#ffffff, title="Primary Trendline Color", group=group10) b_Line_Color = input.color(#ffffff, title="Secondary Trendline Color", group=group10) a_bar_time = time - time[1] b_bar_time = time - time[1] //primary trendline // trendline extension a_Extension_Multiplier= a_Extensions=="25"? 1 : a_Extensions=="50"? 2 : a_Extensions=="75"? 3 : a_Extensions=="100"? 4 : a_Extensions=="150"? 6 : a_Extensions=="200"? 8 : a_Extensions=="300"? 12 : a_Extensions=="400"? 16 : a_Extensions=="500"? 20 : a_Extensions=="750"? 30 : a_Extensions=="1000"? 40 : a_Extensions=="Infinate"? 0 : na // trendline function a_f_trendline(a__input_function, a__delay, a__only_up, a__extend) => var int a_Ax = 1 var int a_Bx = 1 var float a_By = 0 var float a_slope = 0 a_Ay = fixnan(a__input_function) if ta.change(a_Ay) != 0 a_Ax := time[a__delay] a_By := a_Ay[1] a_Bx := a_Ax[1] a_slope := log_chart ? (math.log(a_Ay) - math.log(a_By)) / (a_Ax - a_Bx) : (a_Ay - a_By) / (a_Ax - a_Bx) a_slope else a_Ax := a_Ax[1] a_Bx := a_Bx[1] a_By := a_By[1] a_By // draw trendline var line a_trendline = na var int a_Axbis = 0 var float a_Aybis = 0 var bool a__xtend = true a_extension_time = a_Extension_Multiplier * a_bar_time * 25 a_Axbis := a_Ax + a_extension_time a_Aybis := log_chart ? a_Ay * math.exp(a_extension_time * a_slope) : a_Ay + a_extension_time * a_slope if a_Extension_Multiplier != 0 a__xtend := false a__xtend if ta.change(a_Ay) != 0 a_line_color_Rising_Falling = a_slope * time < 0 ? a__only_up ? a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : a_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na a_line_color_Not_Rising_Falling = a_slope * time < 0 ? a__only_up ? na : a_Color_Type == 'Colored' ? #cf0a83 : color.teal : a__only_up ? a_Color_Type == 'Colored' ? #027521 : color.teal : na a_line_color = a_Show_Primary and not a_Rising_Upper_Falling_Lower ? a_line_color_Not_Rising_Falling : a_Show_Primary and a_Rising_Upper_Falling_Lower ? a_line_color_Rising_Falling : na if not na(a_line_color) a_trendline := line.new(a_Bx, a_By, a_Axbis, a_Aybis, xloc.bar_time, extend=a__xtend ? extend.right : extend.none, color=a_Line_Color, style=a_Line_Type, width=a_width) a_trendline [a_Bx, a_By, a_Axbis, a_Aybis, a_slope] // calc pivot points a_high_point = ta.pivothigh(c > o ? h : l, a_len, a_len / 2) a_low_point = ta.pivotlow(c > o ? l : h, a_len, a_len / 2) // call trendline function [a_phx1, a_phy1, a_phx2, a_phy2, a_slope_high] = a_f_trendline(a_high_point, a_len / 2, false, true) [a_plx1, a_ply1, a_plx2, a_ply2, a_slope_low] = a_f_trendline(a_low_point, a_len / 2, true, true) // secondary trendline // trendline extension b_Extension_Multiplier= b_Extensions=="25"? 1 : b_Extensions=="50"? 2 : b_Extensions=="75"? 3 : b_Extensions=="100"? 4 : b_Extensions=="150"? 6 : b_Extensions=="200"? 8 : b_Extensions=="300"? 12 : b_Extensions=="400"? 16 : b_Extensions=="500"? 20 : b_Extensions=="750"? 30 : b_Extensions=="1000"? 40 : b_Extensions=="Infinate"? 0 : na // trendline function b_f_trendline(b__input_function, b__delay, b__only_up, b__extend) => var int b_Ax = 1 var int b_Bx = 1 var float b_By = 0 var float b_slope = 0 b_Ay = fixnan(b__input_function) if ta.change(b_Ay) != 0 b_Ax := time[b__delay] b_By := b_Ay[1] b_Bx := b_Ax[1] b_slope := log_chart ? (math.log(b_Ay) - math.log(b_By)) / (b_Ax - b_Bx) : (b_Ay - b_By) / (b_Ax - b_Bx) b_slope else b_Ax := b_Ax[1] b_Bx := b_Bx[1] b_By := b_By[1] b_By // draw trendlines var line b_trendline = na var int b_Axbis = 0 var float b_Aybis = 0 var bool b__xtend = true b_extension_time = b_Extension_Multiplier * b_bar_time * 25 b_Axbis := b_Ax + b_extension_time b_Aybis := log_chart ? b_Ay * math.exp(b_extension_time * b_slope) : b_Ay + b_extension_time * b_slope if b_Extension_Multiplier != 0 b__xtend := false b__xtend if ta.change(b_Ay) != 0 b_line_color_Rising_Falling = b_slope * time < 0 ? b__only_up ? b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : b_Rising_Upper_Falling_Lower ? a_Color_Type == 'Colored' ? color.gray : color.teal : na b_line_color_Not_Rising_Falling = b_slope * time < 0 ? b__only_up ? na : a_Color_Type == 'Colored' ? color.red : color.teal : b__only_up ? a_Color_Type == 'Colored' ? color.green : color.teal : na b_line_color = b_Show_Secondary and not b_Rising_Upper_Falling_Lower ? b_line_color_Not_Rising_Falling : b_Show_Secondary and b_Rising_Upper_Falling_Lower ? b_line_color_Rising_Falling : na if not na(b_line_color) b_trendline := line.new(b_Bx, b_By, b_Axbis, b_Aybis, xloc.bar_time, extend=b__xtend ? extend.right : extend.none, color=b_Line_Color, style=b_Line_Type, width=b_width) b_trendline [b_Bx, b_By, b_Axbis, b_Aybis, b_slope] // calc pivot points b_high_point = ta.pivothigh(c > o ? h : l, b_len, b_len / 2) b_low_point = ta.pivotlow(c > o ? l : h, b_len, b_len / 2) // call trendline function [b_phx1, b_phy1, b_phx2, b_phy2, b_slope_high] = b_f_trendline(b_high_point, b_len / 2, false, true) [b_plx1, b_ply1, b_plx2, b_ply2, b_slope_low] = b_f_trendline(b_low_point, b_len / 2, true, true) // plot b_color_high = b_slope_high * time < 0 ? color.green : na b_color_low = b_slope_low * time > 0 ? color.red : na
Symbol Viewer
https://www.tradingview.com/script/Ai9qt7qT-Symbol-Viewer/
SamRecio
https://www.tradingview.com/u/SamRecio/
61
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("Symbol Viewer", shorttitle = "🔎") //Settings ticker = input.symbol("TICK", title = "Symbol:", inline = "1") green = input.color(#26a69a, title = "Up Color", inline = "2") red = input.color(#ef5350, title = "Down Color", inline = "2") //Grabbing Values [tick_open,tick_high,tick_low,tick_close] = request.security(ticker, "", [open,high,low,close]) //Candle Color rg = tick_open > tick_close ? red : tick_open < tick_close ? green : color.gray //Plotting plotcandle(tick_open, tick_high,tick_low,tick_close, title = "Symbol", color = rg, wickcolor = rg, bordercolor = rg, editable = false) plot(tick_open, display = display.none, title = "Open") plot(tick_high, display = display.none, title = "High") plot(tick_low, display = display.none, title = "Low") plot(tick_close, display = display.none, title = "Close") //Tracking Line l1 = line.new(bar_index, tick_close, bar_index - 1, tick_close, extend = extend.both, color = rg, style = line.style_dotted) line.delete(l1[1]) lab1 = label.new(bar_index + 10, tick_close, text = ticker + "\n" + str.tostring(tick_close), size = size.normal, style = label.style_none, textcolor = rg, textalign = text.align_left) label.delete(lab1[1]) hline(0, title = "Zero Line")
Crypto Society EMAs
https://www.tradingview.com/script/3q2y39OV-Crypto-Society-EMAs/
hakanar
https://www.tradingview.com/u/hakanar/
10
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © hakanar //@version=5 indicator("Crypto Society EMAs",shorttitle="Crypto Society EMAs", overlay=true, max_bars_back=5000, max_labels_count=500) InputEma1 = input.int(9, "Ema 1", minval=1, maxval=5000) InputEma2 = input.int(34, "Ema 2", minval=1, maxval=5000) InputEma3 = input.int(50, "Ema 3", minval=1, maxval=5000) InputEma4 = input.int(100, "Ema 4", minval=1, maxval=5000) InputEma5 = input.int(200, "Ema 5", minval=1, maxval=5000) Ema1 = ta.vwma(close, InputEma1) Ema2 = ta.vwma(close, InputEma2) Ema3 = ta.vwma(close, InputEma3) Ema4 = ta.vwma(close, InputEma4) Ema5 = ta.vwma(close, InputEma5) plot(Ema1, title="Ema1", color=color.new(color.red, 30)) plot(Ema2, title="Ema2", color=color.new(color.blue, 30)) plot(Ema3, title="Ema3", color=color.new(color.green, 30)) plot(Ema4, title="Ema4", color=color.new(color.olive, 30)) plot(Ema5, title="Ema5", color=color.new(color.gray, 30)) ema1_min1 = request.security(syminfo.tickerid, "1", ta.vwma(close, InputEma1)) ema2_min1 = request.security(syminfo.tickerid, "1", ta.vwma(close, InputEma2)) ema3_min1 = request.security(syminfo.tickerid, "1", ta.vwma(close, InputEma3)) ema4_min1 = request.security(syminfo.tickerid, "1", ta.vwma(close, InputEma4)) ema5_min1 = request.security(syminfo.tickerid, "1", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min1[1], ema3_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1[1], ema4_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1[1], ema5_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min1[1], ema3_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1[1], ema4_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1[1], ema5_min1[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min3 = request.security(syminfo.tickerid, "3", ta.vwma(close, InputEma1)) ema2_min3 = request.security(syminfo.tickerid, "3", ta.vwma(close, InputEma2)) ema3_min3 = request.security(syminfo.tickerid, "3", ta.vwma(close, InputEma3)) ema4_min3 = request.security(syminfo.tickerid, "3", ta.vwma(close, InputEma4)) ema5_min3 = request.security(syminfo.tickerid, "3", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min3[1], ema3_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min3[1], ema4_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min3[1], ema5_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min3[1], ema3_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min3[1], ema4_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min3[1], ema5_min3[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "3m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min5 = request.security(syminfo.tickerid, "5", ta.vwma(close, InputEma1)) ema2_min5 = request.security(syminfo.tickerid, "5", ta.vwma(close, InputEma2)) ema3_min5 = request.security(syminfo.tickerid, "5", ta.vwma(close, InputEma3)) ema4_min5 = request.security(syminfo.tickerid, "5", ta.vwma(close, InputEma4)) ema5_min5 = request.security(syminfo.tickerid, "5", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min5[1], ema3_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min5[1], ema4_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min5[1], ema5_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min5[1], ema3_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min5[1], ema4_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min5[1], ema5_min5[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "5m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min10 = request.security(syminfo.tickerid, "10", ta.vwma(close, InputEma1)) ema2_min10 = request.security(syminfo.tickerid, "10", ta.vwma(close, InputEma2)) ema3_min10 = request.security(syminfo.tickerid, "10", ta.vwma(close, InputEma3)) ema4_min10 = request.security(syminfo.tickerid, "10", ta.vwma(close, InputEma4)) ema5_min10 = request.security(syminfo.tickerid, "10", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min10[1], ema3_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min10[1], ema4_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min10[1], ema5_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min10[1], ema3_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min10[1], ema4_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min10[1], ema5_min10[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "10m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min15 = request.security(syminfo.tickerid, "15", ta.vwma(close, InputEma1)) ema2_min15 = request.security(syminfo.tickerid, "15", ta.vwma(close, InputEma2)) ema3_min15 = request.security(syminfo.tickerid, "15", ta.vwma(close, InputEma3)) ema4_min15 = request.security(syminfo.tickerid, "15", ta.vwma(close, InputEma4)) ema5_min15 = request.security(syminfo.tickerid, "15", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min15[1], ema3_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min15[1], ema4_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min15[1], ema5_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min15[1], ema3_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min15[1], ema4_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min15[1], ema5_min15[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "15m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min30 = request.security(syminfo.tickerid, "30", ta.vwma(close, InputEma1)) ema2_min30 = request.security(syminfo.tickerid, "30", ta.vwma(close, InputEma2)) ema3_min30 = request.security(syminfo.tickerid, "30", ta.vwma(close, InputEma3)) ema4_min30 = request.security(syminfo.tickerid, "30", ta.vwma(close, InputEma4)) ema5_min30 = request.security(syminfo.tickerid, "30", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min30[1], ema3_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min30[1], ema4_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min30[1], ema5_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min30[1], ema3_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min30[1], ema4_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min30[1], ema5_min30[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "30m\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min1H = request.security(syminfo.tickerid, "60", ta.vwma(close, InputEma1)) ema2_min1H = request.security(syminfo.tickerid, "60", ta.vwma(close, InputEma2)) ema3_min1H = request.security(syminfo.tickerid, "60", ta.vwma(close, InputEma3)) ema4_min1H = request.security(syminfo.tickerid, "60", ta.vwma(close, InputEma4)) ema5_min1H = request.security(syminfo.tickerid, "60", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min1H[1], ema3_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1H[1], ema4_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1H[1], ema5_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min1H[1], ema3_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1H[1], ema4_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1H[1], ema5_min1H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1H\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min4H = request.security(syminfo.tickerid, "240", ta.vwma(close, InputEma1)) ema2_min4H = request.security(syminfo.tickerid, "240", ta.vwma(close, InputEma2)) ema3_min4H = request.security(syminfo.tickerid, "240", ta.vwma(close, InputEma3)) ema4_min4H = request.security(syminfo.tickerid, "240", ta.vwma(close, InputEma4)) ema5_min4H = request.security(syminfo.tickerid, "240", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min4H[1], ema3_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min4H[1], ema4_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min4H[1], ema5_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min4H[1], ema3_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min4H[1], ema4_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min4H[1], ema5_min4H[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "4H\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) ema1_min1D = request.security(syminfo.tickerid, "1D", ta.vwma(close, InputEma1)) ema2_min1D = request.security(syminfo.tickerid, "1D", ta.vwma(close, InputEma2)) ema3_min1D = request.security(syminfo.tickerid, "1D", ta.vwma(close, InputEma3)) ema4_min1D = request.security(syminfo.tickerid, "1D", ta.vwma(close, InputEma4)) ema5_min1D = request.security(syminfo.tickerid, "1D", ta.vwma(close, InputEma5)) if ta.crossover(ema1_min1D[1], ema3_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1D[1], ema4_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossover(ema1_min1D[1], ema5_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.green, 30)) label.set_yloc( lbl, yloc.belowbar) label.set_style(lbl, label.style_label_up) if ta.crossunder(ema1_min1D[1], ema3_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma3)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1D[1], ema4_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma4)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down) if ta.crossunder(ema1_min1D[1], ema5_min1D[1]) lbl = label.new(bar_index, na) label.set_text( lbl, "1D\n" + str.tostring(InputEma5)) label.set_color(lbl, color.new(color.red, 30)) label.set_yloc( lbl, yloc.abovebar) label.set_style(lbl, label.style_label_down)
RedK Dual VADER with Energy Bars (VADER-DEB)
https://www.tradingview.com/script/6KGhHBkz-RedK-Dual-VADER-with-Energy-Bars-VADER-DEB/
RedKTrader
https://www.tradingview.com/u/RedKTrader/
721
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/ // © RedKTrader //@version=5 indicator('RedK Dual VADER with Energy Bars [VADER-DEB]', 'RedK VADER-DEB v5.0', precision=0, timeframe='', timeframe_gaps=false) // This version is the same as VADER v3.0 with enhanced visuals, using Energy Bars instead of the positive/energy lines // Sentiment plot changed from histogram to area and is exposed by default (hence Dual w/ Energy Bars -- DEB) // No change in core calculations from VADER v4.0 -- and that's why i'll just call it VADER v4.0 // *********************************************************************************************************** // Choose MA type for the base DER calculation .. // WMA is my preference and is default .. SMA is really slow and lags a lot - but added for comparison f_derma(_data, _len, MAOption) => value = MAOption == 'SMA' ? ta.sma(_data, _len) : MAOption == 'EMA' ? ta.ema(_data, _len) : ta.wma(_data, _len) // *********************************************************************************************************** // =========================================================================================================== // Inputs // =========================================================================================================== price = close length = input.int(10, minval=1) DER_avg = input.int(5, 'Average', minval=1, inline='DER', group='Directional Energy Ratio') MA_Type = input.string('WMA', 'DER MA type', options=['WMA', 'EMA', 'SMA'], inline='DER', group='Directional Energy Ratio') smooth = input.int(3, 'Smooth', minval=1, inline='DER_1', group='Directional Energy Ratio') show_senti = input.bool(true, 'Sentiment', inline='DER_s', group='Directional Energy Ratio') senti = input.int(20, 'Length', minval=1, inline='DER_s', group='Directional Energy Ratio') v_calc = input.string('Relative', 'Calculation', options=['Relative', 'Full', 'None'], group='Volume Parameters') vlookbk = input.int(20, 'Lookback (for Relative)', minval=1, group='Volume Parameters') // =========================================================================================================== // Calculations // =========================================================================================================== // Volume Calculation Option -- will revert to no volume acceleration for instruments with no volume data v = volume vola = v_calc == 'None' or na(volume) ? 1 : v_calc == 'Relative' ? ta.stoch(v, v, v, vlookbk) / 100 : v R = (ta.highest(2) - ta.lowest(2)) / 2 // R is the 2-bar average bar range - this method accomodates bar gaps sr = ta.change(price) / R // calc ratio of change to R rsr = math.max(math.min(sr, 1), -1) // ensure ratio is restricted to +1/-1 in case of big moves c = fixnan(rsr * vola) // add volume accel -- fixnan adresses cases where no price change between bars c_plus = math.max(c, 0) // calc directional vol-accel energy c_minus = -math.min(c, 0) // plot(c_plus) // plot(c_minus) avg_vola = f_derma(vola, length, MA_Type) dem = f_derma(c_plus, length, MA_Type) / avg_vola // directional energy ratio sup = f_derma(c_minus, length, MA_Type) / avg_vola adp = 100 * ta.wma(nz(dem), DER_avg) // average DER asp = 100 * ta.wma(nz(sup), DER_avg) anp = adp - asp // net DER.. anp_s = ta.wma(anp, smooth) // Calculate Sentiment - a VADER for a longer period and can act as a baseline (compared to a static 0 value) // note we're not re-calculating vol_avg, demand or supply energy for sentiment. this would've been a different approach s_adp = 100 * ta.wma(nz(dem), senti) // average DER for sentiment length s_asp = 100 * ta.wma(nz(sup), senti) V_senti = ta.wma(s_adp - s_asp, smooth) // =========================================================================================================== // Colors & plots // =========================================================================================================== c_adp = color.new(#11ff20, 30) c_asp = color.new(#ff1111, 30) c_fd = color.new(color.green, 80) c_fs = color.new(color.red, 80) c_zero = color.new(#ffee00, 70) c_up = color.new(#11ff20, 0) c_dn = color.new(#ff1111, 0) up = anp_s >= 0 s_up = V_senti >=0 hline(0, 'Zero Line', c_zero, hline.style_solid) // ============================================================================= // v4.0 --- Sentiment will be represented as a 4-color area graph c_grow_above = #1b5e2080 c_grow_below = #dc4c4a80 c_fall_above = #66bb6a80 c_fall_below = #ef8e9880 sflag_up = math.abs(V_senti) >= math.abs(V_senti[1]) plot(show_senti ? V_senti : na, "Sentiment", style=plot.style_area, color = s_up ? (sflag_up ? c_grow_above : c_fall_above) : sflag_up ? c_grow_below : c_fall_below) // =========================================================================================================== // v4.0 Use Energy Bars instead of DER lines // =========================================================================================================== // Prep the Energy Bars bo = fixnan(asp) bc = fixnan(adp) bh = math.max(bo, bc) bl = math.min(bo, bc) rising = ta.change(bc) > 0 c_barup = #11ff2088 c_bardn = #ff111188 c_bardj = #ffffff88 barcolor = bc > bo and rising ? c_barup : bc < bo and not rising ? c_bardn : c_bardj plotcandle(bo, bh, bl, bc, 'Energy Bars', barcolor, barcolor, bordercolor = barcolor) // ============================================================================================================ s = plot(asp, 'Supply Energy', c_asp, 2, display = display.none) d = plot(adp, 'Demand Energy', c_adp, 2, display = display.none) plot(anp, 'VADER', color.new(color.gray, 30), display=display.none) plot(anp_s, 'Signal', up ? c_up : c_dn, 4) // =========================================================================================================== // v2.0 adding alerts // =========================================================================================================== Alert_up = ta.crossover(anp_s,0) Alert_dn = ta.crossunder(anp_s,0) Alert_swing = ta.cross(anp_s,0) // "." in alert title for the alerts to show in the right order up/down/swing alertcondition(Alert_up, ". VADER Crossing 0 Up", "VADER Up - Buying Energy Detected!") alertcondition(Alert_dn, ".. VADER Crossing 0 Down", "VADER Down - Selling Energy Detected!") alertcondition(Alert_swing, "... VADER Crossing 0", "VADER Swing - Possible Reversal") // =========================================================================================================== // v3.0 more alerts for VADER crossing Sentiment // =========================================================================================================== v_speedup = ta.crossover(anp_s, V_senti) v_slowdn = ta.crossunder(anp_s, V_senti) alertcondition(v_speedup, "* VADER Speeding Up", "VADER Speeding Up!") alertcondition(v_slowdn, "** VADER Slowing Down", "VADER Slowing Down!")
75 min candle
https://www.tradingview.com/script/aXfVDfSI-75-min-candle/
hirawatt
https://www.tradingview.com/u/hirawatt/
144
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/ // © yesgoods //@version=5 indicator(title="75 min candle", shorttitle="75 min", overlay=true) // Use gaps to only return data when the 1D timeframe completes, `na` otherwise. [o, h, l, c] = request.security(syminfo.tickerid, "75", [open, high, low, close], gaps = barmerge.gaps_on) var color UP_COLOR = color.lime var color DN_COLOR = color.red color wickColor = c >= o ? UP_COLOR : DN_COLOR color bodyColor = c >= o ? color.new(UP_COLOR, 20) : color.new(DN_COLOR, 20) // Only plot candles on intraday timeframes, // and when non `na` values are returned by `request.security()` because a HTF has completed. plotcandle(timeframe.isintraday ? o : na, h, l, c, color = bodyColor, wickcolor = wickColor)
Hammers & Stars Candle [2022]
https://www.tradingview.com/script/I7iumx8R-Hammers-Stars-Candle-2022/
LuxTradeVenture
https://www.tradingview.com/u/LuxTradeVenture/
174
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MINTYFRESH97 //@version=5 indicator("Hammers & Stars", overlay=true) // Get user input fibLevel = input.float(title="Fib Level", defval=0.400) colorFilter = input.bool(title="Color Filter", defval=false) atrFilter = input.float(title="ATR Filter", defval=0.1) //swing high/low filter swingHigh = high == ta.highest(high,10) or high[1] == ta.highest(high,10) swingLow = low == ta.lowest(low,10) or low[1] ==ta.lowest(low,10) //user input var g_ema = "EMA Filter" emaLength = input.int(title="EMA Length", defval=50, tooltip="Length of the EMA filter", group=g_ema) useEmaFilter = input.bool(title="Use EMA Filter?", defval=false, tooltip="Turns on/off the EMA filter", group=g_ema) // Get EMA filter ema = ta.ema(close, emaLength) emaFilterLong = not useEmaFilter or close > ema emaFilterShort = not useEmaFilter or close < ema // Check our ATR filter atr = ta.atr(14) candleSize = high - low atrFilterCheck = candleSize >= atr * atrFilter // Calculate fibonacci level for current candle bullFib = (low - high) * fibLevel + high bearFib = (high - low) * fibLevel + low // Determine which price source closes or opens highest/lowest lowestBody = close < open ? close : open highestBody = close > open ? close : open // Determine if we have a valid hammer or shooting star candle hammerCandle = lowestBody >= bullFib and (not colorFilter or close > open) and atrFilterCheck and swingLow and close and emaFilterLong starCandle = highestBody <= bearFib and (not colorFilter or close < open) and atrFilterCheck and swingHigh and close and emaFilterShort // Plot our candle patterns barcolor(hammerCandle ? color.green:na) barcolor(starCandle ? color.yellow :na) plotshape(hammerCandle, style=shape.triangleup, size=size.tiny, text="H",color=color.green, location=location.belowbar, color=color.green) plotshape(starCandle, style=shape.triangledown, size=size.tiny, text="S", color=color.yellow, location=location.abovebar, color=color.yellow) alertcondition(hammerCandle, "Hammer", "hammerCandle detected for {{ticker}}") alertcondition(starCandle, "Shooting Star", "starCandle detected for {{ticker}}")
Scrolling Watermark
https://www.tradingview.com/script/JvYmzoFr-Scrolling-Watermark/
SamRecio
https://www.tradingview.com/u/SamRecio/
55
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © SamRecio //@version=5 indicator("Scrolling Watermark", shorttitle = "📜", overlay = true) //Inputs text_input = input.string("I💙TradingView ", title = "Text", inline = "1", group = "Text Settings") scroll = input.string("Left", options = ["Left","Right"], title = "Scroll", inline = "1", group = "Text Settings") txtcolor = input.color(color.white, title = "", inline = "1", group = "Text Settings") tl1 = input.string("bottom", title = "Table Location", options = ["top", "middle", "bottom"], group = "Table Settings", inline = "1") tl2 = input.string("right", title = "", options = ["left", "center", "right"], group = "Table Settings", inline = "1") tsize = input.string("normal", title = "Table Size", options = ["small", "normal", "large", "huge"], group = "Table Settings", inline = "2") tblcolor = input.color(color.rgb(0,0,0), title = "Table Color", group = "Table Settings", inline = "2") //BTC Pulling in BTC data and plotting it to force the indicator to update at every price change of BTC. This means we get more consistent updates from the indidcator, which makes it move smoother across all tickers. btc = request.security("COINBASE:BTCUSD","",close) plot(btc, display = display.none, editable = false) //Main Logic and scrolling functionality. // -Move first letter to the end (Left) or Last letter to the front. (Right) // varip lot = str.split(text_input,"") //Turns our Text input into an array of letters ex. [I,💙,T,r,a,d,i,n,g,V,i,e,w, ] Spaces are included in this array. varip string output = na //creates an assignable output string variable if scroll == "Left" temp = array.get(lot,0) // assigns "temp" the value of the first letter in the array. array.remove(lot,0)// removes the first value of the array. array.push(lot,temp)// adds out "temp" value (previously the 1st value in the array), to the end of the array. output := na// clears the current value of output because we are generating an entirely new output every tick. for i = 0 to array.size(lot)- 1 // for every letter in our array output := output + array.get(lot,i) // add it to our output string (ex. t + e + s + t) if scroll == "Right" temp = array.get(lot,array.size(lot) - 1) // assigns "temp" the value of the last letter in the array. array.remove(lot,array.size(lot) - 1) // removes the last value of the array. array.unshift(lot,temp) // adds out "temp" value (previously the last value in the array), to the beginning of the array. output := na for i = 0 to array.size(lot)- 1 output := output + array.get(lot,i) //Displaying the table. var table t1 = table.new(tl1 +"_" + tl2,1,2) table.cell(t1,0,0,text = str.tostring(output), text_size = tsize, bgcolor = tblcolor, text_color = txtcolor)
Measure Volume, Momentum, Trend, Volatility
https://www.tradingview.com/script/PRSRg9KP-Measure-Volume-Momentum-Trend-Volatility/
kfatkin
https://www.tradingview.com/u/kfatkin/
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/ // © kfatkin //@version=5 indicator(title="Measure Volume, Momentum, Trend, Volatility", shorttitle="Measure Volume/Momentum/Trend/Volatility", format=format.price, precision=2, timeframe="", timeframe_gaps=true, overlay=false) // Parameters Input Section // RSI Inputs showRsi = input(true, "Show RSI (Momentum)", inline="Dispay RSI", group="RSI") lengthRsi = input.int(14, "Length", inline="Configure RSI", minval=1, maxval=200, group="RSI") sourceRsi = input(close, "Source", inline="Configure RSI", group="RSI") rsiHighLevelPlot = input.int(70, "Overbought Level", inline="RSI Levels", group="RSI") rsiLowLevelPlot = input.int(30, "Oversold Level", inline="RSI Levels", group="RSI") colorRsiBull = input(color.white, "Bull Color", inline="RSI Line Colors", group="RSI") colorRsiBear = input(color.white, "Bear Color", inline="RSI Line Colors", group="RSI") rsiBackgroundFillColor = input(color.purple, "Background Color", inline="RSI Background Colors", group="RSI") rsiBackgroundTransparency = input.int(90, "Background Transparency", inline="RSI Background Colors", group="RSI") rsiMiddleLevelPlot = input.int(50, "Middle RSI/MFI Level", inline="RSI/MFI Settings", group="RSI/MFI") rsiSeperatorColor = input(color.white, "RSI/MFI Seperator Color", inline="RSI/MFI Settings", group="RSI/MFI") // MFI Inputs showMfi = input(true, "Show MFI (Volume)", inline="Display MFI", group="MFI") lengthMfi = input.int(14, "Length", minval=1, maxval=200, inline="Configure MFI", group="MFI") sourceMfi = input(hlc3, "Source", inline="Configure MFI", group="MFI") mfiHighLevelPlot = input.int(80, "Overbought MFI Level", inline="MFI Levels", group="MFI") mfiLowLevelPlot = input.int(20, "Oversold MFI Level", inline="MFI Levels", group="MFI") colorMfiBull = input(color.fuchsia, "Bull Color", inline="MFI Line Colors", group="MFI") colorMfiBear = input(color.fuchsia, "Bear Color", inline="MFI Line Colors", group="MFI") mfiHighLevelColor = input(color.green, "MFI High Background Color", inline="MFI Background Colors", group="MFI") mfiLowLevelColor = input(color.red, "MFI Low Background Color", inline="MFI Background Colors", group="MFI") mfiBackgroundTransparency = input.int(90, "MFI Background Transparency", inline="MFI Background Colors", group="MFI") // DMI Inputs showDmi = input(true, "Show DMI (Volatility)", inline="DMI", group="DMI") lengthDmi = input.int(14, "Length", inline="Configure MI", minval=1, maxval=200, group="DMI") lengthSigDmi = input.int(14, "Signal Length", inline="Configure DMI", minval=1, maxval=50, group="DMI") strongAdxSignal = input.int(20, "Strong ADX Level", minval=1, inline="DMI Levels", group="DMI" ) colorDmiAdx = input(color.yellow, "ADX Color", inline="DMI Colors", group="DMI") colorDmiWeakAdx = input(color.gray, "Weak ADX Color", inline="DMI Colors", group="DMI") dmiTrans = input.int(65, "DMI Transparency", inline="DMI Colors", group="DMI") colorDmiDiPlus = input(color.lime, "DI +", inline="DI Colors", group="DMI") colorDmiDiMinus = input(color.red, "DI -", inline="DI Colors", group="DMI") // Parabolic SAR Inputs showPsar = input(true, "Show Parabolic SAR (Trend)", inline="Show SAR", group="SAR") psarStart = input(0.02, "Start", inline="SAR Start", group="SAR") psarIncrement = input(0.02, "Increment", inline="SAR Inc", group="SAR") psarMax = input(0.2, "Max Value", inline="SAR Max", group="SAR") pricePeriod = input(ohlc4, "Source", inline="SAR Period", group="SAR") psarBullColor = input(color.green, "Bull Color", inline="SAR Color", group="SAR") psarBearColor = input(color.red, "Bear Color", inline="SAR Color", group="SAR") psarTrans = input.int(55, "Transparency", inline="SAR Color", group="SAR") // Indicators Section // RSI rsi = ta.rsi(sourceRsi, lengthRsi) // MFI mf = ta.mfi(sourceMfi, lengthMfi) // DMI 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, lengthDmi) plus = fixnan(100 * ta.rma(plusDM, lengthDmi) / trur) minus = fixnan(100 * ta.rma(minusDM, lengthDmi) / trur) sum = plus + minus adx = (100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lengthSigDmi)) goodVolatility = adx >= strongAdxSignal adxColor = goodVolatility ? colorDmiAdx : colorDmiWeakAdx determineDiWinner = plus > minus diWinner = determineDiWinner ? plus : minus // Parabolic SAR psarOut = ta.sar(psarStart, psarIncrement, psarMax) price = request.security(syminfo.tickerid, timeframe.period, pricePeriod) psarAbovePrice = psarOut >= price // Drawing Section // Plot ADX symbols diColor = determineDiWinner ? colorDmiDiPlus : colorDmiDiMinus plotchar(showDmi ? adx : na, "Show ADX", color = showDmi ? color.new(adxColor, dmiTrans) : na, char = '•', location = location.top, size = size.small) plotchar(showDmi ? diWinner : na, "Show DI", color = showDmi ? color.new(diColor, dmiTrans) : na, char = '•', location = location.top, size = size.tiny) // Plot RSI and MFI Lines rsiBullColor = color.from_gradient(rsi, rsiMiddleLevelPlot, rsiHighLevelPlot, color.new(colorRsiBull, 10), color.new(colorRsiBull, 0)) rsiBearColor = color.from_gradient(rsi, rsiLowLevelPlot, rsiMiddleLevelPlot, color.new(colorRsiBear, 0), color.new(colorRsiBear, 10)) rsiColor = rsi > rsiMiddleLevelPlot ? rsiBullColor : rsiBearColor plot(showRsi ? rsi : na, color = showRsi ? rsiColor : na, style = plot.style_line) mfiBullColor = color.from_gradient(mf, rsiMiddleLevelPlot, mfiHighLevelPlot, color.new(colorMfiBull, 10), color.new(colorMfiBull, 0)) mfiBearColor = color.from_gradient(mf, mfiLowLevelPlot, rsiMiddleLevelPlot, color.new(colorMfiBear, 0), color.new(colorMfiBear, 10)) mfiColor = mf > rsiMiddleLevelPlot ? colorMfiBull : colorMfiBear plot(showMfi ? mf : na, "MFI", color= showMfi ? mfiColor : na, style = plot.style_line) hline(rsiMiddleLevelPlot, title="Middle Line", linestyle=hline.style_dotted) rsiHighLevel = hline(rsiHighLevelPlot, title="RSI Overbought", linestyle=hline.style_dotted, color=rsiSeperatorColor) rsiLowLevel = hline(rsiLowLevelPlot, title="RSI Oversold", linestyle=hline.style_dotted, color=rsiSeperatorColor) fill(rsiHighLevel, rsiLowLevel, title="RSI/MFI Background", color=color.new(rsiBackgroundFillColor, rsiBackgroundTransparency)) mfiHighLevel = hline(mfiHighLevelPlot, title="MFI Overbought", linestyle=hline.style_dotted, color=rsiSeperatorColor) mfiLowLevel = hline(mfiLowLevelPlot, title="MFI Oversold", linestyle=hline.style_dotted, color=rsiSeperatorColor) oscMaxLevel = hline(100, title="Oscillator Max", linestyle=hline.style_solid, color=color.new(rsiSeperatorColor, 100)) oscMinLevel = hline(0, title="Oscillator Min", linestyle=hline.style_solid, color=color.new(rsiSeperatorColor, 100)) fill(rsiHighLevel, mfiHighLevel, title="MFI Overbought Background", color=color.new(mfiHighLevelColor, mfiBackgroundTransparency)) fill(mfiLowLevel, rsiLowLevel, title="MFI Oversold Background", color=color.new(mfiLowLevelColor, mfiBackgroundTransparency)) // Plot Parabolic SAR Symbols signalColor = psarAbovePrice ? psarBearColor : psarBullColor plotchar(showPsar ? psarOut : na, "ParabolicSAR", color= showPsar ? color.new(signalColor, psarTrans) : na , char= showPsar ? '◆' : na, location = showPsar ? location.bottom : na, size = size.tiny)
rth vwap and mid
https://www.tradingview.com/script/jT63yLdu/
mgruner
https://www.tradingview.com/u/mgruner/
33
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/ // This script is based on work done by ldbc (RTH VWAP) and NorthStarDayTrading (24 hour midline) // Intention of the script is to provide the trader with a plot of RTH VWAP and MidPoint as these are sometimes turning points in price action //@version=4 study("rth vwap and mid", overlay=true) input_rth = input("0930-1600", type=input.session, title="Regular Session Time (EST)", tooltip="If you want to get full session (including overnight) high/low values, then change the regular session interval. For example, on a 5-mninute chart, 1800-1655 will provide the high and low for the full daily session.") rth_session = time("1440",str.format("{0}:23456", input_rth), "America/New_York") // declare the variables var float rth_vwap = na var float rth_p = na var float rth_vol = na var float day_high = na var float day_low = na var float MidLineValue = na if rth_session if not rth_session[1] rth_p := hlc3 * volume rth_vol := volume rth_vwap := hlc3 day_high := high day_low := low day_low else rth_p := rth_p[1] + hlc3 * volume rth_vol := rth_vol[1] + volume rth_vwap := rth_p / rth_vol day_high := day_high[1] day_low := day_low [1] day_low if high > day_high day_high := high day_high if low < day_low day_low := low day_low MidLineValue := (day_high + day_low)/2 else rth_vwap := na MidLineValue := na // Plots rth_vwap_plot = plot(rth_session ? rth_vwap : na, title="rth_vwap", color = #00FFFFDD, linewidth=2, style=plot.style_linebr) rth_midline_plot = plot(rth_session ? MidLineValue : na, title="rth_midline",style=plot.style_linebr, linewidth=2, color=color.black)
Pivot Based Trailing Maxima & Minima [LuxAlgo]
https://www.tradingview.com/script/BEUgu3o1-Pivot-Based-Trailing-Maxima-Minima-LuxAlgo/
LuxAlgo
https://www.tradingview.com/u/LuxAlgo/
6,154
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("Pivot Based Trailing Maxima & Minima [LuxAlgo]", "LuxAlgo - Pivot Based Trailing Maxima & Minima", overlay = true, max_bars_back = 500, max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ length = input.int(24, minval = 2, maxval = 500) backpaint = input(false, tooltip = 'Backpainting offset displayed elements in the past. Disable backpainting to see real time information returned by the indicator.') //Style maxCss = input.color(color.teal, 'Trailing Maximum Color', group = 'Style') minCss = input.color(color.red , 'Trailing Minimum Color', group = 'Style') avgCss = input.color(#ff5d00 , 'Trailing Maximum Color', group = 'Style') bullFill = input.color(color.new(color.teal,80), 'Uptrend Area' , group = 'Style') bearFill = input.color(color.new(color.red,80) , 'Downtrend Area', group = 'Style') //-----------------------------------------------------------------------------} //Calculation //-----------------------------------------------------------------------------{ var float max = na var float min = na var offset = backpaint ? length : 0 ph = ta.pivothigh(length, length) pl = ta.pivotlow(length, length) if ph or pl max := high[length] min := low[length] max := math.max(high[offset], max) min := math.min(low[offset], min) avg = math.avg(max,min) //-----------------------------------------------------------------------------} //Non offset trailing max/min //-----------------------------------------------------------------------------{ n = bar_index max_prev = max min_prev = min avg_prev = avg max2 = max min2 = min fill_css = fixnan(ph ? bearFill : pl ? bullFill : na) if barstate.islast and backpaint //Delete previously set lines for line_object in line.all line.delete(line_object) //Loop trough calculation window for i = 0 to length-1 max2 := math.max(high[length-1-i], max_prev) min2 := math.min(low[length-1-i], min_prev) avg2 = math.avg(max2, min2) //Set lines line1 = line.new(n-(length-i), max_prev, n-(length-1-i), max2, color= maxCss) line2 = line.new(n-(length-i), min_prev, n-(length-1-i), min2, color= minCss) linefill.new(line1,line2,color.new(fill_css, 80)) line.new(n-(length-i), avg_prev, n-(length-1-i), avg2, color= avgCss) max_prev := max2 min_prev := min2 avg_prev := avg2 //-----------------------------------------------------------------------------} //Plots //-----------------------------------------------------------------------------{ plot1 = plot(max, 'Trailing Maximum' , ph or pl ? na : maxCss , 1 , plot.style_linebr , offset = -offset) plot2 = plot(min, 'Trailing Minimum' , ph or pl ? na : minCss , 1 , plot.style_linebr , offset = -offset) plot(avg, 'Average' , ph or pl ? na : avgCss , 1 , plot.style_linebr , offset = -offset) fill(plot1, plot2, ph or pl ? na : fill_css) //Labels plotshape(pl ? pl : na, "Pivot High" , shape.labelup , location.absolute , maxCss , -offset , text = "▲" , textcolor = color.white , size = size.tiny) plotshape(ph ? ph : na, "Pivot Low" , shape.labeldown , location.absolute , minCss , -offset , text = "▼" , textcolor = color.white , size = size.tiny) //-----------------------------------------------------------------------------}
CapX Core Signals
https://www.tradingview.com/script/SpahFc0D-CapX-Core-Signals/
CapovexIntech
https://www.tradingview.com/u/CapovexIntech/
65
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/ // © CapovexIntech //@version=5 indicator(title='Capovex Core', overlay=true,max_labels_count=500) // Bollinger Bands length = 20 src = close mult = 2 basis = ta.sma(src, length) dev = mult * ta.stdev(src, length) upper = basis + dev lower = basis - dev offset = 0 //input.int(0, "Offset", minval = -500, maxval = 500) plot(basis, 'Basis', color=color.new(#FF6D00, 0), offset=offset) p1 = plot(upper, 'Upper', color=color.new(#2962FF, 0), offset=offset) p2 = plot(lower, 'Lower', color=color.new(#2962FF, 0), offset=offset) fill(p1, p2, title='Background', color=color.rgb(33, 150, 243, 95)) // Stop Loss lengtha = 14 smoothing = input.string(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"],group= "Stop Loss") ma_function(source, lengtha) => switch smoothing "RMA" => ta.rma(source, lengtha) "SMA" => ta.sma(source, lengtha) "EMA" => ta.ema(source, lengtha) => ta.wma(source, lengtha) atr = ma_function(ta.tr(true), lengtha) x=input.float(2.0, title='Float Value',group= "Stop Loss") chigh = high - (atr*x) // buy sl clow = low + (atr*x) //sell sl // Moving Averages ema9 = ta.ema(close,9) ema14 = ta.ema(close,14) ema21 = ta.ema(close,21) uptrend = ema9 < low and ema14 < low // green downtrend = ema14 > high and ema21 > high // red sideway = ema9 < high and ema9 > low //Yellow sideway1 = ema21 > low and ema21 < high //Yellow // DEMA lengthd =100 srcd =close e1 = ta.ema(srcd, lengthd) e2 = ta.ema(e1, lengthd) dema = 2 * e1 - e2 length2 =200 src2 =close e12 = ta.ema(src2, length2) e22 = ta.ema(e12, length2) dema2 = 2 * e12 - e22 Bullish = dema > dema2 Bearish = dema < dema2 // SuperTrend //@version=5 atrPeriod = 10 factor = 1 [supertrend, direction] = ta.supertrend(factor, atrPeriod) upTrend1 = direction < 0 downTrend1 = direction > 0 // Volatility // ADX len = 14 th = 14 TrueRange = math.max(math.max(high-low, math.abs(high-nz(close[1]))), math.abs(low-nz(close[1]))) DirectionalMovementPlus = high-nz(high[1]) > nz(low[1])-low ? math.max(high-nz(high[1]), 0): 0 DirectionalMovementMinus = nz(low[1])-low > high-nz(high[1]) ? math.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 = math.abs(DIPlus-DIMinus) / (DIPlus+DIMinus)*100 ADX = ta.sma(DX, len) lowvol = ADX>0 and ADX<=20 //Low Volatile-red medvol = ADX>20 and ADX<=30 //Medium Volatile-green highvol = ADX>30 and ADX<=40 //High Volatile-yellow vhighvol = ADX>40 and ADX<=75 //Very High Volatile-red extremevol = ADX>75 and ADX<=100 //Extreme Volatile-red // Relative Strength Index (RSI) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) rsiLengthInput =14 rsiSourceInput = close maTypeInput ="SMA" maLengthInput =14 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)) rsiMA = ma(rsi, maLengthInput, maTypeInput) overbought = rsi > 75 oversold = rsi < 25 //MACD Formula fast_length = 12 slow_length = 26 signal_length = 9 // Calculating fast_ma = ta.ema(src, fast_length) slow_ma = ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = ta.ema(macd, signal_length) hist = macd - signal /// Table greenc = color.green redc = color.red yellowc = color.yellow ///// -- Table Inputs dash_loc = input.session("Bottom Right","Bank Dashboard Location" , options = ["Top Right","Bottom Right","Top Left","Bottom Left","Middle Right","Bottom Center"] , group = 'Dashboard Settings') text_size = input.session('Small',"Dashboard Size" , options = ["Tiny","Small","Normal","Large"] , group = 'Dashboard Settings') max = 120 min = 10 // Prepare table var table testTable = table.new(position.top_right, 5, 4, border_width=1) f_fillCell(_table, _column, _row, _title, _value, _bgcolor, _txtcolor) => _cellText = _title + '\n' + _value table.cell(_table, _column, _row, _cellText, bgcolor=_bgcolor, text_color=_txtcolor) // Draw table var bgcolorgreen = color.new(color.green, 0) var bgcolorred = color.new(color.red, 0) var bgcolorgray = color.new(color.gray, 0) var bgcolorblack = color.new(color.black, 100) var bgcoloryellow = color.new(color.yellow, 40) truncate(_number, _decimalPlaces) => _factor = math.pow(10, _decimalPlaces) int(_number * _factor) / _factor /// -------------- Table Start ------------------- txt_col = color.white var table_position = dash_loc == 'Top Left' ? position.top_left : dash_loc == 'Bottom Left' ? position.bottom_left : dash_loc == 'Middle Right' ? position.middle_right : dash_loc == 'Bottom Center' ? position.bottom_center : dash_loc == 'Top Right' ? position.top_right : position.bottom_right var table_text_size = text_size == 'Tiny' ? size.tiny : text_size == 'Small' ? size.small : text_size == 'Normal' ? size.normal : size.large var t = table.new(table_position,8,math.abs(max-min)+2, frame_color=txt_col, frame_width=0, border_color=txt_col, border_width=0) table.cell(t, 0, 0, "⚠️ Volalility", text_color = color.white, bgcolor = bgcolorblack, text_size = table_text_size) table.cell(t, 0, 1, "📈 Trend", text_color = color.white, bgcolor = bgcolorblack, text_size = table_text_size) table.cell(t, 0, 2, "💹 Direction", text_color = color.white, bgcolor = bgcolorblack, text_size = table_text_size) table.cell(t, 0, 3, "🏁 Strength", text_color = color.white, bgcolor = bgcolorblack, text_size = table_text_size) table.cell(t, 1, 0, lowvol ? 'Low': medvol ? 'Medium ' : highvol ? 'High ': vhighvol ? 'Very High' : extremevol ? 'Extreme' : "-" , bgcolor = bgcolorblack , text_color = lowvol ? color.red : medvol ? color.green : highvol ? color.green : color.red , text_size = table_text_size) table.cell(t, 1, 1, uptrend ? 'Up-Trend': downtrend ?'Down-Trend': (sideway or sideway1 )? 'Sideway ':"-" , bgcolor = bgcolorblack , text_color = uptrend ? greenc:downtrend?redc: (sideway or sideway1 )? yellowc : color.yellow , text_size=table_text_size) table.cell(t, 1, 2, Bullish?"Bullish" : "Bearish", bgcolor = bgcolorblack , text_color =Bullish ? color.green : color.red, text_size=table_text_size) table.cell(t, 1, 3, overbought ? "Overbought":oversold ? "Oversold":"Normal" , bgcolor = bgcolorblack, text_color = overbought ? redc:oversold ? greenc : color.white, text_size = table_text_size) // Signal Strategy longcondition = ta.crossover(rsi, rsiMA) and hist > hist[1] and upTrend1 and ADX > 20 shortcondition = ta.crossover(rsiMA, rsi) and hist[1] > hist and downTrend1 and ADX > 20 if (longcondition) a= label.new(bar_index, low,yloc= yloc.belowbar , text="Go long\n"+ "SL : "+ str.tostring(chigh,"#.#") + "\n" ,textcolor= color.green, style=label.style_label_up,color=color.new(color.green,100),size=size.normal) plotshape(longcondition , title="B", text='B', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny) if (shortcondition) a= label.new(bar_index, high,yloc= yloc.abovebar , text="Go Short\n"+ "SL : "+ str.tostring(clow,"#.#") + "\n" ,textcolor= color.red, style=label.style_label_up,color=color.new(color.red,100),size=size.normal) plotshape(shortcondition , title="S", text='S', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
Trend Trading with Currency Strength Meter
https://www.tradingview.com/script/0PSFlIYB-Trend-Trading-with-Currency-Strength-Meter/
exlux99
https://www.tradingview.com/u/exlux99/
335
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/ // © exlux99 //@version=5 indicator('Strong Weak Analysis', shorttitle='Currency Strength Analysis', overlay=true) // ----------------------------------------------------------------------------- // === INPUTS === fast = input.int(10, minval=1, maxval=50, title='TSI slow MA period', group="Parameters Inputs") slow = input.int(25, minval=2, maxval=50, title='TSI slow MA period', group="Parameters Inputs") src = input(hl2, title='Index Source', group="Parameters Inputs") length_ema = input.int(200, title="Baseline EMA Length", group="Parameters Inputs") out_ema = ta.ema(src, length_ema) // === /INPUTS === // === SERIES === // Current source from each indice USD = request.security('DXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) EUR = request.security('EXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) NZD = request.security('ZXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) AUD = request.security('AXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) JPY = request.security('JXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) CHF = request.security('SXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) CAD = request.security('CXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) GBP = request.security('BXY', timeframe.period, src, barmerge.gaps_off, barmerge.lookahead_on) // Use True Strength Index, to calculate Currency Strength. eur = ta.tsi(EUR, fast, slow) gbp = ta.tsi(GBP, fast, slow) jpy = ta.tsi(JPY, fast, slow) usd = ta.tsi(USD, fast, slow) aud = ta.tsi(AUD, fast, slow) cad = ta.tsi(CAD, fast, slow) chf = ta.tsi(CHF, fast, slow) nzd = ta.tsi(NZD, fast, slow) i_position = input.string(title = "Table Placement", defval = "Bottom Right", options = ["Top Right", "Middle Right", "Bottom Right"], group = "Table Characteristics") position = i_position == "Top Right" ? position.top_right : i_position == "Middle Right" ? position.middle_right : position.bottom_right i_w = 10 i_h = 3 i_text_size = input.string( title = "Text Size", defval = "Normal", options = ["Auto", "Tiny", "Small", "Normal", "Large", "Huge"], group = "Table Characteristics") text_size = i_text_size == "Normal" ? size.normal : i_text_size == "Auto" ? size.auto : i_text_size == "Auto" ? size.auto : i_text_size == "Tiny" ? size.tiny : i_text_size == "Small" ? size.small : i_text_size == "Large" ? size.large : size.huge var table currencyTable = table.new(position, 2, 9, border_width = 1) aud_green = aud > cad and aud > chf and aud > eur and aud > gbp and aud > jpy and aud > nzd and aud > usd aud_red = aud < cad and aud < chf and aud < eur and aud < gbp and aud < jpy and aud < nzd and aud < usd cad_green = cad > aud and cad > chf and cad > eur and cad > gbp and cad > jpy and cad > nzd and cad > usd cad_red = cad < aud and cad < chf and cad < eur and cad < gbp and cad < jpy and cad < nzd and cad < usd chf_green = chf > cad and chf > aud and chf > eur and chf > gbp and chf > jpy and chf > nzd and chf > usd chf_red = chf < cad and chf < aud and chf < eur and chf < gbp and chf < jpy and chf < nzd and chf < usd eur_green = eur > chf and eur > cad and eur > aud and eur > gbp and eur > jpy and eur > nzd and eur > usd eur_red = eur < chf and eur < cad and eur < aud and eur < gbp and eur < jpy and eur < nzd and eur < usd gbp_green = gbp > eur and gbp > chf and gbp > cad and gbp > aud and gbp > jpy and gbp > nzd and gbp > usd gbp_red = gbp < eur and gbp < chf and gbp < cad and gbp < aud and gbp < jpy and gbp < nzd and gbp < usd jpy_green = jpy > gbp and jpy > eur and jpy > chf and jpy > cad and jpy > aud and jpy > nzd and jpy > usd jpy_red = jpy < gbp and jpy < eur and jpy < chf and jpy < cad and jpy < aud and jpy < nzd and jpy < usd nzd_green = nzd > jpy and nzd > gbp and nzd > eur and nzd >chf and nzd > cad and nzd > aud and nzd > usd nzd_red = nzd < jpy and nzd < gbp and nzd < eur and nzd <chf and nzd < cad and nzd < aud and nzd < usd usd_green = usd > nzd and usd > jpy and usd > gbp and usd > eur and usd > chf and usd > cad and usd > aud usd_red = usd < nzd and usd < jpy and usd < gbp and usd < eur and usd < chf and usd< cad and usd < aud table.cell(currencyTable, 0, 0, "CURRENCY", bgcolor = color.new(color.yellow,50), text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 1, "AUD", bgcolor = aud_green? color.new(color.green,25) : aud_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 2, "CAD", bgcolor = cad_green? color.new(color.green,25) : cad_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 3, "CHF", bgcolor = chf_green? color.new(color.green,25) : chf_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 4, "EUR", bgcolor = eur_green? color.new(color.green,25) : eur_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 5, "GBP", bgcolor = gbp_green? color.new(color.green,25) : gbp_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 6, "JPY", bgcolor = jpy_green? color.new(color.green,25) : jpy_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 7, "NZD", bgcolor = nzd_green? color.new(color.green,25) : nzd_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 0, 8, "USD", bgcolor = usd_green? color.new(color.green,25) : usd_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 0, "Strength Power TSI",bgcolor= color.new(color.yellow,50), text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 1, str.tostring(aud), bgcolor = aud_green? color.new(color.green,25) : aud_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 2, str.tostring(cad), bgcolor = cad_green? color.new(color.green,25) : cad_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 3, str.tostring(chf), bgcolor = chf_green? color.new(color.green,25) : chf_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 4, str.tostring(eur), bgcolor = eur_green? color.new(color.green,25) : eur_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 5, str.tostring(gbp), bgcolor = gbp_green? color.new(color.green,25) : gbp_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 6, str.tostring(jpy), bgcolor = jpy_green? color.new(color.green,25) : jpy_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 7, str.tostring(nzd), bgcolor = nzd_green? color.new(color.green,25) : nzd_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) table.cell(currencyTable, 1, 8, str.tostring(usd), bgcolor = usd_green? color.new(color.green,25) : usd_red? color.new(color.red,25) : color.blue, text_color = color.new(color.silver, 0), width = i_w, height = i_h, text_size = text_size) plot(out_ema)
Relative Strength Index - Divergences, Stoch, Reverse Stoch
https://www.tradingview.com/script/JLAsY3AR-Relative-Strength-Index-Divergences-Stoch-Reverse-Stoch/
CryptoTechGuy1
https://www.tradingview.com/u/CryptoTechGuy1/
68
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // This is not my code, it's just aggregation and some tweaks // Thanks to ©JayTradingCharts and ©mohanee for the RSI Divergences code // Thanks to BApig - Motgench, balipour and Wugamlo for the reverse stoch code // Changes: // 1. Add option to calc divs based on close or wicks or both (RSI is close based) // 2. Add pivots (marking local high/low) // 3. Update to Pine v5 // 4. Cleanup of unused code //@version=5 indicator ( 'Relative Strength Index - Divergences, Stoch, Reverse Stoch', 'RSI Div + (Re)Stoch', overlay = false) /////////////////////////////////////////////////////////////////////////////// // RSI len = input.int(14, minval=1, title="RSI Length") ob = input.int(70, title="Overbought", minval=50, maxval=100) os = input.int(30, title="Oversold", minval=0, maxval=50) ob_color = color.new(color.aqua, 40) os_color = color.new(color.purple, 40) h_color = color.new(color.gray, 40) rsi = ta.rsi(close, len) obLine1 = hline(ob, title="Overbought", color=ob_color, linestyle=hline.style_dashed) osLine1 = hline(os, title="Oversold", color=os_color, linestyle=hline.style_dashed) obLine2 = hline(80, color=ob_color, linestyle=hline.style_dotted) osLine2 = hline(20, color=os_color, linestyle=hline.style_dotted) fill(obLine1, obLine2, color=color.new(color.aqua, 95)) fill(osLine1, osLine2, color=color.new(color.purple, 95)) midline = hline(50, color=h_color, linestyle=hline.style_dotted) band1 = hline(100, color=h_color, linestyle=hline.style_dotted) band2 = hline(0, color=h_color, linestyle=hline.style_dotted) plot(rsi, title="RSI", color=(rsi > ob or rsi < os ? color.new(#f29999, 0) : color.new(color.silver, 0)), linewidth=2) /////////////////////////////////////////////////////////////////////////////// // DIVS plotHidden = input.bool(true, title="Show Hidden", group="Divergences") lbR = input.int(4, title="Pivot Right", minval=1, group="Divergences") lbL = input.int(4, title="Pivot Left", minval=1, group="Divergences") rangeUpper = input.int(50, title="Range Max", minval=1, group="Divergences") rangeLower = input.int(1, title="Range Min", minval=1, group="Divergences") // control if divs are calculated based on 'Close' or 'Wick' or 'Close or Wicks' (both) wicks = input.string("Close or Wicks", title="Close/Wicks", options=["Close", "Wicks","Close or Wicks"], group = "Divergences") closeLow = (wicks == "Wicks") ? low[lbR] : close[lbR] closeHigh = (wicks == "Wicks") ? high[lbR] : close[lbR] plFound = na(ta.pivotlow(rsi, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(rsi, lbL, lbR)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper bearColor = color.new(color.red, 10) bullColor = color.new(color.green, 10) hiddenBullColor = color.new(color.aqua, 10) hiddenBearColor = color.new(color.fuchsia, 10) textColor = color.white //------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low oscHL = rsi[lbR] > ta.valuewhen(plFound, rsi[lbR], 1) and _inRange(plFound[1]) // Price: Lower Low priceLL = closeLow < ta.valuewhen(plFound, closeLow, 1) if(wicks == "Close or Wicks") priceLL := low[lbR] < ta.valuewhen(plFound, low[lbR], 1) or close[lbR] < ta.valuewhen(plFound, close[lbR], 1) bullCond = priceLL and oscHL and plFound plot( plFound ? rsi[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=2, color=(bullCond ? bullColor : na) ) plotshape( bullCond ? rsi[lbR] : na, offset=-lbR, title="Regular Bullish Label", style=shape.labelup, location=location.absolute, color=bullColor, size=size.tiny ) //------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low oscLL = rsi[lbR] < ta.valuewhen(plFound, rsi[lbR], 1) and _inRange(plFound[1]) // Price: Higher Low priceHL = closeLow > ta.valuewhen(plFound, closeLow, 1) if(wicks == "Close or Wicks") priceHL := low[lbR] > ta.valuewhen(plFound, low[lbR], 1) or close[lbR] > ta.valuewhen(plFound, close[lbR], 1) hiddenBullCond = plotHidden and priceHL and oscLL and plFound plot( plFound ? rsi[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCond ? hiddenBullColor : na) ) plotshape( hiddenBullCond ? rsi[lbR] : na, offset=-lbR, title="Hidden Bullish Label", style=shape.labelup, location=location.absolute, color=hiddenBullColor, size=size.tiny ) //------------------------------------------------------------------------------ // Regular Bearish // Osc: Lower High oscLH = rsi[lbR] < ta.valuewhen(phFound, rsi[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = closeHigh > ta.valuewhen(phFound, closeHigh, 1) if(wicks == "Close or Wicks") priceHH := high[lbR] > ta.valuewhen(phFound, high[lbR], 1) or close[lbR] > ta.valuewhen(phFound, close[lbR], 1) bearCond = priceHH and oscLH and phFound plot( phFound ? rsi[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? bearColor : na) ) plotshape( bearCond ? rsi[lbR] : na, offset=-lbR, title="Regular Bearish Label", style=shape.labeldown, location=location.absolute, color=bearColor, size=size.tiny ) //------------------------------------------------------------------------------ // Hidden Bearish // Osc: Higher High oscHH = rsi[lbR] > ta.valuewhen(phFound, rsi[lbR], 1) and _inRange(phFound[1]) // Price: Lower High priceLH = closeHigh < ta.valuewhen(phFound, closeHigh, 1) if(wicks == "Close or Wicks") priceLH := high[lbR] < ta.valuewhen(phFound, high[lbR], 1) or close[lbR] < ta.valuewhen(phFound, close[lbR], 1) hiddenBearCond = plotHidden and priceLH and oscHH and phFound plot( phFound ? rsi[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? hiddenBearColor : na) ) plotshape( hiddenBearCond ? rsi[lbR] : na, offset=-lbR, title="Hidden Bearish Label", style=shape.labeldown, location=location.absolute, color=hiddenBearColor, size=size.tiny ) //------------------------------------------------------------------------------ // Pivots pivhigh = ta.pivothigh(rsi, math.max(lbR, 5), lbR) pivlow = ta.pivotlow(rsi, math.max(lbR, 5), lbR) pivCond = bullCond or hiddenBullCond or bearCond or hiddenBearCond plotshape( pivCond ? na : pivhigh+2, offset=-lbR, title="Pivot High", style=shape.triangledown, location=location.absolute, color=color.silver, size=size.tiny ) plotshape( pivCond ? na : pivlow-2, offset=-lbR, title="Pivot Low", style=shape.triangleup, location=location.absolute, color=color.silver, size=size.tiny ) //------------------------------------------------------------------------------ // Alerts alertcondition(bullCond, title="Bull", message="Regular Bull Div {{ticker}} XXmin") alertcondition(bearCond, title="Bear", message="Regular Bear Div {{ticker}} XXmin") alertcondition(hiddenBullCond, title="H Bull", message="Hidden Bull Div {{ticker}} XXmin") alertcondition(hiddenBearCond, title="H Bear", message="Hidden Bear Div {{ticker}} XXmin") /////////////////////////////////////////////////////////////////////////////// //Stoch RSI showsrsi = input.bool(true, title="Show Stoch RSI", group="Stochastic RSI") smoothK = input.int(3, minval=1, group="Stochastic RSI") smoothD = input.int(3, minval=1, group="Stochastic RSI") lenStoch = input.int(14, minval=1, group="Stochastic RSI") k = ta.sma(ta.stoch(rsi, rsi, rsi, lenStoch), smoothK) d = ta.sma(k, smoothD) plot(showsrsi ? k : na, title="K", color=color.new(color.blue, 30), linewidth=2) plot(showsrsi ? d : na, title="D", color=color.new(color.purple, 30), linewidth=2) /////////////////////////////////////////////////////////////////////////////// // Reverse Stoch showresrsi = input.bool(true, title="Show Reverse Stoch RSI", group="Reverse Stochastic") Klen = input.int(14, "K", minval = 2, group="Reverse Stochastic") D = input.int(3, "D", minval = 1, group="Reverse Stochastic") E = input.string("Forecasted KD", title="KD Estimation", options=["Current Dynamic KD", "Current Static KD","Forecasted KD"], group="Reverse Stochastic") smooth = input.int(3, "Smooth", minval = 1, group="Reverse Stochastic") sm = input.bool(true, "Stoch Cross Smoothing", group="Reverse Stochastic") slen = input.int(3, "  Smoothing Length", group="Reverse Stochastic") dec = input.int(3, "Decimals", minval = 0, maxval = 10, group="Reverse Stochastic") ss(Series, Period) => // Super Smoother Function // period = input(8, "Super Smoother Period", input.float, minval=2.0, step=0.5) var PI = 2.0 * math.asin(1.0) var SQRT2 = math.sqrt(2.0) lambda = PI * SQRT2 / Period a1 = math.exp(-lambda) coeff2 = 2.0 * a1 * math.cos(lambda) coeff3 = - math.pow(a1, 2.0) coeff1 = 1.0 - coeff2 - coeff3 filt1 = 0.0 filt1 := coeff1 * (Series + nz(Series[1])) * 0.5 + coeff2 * nz(filt1[1]) + coeff3 * nz(filt1[2]) filt1 Round( _val, _decimals) => // Rounds _val to _decimals places. _p = math.pow(10,_decimals) math.round(math.abs(_val)*_p)/_p*math.sign(_val) x = ta.stoch(close,high,low,Klen)*0.01 x2 = ta.sma(x,smooth) x3 = ta.sma(x2,D) C(level, len, smooth) => if smooth == 1 C = (ta.highest(high,len) - ta.lowest(low,len))*level + ta.lowest(low,len) else sum = 0.0 for i = 1 to smooth -1 sum := x[i] + sum a = smooth*level - sum C = a * (ta.highest(high,len) - ta.lowest(low,len)) + ta.lowest(low,len) C2(len, smooth) => float sumK = 0 for i = 1 to smooth-1 sumK := sumK + x[i] float sumKS = 0 for i = 1 to D-1 sumKS := sumKS + x2[i] C2 = ((((sumKS*smooth)+sumK-(sumK*D))*(ta.highest(high,len)-ta.lowest(low,len)))/((D-1)))+ta.lowest(low,len) Cf(level, len, smooth) => if smooth == 1 Cf = (ta.highest(high,len) - ta.lowest(low,len))*level + ta.lowest(low,len) else sum = 0.0 for i = 0 to smooth -2 sum := x[i] + sum a = smooth*level - sum Cf = a * (ta.highest(high,len-1) - ta.lowest(low,len-1)) + ta.lowest(low,len-1) stp(len) => (close - ta.lowest(low,len-1))/(ta.highest(high,len-1) - ta.lowest(low,len-1)) kk = ta.stoch(close, high, low, len)*0.01 X = stp(len) xk = 100* ta.sma(kk,smooth) k1(len)=> sum = 0.0 for i = 0 to len - 2 sum := kk[i] + sum mean = (sum + X) /len X2 = 100*k1(smooth) d1(len)=> sum = 0.0 for i = 0 to len - 2 sum := xk[i] + sum mean = (sum + X2)/len x3p = d1(D)*0.01 ccks = ss(C(x3,Klen,smooth),slen) cck = C(x3,Klen,smooth) ccks2 = ss(C2(Klen,smooth),slen) cck2 = C2(Klen,smooth) cfks = ss(Cf(x3p,Klen,smooth),slen) cfk = Cf(x3p,Klen,smooth) float Cross = na if (E == "Current Dynamic KD") // Close one day ago Cross := sm? ccks : cck if (E == "Current Static KD") Cross := sm ? ccks2 : cck2 if (E == "Forecasted KD") Cross := sm ? cfks : cfk PnL_Label = label.new( showresrsi ? bar_index : na, 50, text=("Crossing " + (x3 > x2 ? "UP" : "DOWN") + ": " + str.tostring(Round(Cross,dec))), color=color.new(#000000, 50), textcolor=color.white, style=label.style_label_left, yloc=yloc.price, xloc=xloc.bar_index, size=size.normal ) label.delete(PnL_Label[1]) ///////////////////////////////////////////////////////////////////////////////
T3 Super Guppy
https://www.tradingview.com/script/Kh9mgNHM-T3-Super-Guppy/
waifuGod
https://www.tradingview.com/u/waifuGod/
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/ // © waifuGod //@version=5 indicator(title = "T3 Super Guppy",shorttitle = "T3SuperGuppy by WaifuMaxi" ,overlay = true) // # ============================ Inputs ============================================ # dis_type = input.string("Compact",title = "Display Type", options = ["Compact","Full"], tooltip ="Compact will only show half the t3 MA, but dosent affect calculation") const = input.float(0.7,title = "Constant") show1 = input.bool(defval = false , title = "show only one colour", tooltip = "to make colour constant, uses base colour", group = "colour settings") upCol = input.color(#205bfc,title ="T3 Up Trend Colour",group ="colour settings") downCol = input.color(#f12838,title ="T3 Down Trend Colour",group ="colour settings") baseCol = input.color(#e91e63,title ="T3 Base Colour",group ="colour settings") source = close // # ========================== Functions =========================================== # t3_calc(_src, _len, _const) => ema1 = ta.ema(_src, _len) ema2 = ta.ema(ema1, _len) ema3 = ta.ema(ema2, _len) ema4 = ta.ema(ema3, _len) ema5 = ta.ema(ema4, _len) ema6 = ta.ema(ema5, _len) b = _const c1 = -b * b * b c2 = 3 * b * b + 3 * b * b * b c3 = -6 * b * b - 3 * b - 3 * b * b * b c4 = 1 + 3 * b + b * b * b + 3 * b * b T3_val = c1 * ema6 + c2 * ema5 + c3 * ema4 + c4 * ema3 T3_val // use to calculate transparency step based on display type transp_multi(_step)=> step = dis_type == "Compact" ? _step : _step + 1 stepVal = dis_type == "Compact" ? 5 : 2 mltp = 100 - (step * stepVal) tval = mltp < 0 ? 100 : mltp tval // to calculate crosses to determine colour gradienti colour_step(_arr)=> counter = 0 for i = 0 to (array.size(id = _arr) - 2) bool c_type = array.get(_arr, i) > array.get(_arr,i + 1) if c_type counter := counter + 1 counter // # ========================== T3 MA =============================================== # // fast t3 T1 = t3_calc(source, 3,const) T2 = t3_calc(source, 6,const) T3 = t3_calc(source, 9,const) T4 = t3_calc(source, 12,const) T5 = t3_calc(source, 15,const) T6 = t3_calc(source, 18,const) T7 = t3_calc(source, 21,const) // slow t3 T8 = t3_calc(source, 24,const) T9 = t3_calc(source, 27,const) T10 = t3_calc(source, 30,const) T11 = t3_calc(source, 33,const) T12 = t3_calc(source, 36,const) T13 = t3_calc(source, 39,const) T14 = t3_calc(source, 42,const) T15 = t3_calc(source, 45,const) T16 = t3_calc(source, 48,const) T17 = t3_calc(source, 51,const) T18 = t3_calc(source, 54,const) T19 = t3_calc(source, 57,const) T20 = t3_calc(source, 60,const) // # ========================== arrays to store t3 vals ========================================= # T3Arr = array.from(T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20) // # ========================== Colour Rules ========================================= # t_val = colour_step(T3Arr) col_g = color.from_gradient(value = t_val, bottom_value = 0 , top_value = 19 , bottom_color = downCol, top_color = upCol) finalCol = show1 ? baseCol : col_g // # =========================== Plots =============================================== # bool plotBool = dis_type == "Compact" // fast t1l =plot(T1, color=color.new(finalCol,98), editable = false ) t2l =plot(T2, color=color.new(finalCol,98), editable = false) t3l =plot(T3, color=color.new(finalCol,transp_multi(1)), editable = false) t4l =plot(T4, color=color.new(finalCol,transp_multi(2)), editable = false) t5l =plot(T5, color=color.new(finalCol,transp_multi(3)), editable = false) t6l =plot(T6, color=color.new(finalCol,transp_multi(4)), editable = false) t7l =plot(T7, color=color.new(finalCol,transp_multi(5)), editable = false) //slow t8l =plot(T8, color=color.new(finalCol,transp_multi(6)), editable = false) t9l =plot(T9, color=color.new(finalCol,transp_multi(7)), editable = false) t10l=plot(T10, color=color.new(finalCol,transp_multi(8)), editable = false) t11l =plot(plotBool ? na : T11, color=color.new(finalCol,transp_multi(9)), editable = false) t12l =plot(plotBool ? na : T12, color=color.new(finalCol,transp_multi(10)), editable = false) t13l =plot(plotBool ? na : T13, color=color.new(finalCol,transp_multi(11)), editable = false) t14l =plot(plotBool ? na : T14, color=color.new(finalCol,transp_multi(12)), editable = false) t15l =plot(plotBool ? na : T15, color=color.new(finalCol,transp_multi(13)), editable = false) t16l =plot(plotBool ? na : T16, color=color.new(finalCol,transp_multi(14)), editable = false) t17l =plot(plotBool ? na : T17, color=color.new(finalCol,transp_multi(15)), editable = false) t18l =plot(plotBool ? na : T18, color=color.new(finalCol,transp_multi(16)), editable = false) t19l =plot(plotBool ? na : T19, color=color.new(finalCol,transp_multi(17)), editable = false) t20l =plot(plotBool ? na : T20, color=color.new(finalCol,transp_multi(18)), editable = false) // # =========================== Fills =============================================== # fill(t1l,t2l, color.new(finalCol,98)) fill(t2l,t3l, color.new(finalCol,transp_multi(1))) fill(t3l,t4l, color.new(finalCol,transp_multi(2))) fill(t4l,t5l, color.new(finalCol,transp_multi(3))) fill(t5l,t6l, color.new(finalCol,transp_multi(4))) fill(t6l,t7l, color.new(finalCol,transp_multi(5))) fill(t7l,t8l, color.new(finalCol,transp_multi(6))) fill(t8l,t9l, color.new(finalCol,transp_multi(7))) fill(t9l,t10l, color.new(finalCol,transp_multi(8))) fill(t10l,t11l, color.new(finalCol,transp_multi(9))) fill(t11l,t12l, color.new(finalCol,transp_multi(10))) fill(t12l,t13l, color.new(finalCol,transp_multi(11))) fill(t13l,t14l, color.new(finalCol,transp_multi(12))) fill(t14l,t15l, color.new(finalCol,transp_multi(13))) fill(t15l,t16l, color.new(finalCol,transp_multi(14))) fill(t16l,t17l, color.new(finalCol,transp_multi(15))) fill(t17l,t18l, color.new(finalCol,transp_multi(16))) fill(t18l,t19l, color.new(finalCol,transp_multi(17))) fill(t19l,t20l, color.new(finalCol,transp_multi(18)))
4c ATR Threshold
https://www.tradingview.com/script/gucMqCHN-4c-ATR-Threshold/
FourC
https://www.tradingview.com/u/FourC/
18
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © FourC //This script paints the chart background color when the ATR is below the user defined minimum. A good visual that can help to keep you out of trades that require a certain ATR or greater. //@version=5 indicator(title="4c ATR Threshold", shorttitle="4C ATR Paint", overlay=true, timeframe="", timeframe_gaps=true) source = input.source(title="Source", defval=close) length = input.int(title="Length", defval=14, minval=1) atrmin = input.float(title="ATR Minimum", defval=2, step=0.1) smoothing = input.string(title="Smoothing", defval="RMA", 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) atrref = ma_function(ta.tr(true), length) bgcolor(atrref < atrmin ? color.rgb(255,0,0,95) : na)
VWAP with 7EMA with Zones
https://www.tradingview.com/script/EjmX9hPM-VWAP-with-7EMA-with-Zones/
Bishnujyoti
https://www.tradingview.com/u/Bishnujyoti/
29
study
4
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Bishnujyoti //@version=4 study(title="VWAP with 7EMA with Zones",shorttitle="Vulture",overlay=true) //Daily zones daily = input(title = "Daily",type = input.bool,defval=true) dopen = security(syminfo.tickerid,'D',open,barmerge.gaps_off,barmerge.lookahead_on) dayrange=(high-low) dcol = color.red r1 = security(syminfo.tickerid,'D',dayrange) r2 = security(syminfo.tickerid, 'D', dayrange[1]) r3 = security(syminfo.tickerid, 'D', dayrange[2]) r4= security(syminfo.tickerid, 'D', dayrange[3]) r5= security(syminfo.tickerid, 'D', dayrange[4]) r6 = security(syminfo.tickerid, 'D', dayrange[5]) r7 = security(syminfo.tickerid, 'D', dayrange[6]) r8 = security(syminfo.tickerid, 'D', dayrange[7]) r9= security(syminfo.tickerid, 'D', dayrange[8]) r10= security(syminfo.tickerid, 'D', dayrange[9]) adr_10 = (r1+r2+r3+r4+r5+r6+r7+r8+r9+r10) /10 adr_9 = (r1+r2+r3+r4+r5+r6+r7+r8+r9) /9 adr_8 = (r1+r2+r3+r4+r5+r6+r7+r8) /8 adr_7 = (r1+r2+r3+r4+r5+r6+r7) /7 adr_6 = (r1+r2+r3+r4+r5+r6) /6 adr_5 = (r1+r2+r3+r4+r5) /5 adr_4 = (r1+r2+r3+r4) /4 adr_3 = (r1+r2+r3) /3 adr_2= (r1+r2)/2 adr_1 = r1 adrhigh10 = dopen+(adr_10/2) adrhigh5 = dopen+(adr_5/2) adrlow5 = dopen-(adr_5/2) adrlow10 = dopen-(adr_10/2) dayh5 = plot( daily? adrhigh5 : na, color = dcol) dayh10 = plot( daily? adrhigh10 : na, color = dcol) dayl5 = plot( daily? adrlow5 : na, color = dcol) dayl10 = plot( daily? adrlow10 : na, color = dcol) fill(dayh5,dayh10 , color=dcol) fill(dayl5,dayl10,color=dcol) //Weekly zones weekly = input(title = "Weekly",type = input.bool,defval=true) wopen = security(syminfo.tickerid,'W',open,barmerge.gaps_off,barmerge.lookahead_on) weekrange=(high-low) wcol = color.blue wr1 = security(syminfo.tickerid,'W',weekrange) wr2 = security(syminfo.tickerid, 'W', weekrange[1]) wr3 = security(syminfo.tickerid, 'W', weekrange[2]) wr4= security(syminfo.tickerid, 'W', weekrange[3]) wr5= security(syminfo.tickerid, 'W', weekrange[4]) wr6 = security(syminfo.tickerid, 'W', weekrange[5]) wr7 = security(syminfo.tickerid, 'W', weekrange[6]) wr8 = security(syminfo.tickerid, 'W', weekrange[7]) wr9= security(syminfo.tickerid, 'W', weekrange[8]) wr10= security(syminfo.tickerid, 'W', weekrange[9]) awr_10 = (wr1+wr2+wr3+wr4+wr5+wr6+wr7+wr8+wr9+wr10) /10 awr_9 = (wr1+wr2+wr3+wr4+wr5+wr6+wr7+wr8+wr9) /9 awr_8 = (wr1+wr2+wr3+wr4+wr5+wr6+wr7+wr8) /8 awr_7 = (wr1+wr2+wr3+wr4+wr5+wr6+wr7) /7 awr_6 = (wr1+wr2+wr3+wr4+wr5+wr6) /6 awr_5 = (wr1+wr2+wr3+wr4+wr5) /5 awr_4 = (wr1+wr2+wr3+wr4) /4 awr_3 = (wr1+wr2+wr3) /3 awr_2= (wr1+wr2)/2 awr_1 = wr1 awrhigh10 = wopen+(awr_10/2) awrhigh5 = wopen+(awr_5/2) awrlow5 = wopen-(awr_5/2) awrlow10 = wopen-(awr_10/2) weekh5 = plot( weekly? awrhigh5 : na, color = wcol) weekh10 = plot( weekly? awrhigh10 : na, color = wcol) weekl5 = plot( weekly? awrlow5 : na, color = wcol) weekl10 = plot( weekly? awrlow10 : na, color = wcol) fill(weekh5,weekh10,color=wcol) fill(weekl5,weekl10,color=wcol) //Monthly zones monthly = input(title = "Monthly",type = input.bool,defval=true) mopen = security(syminfo.tickerid,'M',open,barmerge.gaps_off,barmerge.lookahead_on) monthrange=(high-low) mcol = color.green mr1 = security(syminfo.tickerid,'M',monthrange) mr2 = security(syminfo.tickerid, 'M', monthrange[1]) mr3 = security(syminfo.tickerid, 'M', monthrange[2]) mr4= security(syminfo.tickerid, 'M', monthrange[3]) mr5= security(syminfo.tickerid, 'M', monthrange[4]) mr6 = security(syminfo.tickerid, 'M', monthrange[5]) mr7 = security(syminfo.tickerid, 'M', monthrange[6]) mr8 = security(syminfo.tickerid, 'M', monthrange[7]) mr9= security(syminfo.tickerid, 'M', monthrange[8]) mr10= security(syminfo.tickerid, 'M', monthrange[9]) amr_10 = (mr1+mr2+mr3+mr4+mr5+mr6+mr7+mr8+mr9+mr10) /10 amr_9 = (mr1+mr2+mr3+mr4+mr5+mr6+mr7+mr8+mr9) /9 amr_8 = (mr1+mr2+mr3+mr4+mr5+mr6+mr7+mr8) /8 amr_7 = (mr1+mr2+mr3+mr4+mr5+mr6+mr7) /7 amr_6 = (mr1+mr2+mr3+mr4+mr5+mr6) /6 amr_5 = (mr1+mr2+mr3+mr4+mr5) /5 amr_4 = (mr1+mr2+mr3+mr4) /4 amr_3 = (mr1+mr2+mr3) /3 amr_2= (mr1+mr2)/2 amr_1 = mr1 amrhigh10 = mopen+(amr_10/2) amrhigh5 = mopen+(amr_5/2) amrlom5 = mopen-(amr_5/2) amrlom10 = mopen-(amr_10/2) monthh5 = plot( monthly? amrhigh5 : na, color = mcol) monthh10 = plot( monthly? amrhigh10 : na, color = mcol) monthl5 = plot( monthly? amrlom5 : na, color = mcol) monthl10 = plot( monthly? amrlom10 : na, color = mcol) fill(monthh5,monthh10,color=mcol) fill(monthl5,monthl10,color=mcol) EMA5 = ema(close, 5) EMA10 = ema(close, 10) EMA20 = ema(close, 20) EMA30 = ema(close, 30) EMA50 = ema(close, 50) EMA100 = ema(close, 100) EMA200 = ema(close, 200) plot(EMA5, color=color.red, title="EMA5", linewidth=2) plot(EMA10, color=color.blue, title="EMA10", linewidth=2) plot(EMA20, color=#FFD700, title="EMA20", linewidth=2) plot(EMA30, color=color.orange, title="EMA30", linewidth=2) plot(EMA50, color=color.green, title="EMA50", linewidth=2) plot(EMA100, color=color.purple, title="EMA100", linewidth=2) plot(EMA200, color=color.fuchsia, title="EMA200", linewidth=2) log = input(true, "Log") mvLen = input(10, "MVWAP Length", minval=1) mgLen = input(11, " Length", minval=1) showX = input(true, "Show Crosses") src = log ? log(vwap) : vwap //makes it faster mg = 0.0 mg := na(mg[1]) ? ema(src, mgLen) : mg[1] + (src - mg[1]) / (mgLen * pow(src/mg[1], 4)) mgFinal = log ? exp(mg) : mg plot(mgFinal, "ADVANCED VWAP", #f6546a) mv = log ? exp(ema(src, mvLen)) : ema(src, mvLen) plot(mv, "EMA VWAP", #0079cf, 1) xUp = mv > mgFinal xDn = mv < mgFinal plotshape(showX and xUp and xUp != xUp[1] ? close : na, "Uptrend", shape.circle, location.top, #0079cf, size=size.tiny) plotshape(showX and xDn and xDn != xDn[1] ? close : na, "Downtrend", shape.xcross, location.top, #f6546a, size=size.tiny)
4C Moving Avg Cloud
https://www.tradingview.com/script/YJl6aCX7-4C-Moving-Avg-Cloud/
FourC
https://www.tradingview.com/u/FourC/
107
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/ // © FourC //@version=5 //This indicator plots 2 moving averages with a cloud filling the area between the two. //Features the ability to choose the average type for each of the moving averages. //Also includes moving average slope direction coloring. //Some aspects of this indicator were adapted by a few other available indicators by 4C. indicator(title='4C Moving Avg Cloud', shorttitle='4C MA Cloud', overlay=true) source = input.source(close, "Source") lengthshort = input.int(21, minval=1, title='Short Avg Length') shortavgtype = input.string(title="Short Avg Type", defval="EMA", options=["SMA", "EMA", "WMA", "RMA"]) ma_function1(source, length) => switch shortavgtype "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "WMA" => ta.wma(source, length) lengthlong = input.int(200, minval=1, title='Long Avg Length') longavgtype = input.string(title="Long Avg Type", defval="SMA", options=["SMA", "EMA", "WMA", "RMA"]) ma_function2(source, length) => switch longavgtype "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "WMA" => ta.wma(source, length) showthirdavg = input(title='Show Third Moving Avg?', defval=true) thirdavglength = input.int(8, minval=1, title='Third Avg Length') thirdavgtype = input.string(title="Third Avg Type", defval="EMA", options=["SMA", "EMA", "WMA", "RMA"]) ma_function3(source, length) => switch thirdavgtype "RMA" => ta.rma(source, length) "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "WMA" => ta.wma(source, length) mashort = ma_function1(source, lengthshort) malong = ma_function2(source, lengthlong) thirdma = ma_function3(source, thirdavglength) mashortcolor = mashort >= mashort[1] ? color.rgb(0,255,0) : color.rgb(255,0,0) mashortline = plot(mashort, color=mashortcolor, linewidth=2, title='Short Avg') malongcolor = malong >= malong[1] ? color.fuchsia : color.rgb(255,0,0) malongline = plot(malong, color=malongcolor, linewidth=3, title='Long Avg') thirdmacolor = thirdma >= thirdma[1] ? color.rgb(0,255,255) : color.rgb(255,0,0) thirdmaline = plot(showthirdavg ? thirdma : na, color=thirdmacolor, linewidth=1, title='Third Avg') //CLOUD// cloudcolor = mashort >= malong ? color.new(color.green,85) : color.new(color.red,85) showstate = input(title='Show Wide State Cloud Shading?', defval=true) wide = input(title='Wide State Multiplier', defval=8) [kcmiddle, kcupper, kclower] = ta.kc(close, lengthlong, wide) widestatecolor = showstate and mashort >= kcupper or mashort <= kclower and showstate ? color.new(color.blue,85) : cloudcolor fill(mashortline, malongline, color=widestatecolor, title='MA Cloud')
VIX Range
https://www.tradingview.com/script/DnCO9jly-VIX-Range/
ajithcpas
https://www.tradingview.com/u/ajithcpas/
104
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/ // © ajithcpas // // This indicator shows the daily expected trading range of the instrument. // The vix top and bottom denotes the range. It is calculated based on the // volatility index selected (NSE:India VIX is used by default). // Also it shows vix center, developing vix top, center and bottom for the next trading day. // // Non-directional option strategies (like straddle, strangle) can be performed // based on the expected trading range. //@version=5 indicator("VIX Range", overlay=true) volSymbol = input.symbol("NSE:INDIAVIX", "Volatility Index") timeFrame = input.string(title="Timeframe", defval="Auto", options=["Auto", "Daily", "Weekly", "Monthly"]) getResolution() => resolution = "M" if timeFrame == "Auto" if timeframe.isintraday resolution := "D" else if timeFrame == "Daily" resolution := "W" else if timeFrame == "Weekly" resolution := "M" else if timeFrame == "Monthly" resolution := "12M" resolution calculateRange(dClose, dVixClose) => dailyRange = (dClose * dVixClose / 16 / 100) vixTop = dClose + dailyRange vixBottom = dClose - dailyRange vixCenter = (vixTop + vixBottom) / 2 [vixTop, vixCenter, vixBottom] resolution = getResolution() symbolDailyClose = request.security(syminfo.tickerid, resolution, close) vixDailyClose = request.security(volSymbol, resolution, close) vixClose = request.security(volSymbol, timeframe.period, close) [vixTop, vixCenter, vixBottom] = calculateRange(symbolDailyClose[1], vixDailyClose[1]) plot(vixTop, title="Vix Top") plot(vixCenter, title="Vix Center") plot(vixBottom, title="Vix Bottom") [devVixTop, devVixCenter, devVixBottom] = calculateRange(close, vixClose) plot(devVixTop, title="Developing Vix Top", color=color.new(color.green, 20)) plot(devVixBottom, title="Developing Vix Bottom", color=color.new(color.red, 20))
Average Quarterly and Annual Gain/Loss (Color Divided)
https://www.tradingview.com/script/II3EtntC-Average-Quarterly-and-Annual-Gain-Loss-Color-Divided/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
159
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 //@version=5 indicator("Average Quarterly and Annual Gain/Loss", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back = 500) // _______________________________________________________ // // Input Tab to Change Label Text Size and Divider Colors // _______________________________________________________ benchmark = input.symbol(defval = "SPX", title = "Benchmark Asset", tooltip = "Changing the Symbol Allows for Comparison of Performance Between the Asset on Your Chart and the Asset Selected Here!") warn = input.string(defval = "No", title = "Remove Top Right Instructions?", options = ["No", "Yes"]) size = input.string(defval = "Small", title = "Label Size", options = ["Small", "Tiny"], group = "Hover over labels for additional information") hide = input.string(defval = "Off", title = "Hide Lines and Labels ? (Color Divided Quarters Only)", options = ["Off", "On"]) Q1color = input.color(defval = color.blue, title = "Q1 Color Scheme") Q2color = input.color(defval = color.green, title = "Q2 Color Scheme") Q3color = input.color(defval = color.red, title = "Q2 Color Scheme") Q4color = input.color(defval = color.yellow, title = "Q4 Color Scheme") annualColorFixed = input.color(defval = color.white, title = "Annual Fixed Plot Color") annualColorRunning = input.color(defval = color.black, title = "Annual Running Color") // _______________________________________________________ // // Defining Fiscal Quarter Periods // _______________________________________________________ var bool startCalculations = false if bar_index > 0 and year(time) != year(time[1]) startCalculations := true var bool Q1 = false if time >= timestamp(year(time), 01,01,00,00,00) and time <= timestamp(year(time), 03, 31, 23, 59, 59) and startCalculations == true Q1 := true else Q1 := false var bool Q2 = false if time >= timestamp(year(time), 04, 1, 00, 00, 00) and time <= timestamp(year(time), 06, 30, 23, 59, 59) and startCalculations == true Q2 := true else Q2 := false var bool Q3 = false if time >= timestamp(year(time), 07, 1, 00, 00, 00) and time <= timestamp(year(time), 09, 30, 23, 59, 59) and startCalculations == true Q3 := true else Q3 := false var bool Q4 = false if time >= timestamp(year(time), 10, 1, 00, 00, 00) and time <= timestamp(year(time), 12, 31, 23, 59, 59) and startCalculations == true Q4 := true else Q4 := false // _______________________________________________________ // // Pulling Index Data // _______________________________________________________ SPXindex() => [close, open, high, low] [spClose, spOpen, spHigh, spLow] = request.security(benchmark, "D", SPXindex()) // _______________________________________________________ // // Quarter 1 Calculations // _______________________________________________________ var int Q1startIndex = 0 var int totalQ1 = 0 var bool onOffQ1 = false var float Q1startClose = 0.0 var float Q1startHigh = 0.0 var float CumulativeQ1GainOrLoss = 0.0 var float Q1highest = 0.0 var float Q1lowest = 0.0 Q1highestHigh = ta.highest(high, bar_index + 1 - Q1startIndex)[1] Q1lowestLow = ta.lowest(low, bar_index + 1 - Q1startIndex)[1] if Q1 == true and Q1[1] == false onOffQ1 := true Q1startClose := close Q1startIndex := bar_index Q1startHigh := high if Q1[1] == true and Q1 == false and onOffQ1[1] == true CumulativeQ1GainOrLoss := ((close[1] / Q1startClose) - 1) * 100 CumulativeQ1GainOrLoss := CumulativeQ1GainOrLoss[1] + CumulativeQ1GainOrLoss Q1highest := Q1highestHigh Q1lowest := Q1lowestLow if Q1[1] == true and Q1 == false and onOffQ1 == true totalQ1 += 1 onOffQ1 := false avgQ1GainOrLoss = CumulativeQ1GainOrLoss / totalQ1 // _______________________________________________________ // // Quarter 1 Index Calculations // _______________________________________________________ var int SPQ1startIndex = 0 var int totalSPQ1 = 0 var bool onOffSPQ1 = false var float SPQ1startClose = 0.0 var float SPQ1startHigh = 0.0 var float CumulativeSPQ1GainOrLoss = 0.0 var float SPQ1highest = 0.0 var float SPQ1lowest = 0.0 var bool spxStart = false if bar_index > 0 and year(time) != year(time[1]) spxStart := true SPQ1highestHigh = ta.highest(spHigh, bar_index + 1 - SPQ1startIndex)[1] SPQ1lowestLow = ta.lowest(spLow, bar_index + 1 - SPQ1startIndex)[1] if Q1 == true and Q1[1] == false and spxStart == true onOffSPQ1 := true SPQ1startClose := spClose SPQ1startIndex := bar_index SPQ1startHigh := spHigh if Q1[1] == true and Q1 == false and onOffSPQ1[1] == true and spxStart == true CumulativeSPQ1GainOrLoss := ((spClose[1] / SPQ1startClose) - 1) * 100 CumulativeSPQ1GainOrLoss := CumulativeSPQ1GainOrLoss[1] + CumulativeSPQ1GainOrLoss SPQ1highest := SPQ1highestHigh SPQ1lowest := SPQ1lowestLow if Q1[1] == true and Q1 == false and onOffSPQ1 == true and spxStart == true totalSPQ1 += 1 onOffSPQ1 := false avgSPQ1GainOrLoss = CumulativeSPQ1GainOrLoss / totalSPQ1 // _______________________________________________________ // // Quarter 2 Calculations // _______________________________________________________ var int Q2startIndex = 0 var int totalQ2 = 0 var bool onOffQ2 = false var float Q2startClose = 0.0 var float Q2startHigh = 0.0 var float CumulativeQ2GainOrLoss = 0.0 var float Q2highest = 0.0 var float Q2lowest = 0.0 Q2highestHigh = ta.highest(high, bar_index + 1 - Q2startIndex)[1] Q2lowestLow = ta.lowest(low, bar_index + 1 - Q2startIndex)[1] if Q2 == true and Q2[1] == false onOffQ2 := true Q2startClose := close Q2startIndex := bar_index Q2startHigh := high if Q2[1] == true and Q2 == false CumulativeQ2GainOrLoss := ((close[1] / Q2startClose) - 1) * 100 CumulativeQ2GainOrLoss := CumulativeQ2GainOrLoss[1] + CumulativeQ2GainOrLoss Q2highest := Q2highestHigh Q2lowest := Q2lowestLow if Q2[1] == true and Q2 == false and onOffQ2 == true totalQ2 += 1 onOffQ2 := false avgQ2GainOrLoss = CumulativeQ2GainOrLoss / totalQ2 // _______________________________________________________ // // Quarter 2 Index Calculations // _______________________________________________________ var int SPQ2startIndex = 0 var int totalSPQ2 = 0 var bool onOffSPQ2 = false var float SPQ2startClose = 0.0 var float SPQ2startHigh = 0.0 var float CumulativeSPQ2GainOrLoss = 0.0 var float SPQ2highest = 0.0 var float SPQ2lowest = 0.0 SPQ2highestHigh = ta.highest(spHigh, bar_index + 1 - SPQ2startIndex)[1] SPQ2lowestLow = ta.lowest(spLow, bar_index + 1 - SPQ2startIndex)[1] if Q2 == true and Q2[1] == false and spxStart == true onOffSPQ2 := true SPQ2startClose := spClose SPQ2startIndex := bar_index SPQ2startHigh := spHigh if Q2[1] == true and Q2 == false and onOffSPQ2[1] == true and spxStart == true CumulativeSPQ2GainOrLoss := ((spClose[1] / SPQ2startClose) - 1) * 100 CumulativeSPQ2GainOrLoss := CumulativeSPQ2GainOrLoss[1] + CumulativeSPQ2GainOrLoss SPQ2highest := SPQ2highestHigh SPQ2lowest := SPQ2lowestLow if Q2[1] == true and Q2 == false and onOffSPQ2 == true and spxStart == true totalSPQ2 += 1 onOffSPQ2 := false avgSPQ2GainOrLoss = CumulativeSPQ2GainOrLoss / totalSPQ2 // _______________________________________________________ // // Quarter 3 Calculations // _______________________________________________________ var int Q3startIndex = 0 var int totalQ3 = 0 var bool onOffQ3 = false var float Q3startClose = 0.0 var float Q3startHigh = 0.0 var float CumulativeQ3GainOrLoss = 0.0 var float Q3highest = 0.0 var float Q3lowest = 0.0 Q3highestHigh = ta.highest(high, bar_index + 1 - Q3startIndex)[1] Q3lowestLow = ta.lowest(low, bar_index + 1 - Q3startIndex)[1] if Q3 == true and Q3[1] == false onOffQ3 := true Q3startClose := close Q3startIndex := bar_index Q3startHigh := high if Q3[1] == true and Q3 == false CumulativeQ3GainOrLoss := ((close[1] / Q3startClose) - 1) * 100 CumulativeQ3GainOrLoss := CumulativeQ3GainOrLoss[1] + CumulativeQ3GainOrLoss Q3highest := Q3highestHigh Q3lowest := Q3lowestLow if Q3 == false and Q3[1] == true and onOffQ3 == true totalQ3 += 1 onOffQ3 := false avgQ3GainOrLoss = CumulativeQ3GainOrLoss / totalQ3 // _______________________________________________________ // // Quarter 3 Index Calculations // _______________________________________________________ var int SPQ3startIndex = 0 var int totalSPQ3 = 0 var bool onOffSPQ3 = false var float SPQ3startClose = 0.0 var float SPQ3startHigh = 0.0 var float CumulativeSPQ3GainOrLoss = 0.0 var float SPQ3highest = 0.0 var float SPQ3lowest = 0.0 SPQ3highestHigh = ta.highest(spHigh, bar_index + 1 - SPQ3startIndex)[1] SPQ3lowestLow = ta.lowest(spLow, bar_index + 1 - SPQ3startIndex)[1] if Q3 == true and Q3[1] == false and spxStart == true onOffSPQ3 := true SPQ3startClose := spClose SPQ3startIndex := bar_index SPQ3startHigh := spHigh if Q3[1] == true and Q3 == false and onOffSPQ3[1] == true and spxStart == true CumulativeSPQ3GainOrLoss := ((spClose[1] / SPQ3startClose) - 1) * 100 CumulativeSPQ3GainOrLoss := CumulativeSPQ3GainOrLoss[1] + CumulativeSPQ3GainOrLoss SPQ3highest := SPQ3highestHigh SPQ3lowest := SPQ3lowestLow if Q3[1] == true and Q3 == false and onOffSPQ3 == true and spxStart == true totalSPQ3 += 1 onOffSPQ3 := false avgSPQ3GainOrLoss = CumulativeSPQ3GainOrLoss / totalSPQ3 // _______________________________________________________ // // Quarter 4 Calculations // _______________________________________________________ var int Q4startIndex = 0 var int totalQ4 = 0 var bool onOffQ4 = false var float Q4startClose = 0.0 var float Q4startHigh = 0.0 var float CumulativeQ4GainOrLoss = 0.0 var float Q4highest = 0.0 var float Q4lowest = 0.0 Q4highestHigh = ta.highest(high, bar_index + 1 - Q4startIndex)[1] Q4lowestLow = ta.lowest(low, bar_index + 1 - Q4startIndex)[1] if Q4 == true and Q4[1] == false onOffQ4 := true Q4startClose := close Q4startIndex := bar_index Q4startHigh := high if Q4[1] == true and Q4 == false CumulativeQ4GainOrLoss := ((close[1] / Q4startClose) - 1) * 100 CumulativeQ4GainOrLoss := CumulativeQ4GainOrLoss[1] + CumulativeQ4GainOrLoss Q4highest := Q4highestHigh Q4lowest := Q4lowestLow if Q4 == false and Q4[1] == true and onOffQ4 == true totalQ4 += 1 onOffQ4 := false avgQ4GainOrLoss = CumulativeQ4GainOrLoss / totalQ4 // _______________________________________________________ // // Quarter 4 Index Calculations // _______________________________________________________ var int SPQ4startIndex = 0 var int totalSPQ4 = 0 var bool onOffSPQ4 = false var float SPQ4startClose = 0.0 var float SPQ4startHigh = 0.0 var float CumulativeSPQ4GainOrLoss = 0.0 var float SPQ4highest = 0.0 var float SPQ4lowest = 0.0 SPQ4highestHigh = ta.highest(spHigh, bar_index + 1 - SPQ4startIndex)[1] SPQ4lowestLow = ta.lowest(spLow, bar_index + 1 - SPQ4startIndex)[1] if Q4 == true and Q4[1] == false and spxStart == true onOffSPQ4 := true SPQ4startClose := spClose SPQ4startIndex := bar_index SPQ4startHigh := spHigh if Q4[1] == true and Q4 == false and onOffSPQ4[1] == true and spxStart == true CumulativeSPQ4GainOrLoss := ((spClose[1] / SPQ4startClose) - 1) * 100 CumulativeSPQ4GainOrLoss := CumulativeSPQ4GainOrLoss[1] + CumulativeSPQ4GainOrLoss SPQ4highest := SPQ4highestHigh SPQ4lowest := SPQ4lowestLow if Q4[1] == true and Q4 == false and onOffSPQ4 == true and spxStart == true totalSPQ4 += 1 onOffSPQ4 := false avgSPQ4GainOrLoss = CumulativeSPQ4GainOrLoss / totalSPQ4 // _______________________________________________________ // // Annual Calculations // _______________________________________________________ yearChange = year(time) != year(time[1]) annualClosePrev = ta.valuewhen(yearChange, close, 1) var float yearClose = 0.0 var float yearClosePrev = 0.0 var float cumulativeAnnualPerformance = 0.0 var int annualCounter = -1 if yearChange and startCalculations == true yearClose := close yearClosePrev := annualClosePrev annualCounter += 1 cumulativeAnnualPerformance := ((close[1] / yearClosePrev) - 1) * 100 if cumulativeAnnualPerformance[1] != cumulativeAnnualPerformance and startCalculations[10] == true cumulativeAnnualPerformance := cumulativeAnnualPerformance[1] + cumulativeAnnualPerformance if cumulativeAnnualPerformance[1] != cumulativeAnnualPerformance and startCalculations[10] == false cumulativeAnnualPerformance := 0.0 avgAnnualGainOrLoss = cumulativeAnnualPerformance / annualCounter runningAnnualPerformance = ((close / yearClose) - 1) * 100 // _______________________________________________________ // // Annual Index Calculations // _______________________________________________________ annualClosePrevSP = ta.valuewhen(yearChange, spClose, 1) var float yearCloseSP = 0.0 var float yearClosePrevSP = 0.0 var float cumulativeAnnualPerformanceSP = 0.0 var int annualCounterSP = -1 if yearChange and startCalculations == true yearCloseSP := spClose yearClosePrevSP := annualClosePrevSP annualCounterSP += 1 cumulativeAnnualPerformanceSP := ((spClose[1] / yearClosePrevSP) - 1) * 100 if cumulativeAnnualPerformanceSP[1] != cumulativeAnnualPerformanceSP cumulativeAnnualPerformanceSP := cumulativeAnnualPerformanceSP[1] + cumulativeAnnualPerformanceSP if cumulativeAnnualPerformanceSP[1] != cumulativeAnnualPerformanceSP and startCalculations[10] == false cumulativeAnnualPerformanceSP := 0.0 avgAnnualGainOrLossSP = 0.0 if syminfo.ticker == "SPX" and startCalculations == true avgAnnualGainOrLossSP := avgAnnualGainOrLoss else avgAnnualGainOrLossSP := cumulativeAnnualPerformanceSP / annualCounterSP runningAnnualPerformanceSP = ((spClose / yearCloseSP) - 1) * 100 // ___________________________________________________________________ // // One-Time Initialization Variables for Lines, Labels, and Linefills // ___________________________________________________________________ var line Q1divider1 = na var line Q1divider2 = na var line Q2divider1 = na var line Q2divider2 = na var line Q3divider1 = na var line Q3divider2 = na var line Q4divider1 = na var line Q4divider2 = na var line Q1connector = na var line Q2connector = na var line Q3connector = na var line Q4connector = na var line annualConnector = na var linefill Q1Q1connector = na var linefill Q1Q2connector = na var linefill Q2Q2connector = na var linefill Q2Q3connector = na var linefill Q3Q3connector = na var linefill Q4Q4connector = na var linefill Q4Q1connector = na var label Q1performance = na var label Q2performance = na var label Q3performance = na var label Q4performance = na var label annualPerformance = na var label currentAnnualPerformance = na // _____________________________________________________________________________ // // User Input Variable for Calculating the % Gain/Loss Between Quarter Changes // _____________________________________________________________________________ quarterPerformance(x, y) => calculation = x / y calculation1 = calculation - 1 finalCalculation = calculation1 * 100 finalCalculation currentQ1Performance = quarterPerformance(close, Q1startClose) currentQ2Performance = quarterPerformance(close, Q2startClose) currentQ3Performance = quarterPerformance(close, Q3startClose) currentQ4Performance = quarterPerformance(close, Q4startClose) currentSPQ1Performance = quarterPerformance(spClose[1], SPQ1startClose) currentSPQ2Performance = quarterPerformance(spClose[1], SPQ2startClose) currentSPQ3Performance = quarterPerformance(spClose[1], SPQ3startClose) currentSPQ4Performance = quarterPerformance(spClose[1], SPQ4startClose) runningSPQ1Performance = quarterPerformance(spClose, SPQ1startClose) runningSPQ2Performance = quarterPerformance(spClose, SPQ2startClose) runningSPQ3Performance = quarterPerformance(spClose, SPQ3startClose) runningSPQ4Performance = quarterPerformance(spClose, SPQ4startClose) // _____________________________________________________________________________ // // Additional Calculations // _____________________________________________________________________________ Q1comparison = currentSPQ1Performance - quarterPerformance(close[1], Q1startClose) Q2comparison = currentSPQ2Performance - quarterPerformance(close[1], Q2startClose) Q3comparison = currentSPQ3Performance - quarterPerformance(close[1], Q3startClose) Q4comparison = currentSPQ4Performance - quarterPerformance(close[1], Q4startClose) annualComparison = runningAnnualPerformanceSP[1] - runningAnnualPerformance[1] runningQ1comparison = quarterPerformance(spClose, SPQ1startClose) - quarterPerformance(close, Q1startClose) runningQ2comparison = quarterPerformance(spClose, SPQ2startClose) - quarterPerformance(close, Q2startClose) runningQ3comparison = quarterPerformance(spClose, SPQ3startClose) - quarterPerformance(close, Q3startClose) runningQ4comparison = quarterPerformance(spClose, SPQ4startClose) - quarterPerformance(close, Q4startClose) runningAnnualComparison = runningAnnualPerformanceSP - runningAnnualPerformance comparisonString1 = Q1comparison > 0.0 ? " Better Than Asset" : Q1comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" comparisonString2 = Q2comparison > 0.0 ? " Better Than Asset" : Q2comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" comparisonString3 = Q3comparison > 0.0 ? " Better Than Asset" : Q3comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" comparisonString4 = Q4comparison > 0.0 ? " Better Than Asset" : Q4comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" runningComparisonString1 = runningQ1comparison > 0.0 ? " Better Than Asset" : runningQ1comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" runningComparisonString2 = runningQ2comparison > 0.0 ? " Better Than Asset" : runningQ2comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" runningComparisonString3 = runningQ3comparison > 0.0 ? " Better Than Asset" : runningQ3comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" runningComparisonString4 = runningQ4comparison > 0.0 ? " Better Than Asset" : runningQ4comparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" annualComparisonString = annualComparison > 0.0 ? " Better Than Asset" : annualComparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" runningAnnualComparisonString = runningAnnualComparison > 0.0 ? " Better Than Asset" : runningAnnualComparison == 0.0 ? " Equal Performance to Asset" : " Worse Than Asset" // _____________________________________________________________________________ // // Y-axis Plot for Lables // _____________________________________________________________________________ quarterPlot = ta.lowest(close, 63) highL = timeframe.isdwm ? high * 1.25 : high * 1.05 lowL = timeframe.isdwm ? low * .75 : low * .95 highL1 = timeframe.isdwm ? high * 1.26 : high * 1.06 lowL1 = timeframe.isdwm ? low * .73 : low * .94 // __________________________________________________________ // // Plotting Lines, Labels, and Linefills for Q1 // __________________________________________________________ if Q1[1] == false and Q1 == true line.delete(Q4divider2) line.delete(Q4connector) Q1divider1 := line.new(bar_index, highL, bar_index - 1, lowL, color = hide == "Off" ? color.new(Q1color, 0) : color.new(color.white, 100)) Q4Q1connector := linefill.new(Q1divider1, Q4divider1, color.new(Q4color, 95)) label.delete(Q4performance) Q4performance := startCalculations[10] == true ? label.new(bar_index - 30, quarterPlot * .90, color = hide == "Off" ? color.new(Q4color, 50) : color.new(color.white, 100), text = "Q4 " + str.tostring(year(time[1])) + " Performance: " + str.tostring(currentQ4Performance[1], format.percent) + "\nAverage Q4 Performance: " + str.tostring(avgQ4GainOrLoss, format.percent) + "\n\nQ4 Highest High: $" + str.tostring(Q4highest, format.mintick) + "\nQ4 Lowest Low: $" + str.tostring(Q4lowest, format.mintick), tooltip = "Q4 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(currentSPQ4Performance, format.percent) + " \n(" + str.tostring(Q4comparison,format.percent) + " " + comparisonString4 + ")" + "\nAverage Q4 " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ4GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", textcolor = hide == "Off" ? color.white : color.new(color.white, 100), style = label.style_label_center, size = size == "Small" ? size.small : size.tiny) : na Q1performance := label.new(bar_index + 1, highL1, text = "Current Q1 Performance: " + str.tostring(currentQ1Performance, format.percent) + "\nAverage Q1 Performance: " + str.tostring(avgQ1GainOrLoss, format.percent), color = hide == "Off" ? color.new(Q1color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) annualPerformance := startCalculations[10] == true ? label.new(Q1startIndex - 1, line.get_y2(Q1divider1) * .75, text = str.tostring(year(time[1])) + " Annual Performance: " + str.tostring(runningAnnualPerformance[1], format.percent) + "\nAverage Annual Performace: " + str.tostring(avgAnnualGainOrLoss, format.percent), tooltip = str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Annual Performance: " + str.tostring(runningAnnualPerformanceSP[1], format.percent) + "\n(" + str.tostring(annualComparison, format.percent) + annualComparisonString + ")\n" + str.tostring(benchmark) + " Average Annual Performance: " + str.tostring(avgAnnualGainOrLossSP, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", color = hide == "Off" ? color.new(annualColorFixed, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.black : color.new(color.white, 100), style = label.style_label_up, size = size == "Small" ? size.small : size.tiny) : na annualConnector := line.new(Q1startIndex - 1, lowL, Q1startIndex - 1, label.get_y(annualPerformance), color = annualColorFixed, style = line.style_dashed) if Q1 == true line.delete(Q1divider2[1]) Q1divider2 := line.new(bar_index + 1 , highL, bar_index + 1, lowL, color = hide == "Off" ? color.new(Q1color,0) : color.new(color.white, 100)) Q1Q1connector := linefill.new(Q1divider1, Q1divider2, color.new(Q1color, 95)) label.delete(Q1performance) Q1performance := label.new(bar_index + 1, highL1, text = "Current Q1 Performance: " + str.tostring(currentQ1Performance, format.percent) + "\nAverage Q1 Performance: " + str.tostring(avgQ1GainOrLoss, format.percent), tooltip = "Q1 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(runningSPQ1Performance, format.percent) + " \n(" + str.tostring(runningQ1comparison, format.percent) + runningComparisonString1 + ")" + "\nAverage Q1 " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ1GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", color = hide == "Off" ? color.new(Q1color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) line.delete(Q1connector[1]) Q1connector := line.new(Q1startIndex, Q1startHigh, bar_index, high, color = hide == "Off" ? Q1color : color.new(color.white, 100)) // __________________________________________________________ // // Plotting Lines, Labels, and Linefills for Q2 // __________________________________________________________ if Q2[1] == false and Q2 == true line.delete(Q1divider2) line.delete(Q1connector) Q2divider1 := line.new(bar_index, highL, bar_index - 1, lowL, color = hide == "Off" ? Q2color : color.new(color.white, 100)) Q1Q2connector := linefill.new(Q2divider1, Q1divider1, color.new(Q1color, 95)) label.delete(Q1performance) Q1performance := label.new(bar_index - 30, quarterPlot * .90, color = hide == "Off" ? color.new(Q1color, 50) : color.new(color.white, 100), text = "Q1 " + str.tostring(year(time)) + " Performance: " + str.tostring(currentQ1Performance[1], format.percent) + "\nAverage Q1 Performance: " + str.tostring(avgQ1GainOrLoss, format.percent) + "\n\nHighest Q1 High: $" + str.tostring(Q1highest, format.mintick) + "\nLowest Q1 Low: $" + str.tostring(Q1lowest, format.mintick), tooltip = "Q1 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(currentSPQ1Performance, format.percent) + " \n(" + str.tostring(Q1comparison,format.percent) + " " + comparisonString1 + ")" + "\nAverage Q1 " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ1GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", textcolor = hide == "Off" ? color.white : color.new(color.white, 100), style = label.style_label_center, size = size == "Small" ? size.small : size.tiny) Q2performance := label.new(bar_index + 1, highL1, text = "Current Q2 Performance: " + str.tostring(currentQ2Performance, format.percent) + "\nAverage Q2 Performance: " + str.tostring(avgQ2GainOrLoss, format.percent), color = hide == "Off" ? color.new(Q2color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) if Q2 == true line.delete(Q2divider2[1]) Q2divider2 := line.new(bar_index + 1 , high * 1.24, bar_index + 1, lowL, color = hide == "Off" ? color.new(Q2color,0) : color.new(color.white, 100)) Q2Q2connector := linefill.new(Q2divider1, Q2divider2, color.new(Q2color, 95)) label.delete(Q2performance) Q2performance := label.new(bar_index + 1, highL1, text = "Current Q2 Performance: " + str.tostring(currentQ2Performance, format.percent) + "\nAverage Q2 Performance: " + str.tostring(avgQ2GainOrLoss, format.percent), tooltip = "Q2 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(runningSPQ2Performance, format.percent) + " \n(" + str.tostring(runningQ2comparison, format.percent) + runningComparisonString2 + ")" + "\nAverage Q2 " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ2GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", color = hide == "Off" ? color.new(Q2color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) line.delete(Q2connector[1]) Q2connector := line.new(Q2startIndex, Q2startHigh, bar_index, high, color = hide == "Off" ? Q2color : color.new(color.white, 100)) // __________________________________________________________ // // Plotting Lines, Labels, and Linefills for Q3 // __________________________________________________________ if Q3 == true and Q3[1] == false line.delete(Q2divider2) line.delete(Q2connector) Q3divider1 := line.new(bar_index, highL, bar_index - 1, lowL, color = hide == "Off" ? Q3color : color.new(color.white, 100)) Q2Q3connector := linefill.new(Q2divider1, Q3divider1, color.new(Q2color, 95)) label.delete(Q2performance) Q2performance := label.new(bar_index - 30, quarterPlot * .90, color = hide == "Off" ? color.new(Q2color, 50) : color.new(color.white, 100), text = "Q2 " + str.tostring(year(time)) + " Performance: " + str.tostring(currentQ2Performance[1], format.percent) + "\nAverage Q2 Performance: " + str.tostring(avgQ2GainOrLoss, format.percent) + "\n\nQ2 Highest High: $" + str.tostring(Q2highest, format.mintick) + "\nQ2 Lowest Low: $" + str.tostring(Q2lowest, format.mintick), textcolor = hide == "Off" ? color.white : color.new(color.white, 100), style = label.style_label_center, size = size == "Small" ? size.small : size.tiny, tooltip = "Q2 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(currentSPQ2Performance, format.percent) + " \n(" + str.tostring(Q2comparison,format.percent) + " " + comparisonString2 + ")" + "\nAverage Q2" + " " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ2GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart") Q3performance := label.new(bar_index + 1, highL1, text = "Current Q3 Performance: " + str.tostring(currentQ3Performance, format.percent) + "\nAverage Q2 Performance: " + str.tostring(avgQ3GainOrLoss, format.percent), color = hide == "Off" ? color.new(Q3color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) if Q3 == true line.delete(Q3divider2) Q3divider2 := line.new(bar_index + 1 , highL, bar_index + 1, lowL, color = hide == "Off" ? color.new(Q3color ,0) : color.new(color.white, 100)) Q3Q3connector := linefill.new(Q3divider1, Q3divider2, color.new(Q3color, 95)) label.delete(Q3performance) Q3performance := label.new(bar_index + 1, highL1, text = "Current Q3 Performance: " + str.tostring(currentQ3Performance, format.percent) + "\nAverage Q3 Performance: " + str.tostring(avgQ3GainOrLoss, format.percent), tooltip = "Q3 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(runningSPQ3Performance, format.percent) + " \n(" + str.tostring(runningQ3comparison, format.percent) + runningComparisonString3 + ")" + "\nAverage Q3 "+ str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ3GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", color = hide == "Off" ? color.new(Q3color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) line.delete(Q3connector[1]) Q3connector := line.new(Q3startIndex, Q3startHigh, bar_index, high, color = hide == "Off" ? Q3color : color.new(color.white, 100)) // __________________________________________________________ // // Plotting Lines, Labels, and Linefills for Q4 // __________________________________________________________ if Q4 == true and Q4[1] == false line.delete(Q3divider2) line.delete(Q3connector) Q4divider1 := line.new(bar_index, highL, bar_index - 1, lowL, color = hide == "Off" ? Q4color : color.new(color.white, 100)) Q4Q1connector := linefill.new(Q4divider1, Q3divider1, color.new(Q3color, 95)) label.delete(Q3performance) Q3performance := label.new(bar_index - 30, quarterPlot * .90, color = hide == "Off" ? color.new(Q3color, 50) : color.new(color.white, 100), text = "Q3 " + str.tostring(year(time)) + " Performance: " + str.tostring(currentQ3Performance[1], format.percent) + "\nAverage Q3 Performance: " + str.tostring(avgQ3GainOrLoss, format.percent) + "\n\nQ3 Highest High: $" + str.tostring(Q3highest, format.mintick) + "\nQ3 Lowest Low: $" + str.tostring(Q3lowest, format.mintick), tooltip = "Q3 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: "+ str.tostring(currentSPQ3Performance, format.percent) + " \n(" + str.tostring(Q3comparison,format.percent) + " " + comparisonString3 + ")" + "\nAverage Q1" + " " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ3GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", textcolor = hide == "Off" ? color.white : color.new(color.white, 100), style = label.style_label_center, size = size == "Small" ? size.small : size.tiny) Q4performance := label.new(bar_index + 1, highL1, text = "Current Q4 Performance: " + str.tostring(currentQ4Performance, format.percent) + " (" + str.tostring(Q1comparison,format.percent) + " " + comparisonString1 + ")" + "\nAverage Q4 Performance: " + str.tostring(avgQ4GainOrLoss, format.percent), color = hide == "Off" ? color.new(Q4color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) if Q4 == true line.delete(Q4divider2) Q4divider2 := line.new(bar_index + 1 , highL, bar_index + 1, lowL, color = hide == "Off" ? color.new(Q4color ,0) : color.new(color.white, 100)) Q4Q4connector := linefill.new(Q4divider1, Q4divider2, color.new(Q4color, 95)) label.delete(Q4performance) Q4performance := label.new(bar_index + 1, highL1, text = "Current Q4 Performance: " + str.tostring(currentQ4Performance, format.percent) + "\nAverage Q4 Performance: " + str.tostring(avgQ4GainOrLoss, format.percent), tooltip = "Q4 " + str.tostring(year(time[1])) + " " + str.tostring(benchmark) + " Performance: " + str.tostring(runningSPQ4Performance, format.percent) + " \n(" + str.tostring(runningQ4comparison, format.percent) + runningComparisonString4 + ")" + "\nAverage Q4"+ " " + str.tostring(benchmark) + " Performance: " + str.tostring(avgSPQ4GainOrLoss, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart", color = hide == "Off" ? color.new(Q4color, 50) : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100)) line.delete(Q4connector[1]) Q4connector := line.new(Q4startIndex, Q4startHigh, bar_index, high, color = hide == "Off" ? Q4color : color.new(color.white, 100)) // __________________________________________________________ // // Plotting Label for Current Annual % Gain/Loss // __________________________________________________________ if barstate.islast label.delete(currentAnnualPerformance[1]) currentAnnualPerformance := label.new(bar_index + 1, lowL, style = label.style_label_up, color = hide == "Off" ? color.black : color.new(color.white, 100), textcolor = hide == "Off" ? color.white : color.new(color.white, 100), text = "Current Annual Performance: " + str.tostring(runningAnnualPerformance, format.percent) + "\nAverage Annual Performance: " + str.tostring(avgAnnualGainOrLoss, format.percent), tooltip = str.tostring(benchmark) + " Current Annual Performance: " + str.tostring(runningAnnualPerformanceSP, format.percent) + " \n(" + str.tostring(runningAnnualComparison, format.percent) + runningAnnualComparisonString + ")" + "\nAverage " + str.tostring(benchmark) + " Annual Performance: " + str.tostring(avgAnnualGainOrLossSP, format.percent) + "\n___________________________\n⬆️Average Performance Calculation Starts on the First Trading Session for the Asset on Your Chart") t = table.new(position.top_right, 1, 1) if barstate.islast and warn == "No" table.cell(t, 0, 0, text = "Hover Over Labels to View the Performance of the Asset on Your Chart Against the Benchmark Asset!", text_size = size.auto, text_color = color.white) if timeframe.isintraday runtime.error("Try Daily Chart")
[_ParkF]RSI Divergence_overlay
https://www.tradingview.com/script/EUP4jfiK/
ParkF
https://www.tradingview.com/u/ParkF/
418
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/ // © ParkF //@version=5 indicator("[_ParkF]RSI_Div(Overlay)", overlay=true) // rsi divergence // input group1 = 'RSI DIV SETTING' len = input(14, 'RSI Period', group=group1) lb = input(15, 'Pivot Leftbars', group=group1) rb = input(2, 'Pivot Rightbars', group=group1) bear_src = input(close, 'Bearish Divs_Pivot Source', group=group1) bull_src = input(close, 'Bullish Divs_Pivot Source', group=group1) lvl = input.int(5, 'Lookback Level_Divs', options=[1, 2, 3, 4, 5], group=group1) divsw = input(true, 'Divergence On / Off Switch', group=group1) // get indicator rsi = ta.rsi(close, len) // pivot bar = bar_index[rb] ph = ta.pivothigh(bear_src, lb, rb) pl = ta.pivotlow(bull_src, lb, rb) // div function hi0 = ta.valuewhen(ph, bear_src[rb], 0), hi1 = ta.valuewhen(ph, bear_src[rb], 1) hi2 = ta.valuewhen(ph, bear_src[rb], 2), hi3 = ta.valuewhen(ph, bear_src[rb], 3) hi4 = ta.valuewhen(ph, bear_src[rb], 4), hi5 = ta.valuewhen(ph, bear_src[rb], 5) lo0 = ta.valuewhen(pl, bull_src[rb], 0), lo1 = ta.valuewhen(pl, bull_src[rb], 1) lo2 = ta.valuewhen(pl, bull_src[rb], 2), lo3 = ta.valuewhen(pl, bull_src[rb], 3) lo4 = ta.valuewhen(pl, bull_src[rb], 4), lo5 = ta.valuewhen(pl, bull_src[rb], 5) dh0 = ta.valuewhen(ph, rsi[rb], 0), dh1 = ta.valuewhen(ph, rsi[rb], 1) dh2 = ta.valuewhen(ph, rsi[rb], 2), dh3 = ta.valuewhen(ph, rsi[rb], 3) dh4 = ta.valuewhen(ph, rsi[rb], 4), dh5 = ta.valuewhen(ph, rsi[rb], 5) dl0 = ta.valuewhen(pl, rsi[rb], 0), dl1 = ta.valuewhen(pl, rsi[rb], 1) dl2 = ta.valuewhen(pl, rsi[rb], 2), dl3 = ta.valuewhen(pl, rsi[rb], 3) dl4 = ta.valuewhen(pl, rsi[rb], 4), dl5 = ta.valuewhen(pl, rsi[rb], 5) bear_div1 = hi0 > hi1 and dh1 > dh0 bear_div2 = hi0 > hi1 and hi0 > hi2 and dh2 > dh0 and dh2 > dh1 and lvl >= 2 bear_div3 = hi0 > hi1 and hi0 > hi2 and hi0 > hi3 and dh3>dh0 and dh3>dh1 and dh3>dh2 and lvl >= 3 bear_div4 = hi0 > hi1 and hi0 > hi2 and hi0 > hi3 and hi0 > hi4 and dh4 > dh0 and dh4 > dh1 and dh4 > dh2 and dh4 > dh3 and lvl >= 4 bear_div5 = hi0>hi1 and hi0>hi2 and hi0>hi3 and hi0 > hi4 and hi0 > hi5 and dh5 > dh0 and dh5 > dh1 and dh5 > dh2 and dh5 > dh3 and dh5 > dh4 and lvl >= 5 bull_div1 = lo0 < lo1 and dl1 < dl0 bull_div2 = lo0<lo1 and lo0<lo2 and dl2 < dl0 and dl2 < dl1 and lvl >= 2 bull_div3 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and dl3 < dl0 and dl3 < dl1 and dl3 < dl2 and lvl >= 3 bull_div4 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and lo0 < lo4 and dl4 < dl0 and dl4 < dl1 and dl4 < dl2 and dl4 < dl3 and lvl >= 4 bull_div5 = lo0 < lo1 and lo0 < lo2 and lo0 < lo3 and lo0 < lo4 and lo0 < lo5 and dl5 < dl0 and dl5 < dl1 and dl5 < dl2 and dl5 < dl3 and dl5 < dl4 and lvl >= 5 _bear1 = bear_div1 and not bear_div1[1], _bear2 = bear_div2 and not bear_div2[1] _bear3 = bear_div3 and not bear_div3[1], _bear4 = bear_div4 and not bear_div4[1] _bear5 = bear_div5 and not bear_div5[1] _bull1 = bull_div1 and not bull_div1[1], _bull2 = bull_div2 and not bull_div2[1] _bull3 = bull_div3 and not bull_div3[1], _bull4 = bull_div4 and not bull_div4[1] _bull5 = bull_div5 and not bull_div5[1] // plotshape plotshape(title='bear_div1', series=_bear1 and divsw, style=shape.triangledown, color=#ff0000, location=location.abovebar, size=size.tiny, offset=-2) plotshape(title='bear_div2', series=_bear2 and divsw, style=shape.triangledown, color=#ff0000, location=location.abovebar, size=size.tiny, offset=-2) plotshape(title='bear_div3', series=_bear3 and divsw, style=shape.triangledown, color=#ff0000, location=location.abovebar, size=size.tiny, offset=-2) plotshape(title='bear_div4', series=_bear4 and divsw, style=shape.triangledown, color=#ff0000, location=location.abovebar, size=size.tiny, offset=-2) plotshape(title='bear_div5', series=_bear5 and divsw, style=shape.triangledown, color=#ff0000, location=location.abovebar, size=size.tiny, offset=-2) plotshape(title='bull_div1', series=_bull1 and divsw, style=shape.triangleup, color=#00ff0a, location=location.belowbar, size=size.tiny, offset=-2) plotshape(title='bull_div2', series=_bull2 and divsw, style=shape.triangleup, color=#00ff0a, location=location.belowbar, size=size.tiny, offset=-2) plotshape(title='bull_div3', series=_bull3 and divsw, style=shape.triangleup, color=#00ff0a, location=location.belowbar, size=size.tiny, offset=-2) plotshape(title='bull_div4', series=_bull4 and divsw, style=shape.triangleup, color=#00ff0a, location=location.belowbar, size=size.tiny, offset=-2) plotshape(title='bull_div5', series=_bull5 and divsw, style=shape.triangleup, color=#00ff0a, location=location.belowbar, size=size.tiny, offset=-2)
Cyatophilum Auto Key Levels
https://www.tradingview.com/script/JherL5Vf-Cyatophilum-Auto-Key-Levels/
cyatophilum
https://www.tradingview.com/u/cyatophilum/
256
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/ // © cyatophilum //@version=5 indicator("Cyatophilum Auto Key Levels",overlay=true,max_boxes_count=500,max_bars_back=5000) import PineCoders/VisibleChart/4 as vchart // inputs { precision = input.int(200,title="Precision",minval=5,maxval=100000,group="Lines Calculation",tooltip="The number of steps. Increase if you want more precise levels or decrease for bigger areas.") uselookback = input.bool(false,'Use a lookback instead of visible bars?',inline='vchart',group="Lines Calculation") lookback = input.int(230,title="Lookback",minval=5,group="Lines Calculation",tooltip="The number of bars from the past used to calculate the levels.",inline = 'vchart') tolerance = input.float(3,title="Strength",minval=0,group="Lines Calculation",tooltip="The amount of lines to show") use_volume = input.bool(true,title="Use volume",group="Lines Calculation",tooltip="volume weighted key levels") show_h_l = input.bool(true,title="Show Highest and Lowest",group="Graphics") boxes_transparency = input.int(50,title="Lines Transparency",minval=0,maxval=100,group="Graphics") use_lines_color = input.bool(true,title='',inline='lines color',group='Graphics') lines_color = input.color(color.rgb(0, 89, 255),title="Lines color",inline='lines color',group="Graphics") top_color = input.color(color.lime,'Top line color',group="Graphics") bottom_color = input.color(color.red,'Bottom line color',group="Graphics") // } var float highest_price = na var float lowest_price = na var int leftBarIndex = na var int rightBarIndex = na lines_color := use_lines_color ? lines_color : chart.fg_color if not uselookback highest_price := vchart.high() //ta.highest(high,lookback) lowest_price := vchart.low() //ta.lowest(low,lookback) // var int test = na leftBarIndex := vchart.leftBarIndex() rightBarIndex := vchart.rightBarIndex() else highest_price := ta.highest(high,lookback) lowest_price := ta.lowest(low,lookback) leftBarIndex := bar_index - lookback rightBarIndex := bar_index if barstate.islast //delete all lines a_allLines = line.all if array.size(a_allLines) > 0 for i = 0 to array.size(a_allLines) - 1 line.delete(array.get(a_allLines, i)) if show_h_l line.new(bar_index - 1, highest_price, bar_index, highest_price,extend = extend.both, width = 3,color=top_color) line.new(bar_index - 1, lowest_price, bar_index, lowest_price,extend = extend.both, width = 3,color=bottom_color) 1 // Array declaration var steps = array.new_float(0) array.clear(steps) var prices = array.new_float(0) array.clear(prices) var volumes = array.new_float(0) _range = highest_price - lowest_price quotien = precision step = _range / quotien sum = lowest_price sum_cpt_prices = 0.0 for i = 0 to (precision - 1) step_price = sum sum := sum + step array.push(steps,step_price) cpt_prices = 0.0 if i > 0 for j = (bar_index - rightBarIndex) to (bar_index - leftBarIndex) if (close[j] > array.get(steps,i - 1) and close[j] < array.get(steps,i)) cpt_prices := use_volume ? cpt_prices + volume[j] : cpt_prices + 1 array.push(prices,cpt_prices) sum_cpt_prices += cpt_prices avg_price_cpt = sum_cpt_prices / (precision - 1) //delete all boxes a_allBoxes = box.all if array.size(a_allBoxes) > 0 for i = 0 to array.size(a_allBoxes) - 1 box.delete(array.get(a_allBoxes, i)) for k = 0 to (array.size(prices) == 0 ? na : array.size(prices) - 1) if array.get(prices,k) > avg_price_cpt * tolerance box.new(bar_index - 1, array.get(steps,k + 1), bar_index, array.get(steps,k), bgcolor = color.new(lines_color, boxes_transparency),extend = extend.both,border_color = color.new(color.aqua,100))
Day of Week Rainbow
https://www.tradingview.com/script/XJRQtmqX-Day-of-Week-Rainbow/
JackSo6
https://www.tradingview.com/u/JackSo6/
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/ // © JackSo6 //@version=5 indicator("Day of Week", overlay=true) show_monday = input.bool(true, "Monday") show_tuesday = input.bool(true, "Tuesday") show_wednesday = input.bool(true, "Wednesday") show_thursday = input.bool(true, "Thursday") show_friday = input.bool(true, "Friday") show_saturday = input.bool(true, "Saturday") show_sunday = input.bool(true, "Sunday") transp = input.int(85, "Transp", minval=0, maxval=100) c_monday = color.new(color.red, transp) c_tuesday = color.new(color.orange, transp) c_wednesday = color.new(color.yellow, transp) c_thursday = color.new(color.green, transp) c_friday = color.new(color.aqua, transp) c_saturday = color.new(color.blue, transp) c_sunday = color.new(color.purple, transp) day = dayofweek monday = dayofweek.monday tuesday = dayofweek.tuesday wednesday = dayofweek.wednesday thursday = dayofweek.thursday friday = dayofweek.friday saturday = dayofweek.saturday sunday = dayofweek.sunday bgcolor(show_monday and day == monday ? c_monday : na) bgcolor(show_tuesday and day == tuesday ? c_tuesday : na) bgcolor(show_wednesday and day == wednesday ? c_wednesday : na) bgcolor(show_thursday and day == thursday ? c_thursday : na) bgcolor(show_friday and day == friday ? c_friday : na) bgcolor(show_saturday and day == saturday ? c_saturday : na) bgcolor(show_sunday and day == sunday ? c_sunday : na)
Momentum Cloud
https://www.tradingview.com/script/RM5QI2EJ-Momentum-Cloud/
TheRiskChair
https://www.tradingview.com/u/TheRiskChair/
133
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/ // © TheRiskChair // @version=5 indicator(title="Momentum Cloud", shorttitle="Mom. Cloud", overlay=true) conversionPeriods = input.int(20, 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(30, 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) avLine = (leadLine1 + leadLine2) / 2 p1 = plot(leadLine1, offset = displacement - 1, color=#1dc400, title="Leading Span A") p2 = plot(leadLine2, offset = displacement - 1, color=#c40000, title="Leading Span B") fillColor = leadLine1 > leadLine2 ? (color.from_gradient(close, leadLine2, leadLine1, color.new(#3363ff85, 85), color.new(#36ff4a,85))) : leadLine1 < leadLine2 ? color.from_gradient(close, leadLine1, leadLine2, color.new(#fc0000,85), color.new(#3363ff,85)) : na fill(p1, p2, fillColor)
[_ParkF]Fractal
https://www.tradingview.com/script/4dMBA71q/
ParkF
https://www.tradingview.com/u/ParkF/
116
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/ // © ParkF //@version=5 indicator(title='[_ParkF]Fractal', overlay=true) // input ShowFractals = true ShowFractalLevels = input(true, title='Show Fractal Levels') ShowHHLL = input(true, title='Show HH/LL') filterBW = input(true, title='Show Ideal Fractals Only') uRenko = false maxLvlLen = input(0, title='Maximum Fractal Level Extension Length (0=No limit)') // uRenko calc close_ = close open_ = open high_ = uRenko ? math.max(close_, open_) : high low_ = uRenko ? math.min(close_, open_) : low // fractal function isIdealFractal(mode) => ret = mode == 1 ? high_[5] < high_[4] and high_[4] < high_[3] and high_[3] > high_[2] and high_[2] > high_[1] : mode == -1 ? low_[5] > low_[4] and low_[4] > low_[3] and low_[3] < low_[2] and low_[2] < low_[1] : false ret isRegularFractal(mode) => ret = mode == 1 ? high_[5] < high_[3] and high_[4] < high_[3] and high_[3] > high_[2] and high_[3] > high_[1] : mode == -1 ? low_[5] > low_[3] and low_[4] > low_[3] and low_[3] < low_[2] and low_[3] < low_[1] : false ret // fractals isIdealFractal__1 = isIdealFractal(1) isRegularFractal__1 = isRegularFractal(1) filteredtopf = filterBW ? isIdealFractal__1 : isRegularFractal__1 isIdealFractal__2 = isIdealFractal(-1) isRegularFractal__2 = isRegularFractal(-1) filteredbotf = filterBW ? isIdealFractal__2 : isRegularFractal__2 plotshape(ShowFractals or filterBW ? filteredtopf : na, title='Top Fractal', style=shape.circle, location=location.abovebar, color=color.new(color.black, 0), offset=-3) plotshape(ShowFractals or filterBW ? filteredbotf : na, title='Bottom Fractal', style=shape.circle, location=location.belowbar, color=color.new(color.black, 0), offset=-3) topfractals = 0.0 botfractals = 0.0 topfractals := filteredtopf ? high_[3] : topfractals[1] botfractals := filteredbotf ? low_[3] : botfractals[1] topfcolor = topfractals != topfractals[1] ? na : color.black botfcolor = botfractals != botfractals[1] ? na : color.black // HH, LH, HL, LL calc valuewhen_1 = ta.valuewhen(filteredtopf == true, high_[3], 1) valuewhen_2 = ta.valuewhen(filteredtopf == true, high_[3], 0) valuewhen_3 = ta.valuewhen(filteredtopf == true, high_[3], 2) valuewhen_4 = ta.valuewhen(filteredtopf == true, high_[3], 0) higherhigh = filteredtopf == false ? false : valuewhen_1 < valuewhen_2 and (filterBW or valuewhen_3 < valuewhen_4) valuewhen_5 = ta.valuewhen(filteredtopf == true, high_[3], 1) valuewhen_6 = ta.valuewhen(filteredtopf == true, high_[3], 0) valuewhen_7 = ta.valuewhen(filteredtopf == true, high_[3], 2) valuewhen_8 = ta.valuewhen(filteredtopf == true, high_[3], 0) lowerhigh = filteredtopf == false ? false : valuewhen_5 > valuewhen_6 and (filterBW or valuewhen_7 > valuewhen_8) valuewhen_9 = ta.valuewhen(filteredbotf == true, low_[3], 1) valuewhen_10 = ta.valuewhen(filteredbotf == true, low_[3], 0) valuewhen_11 = ta.valuewhen(filteredbotf == true, low_[3], 2) valuewhen_12 = ta.valuewhen(filteredbotf == true, low_[3], 0) higherlow = filteredbotf == false ? false : valuewhen_9 < valuewhen_10 and (filterBW or valuewhen_11 < valuewhen_12) valuewhen_13 = ta.valuewhen(filteredbotf == true, low_[3], 1) valuewhen_14 = ta.valuewhen(filteredbotf == true, low_[3], 0) valuewhen_15 = ta.valuewhen(filteredbotf == true, low_[3], 2) valuewhen_16 = ta.valuewhen(filteredbotf == true, low_[3], 0) lowerlow = filteredbotf == false ? false : valuewhen_13 > valuewhen_14 and (filterBW or valuewhen_15 > valuewhen_16) // HH, LH, HL, LL plot plotshape(ShowHHLL ? higherhigh : na, title='HH', style=shape.square, location=location.abovebar, color=color.new(color.black, 0), text='HH', offset=-3) plotshape(ShowHHLL ? lowerhigh : na, title='LH', style=shape.square, location=location.abovebar, color=color.new(color.black, 0), text='LH', offset=-3) plotshape(ShowHHLL ? higherlow : na, title='HL', style=shape.square, location=location.belowbar, color=color.new(color.black, 0), text='HL', offset=-3) plotshape(ShowHHLL ? lowerlow : na, title='LL', style=shape.square, location=location.belowbar, color=color.new(color.black, 0), text='LL', offset=-3) // pivot lv counting and new reset topcnt = 0 botcnt = 0 topcnt := filteredtopf ? 0 : nz(topcnt[1]) + 1 botcnt := filteredbotf ? 0 : nz(botcnt[1]) + 1 topfs = 0.0 botfs = 0.0 topfs := filteredtopf ? high_[3] : topfs[1] botfs := filteredbotf ? low_[3] : botfs[1] topfc = topfs != topfs[1] ? na : color.new(#787b86, 25) botfc = botfs != botfs[1] ? na : color.new(#787b86, 25) // fractal lv line plot plot(ShowFractalLevels and topcnt <= 3 ? topfs : na, color=topfc, linewidth=4, offset=-3, title='Top LV -3') plot(ShowFractalLevels and botcnt <= 3 ? botfs : na, color=botfc, linewidth=4, offset=-3, title='Bottom LV -3') plot(ShowFractalLevels and (maxLvlLen == 0 or topcnt < maxLvlLen) ? topfs : na, color=topfc, linewidth=4, offset=0, title='Top Lv 1') plot(ShowFractalLevels and (maxLvlLen == 0 or botcnt < maxLvlLen) ? botfs : na, color=botfc, linewidth=4, offset=0, title='Bottom Lv 1') plot(math.avg(topfs, botfs), color=color.new(#FF0000, 0), linewidth=2, title='AVG Fractal', offset=-1)
High Low Index SPY Top 40
https://www.tradingview.com/script/oJEwDsnN-High-Low-Index-SPY-Top-40/
PtGambler
https://www.tradingview.com/u/PtGambler/
177
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // original code for "High Low Index" by © LonesomeTheBlue // - Made modification specifically for Top 40 SPY holdings // - Added Market sentiment histogram (Total count green vs red), and SMA line for it // - Added arrows for peaks and dips on High Low Index and Market Sentiment MA // © PtGambler //@version=5 indicator("High Low Index SPY", explicit_plot_zorder = true) sym_count = input.string('Top 10', 'Number of Tickers', ['Top 10', 'Top 20', 'Top 30', 'Top 40'], group = "Setup") timeFrame = input.timeframe(defval = '', title = "Time Frame", group = "Setup") length = input.int(defval = 10, title = "Length", minval = 1, group = "Setup") source = input.string(defval = "High/Low", title = "Source", options = ["High/Low", "Close"], group = "Setup") smoothLength = input.int(defval = 10, title = "Smoothing Length", minval = 1, group = "Setup") showRecordHighPercent = input.bool(defval = true, title = "Record High Percent", group = "Setup") showTable= input.bool(defval = true, title = "Show Table", inline = "table", group = "Setup") textsize = input.string(defval = size.tiny, title = " | Text Size", options = [size.tiny, size.small, size.normal], inline = "table", group = "Setup") showEma = input.bool(defval = true, title = "EMA", inline = "ema", group = "Setup") emaLength = input.int(defval = 10, title = " | Length", minval = 1, inline = "ema", group = "Setup") showHisto = input.bool(defval=true, title = "Market Sentiment Histogram", group = "Setup - Market Sentiment") showHistoMA = input.bool(defval=true, title = "Sentiment MA Line", group = "Setup - Market Sentiment") HistoLen = input.int(defval = 5, title = "Smoothing Length for Sentiment MA line", minval = 1, group = "Setup - Market Sentiment") showHLI_PD = input.bool(defval = true, title = "Show Peaks and Dips on High Low Index", group = "Extra") showHist_PD = input.bool(defval = true, title = "Show Peaks and Dips on Market Sentiment", group = "Extra") ShowExchange = input.bool(defval = false, title = "Show Exchange Info in the Table", group = "Extra") count = switch sym_count 'Top 10' => 10 'Top 20' => 20 'Top 30' => 30 'Top 40' => 40 symbol1 = input.symbol(defval = "AAPL", group = "Symbols") symbol2 = input.symbol(defval = "MSFT", group = "Symbols") symbol3 = input.symbol(defval = "AMZN", group = "Symbols") symbol4 = input.symbol(defval = "NVDA", group = "Symbols") symbol5 = input.symbol(defval = "BRK.B", group = "Symbols") symbol6 = input.symbol(defval = "GOOGL", group = "Symbols") symbol7 = input.symbol(defval = "TSLA", group = "Symbols") symbol8 = input.symbol(defval = "GOOG", group = "Symbols") symbol9 = input.symbol(defval = "UNH", group = "Symbols") symbol10 = input.symbol(defval = "XOM", group = "Symbols") symbol11 = input.symbol(defval = "JNJ", group = "Symbols") symbol12 = input.symbol(defval = "JPM", group = "Symbols") symbol13 = input.symbol(defval = "META", group = "Symbols") symbol14 = input.symbol(defval = "V", group = "Symbols") symbol15 = input.symbol(defval = "PG", group = "Symbols") symbol16 = input.symbol(defval = "HD", group = "Symbols") symbol17 = input.symbol(defval = "MA", group = "Symbols") symbol18 = input.symbol(defval = "CVX", group = "Symbols") symbol19 = input.symbol(defval = "MRK", group = "Symbols") symbol20 = input.symbol(defval = "ABBV", group = "Symbols") symbol21 = input.symbol(defval = "LLY", group = "Symbols") symbol22 = input.symbol(defval = "PEP", group = "Symbols") symbol23 = input.symbol(defval = "BAC", group = "Symbols") symbol24 = input.symbol(defval = "PFE", group = "Symbols") symbol25 = input.symbol(defval = "AVGO", group = "Symbols") symbol26 = input.symbol(defval = "KO", group = "Symbols") symbol27 = input.symbol(defval = "COST", group = "Symbols") symbol28 = input.symbol(defval = "TMO", group = "Symbols") symbol29 = input.symbol(defval = "CSCO", group = "Symbols") symbol30 = input.symbol(defval = "WMT", group = "Symbols") symbol31 = input.symbol(defval = "MCD", group = "Symbols") symbol32 = input.symbol(defval = "DIS", group = "Symbols") symbol33 = input.symbol(defval = "ABT", group = "Symbols") symbol34 = input.symbol(defval = "WFC", group = "Symbols") symbol35 = input.symbol(defval = "ACN", group = "Symbols") symbol36 = input.symbol(defval = "GS", group = "Symbols") symbol37 = input.symbol(defval = "CRM", group = "Symbols") symbol38 = input.symbol(defval = "SNOW", group = "Symbols") symbol39 = input.symbol(defval = "NFLX", group = "Symbols") symbol40 = input.symbol(defval = "ADBE", group = "Symbols") // old list of Top 40 // symbol1 = input.symbol(defval = "AAPL", group = "Symbols") // symbol2 = input.symbol(defval = "MSFT", group = "Symbols") // symbol3 = input.symbol(defval = "AMZN", group = "Symbols") // symbol4 = input.symbol(defval = "GOOG", group = "Symbols") // symbol5 = input.symbol(defval = "FB", group = "Symbols") // symbol6 = input.symbol(defval = "TSLA", group = "Symbols") // symbol7 = input.symbol(defval = "NVDA", group = "Symbols") // symbol8 = input.symbol(defval = "BRK.B", group = "Symbols") // symbol9 = input.symbol(defval = "JPM", group = "Symbols") // symbol10 = input.symbol(defval = "UNH", group = "Symbols") // symbol11 = input.symbol(defval = "JNJ", group = "Symbols") // symbol12 = input.symbol(defval = "HD", group = "Symbols") // symbol13 = input.symbol(defval = "PG", group = "Symbols") // symbol14 = input.symbol(defval = "V", group = "Symbols") // symbol15 = input.symbol(defval = "PFE", group = "Symbols") // symbol16 = input.symbol(defval = "BAC", group = "Symbols") // symbol17 = input.symbol(defval = "MA", group = "Symbols") // symbol18 = input.symbol(defval = "ADBE", group = "Symbols") // symbol19 = input.symbol(defval = "DIS", group = "Symbols") // symbol20 = input.symbol(defval = "NFLX", group = "Symbols") // symbol21 = input.symbol(defval = "TMO", group = "Symbols") // symbol22 = input.symbol(defval = "XOM", group = "Symbols") // symbol23 = input.symbol(defval = "CRM", group = "Symbols") // symbol24 = input.symbol(defval = "CSCO", group = "Symbols") // symbol25 = input.symbol(defval = "COST", group = "Symbols") // symbol26 = input.symbol(defval = "ABT", group = "Symbols") // symbol27 = input.symbol(defval = "PEP", group = "Symbols") // symbol28 = input.symbol(defval = "ABBV", group = "Symbols") // symbol29 = input.symbol(defval = "KO", group = "Symbols") // symbol30 = input.symbol(defval = "PYPL", group = "Symbols") // symbol31 = input.symbol(defval = "CVX", group = "Symbols") // symbol32 = input.symbol(defval = "CMCSA", group = "Symbols") // symbol33 = input.symbol(defval = "LLY", group = "Symbols") // symbol34 = input.symbol(defval = "QCOM", group = "Symbols") // symbol35 = input.symbol(defval = "NKE", group = "Symbols") // symbol36 = input.symbol(defval = "VZ", group = "Symbols") // symbol37 = input.symbol(defval = "WMT", group = "Symbols") // symbol38 = input.symbol(defval = "INTC", group = "Symbols") // symbol39 = input.symbol(defval = "ACN", group = "Symbols") // symbol40 = input.symbol(defval = "AVGO", group = "Symbols") HighsLows = array.new_int(count, 0) getHighLow(length)=> highest_ = ta.highest(length)[1] lowest_ = ta.lowest(length)[1] int ret = 0 if na(highest_) ret := 2 else bool h_ = ((source == "High/Low" ? high : close) > highest_) bool l_ = ((source == "High/Low" ? low : close) < lowest_) ret := h_ ? 1 : l_ ? -1 : 0 ret getHLindexForTheSymbol(symbol, timeFrame, length, index)=> highlow = request.security(symbol, timeFrame, getHighLow(length)) array.set(HighsLows, index, na(highlow) ? 2 : highlow) getHLindexForTheSymbol(symbol1, timeFrame, length, 0) getHLindexForTheSymbol(symbol2, timeFrame, length, 1) getHLindexForTheSymbol(symbol3, timeFrame, length, 2) getHLindexForTheSymbol(symbol4, timeFrame, length, 3) getHLindexForTheSymbol(symbol5, timeFrame, length, 4) getHLindexForTheSymbol(symbol6, timeFrame, length, 5) getHLindexForTheSymbol(symbol7, timeFrame, length, 6) getHLindexForTheSymbol(symbol8, timeFrame, length, 7) getHLindexForTheSymbol(symbol9, timeFrame, length, 8) getHLindexForTheSymbol(symbol10, timeFrame, length, 9) if count > 10 getHLindexForTheSymbol(symbol11, timeFrame, length, 10) getHLindexForTheSymbol(symbol12, timeFrame, length, 11) getHLindexForTheSymbol(symbol13, timeFrame, length, 12) getHLindexForTheSymbol(symbol14, timeFrame, length, 13) getHLindexForTheSymbol(symbol15, timeFrame, length, 14) getHLindexForTheSymbol(symbol16, timeFrame, length, 15) getHLindexForTheSymbol(symbol17, timeFrame, length, 16) getHLindexForTheSymbol(symbol18, timeFrame, length, 17) getHLindexForTheSymbol(symbol19, timeFrame, length, 18) getHLindexForTheSymbol(symbol20, timeFrame, length, 19) if count > 20 getHLindexForTheSymbol(symbol21, timeFrame, length, 20) getHLindexForTheSymbol(symbol22, timeFrame, length, 21) getHLindexForTheSymbol(symbol23, timeFrame, length, 22) getHLindexForTheSymbol(symbol24, timeFrame, length, 23) getHLindexForTheSymbol(symbol25, timeFrame, length, 24) getHLindexForTheSymbol(symbol26, timeFrame, length, 25) getHLindexForTheSymbol(symbol27, timeFrame, length, 26) getHLindexForTheSymbol(symbol28, timeFrame, length, 27) getHLindexForTheSymbol(symbol29, timeFrame, length, 28) getHLindexForTheSymbol(symbol30, timeFrame, length, 29) if count > 30 getHLindexForTheSymbol(symbol31, timeFrame, length, 30) getHLindexForTheSymbol(symbol32, timeFrame, length, 31) getHLindexForTheSymbol(symbol33, timeFrame, length, 32) getHLindexForTheSymbol(symbol34, timeFrame, length, 33) getHLindexForTheSymbol(symbol35, timeFrame, length, 34) getHLindexForTheSymbol(symbol36, timeFrame, length, 35) getHLindexForTheSymbol(symbol37, timeFrame, length, 36) getHLindexForTheSymbol(symbol38, timeFrame, length, 37) getHLindexForTheSymbol(symbol39, timeFrame, length, 38) getHLindexForTheSymbol(symbol40, timeFrame, length, 39) highs = 0 lows = 0 total = 0 for x = 0 to count -1 highs += (array.get(HighsLows, x) == 1 ? 1 : 0) lows += (array.get(HighsLows, x) == -1 ? 1 : 0) total += (array.get(HighsLows, x) == 1 or array.get(HighsLows, x) == -1 ? 1 : 0) // calculate & show Record High Percent / High Low Index / EMA var float RecordHighPercent = 50 HighLowHist = (highs - lows) HLHist_ma = ta.sma(HighLowHist,HistoLen) RecordHighPercent := total == 0 ? RecordHighPercent : 100 * highs / total HighLowIndex = ta.sma(RecordHighPercent, smoothLength) HLIema = ta.ema(HighLowIndex, emaLength) hline0 = hline(-count, linestyle = hline.style_dotted) hline50 = hline(0, linestyle = hline.style_dotted) hline100 = hline(count, linestyle = hline.style_dotted) fill(hline0, hline50, color = color.rgb(255, 0, 0, 90)) fill(hline50, hline100, color = color.rgb(0, 255, 0, 90)) plot(showHisto ? HighLowHist : na, style = plot.style_columns, title ="Sentiment Histo", color = HighLowHist > 0 ? color.new(color.green,0) : color.new(color.red,0)) plot(showHistoMA ? HLHist_ma : na, title = "Sentiment Histogram MA", color = color.yellow) plot(showRecordHighPercent ? RecordHighPercent*(count/5)/10 - count : na, color = showRecordHighPercent ? #9598a1 : na, title = "Record High %") plot(showEma ? HLIema*(count/5)/10 - count : na, color = showEma ? color.red : na, title = "EMA line") plot(HighLowIndex*(count/5)/10 - count, color = color.blue, linewidth = 2, title = "High Low Index Line") bull_x = ta.crossover(HighLowIndex,HLIema) bear_x = ta.crossunder(HighLowIndex,HLIema) fill(hline0, hline100, color = bull_x ? color.new(color.green,80) : bear_x ? color.new(color.red,80) : na) peak = HighLowIndex[2] <= HighLowIndex[1] and HighLowIndex < HighLowIndex[1] and HighLowIndex > 5 dip = HighLowIndex[2] >= HighLowIndex[1] and HighLowIndex > HighLowIndex[1] and HighLowIndex < 95 peak_ma = HLHist_ma[2] <= HLHist_ma[1] and HLHist_ma < HLHist_ma[1] dip_ma = HLHist_ma[2] >= HLHist_ma[1] and HLHist_ma > HLHist_ma[1] plotshape(showHLI_PD ? dip : na, style=shape.triangleup, location=location.bottom, offset=-1, color=color.blue) plotshape(showHLI_PD ? peak : na, style=shape.triangledown, location=location.top, offset=-1, color=color.blue) plotshape(showHist_PD ? dip_ma : na, style=shape.triangleup, location=location.bottom, offset=-1, color=color.yellow) plotshape(showHist_PD ? peak_ma : na, style=shape.triangledown, location=location.top, offset=-1, color=color.yellow) removeexchange(string [] symbols)=> for x = 0 to array.size(symbols) - 1 array.set(symbols, x, array.get(str.split(array.get(symbols, x), ':'), 1)) // Keep symbol names in an array var symbols = array.from( symbol1, symbol2, symbol3, symbol4, symbol5, symbol6, symbol7, symbol8, symbol9, symbol10, symbol11, symbol12, symbol13, symbol14, symbol15, symbol16, symbol17, symbol18, symbol19, symbol20, symbol21, symbol22, symbol23, symbol24, symbol25, symbol26, symbol27, symbol28, symbol29, symbol30, symbol31, symbol32, symbol33, symbol34, symbol35, symbol36, symbol37, symbol38, symbol39, symbol40) // remove Exchange from the symbols if barstate.isfirst and not ShowExchange removeexchange(symbols) // show the table if barstate.islast and showTable var Table = table.new(position=position.bottom_left, columns=5, rows= count/5, frame_color=color.gray, frame_width=1, border_width=1, border_color=color.black) index = 0 for c = 0 to 4 for r = 0 to count/5 - 1 bcolor = array.get(HighsLows, index) == 1 ? color.lime : array.get(HighsLows, index) == -1 ? color.red : array.get(HighsLows, index) == 2 ? color.black : color.gray tcolor = array.get(HighsLows, index) == 1 ? color.black : array.get(HighsLows, index) == -1 ? color.white : array.get(HighsLows, index) == 2 ? color.gray : color.black table.cell(table_id=Table, column=c, row=r, text=array.get(symbols, index), bgcolor=bcolor, text_color = tcolor, text_size=textsize) index += 1
Moving Averages 3D
https://www.tradingview.com/script/EtM15SgP-Moving-Averages-3D/
LonesomeTheBlue
https://www.tradingview.com/u/LonesomeTheBlue/
1,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/ // © LonesomeTheBlue //@version=5 indicator("Moving Averages 3D", max_lines_count = 500) matype = input.string(defval = 'SMA', title = 'Moving Average Type', options = ['EMA', 'SMA']) len1 = input.int(defval = 10, title = 'Starting Length', minval = 5, inline = 'len') step = input.int(defval = 5, title = 'Step', minval = 1, inline = 'len') colorup = input.string(defval = 'Green', title = 'Colors', options = ['Green', 'Red', 'Blue'], inline = 'colors') colordown = input.string(defval = 'Red', title = '', options = ['Green', 'Red', 'Blue'], inline = 'colors') width = input.int(defval = 2, title = 'Width', minval = 1, maxval = 5) var lines = array.new_line(500) for x = 0 to array.size(lines) - 1 line.delete(array.get(lines, x)) get_ma(length)=> (matype == 'EMA' ? ta.ema(close, length) : ta.sma(close, length)) var sma1 = array.new_float(50, na), array.unshift(sma1, get_ma(len1 + 9 * step)), array.pop(sma1) var sma2 = array.new_float(50, na), array.unshift(sma2, get_ma(len1 + 8 * step)), array.pop(sma2) var sma3 = array.new_float(50, na), array.unshift(sma3, get_ma(len1 + 7 * step)), array.pop(sma3) var sma4 = array.new_float(50, na), array.unshift(sma4, get_ma(len1 + 6 * step)), array.pop(sma4) var sma5 = array.new_float(50, na), array.unshift(sma5, get_ma(len1 + 5 * step)), array.pop(sma5) var sma6 = array.new_float(50, na), array.unshift(sma6, get_ma(len1 + 4 * step)), array.pop(sma6) var sma7 = array.new_float(50, na), array.unshift(sma7, get_ma(len1 + 3 * step)), array.pop(sma7) var sma8 = array.new_float(50, na), array.unshift(sma8, get_ma(len1 + 2 * step)), array.pop(sma8) var sma9 = array.new_float(50, na), array.unshift(sma9, get_ma(len1 + 1 * step)), array.pop(sma9) var sma10 = array.new_float(50, na), array.unshift(sma10, get_ma(len1 + 0 * step)), array.pop(sma10) get_array(array, element)=> array == 1 ? array.get(sma1, element) : array == 2 ? array.get(sma2, element) : array == 3 ? array.get(sma3, element) : array == 4 ? array.get(sma4, element) : array == 5 ? array.get(sma5, element) : array == 6 ? array.get(sma6, element) : array == 7 ? array.get(sma7, element) : array == 8 ? array.get(sma8, element) : array == 9 ? array.get(sma9, element) : array.get(sma10, element) cwidth = (ta.highest(200) - ta.lowest(200)) / 200 cwidthcolor = (ta.highest(200) - ta.lowest(200)) / 4000 get_min_max(value)=> math.min(math.max(value, 0), 255) get_color(value1, value2)=> diff = math.round((value2 - value1) / cwidthcolor) red = colorup == 'Red' ? get_min_max(128 + diff) : colordown == 'Red' ? get_min_max(128 - diff) : 0 green = colorup == 'Green' ? get_min_max(128 + diff) : colordown == 'Green' ? get_min_max(128 - diff) : 0 blue = colorup == 'Blue' ? get_min_max(128 + diff) : colordown == 'Blue' ? get_min_max(128 - diff) : 0 color.rgb(red, green, blue, 0) base = array.get(sma1, 0) if barstate.islast for x = 39 to 0 b1 = base + x * cwidth b2 = base + (x + 1) * cwidth for y = 10 to 1 array.set(lines, x + 40 * y, line.new(x1 = bar_index - 5 * (10 - y) - x * width, y1 = b1 + cwidth * y * 10 + get_array(y, x) - array.get(sma1, 0), x2 = bar_index - 5 * (10 - y) - x * width - width, y2 = b2 + cwidth * y * 10 + get_array(y, x + 1) - array.get(sma1, 0), color = color.new(color.black, 50), style = line.style_dotted)) if y < 10 linefill.new(array.get(lines, x + 40 * y), array.get(lines, x + 40 * (y + 1)), color = get_color(get_array(y, x + 1), get_array(y, x)))
MACRO BTC HEALTH 1W
https://www.tradingview.com/script/V6uyjRkc-MACRO-BTC-HEALTH-1W/
TheSilverApe
https://www.tradingview.com/u/TheSilverApe/
14
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/ // © TheSilverApe //@version=4 study("Overheated,Cold" ,overlay=true) a=sma(close,53) b=sma(close,10) c=a+b d=sma(close,200) plot(c) plot(d) e=sma(close,53) f=sma(close,20) plot(e) plot(f)
ATR with William %R Signal
https://www.tradingview.com/script/Khxf1Zq1-ATR-with-William-R-Signal/
bobbystenly
https://www.tradingview.com/u/bobbystenly/
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/ // © bobbystenly //@version=5 indicator("ATR with William %R Signal", overlay=true, max_labels_count=500) color textColor = color.white color sellColor = color.red color buyColor = color.green // getting all the parameters needed maLength = input.int(10, "MA Length") wprLength = input.int(10, "William %R Length") buyMul = input.float(1.8, "Buy ATR Multiplier", step=0.1) sellMul = input.float(1.8, "Sell ATR Multiplier", step=0.1) // calculate William %R wpr = ta.wpr(wprLength) // calculate ATR atr = ta.atr(maLength) // calculate MA ma = ta.sma(close, maLength) plot(ma, color=color.blue) plot(ma - (buyMul * atr), color=buyColor) plot(ma + (sellMul * atr), color=sellColor) // Buy If price currently lower than MA substracts by ATR (with some multiplier) // To reduce the false signal, check the William %R value and should be on the oversold area and previously reach < -95 if ma - (buyMul * atr) > open and wpr < -80 and wpr[1] < -95 and close > open label.new(bar_index, low, text = "", color= buyColor, textcolor=textColor, style = label.style_label_up) // Sell If price currently higher than MA add by ATR (with some multiplier) // To reduce the false signal, check the William %R value and should be on the overbought area and previously reach > -5 if ma + (sellMul * atr) < close and wpr > -20 and wpr[1] > -5 label.new(bar_index, high, text = "", color= sellColor, textcolor=textColor)
Opens by Raiden v0.2
https://www.tradingview.com/script/EahGvY9H-Opens-by-Raiden-v0-2/
tvwfree0002
https://www.tradingview.com/u/tvwfree0002/
117
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/ // © rumpypumpydumpy //@version=5 indicator("Opens by Raiden", overlay = true, max_lines_count = 56, max_labels_count = 56) // Create Level Function { // ----------------------------------------------------------------------------- f_create_level(_type, _start_condition, _active_condition, _global_level_array, _color, _line_width, _line_ext, _line_style, _label_size, _title, _iter, _is_enabled) => // _type [ string ] : Determines level type to manage. Available options : "open", "high", "low", "eq" // _start_condition [ bool ] : Determines when to obtain initial value // _active_condition [ bool ] : Determines when to continue updated value if applicable // _global_level_array [ float[] ] : global array where other of same type of levels are stored to find duplicates // _color [ color ] : color of line/text // _line_ext [ int ] : Distance to extend line to the right // _line_style [ const string ] : line style type // _label_size [ const string ] : label size used to set text size // _title [ string ] : Prefix for level's text // _iter [ int ] : How many previous iterations to retrieve level from // _is_enabled : Override for disabling level var float _price = na var int _start_time = na var float _hh = na var float _ll = na var line _price_line = line.new(x1 = na, y1 = na, x2 = na, y2 = na, xloc = xloc.bar_time, color = _color, width = _line_width, style = _line_style) var label _price_label = label.new(x = na, y = na, xloc = xloc.bar_time, style = label.style_label_left, color = #00000000, size = _label_size, textcolor = _color) _end_time = int(time + _line_ext * ta.change(time)) if _type == "open" if _start_condition _price := open _start_time := time else if _type == "high" if _start_condition _price := high _start_time := time else if _active_condition _price := math.max(_price, high) else if _type == "low" if _start_condition _price := low _start_time := time else if _active_condition _price := math.min(_price, low) else if _type == "eq" if _start_condition _hh := high _ll := low _price := math.avg(_hh, _ll) _start_time := time else if _active_condition _hh := math.max(_hh, high) _ll := math.min(_ll, low) _price := math.avg(_hh, _ll) float _price_val = _iter == 0 ? _price : ta.valuewhen(_start_condition, _price[1], _iter - 1) int _start_time_val = _iter == 0 ? _start_time : ta.valuewhen(_start_condition, _start_time[1], _iter - 1) _found_existing = array.indexof(_global_level_array, _price_val) > -1 if _is_enabled if _found_existing line.set_xy1(_price_line, x = na, y = na) line.set_xy2(_price_line, x = na, y = na) label.set_xy(_price_label, x = na, y = na) else array.push(_global_level_array, _price_val) line.set_xy1(_price_line, x = _start_time_val, y = _price_val) line.set_xy2(_price_line, x = _end_time, y = _price_val) label.set_text(_price_label, text = _title + " : " + str.tostring(_price_val)) label.set_xy(_price_label, x = _end_time, y = _price_val) // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // } // Necessary Variables { // ----------------------------------------------------------------------------- // Global arrays used to detect duplicate levels. // Duplication is detected implicitly by execution order and whether the level has already been placed in the global array. float[] global_open_array = array.new_float() float[] global_high_array = array.new_float() float[] global_low_array = array.new_float() float[] global_eq_array = array.new_float() new_H4 = ta.change(time("240")) != 0 new_day = ta.change(time("D")) != 0 new_week = ta.change(time("W")) != 0 new_month = ta.change(time("M")) != 0 new_quarter = ta.change(time("3M")) != 0 new_year = ta.change(time("12M")) != 0 is_monday = dayofweek == dayofweek.monday // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // } // Global settings { // ----------------------------------------------------------------------------- inp_open_line_style = input.string("Solid", options = ["Solid", "Dotted", "Dashed"], title = "Open Line Style", group = "Global Settings") inp_high_line_style = input.string("Solid", options = ["Solid", "Dotted", "Dashed"], title = "High Line Style", group = "Global Settings") inp_low_line_style = input.string("Solid", options = ["Solid", "Dotted", "Dashed"], title = "Low Line Style", group = "Global Settings") inp_eq_line_style = input.string("Solid", options = ["Solid", "Dotted", "Dashed"], title = "EQ Line Style", group = "Global Settings") inp_text_size = input.string("Small", options = ["Small", "Normal", "Large"], title = "Text Size", group = "Global Settings") inp_ext = input.int(30, title = "Line Extension", group = "Global Settings") text_size = inp_text_size == "Small" ? size.small : inp_text_size == "Normal" ? size.normal : size.large open_line_style = inp_open_line_style == "Solid" ? line.style_solid : inp_open_line_style == "Dotted" ? line.style_dotted : line.style_dashed high_line_style = inp_high_line_style == "Solid" ? line.style_solid : inp_high_line_style == "Dotted" ? line.style_dotted : line.style_dashed low_line_style = inp_low_line_style == "Solid" ? line.style_solid : inp_low_line_style == "Dotted" ? line.style_dotted : line.style_dashed eq_line_style = inp_eq_line_style == "Solid" ? line.style_solid : inp_eq_line_style == "Dotted" ? line.style_dotted : line.style_dashed // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // } // Yearly & Prev Yearly // ----------------------------------------------------------------------------- inp_show_yearly_open = input.bool(true, title = "OPEN", group = "Yearly Levels", inline = "1") inp_show_yearly_high = input.bool(true, title = "HIGH", group = "Yearly Levels", inline = "1") inp_show_yearly_low = input.bool(true, title = "LOW", group = "Yearly Levels", inline = "1") inp_show_yearly_eq = input.bool(true, title = "EQ", group = "Yearly Levels", inline = "1") inp_yearly_col = input.color(color.red, title = "color", group = "Yearly Levels", inline = "2") inp_yearly_line_width = input.int(1, title = "Line width", minval = 1, group = "Yearly Levels", inline = "2") yearly_ok = timeframe.isintraday or timeframe.isdaily or timeframe.isweekly or (timeframe.ismonthly and timeframe.multiplier < 12) f_create_level("open", new_year, not new_year, global_open_array, inp_yearly_col, inp_yearly_line_width, inp_ext, open_line_style, text_size, "YO", 0, inp_show_yearly_open and yearly_ok) f_create_level("high", new_year, not new_year, global_high_array, inp_yearly_col, inp_yearly_line_width, inp_ext, high_line_style, text_size, "Yearly HIGH", 0, inp_show_yearly_high and yearly_ok) f_create_level("low", new_year, not new_year, global_low_array, inp_yearly_col, inp_yearly_line_width, inp_ext, low_line_style, text_size, "Yearly LOW", 0, inp_show_yearly_low and yearly_ok) f_create_level("eq", new_year, not new_year, global_eq_array, inp_yearly_col, inp_yearly_line_width, inp_ext, eq_line_style, text_size, "Yearly EQ", 0, inp_show_yearly_eq and yearly_ok) inp_show_prev_yearly_open = input.bool(true, title = "OPEN", group = "Prev Yearly Levels", inline = "1") inp_show_prev_yearly_high = input.bool(true, title = "HIGH", group = "Prev Yearly Levels", inline = "1") inp_show_prev_yearly_low = input.bool(true, title = "LOW", group = "Prev Yearly Levels", inline = "1") inp_show_prev_yearly_eq = input.bool(true, title = "EQ", group = "Prev Yearly Levels", inline = "1") inp_prev_yearly_col = input.color(color.maroon, title = "color", group = "Prev Yearly Levels", inline = "2") inp_prev_yearly_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Yearly Levels", inline = "2") f_create_level("open", new_year, not new_year, global_open_array, inp_prev_yearly_col, inp_prev_yearly_line_width, inp_ext, open_line_style, text_size, "PYO", 1, inp_show_prev_yearly_open and yearly_ok) f_create_level("high", new_year, not new_year, global_high_array, inp_prev_yearly_col, inp_prev_yearly_line_width, inp_ext, high_line_style, text_size, "Prev Yearly HIGH", 1, inp_show_prev_yearly_high and yearly_ok) f_create_level("low", new_year, not new_year, global_low_array, inp_prev_yearly_col, inp_prev_yearly_line_width, inp_ext, low_line_style, text_size, "Prev Yearly LOW", 1, inp_show_prev_yearly_low and yearly_ok) f_create_level("eq", new_year, not new_year, global_eq_array, inp_prev_yearly_col, inp_prev_yearly_line_width, inp_ext, eq_line_style, text_size, "Prev Yearly EQ", 1, inp_show_prev_yearly_eq and yearly_ok) // ----------------------------------------------------------------------------- // Quarterly and Prev Quarterly // ----------------------------------------------------------------------------- inp_show_quarterly_open = input.bool(true, title = "OPEN", group = "Quarterly Levels", inline = "1") inp_show_quarterly_high = input.bool(true, title = "HIGH", group = "Quarterly Levels", inline = "1") inp_show_quarterly_low = input.bool(true, title = "LOW", group = "Quarterly Levels", inline = "1") inp_show_quarterly_eq = input.bool(true, title = "EQ", group = "Quarterly Levels", inline = "1") inp_quarterly_col = input.color(color.orange, title = "color", group = "Quarterly Levels", inline = "2") inp_quarterly_line_width = input.int(1, title = "Line width", minval = 1, group = "Quarterly Levels", inline = "2") quarterly_ok = timeframe.isintraday or timeframe.isdaily or timeframe.isweekly f_create_level("open", new_quarter, not new_quarter, global_open_array, inp_quarterly_col, inp_quarterly_line_width, inp_ext, open_line_style, text_size, "Quarterly Open", 0, inp_show_quarterly_open and quarterly_ok) f_create_level("high", new_quarter, not new_quarter, global_high_array, inp_quarterly_col, inp_quarterly_line_width, inp_ext, high_line_style, text_size, "Quarterly HIGH", 0, inp_show_quarterly_high and quarterly_ok) f_create_level("low", new_quarter, not new_quarter, global_low_array, inp_quarterly_col, inp_quarterly_line_width, inp_ext, low_line_style, text_size, "Quarterly LOW", 0, inp_show_quarterly_low and quarterly_ok) f_create_level("eq", new_quarter, not new_quarter, global_eq_array, inp_quarterly_col, inp_quarterly_line_width, inp_ext, eq_line_style, text_size, "Quarterly EQ", 0, inp_show_quarterly_eq and quarterly_ok) inp_show_prev_quarterly_open = input.bool(true, title = "OPEN", group = "Prev Quarterly Levels", inline = "1") inp_show_prev_quarterly_high = input.bool(true, title = "HIGH", group = "Prev Quarterly Levels", inline = "1") inp_show_prev_quarterly_low = input.bool(true, title = "LOW", group = "Prev Quarterly Levels", inline = "1") inp_show_prev_quarterly_eq = input.bool(true, title = "EQ", group = "Prev Quarterly Levels", inline = "1") inp_prev_quarterly_col = input.color(color.yellow, title = "color", group = "Prev Quarterly Levels", inline = "2") inp_prev_quarterly_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Quarterly Levels", inline = "2") f_create_level("open", new_quarter, not new_quarter, global_open_array, inp_prev_quarterly_col, inp_prev_quarterly_line_width, inp_ext, open_line_style, text_size, "P Quarterly Open", 1, inp_show_prev_quarterly_open and quarterly_ok) f_create_level("high", new_quarter, not new_quarter, global_high_array, inp_prev_quarterly_col, inp_prev_quarterly_line_width, inp_ext, high_line_style, text_size, "Prev Quarterly HIGH", 1, inp_show_prev_quarterly_high and quarterly_ok) f_create_level("low", new_quarter, not new_quarter, global_low_array, inp_prev_quarterly_col, inp_prev_quarterly_line_width, inp_ext, low_line_style, text_size, "Prev Quarterly LOW", 1, inp_show_prev_quarterly_low and quarterly_ok) f_create_level("eq", new_quarter, not new_quarter, global_eq_array, inp_prev_quarterly_col, inp_prev_quarterly_line_width, inp_ext, eq_line_style, text_size, "Prev Quarterly EQ", 1, inp_show_prev_quarterly_eq and quarterly_ok) // ----------------------------------------------------------------------------- // Monthly and Prev Monthly // ----------------------------------------------------------------------------- inp_show_monthly_open = input.bool(true, title = "OPEN", group = "Monthly Levels", inline = "1") inp_show_monthly_high = input.bool(true, title = "HIGH", group = "Monthly Levels", inline = "1") inp_show_monthly_low = input.bool(true, title = "LOW", group = "Monthly Levels", inline = "1") inp_show_monthly_eq = input.bool(true, title = "EQ", group = "Monthly Levels", inline = "1") inp_monthly_col = input.color(color.lime, title = "color", group = "Monthly Levels", inline = "2") inp_monthly_line_width = input.int(1, title = "Line width", minval = 1, group = "Monthly Levels", inline = "2") monthly_ok = timeframe.isintraday or timeframe.isdaily f_create_level("open", new_month, not new_month, global_open_array, inp_monthly_col, inp_monthly_line_width, inp_ext, open_line_style, text_size, "MO", 0, inp_show_monthly_open and monthly_ok) f_create_level("high", new_month, not new_month, global_high_array, inp_monthly_col, inp_monthly_line_width, inp_ext, high_line_style, text_size, "Monthly HIGH", 0, inp_show_monthly_high and monthly_ok) f_create_level("low", new_month, not new_month, global_low_array, inp_monthly_col, inp_monthly_line_width, inp_ext, low_line_style, text_size, "Monthly LOW", 0, inp_show_monthly_low and monthly_ok) f_create_level("eq", new_month, not new_month, global_eq_array, inp_monthly_col, inp_monthly_line_width, inp_ext, eq_line_style, text_size, "Monthly EQ", 0, inp_show_monthly_eq and monthly_ok) inp_show_prev_monthly_open = input.bool(true, title = "OPEN", group = "Prev Monthly Levels", inline = "1") inp_show_prev_monthly_high = input.bool(true, title = "HIGH", group = "Prev Monthly Levels", inline = "1") inp_show_prev_monthly_low = input.bool(true, title = "LOW", group = "Prev Monthly Levels", inline = "1") inp_show_prev_monthly_eq = input.bool(true, title = "EQ", group = "Prev Monthly Levels", inline = "1") inp_prev_monthly_col = input.color(color.green, title = "color", group = "Prev Monthly Levels", inline = "2") inp_prev_monthly_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Monthly Levels", inline = "2") f_create_level("open", new_month, not new_month, global_open_array, inp_prev_monthly_col, inp_prev_monthly_line_width, inp_ext, open_line_style, text_size, "PMO", 1, inp_show_prev_monthly_open and monthly_ok) f_create_level("high", new_month, not new_month, global_high_array, inp_prev_monthly_col, inp_prev_monthly_line_width, inp_ext, high_line_style, text_size, "Prev Monthly HIGH", 1, inp_show_prev_monthly_high and monthly_ok) f_create_level("low", new_month, not new_month, global_low_array, inp_prev_monthly_col, inp_prev_monthly_line_width, inp_ext, low_line_style, text_size, "Prev Monthly LOW", 1, inp_show_prev_monthly_low and monthly_ok) f_create_level("eq", new_month, not new_month, global_eq_array, inp_prev_monthly_col, inp_prev_monthly_line_width, inp_ext, eq_line_style, text_size, "Prev Monthly EQ", 1, inp_show_prev_monthly_eq and monthly_ok) // ----------------------------------------------------------------------------- // Weekly and Prev Weekly // ----------------------------------------------------------------------------- inp_show_weekly_open = input.bool(true, title = "OPEN", group = "Weekly Levels", inline = "1") inp_show_weekly_high = input.bool(true, title = "HIGH", group = "Weekly Levels", inline = "1") inp_show_weekly_low = input.bool(true, title = "LOW", group = "Weekly Levels", inline = "1") inp_show_weekly_eq = input.bool(true, title = "EQ", group = "Weekly Levels", inline = "1") inp_weekly_col = input.color(color.aqua, title = "color", group = "Weekly Levels", inline = "2") inp_weekly_line_width = input.int(1, title = "Line width", minval = 1, group = "Weekly Levels", inline = "2") weekly_ok = timeframe.isintraday or timeframe.isdaily f_create_level("open", new_week, not new_week, global_open_array, inp_weekly_col, inp_weekly_line_width, inp_ext, open_line_style, text_size, "WO", 0, inp_show_weekly_open and weekly_ok) f_create_level("high", new_week, not new_week, global_high_array, inp_weekly_col, inp_weekly_line_width, inp_ext, high_line_style, text_size, "Weekly HIGH", 0, inp_show_weekly_high and weekly_ok) f_create_level("low", new_week, not new_week, global_low_array, inp_weekly_col, inp_weekly_line_width, inp_ext, low_line_style, text_size, "Weekly LOW", 0, inp_show_weekly_low and weekly_ok) f_create_level("eq", new_week, not new_week, global_eq_array, inp_weekly_col, inp_weekly_line_width, inp_ext, eq_line_style, text_size, "Weekly EQ", 0, inp_show_weekly_eq and weekly_ok) inp_show_prev_weekly_open = input.bool(true, title = "OPEN", group = "Prev Weekly Levels", inline = "1") inp_show_prev_weekly_high = input.bool(true, title = "HIGH", group = "Prev Weekly Levels", inline = "1") inp_show_prev_weekly_low = input.bool(true, title = "LOW", group = "Prev Weekly Levels", inline = "1") inp_show_prev_weekly_eq = input.bool(true, title = "EQ", group = "Prev Weekly Levels", inline = "1") inp_prev_weekly_col = input.color(color.blue, title = "color", group = "Prev Weekly Levels", inline = "2") inp_prev_weekly_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Weekly Levels", inline = "2") f_create_level("open", new_week, not new_week, global_open_array, inp_prev_weekly_col, inp_prev_weekly_line_width, inp_ext, open_line_style, text_size, "PWO", 1, inp_show_prev_weekly_open and weekly_ok) f_create_level("high", new_week, not new_week, global_high_array, inp_prev_weekly_col, inp_prev_weekly_line_width, inp_ext, high_line_style, text_size, "Prev Weekly HIGH", 1, inp_show_prev_weekly_high and weekly_ok) f_create_level("low", new_week, not new_week, global_low_array, inp_prev_weekly_col, inp_prev_weekly_line_width, inp_ext, low_line_style, text_size, "Prev Weekly LOW", 1, inp_show_prev_weekly_low and weekly_ok) f_create_level("eq", new_week, not new_week, global_eq_array, inp_prev_weekly_col, inp_prev_weekly_line_width, inp_ext, eq_line_style, text_size, "Prev Weekly EQ", 1, inp_show_prev_weekly_eq and weekly_ok) // ----------------------------------------------------------------------------- // Daily and Prev Daily // ----------------------------------------------------------------------------- inp_show_daily_open = input.bool(true, title = "OPEN", group = "Daily Levels", inline = "1") inp_show_daily_high = input.bool(true, title = "HIGH", group = "Daily Levels", inline = "1") inp_show_daily_low = input.bool(true, title = "LOW", group = "Daily Levels", inline = "1") inp_show_daily_eq = input.bool(true, title = "EQ", group = "Daily Levels", inline = "1") inp_daily_col = input.color(color.white, title = "color", group = "Daily Levels", inline = "2") inp_daily_line_width = input.int(1, title = "Line width", minval = 1, group = "Daily Levels", inline = "2") daily_ok = timeframe.isintraday f_create_level("open", new_day, not new_day, global_open_array, inp_daily_col, inp_daily_line_width, inp_ext, open_line_style, text_size, "DO", 0, inp_show_daily_open and daily_ok) f_create_level("high", new_day, not new_day, global_high_array, inp_daily_col, inp_daily_line_width, inp_ext, high_line_style, text_size, "Daily HIGH", 0, inp_show_daily_high and daily_ok) f_create_level("low", new_day, not new_day, global_low_array, inp_daily_col, inp_daily_line_width, inp_ext, low_line_style, text_size, "Daily LOW", 0, inp_show_daily_low and daily_ok) f_create_level("eq", new_day, not new_day, global_eq_array, inp_daily_col, inp_daily_line_width, inp_ext, eq_line_style, text_size, "Daily EQ", 0, inp_show_daily_eq and daily_ok) inp_show_prev_daily_open = input.bool(true, title = "OPEN", group = "Prev Daily Levels", inline = "1") inp_show_prev_daily_high = input.bool(true, title = "HIGH", group = "Prev Daily Levels", inline = "1") inp_show_prev_daily_low = input.bool(true, title = "LOW", group = "Prev Daily Levels", inline = "1") inp_show_prev_daily_eq = input.bool(true, title = "EQ", group = "Prev Daily Levels", inline = "1") inp_prev_daily_col = input.color(color.gray, title = "color", group = "Prev Daily Levels", inline = "2") inp_prev_daily_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Daily Levels", inline = "2") f_create_level("open", new_day, not new_day, global_open_array, inp_prev_daily_col, inp_prev_daily_line_width, inp_ext, open_line_style, text_size, "PDO", 1, inp_show_prev_daily_open and daily_ok) f_create_level("high", new_day, not new_day, global_high_array, inp_prev_daily_col, inp_prev_daily_line_width, inp_ext, high_line_style, text_size, "Prev Daily HIGH", 1, inp_show_prev_daily_high and daily_ok) f_create_level("low", new_day, not new_day, global_low_array, inp_prev_daily_col, inp_prev_daily_line_width, inp_ext, low_line_style, text_size, "Prev Daily LOW", 1, inp_show_prev_daily_low and daily_ok) f_create_level("eq", new_day, not new_day, global_eq_array, inp_prev_daily_col, inp_prev_daily_line_width, inp_ext, eq_line_style, text_size, "Prev Daily EQ", 1, inp_show_prev_daily_eq and daily_ok) // ----------------------------------------------------------------------------- // Monday and Prev Monday // ----------------------------------------------------------------------------- // Note : Monday range is a special case and is why the _active_condition is implemented in the function. We only want start on Monday, and ONLY update levels during monday. inp_show_monday_open = input.bool(true, title = "OPEN", group = "Monday Levels", inline = "1") inp_show_monday_high = input.bool(true, title = "HIGH", group = "Monday Levels", inline = "1") inp_show_monday_low = input.bool(true, title = "LOW", group = "Monday Levels", inline = "1") inp_show_monday_eq = input.bool(true, title = "EQ", group = "Monday Levels", inline = "1") inp_monday_col = input.color(color.fuchsia, title = "color", group = "Monday Levels", inline = "2") inp_monday_line_width = input.int(1, title = "Line width", minval = 1, group = "Monday Levels", inline = "2") monday_ok = timeframe.isintraday f_create_level("open", new_week, is_monday, global_open_array, inp_monday_col, inp_monday_line_width, inp_ext, open_line_style, text_size, "Monday OPEN", 0, inp_show_monday_open and monday_ok) f_create_level("high", new_week, is_monday, global_high_array, inp_monday_col, inp_monday_line_width, inp_ext, high_line_style, text_size, "M.Day HIGH", 0, inp_show_monday_high and monday_ok) f_create_level("low", new_week, is_monday, global_low_array, inp_monday_col, inp_monday_line_width, inp_ext, low_line_style, text_size, "M.Day LOW", 0, inp_show_monday_low and monday_ok) f_create_level("eq", new_week, is_monday, global_eq_array, inp_monday_col, inp_monday_line_width, inp_ext, eq_line_style, text_size, "M.Day EQ", 0, inp_show_monday_eq and monday_ok) inp_show_prev_monday_open = input.bool(true, title = "OPEN", group = "Prev Monday Levels", inline = "1") inp_show_prev_monday_high = input.bool(true, title = "HIGH", group = "Prev Monday Levels", inline = "1") inp_show_prev_monday_low = input.bool(true, title = "LOW", group = "Prev Monday Levels", inline = "1") inp_show_prev_monday_eq = input.bool(true, title = "EQ", group = "Prev Monday Levels", inline = "1") inp_prev_monday_col = input.color(color.purple, title = "color", group = "Prev Monday Levels", inline = "2") inp_prev_monday_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev Monday Levels", inline = "2") f_create_level("open", new_week, is_monday, global_open_array, inp_prev_monday_col, inp_prev_monday_line_width, inp_ext, open_line_style, text_size, "Prev Monday OPEN", 1, inp_show_prev_monday_open and monday_ok) f_create_level("high", new_week, is_monday, global_high_array, inp_prev_monday_col, inp_prev_monday_line_width, inp_ext, high_line_style, text_size, "Prev Monday HIGH", 1, inp_show_prev_monday_high and monday_ok) f_create_level("low", new_week, is_monday, global_low_array, inp_prev_monday_col, inp_prev_monday_line_width, inp_ext, low_line_style, text_size, "Prev Monday LOW", 1, inp_show_prev_monday_low and monday_ok) f_create_level("eq", new_week, is_monday, global_eq_array, inp_prev_monday_col, inp_prev_monday_line_width, inp_ext, eq_line_style, text_size, "Prev Monday EQ", 1, inp_show_prev_monday_eq and monday_ok) // ----------------------------------------------------------------------------- // H4 and Prev H4 // ----------------------------------------------------------------------------- inp_show_H4_open = input.bool(true, title = "OPEN", group = "H4 Levels", inline = "1") inp_show_H4_high = input.bool(true, title = "HIGH", group = "H4 Levels", inline = "1") inp_show_H4_low = input.bool(true, title = "LOW", group = "H4 Levels", inline = "1") inp_show_H4_eq = input.bool(true, title = "EQ", group = "H4 Levels", inline = "1") inp_H4_col = input.color(color.teal, title = "color", group = "H4 Levels", inline = "2") inp_H4_line_width = input.int(1, title = "Line width", minval = 1, group = "H4 Levels", inline = "2") H4_ok = timeframe.isintraday and timeframe.multiplier < 240 f_create_level("open", new_H4, not new_H4, global_open_array, inp_H4_col, inp_H4_line_width, inp_ext, open_line_style, text_size, "H4 OPEN", 0, inp_show_H4_open and H4_ok) f_create_level("high", new_H4, not new_H4, global_high_array, inp_H4_col, inp_H4_line_width, inp_ext, high_line_style, text_size, "H4 HIGH", 0, inp_show_H4_high and H4_ok) f_create_level("low", new_H4, not new_H4, global_low_array, inp_H4_col, inp_H4_line_width, inp_ext, low_line_style, text_size, "H4 LOW", 0, inp_show_H4_low and H4_ok) f_create_level("eq", new_H4, not new_H4, global_eq_array, inp_H4_col, inp_H4_line_width, inp_ext, eq_line_style, text_size, "H4 EQ", 0, inp_show_H4_eq and H4_ok) inp_show_prev_H4_open = input.bool(true, title = "OPEN", group = "Prev H4 Levels", inline = "1") inp_show_prev_H4_high = input.bool(true, title = "HIGH", group = "Prev H4 Levels", inline = "1") inp_show_prev_H4_low = input.bool(true, title = "LOW", group = "Prev H4 Levels", inline = "1") inp_show_prev_H4_eq = input.bool(true, title = "EQ", group = "Prev H4 Levels", inline = "1") inp_prev_H4_col = input.color(color.olive, title = "color", group = "Prev H4 Levels", inline = "2") inp_prev_H4_line_width = input.int(1, title = "Line width", minval = 1, group = "Prev H4 Levels", inline = "2") f_create_level("open", new_H4, not new_H4, global_open_array, inp_prev_H4_col, inp_prev_H4_line_width, inp_ext, open_line_style, text_size, "Prev H4 OPEN", 1, inp_show_prev_H4_open and H4_ok) f_create_level("high", new_H4, not new_H4, global_high_array, inp_prev_H4_col, inp_prev_H4_line_width, inp_ext, high_line_style, text_size, "Prev H4 HIGH", 1, inp_show_prev_H4_high and H4_ok) f_create_level("low", new_H4, not new_H4, global_low_array, inp_prev_H4_col, inp_prev_H4_line_width, inp_ext, low_line_style, text_size, "Prev H4 LOW", 1, inp_show_prev_H4_low and H4_ok) f_create_level("eq", new_H4, not new_H4, global_eq_array, inp_prev_H4_col, inp_prev_H4_line_width, inp_ext, eq_line_style, text_size, "Prev H4 EQ", 1, inp_show_prev_H4_eq and H4_ok) // -----------------------------------------------------------------------------
15 minute EMA's TM
https://www.tradingview.com/script/F2w4M54J-15-minute-EMA-s-TM/
garethw052
https://www.tradingview.com/u/garethw052/
17
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © garethw052 //@version=5 //@version=5 indicator("15 minute EMA's", overlay=true) //muti timeframe confirmation emaLength1562 = input(title='EMA 15 Length 62', defval=62) emaLength1518 = input(title='EMA 15 Length 18', defval=18) emaLength155 = input(title='EMA 15 Length 5', defval=5) //15 ema8() => ta.ema(close,emaLength155) my_155 = request.security(syminfo.tickerid, '15', ema8() ) plot(my_155,color=color.new(color.blue, 0), linewidth=2) ema9() => ta.ema(close,emaLength1518) my_1518 = request.security(syminfo.tickerid, '15', ema9() ) plot(my_1518,color=color.new(color.black, 0), linewidth=2) ema10() => ta.ema(close,emaLength1562) my_1562 = request.security(syminfo.tickerid, '15', ema10() ) plot(my_1562,color=color.new(color.green, 0), linewidth=2)
Mohsen Big Candle
https://www.tradingview.com/script/PDbm2xgx-Mohsen-Big-Candle/
joyfulPie52104
https://www.tradingview.com/u/joyfulPie52104/
18
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © joyfulPie52104 //@version=5 indicator("Mohsen Big Candle", overlay = true) candle_length = input(10) big_candle = false if math.abs(close - open) > candle_length or math.abs(open - close) > candle_length big_candle := true barcolor(big_candle ? color.black : na) // plot(close)
Momentum Ribbon
https://www.tradingview.com/script/hvU8ssqG-Momentum-Ribbon/
TheRiskChair
https://www.tradingview.com/u/TheRiskChair/
208
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/ // © TheRiskChair // @version=5 indicator("Momentum Ribbon", overlay=true) // Get MA Lengths var g_length = "MA Length" maLength1 = input.int(title="MA Length #1", defval=21, minval=1, step=10, group=g_length) maLength2 = input.int(title="MA Length #2", defval=25, minval=0, step=10, group=g_length) maLength3 = input.int(title="MA Length #3", defval=30, minval=0, step=10, group=g_length) maLength4 = input.int(title="MA Length #4", defval=35, minval=0, step=10, group=g_length) maLength5 = input.int(title="MA Length #5", defval=40, minval=0, step=10, group=g_length) maLength6 = input.int(title="MA Length #5", defval=45, minval=0, step=10, group=g_length) maLength7 = input.int(title="MA Length #5", defval=50, minval=0, step=10, group=g_length) maLength8 = input.int(title="MA Length #5", defval=55, minval=0, step=10, group=g_length) maLength9 = input.int(title="MA Length #5", defval=100, minval=0, step=10, group=g_length) // Get MA Types var g_type = "MA Type" maType1 = input.string(title="MA Type #1", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType2 = input.string(title="MA Type #2", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType3 = input.string(title="MA Type #3", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType4 = input.string(title="MA Type #4", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType5 = input.string(title="MA Type #5", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType6 = input.string(title="MA Type #5", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType7 = input.string(title="MA Type #5", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType8 = input.string(title="MA Type #5", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) maType9 = input.string(title="MA Type #5", defval="EMA", options=["EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) allMaType = input.string(title="ALL MA TYPE", defval="Disabled", options=["Disabled", "EMA", "SMA", "HMA", "WMA", "DEMA", "VWMA", "VWAP"], group=g_type) // Get selected Moving Average getMA(_maType, _maLength) => if _maLength == 0 na else switch allMaType == "Disabled" ? _maType : allMaType "SMA" => ta.sma(close, _maLength) "HMA" => ta.hma(close, _maLength) "WMA" => ta.wma(close, _maLength) "VWMA" => ta.vwma(close, _maLength) "VWAP" => ta.vwap "DEMA" => e1 = ta.ema(close, _maLength) e2 = ta.ema(e1, _maLength) 2 * e1 - e2 => ta.ema(close, _maLength) // Get MAs ma1 = getMA(maType1, maLength1) ma2 = getMA(maType2, maLength2) ma3 = getMA(maType3, maLength3) ma4 = getMA(maType4, maLength4) ma5 = getMA(maType5, maLength5) ma6 = getMA(maType6, maLength6) ma7 = getMA(maType7, maLength7) ma8 = getMA(maType8, maLength8) ma9 = getMA(maType9, maLength9) // Draw MAs a=plot(ma1, color=close >= ma1 ? color.new(#1dfa00, 0) : color.new(#fa0000, 0), linewidth=1, title="MA #1") plot(maLength2 == 0 ? na : ma2, color=close >= ma2 ? color.new(#00ffff, 20) : color.new(#fad900, 20), linewidth=1, title="MA #2") plot(maLength3 == 0 ? na : ma3, color=close >= ma3 ? color.new(#00e8dc, 20) : color.new(#fac800, 20), linewidth=2, title="MA #3") plot(maLength4 == 0 ? na : ma4, color=close >= ma4 ? color.new(#00d9bc, 20) : color.new(#e6a800, 20), linewidth=2, title="MA #4") plot(maLength5 == 0 ? na : ma5, color=close >= ma5 ? color.new(#00bf99, 20) : color.new(#c96f00, 20), linewidth=2, title="MA #5") plot(maLength6 == 0 ? na : ma6, color=close >= ma6 ? color.new(#00b078, 20) : color.new(#a33f00, 20), linewidth=3, title="MA #6") plot(maLength7 == 0 ? na : ma7, color=close >= ma7 ? color.new(#009e52, 20) : color.new(#8f2501, 20), linewidth=3, title="MA #7") b=plot(maLength8 == 0 ? na : ma8, color=close >= ma8 ? color.new(#006e02, 20) : color.new(#750800, 20), linewidth=4, title="MA #8") c=plot(maLength9 == 0 ? na : ma9, color=close >= ma9 ? color.new(#005401, 30) : color.new(#750101, 30), linewidth=5, title="MA #9") clookback = 5 spreadchange = ma1 - ma9 spreaddiff = spreadchange - spreadchange[clookback] spreadPct = (spreaddiff / spreadchange) * 100 fillColor = ma1 > ma9 ? (color.from_gradient(ma6, ma9, ma1, color.new(#36ff4a,60), color.new(#3363ff,85))) : ma1 < ma9 ? color.from_gradient(ma6, ma1, ma9, color.new(#3363ff,90), color.new(#fc0000,40)) : na fill(a, c, fillColor)
PSAR Optimization Script
https://www.tradingview.com/script/6FcNhF4f-PSAR-Optimization-Script/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
570
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 //@version=5 indicator("My script", overlay = true) pType = input.string(defval = "Cumulative Gain", title = "Plot SAR and Data Based on Highest: ", options = ["Cumulative Gain", "Average Gain"], tooltip = "Cumulative Gain: The Table Will Display SAR Performance Based on Cumulative Gains \n\nAverage Gain: The Table Will Display SAR Performance Based on Average Gains") style = input.string(defval = "Diamond", title = "SAR Style", options = ["Diamond", "Circles"]) sMB = input.float(0.01, step = 0.01, minval = 0, title = "Benchmark Starting Acceleration Factor", group = "Benchmark SAR", tooltip = "Becnhmark SAR (SAR #1) Starting Acceleration Factor. Adjusting This Parameter Changes the Initial Acceleration Factor Following a Change in SAR (Rising to Falling : Falling to Rising)") iMB = input.float(0.01, step = 0.01, minval = 0, title = "Benchmark Acceleration Factor Rate of Increase", tooltip = "Benchmark SAR (SAR #1) Acceleration Factor Rate of Increase. Adjusting This Parameter Changes the Rate at Which SAR Increases (When Rising) Or Decreases (When Falling)") mMB = input.float(0.01, step = 0.01, minval = 0, title = "Benchmark Acceleration Factor Max Value", tooltip = "Benchmark SAR (SAR #1) Acceleration Factor Maximum Value. Adjusting This Parameter Changes the Maximum Rate at Which SAR Will Increase (When Rising) Or Decrease (When Falling)") sMT = input.float(0.01, step = 0.01, minval = 0, title = "Test Starting Acceleration Factor", group = "Test SAR", tooltip = "Test SAR (SAR #2) Starting Acceleration Factor. Adjusting This Parameter Changes the Initial Acceleration Factor Following a Change in SAR (Rising to Falling : Falling to Rising)") iMT = input.float(0.01, step = 0.01, minval = 0, title = "Test Acceleration Factor Rate of Increase", tooltip = "Test SAR (SAR #2) Acceleration Factor Rate of Increase. Adjusting This Parameter Changes the Rate at Which SAR Increases (When Rising) Or Decreases (When Falling) ") mMT= input.float(0.01, step = 0.01, minval = 0, title = "Test Acceleration Factor Max Value", tooltip = "Test SAR (SAR #2) Acceleration Factor Maximum Value. Adjusting This Parameter Changes the Maximum Rate at Which SAR Will Increase (When Rising) Or Decrease (When Falling)") ovr = input.string(defval = "Off", title = "Plot SAR Override", options = ["Off", "On"], group = "SAR Override (Visualization Purposes)", tooltip = 'Select "On" to Stop the Script From Plotting the Best Performing SAR. Instead, the Script Will Plot SAR With the Parameters of Your Choice, While Still Displaying the Best Performing SAR Parameters Between Benchmark SAR and Test SAR.') sMO = input.float(0.01, step = 0.01, minval = 0, title = "Override Starting Acceleration Factor", tooltip = "Override SAR Starting Acceleration Factor. Adjusting This Parameter Changes the Initial Acceleration Factor Following a Change in SAR (Rising to Falling : Falling to Rising)") iMO = input.float(0.01, step = 0.01, minval = 0, title = "Override Acceleration Factor Rate of Increase", tooltip = "Override SAR Acceleration Factor Rate of Increase. Adjusting This Parameter Changes the Rate at Which SAR Increases (When Rising) Or Decreases (When Falling)") mMO= input.float(0.01, step = 0.01, minval = 0, title = "Override Acceleration Factor Max Value", tooltip = "Override SAR Acceleration Factor Maximum Value. Adjusting This Parameter Changes the Maximum Rate at Which SAR Will Increase (When Rising) Or Decrease (When Falling)") RSB = input.color(#ffeb3c, title = "Rising SAR Benchmark Color", group = "Benchmark SAR Colors") FSB = input.color(#00ffd4, title = "Falling SAR Benchmark Color") RST = input.color(#03ff00, title = "Rising SAR Test Color", group = "Test SAR Colors") FST = input.color(#ff0500, title = "Falling SAR Test Color") sarB = ta.sar(sMB, iMB, mMB) sarT = ta.sar(sMT, iMT, mMT) sarO = ta.sar(sMO, iMO, mMO) // Calculations Rising SAR var float x = 0.0 var float x1 = 0.0 var int y = 0 var int y1 = 0 var int y2 = 0 var int y4 = 0 if ta.change(sarB) and close > sarB and y == 0 y := 1 x := close y1 := bar_index if ta.change(sarB) and close < sarB and y == 1 y4 += 1 y := 0 x1 := ((close / x) - 1) * 100 x1 := x1[1] + x1 y2 := bar_index - y1 y2 := y2[1] + y2 sarBP = x1 / y4 sarBC = y2 / y4 var float z = 0.0 var float z1 = 0.0 var int n = 0 var int n1 = 0 var int n2 = 0 var int n4 = 0 if ta.change(sarT) and close > sarT and n == 0 n := 1 z := close n1 := bar_index if ta.change(sarT) and close < sarT and n == 1 n4 += 1 n := 0 z1 := ((close / z) - 1) * 100 z1 := z1[1] + z1 n2 := bar_index - n1 n2 := n2[1] + n2 sarTP = z1 / n4 sarTC = n2 / n4 // Calculations Falling SAR var float j = 0.0 var float j1 = 0.0 var int u = 0 var int u1 = 0 var int u2 = 0 var int u4 = 0 if ta.change(sarB) and close < sarB and u == 0 u := 1 j := close u1 := bar_index if ta.change(sarB) and close > sarB and u == 1 u4 += 1 u := 0 j1 := ((close / j) - 1) * 100 j1 := j1[1] + j1 u2 := bar_index - u1 u2 := u2[1] + u2 sarBPS = j1 / u4 sarBCS = u2 / u4 var float q = 0.0 var float q1 = 0.0 var int r = 0 var int r1 = 0 var int r2 = 0 var int r4 = 0 if ta.change(sarT) and close < sarT and r == 0 r := 1 q := close r1 := bar_index if ta.change(sarT) and close > sarT and r == 1 r4 += 1 r := 0 q1 := ((close / q) - 1) * 100 q1 := q1[1] + q1 r2 := bar_index - r1 r2 := r2[1] + r2 sarTPS = q1 / r4 sarTCS = r2 / r4 plot(sarTP >= sarBP and pType == "Average Gain" and ovr == "Off" and style == "Diamond" ? sarT : na, style = plot.style_stepline_diamond, color = close > sarT ? RST : FST ) plot(sarTP >= sarBP and pType == "Average Gain" and ovr == "Off" and style == "Circles" ? sarT : na, style = plot.style_circles, color = close > sarT ? RST : FST ) plot(sarBP > sarTP and pType == "Average Gain" and ovr == "Off" and style == "Diamond" ? sarB : na, style = plot.style_stepline_diamond, color = close > sarB ? RSB : FSB ) plot(sarBP > sarTP and pType == "Average Gain" and ovr == "Off" and style == "Circles" ? sarB : na, style = plot.style_circles, color = close > sarB ? RSB : FSB ) plot(z1 >= x1 and pType == "Cumulative Gain" and ovr == "Off" and style == "Diamond" ? sarT : na, style = plot.style_stepline_diamond, color = close > sarT ? RST : FST ) plot(z1 >= x1 and pType == "Cumulative Gain" and ovr == "Off" and style == "Circles" ? sarT : na, style = plot.style_circles, color = close > sarT ? RST : FST ) plot(x1 > z1 and pType == "Cumulative Gain" and ovr == "Off" and style == "Diamond" ? sarB : na, style = plot.style_stepline_diamond, color = close > sarB ? RSB : FSB ) plot(x1 > z1 and pType == "Cumulative Gain" and ovr == "Off" and style == "Circles" ? sarB : na, style = plot.style_circles, color = close > sarB ? RSB : FSB ) plot(ovr == "On" and style == "Diamond" ? sarO : na, style = plot.style_stepline_diamond, color = close > sarO ? #a9ff8d : #ff8d8d ) plot(ovr == "On" and style == "Circles" ? sarO : na, style = plot.style_circles, color = close > sarO ? #a9ff8d : #ff8d8d ) t = table.new(position.bottom_right, 10, 10) if pType == "Average Gain" and barstate.islast table.cell( t, 0, 0, text = "Rising SAR Performance by Average Gain", text_color = color.blue ) table.cell( t, 0, 1, text = sarTP >= sarBP and sarBP >= 0.0 ? "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" + "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent) +" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" : sarBP > sarTP and sarTP >= 0.0 ? "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" + "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" : sarTP >= sarBP and sarTP >= 0.0 and sarBP < 0.0 ? "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" + "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)" : sarTP >= sarBP and sarTP < 0.0 ? "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)\n\n" + "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)" : sarBP > sarTP and sarTP < 0.0 and sarBP >= 0.0 ? "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" + "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)" : sarBP > sarTP and sarBP < 0.0 ? "Benchmark SAR Rising: " + str.tostring(sarBP, format.percent) +" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)\n\n" + "Test SAR Rising: " + str.tostring(sarTP, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)" : na, text_color = color.white, bgcolor = sarTP >= sarBP ? color.new(RST, 75) : color.new(RSB, 75) ) table.cell( t, 0, 2, text = "\n\nFalling SAR Performance by Average Downside Gain", text_color = color.blue ) table.cell( t, 0, 3, text = sarTPS <= sarBPS and sarBPS <= 0.0 ? "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n\n" + "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") : sarBPS < sarTPS and sarTPS <= 0.0 ? "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n\n" + "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") : sarTPS <= sarBPS and sarTPS <= 0.0 and sarBPS > 0.0 ? "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n\n" + "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)" : sarTPS <= sarBPS and sarTPS > 0.0 ? "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)\n\n" + "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)" : sarBPS < sarTPS and sarTPS > 0.0 and sarBPS <= 0.0 ? "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent)+ "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n\n" + "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)" : sarBPS < sarTPS and sarBPS > 0.0 ? "Benchmark SAR Falling: " + str.tostring(sarBPS, format.percent)+ "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)\n\n" + "Test SAR Falling: " + str.tostring(sarTPS, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)" : na, text_color = color.white, bgcolor = sarTPS <= sarBPS ? color.new(FST, 75) : color.new(FSB, 75) ) else if pType == "Cumulative Gain" and barstate.islast table.cell( t, 0, 0, text = "Rising SAR Performance by Cumulative Gain", text_color = color.orange ) table.cell( t, 0, 1, text = z1 >= x1 and x1 >= 0.0 ? "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" + "Benchmark SAR Rising: " + str.tostring(x1, format.percent) +" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" : x1 > z1 and z1 >= 0.0 ? "Benchmark SAR Rising: " + str.tostring(x1, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" + "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" : z1 >= x1 and z1 >= 0.0 and x1 < 0.0 ? "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" + "Benchmark SAR Rising: " + str.tostring(x1, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)" : z1 >= x1 and z1 < 0.0 ? "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)\n\n" + "Benchmark SAR Rising: " + str.tostring(x1, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)" : x1 > z1 and z1 < 0.0 and x1 >= 0.0 ? "Benchmark SAR Rising: " + str.tostring(x1, format.percent)+" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" + "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)" : x1 > z1 and x1 < 0.0 ? "Benchmark SAR Rising: " + str.tostring(x1, format.percent) +" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n(Long Position Loss!)\n\n" + "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n(Long Position Loss!)" : "Test SAR Rising: " + str.tostring(z1, format.percent) +" \nAvg. # Of Candles Test SAR Remains Rising: " + str.tostring(sarTC, "#") + "\n\n" + "Benchmark SAR Rising: " + str.tostring(x1, format.percent) +" \nAvg. # Of Candles Benchmark SAR Remains Rising: " + str.tostring(sarBC, "#") + "\n\n" , text_color = color.white, bgcolor = x1 >= z1 ? color.new(RST, 75) : color.new(RSB, 75) ) table.cell( t, 0, 2, text = "\n\nFalling SAR Performance by Cumulative Downside Gain", text_color = color.orange ) table.cell( t, 0, 3, text = q1 <= j1 and j1 <= 0.0 ? "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n\n" + "Benchmark SAR Falling: " + str.tostring(j1, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") : j1 < q1 and q1 <= 0.0 ? "Benchmark SAR Falling: " + str.tostring(j1, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n\n" + "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") : q1 <= j1 and q1 <= 0.0 and j1 > 0.0 ? "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n\n" + "Benchmark SAR Falling: " + str.tostring(j1, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)" : q1 <= j1 and q1 > 0.0 ? "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)\n\n" + "Benchmark SAR Falling: " + str.tostring(j1, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)" : j1 < q1 and q1 > 0.0 and j1 <= 0.0 ? "Benchmark SAR Falling: " + str.tostring(j1, format.percent)+ "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n\n" + "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)" : j1 < q1 and j1 > 0.0 ? "Benchmark SAR Falling: " + str.tostring(j1, format.percent)+ "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#") + "\n(Short Position Loss!)\n\n" + "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n(Short Position Loss!)" : "Test SAR Falling: " + str.tostring(q1, format.percent) + " \nAvg. # Of Candles Test SAR Remains Falling: " + str.tostring(sarTCS, "#") + "\n\n" + "Benchmark SAR Falling: " + str.tostring(j1, format.percent) + "\nAvg. # Of Candles Benchmark SAR Remains Falling: " + str.tostring(sarBCS, "#"), text_color = color.white, bgcolor = q1 <= j1 ? color.new(FST, 75) : color.new(FSB, 75) ) instructions = input.string(group = "Instructions", title = "Indicator Instructions", defval = "Off", options = ["Off", "On"]) if instructions == "On" and barstate.islast table.cell( t, 0, 4, text = "This Script Calculates the Cumulative and Average Gain/Loss \nof Rising SAR Following a Price Crossover of SAR. \n\nThe Cumulative and Average Gain/Loss of \nFalling SAR Following a Price Crossunder Is Also Measured. \n\nChanges to the Parameters of SAR Will \nReturn the Requisite Calculations for Evaluating Performance. \n\nBenchmark SAR Can Be Used to \nCompare Performance Against Test SAR", text_color = color.white ) plotchar(close < sarO[1] and close > sarO, location = location.abovebar, color = color.blue, text = "Long", char = "⬇️", size = size.tiny) plotchar(close > sarO[1] and close < sarO, location = location.belowbar, color = color.orange, text = "Short", char = "⬆️", size = size.tiny)
Rupesh Govardhane Support Resistance
https://www.tradingview.com/script/7tp3TmxN-Rupesh-Govardhane-Support-Resistance/
rgovardhane001
https://www.tradingview.com/u/rgovardhane001/
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/ // © LonesomeTheBlue //@version=4 study("Rupesh Govardhane Support Resistance", overlay = true, max_bars_back = 600) rb = input(10, title = "Period", minval = 10) prd = input(284, title = "Loopback Period", minval = 100, maxval = 500) nump = input(2, title ="S/R strength", minval = 1) ChannelW = input(10, title = "Channel Width %", minval = 5) label_location = input(10, title = "Label Location +-", tooltip = "0 means last bar. for example if you set it -5 then label is shown on last 5. bar. + means future bars") linestyle = input('Dashed', title = "Line Style", options = ['Solid', 'Dotted', 'Dashed']) LineColor = input(color.blue, title = "Line Color", type = input.color) drawhl = input(true, title = "Draw Highest/Lowest Pivots in Period") showpp = input(false, title = "Show Point Points") ph = pivothigh(rb, rb) pl = pivotlow(rb, rb) plotshape(ph and showpp, text="PH", style=shape.labeldown, color=color.new(color.white, 100), textcolor = color.red, location=location.abovebar, offset = -rb) plotshape(pl and showpp, text="PL", style=shape.labelup, color=color.new(color.white, 100), textcolor = color.lime, location=location.belowbar, offset = -rb) // S/R levels sr_levels = array.new_float(21, na) // if number of bars is less then the loop then pine highest() fundtion brings 'na'. we need highest/lowest to claculate channel size // so you cannot see S/R until the number of bars is equal/greater then the "Loopback Period" prdhighest = highest(prd) prdlowest = lowest(prd) cwidth = (prdhighest - prdlowest) * ChannelW / 100 //availability of the PPs aas = array.new_bool(41, true) // last privot points have more priority to be support/resistance, so we start from them // if we met new Pivot Point then we calculate all supports/resistances again u1 = 0.0, u1 := nz(u1[1]) d1 = 0.0, d1 := nz(d1[1]) highestph = 0.0 lowestpl = 0.0 highestph := highestph[1] lowestpl := lowestpl[1] if ph or pl //old S/Rs not valid anymore for x = 0 to array.size(sr_levels) - 1 array.set(sr_levels, x, na) highestph := prdlowest lowestpl := prdhighest countpp = 0 // keep position of the PP for x = 0 to prd if na(close[x]) break if not na(ph[x]) or not na(pl[x]) // is it PP? highestph := max(highestph, nz(ph[x], prdlowest), nz(pl[x], prdlowest)) lowestpl := min(lowestpl, nz(ph[x], prdhighest), nz(pl[x], prdhighest)) countpp := countpp + 1 if countpp > 40 break if array.get(aas, countpp) // if PP is not used in a channel upl = (ph[x] ? high[x+rb] : low[x+rb]) + cwidth dnl = (ph[x] ? high[x+rb] : low[x+rb]) - cwidth u1 := countpp == 1 ? upl : u1 d1 := countpp == 1 ? dnl : d1 // to keep the PPs which will be in current channel tmp = array.new_bool(41, true) cnt = 0 // keep which pivot point we are on tpoint = 0 // number of PPs in the channel for xx = 0 to prd if na(close[xx]) break if not na(ph[xx]) or not na(pl[xx]) chg = false cnt := cnt + 1 if cnt > 40 break if array.get(aas, cnt) // if PP not used in other channels if not na(ph[xx]) if high[xx+rb] <= upl and high[xx+rb] >= dnl // PP is in the channel? tpoint := tpoint + 1 chg := true if not na(pl[xx]) if low[xx+rb] <= upl and low[xx+rb] >= dnl // PP is in the channel? tpoint := tpoint + 1 chg := true // set if PP is used in the channel if chg and cnt < 41 array.set(tmp, cnt, false) if tpoint >= nump // met enough PP in the channel? mark the PP as used for a channel and set the SR level for g = 0 to 40 if not array.get(tmp, g) array.set(aas, g, false) if ph[x] and countpp < 21 array.set(sr_levels, countpp, high[x+rb]) if pl[x] and countpp < 21 array.set(sr_levels, countpp, low[x+rb]) setline( level) => LineStyle = linestyle == 'Solid' ? line.style_solid : linestyle == 'Dotted' ? line.style_dotted : line.style_dashed _ret = line.new(bar_index - 1 , level, bar_index , level, color = LineColor, width = 2, style = LineStyle, extend = extend.both) if ph or pl var line highest_ = na var line lowest_ = na line.delete(highest_) line.delete(lowest_) if drawhl highest_ := line.new(bar_index - 1 , highestph, bar_index , highestph, color = color.blue, style = line.style_dashed, width = 1, extend = extend.both) lowest_ := line.new(bar_index - 1 , lowestpl, bar_index , lowestpl, color = color.blue, style = line.style_dashed, width = 1, extend = extend.both) var sr_lines = array.new_line(21, na) for x = 0 to array.size(sr_lines) - 1 line.delete(array.get(sr_lines, x)) if array.get(sr_levels, x) array.set(sr_lines, x, setline(array.get(sr_levels, x))) // set new labels if changed var sr_levs = array.new_float(21, na) if ph or pl for x = 0 to array.size(sr_levs) - 1 array.set(sr_levs, x, array.get(sr_levels, x)) // define and delete old labels label hlabel = na label llabel = na label.delete(hlabel[1]) label.delete(llabel[1]) var sr_labels = array.new_label(21, na) bool resistance_broken = false bool support_broken = false float r_s_level = na // set labels for x = 0 to array.size(sr_labels) - 1 label.delete(array.get(sr_labels, x)) if array.get(sr_levs, x) if close[1] <= array.get(sr_levs, x) and close > array.get(sr_levs, x) resistance_broken := true r_s_level := array.get(sr_levs, x) if close[1] >= array.get(sr_levs, x) and close < array.get(sr_levs, x) support_broken := true r_s_level := array.get(sr_levs, x) lab_loc = (close >= array.get(sr_levs, x) ? label.style_labelup : label.style_labeldown) array.set(sr_labels, x, label.new(x = bar_index + label_location, y = array.get(sr_levs, x), text = tostring(round_to_mintick(array.get(sr_levs, x))), color = color.lime, textcolor = color.black, style = lab_loc)) hlabel := drawhl ? label.new(x = bar_index + label_location + round(sign(label_location)) * 20, y = highestph, text = "Highest PH " + tostring(highestph), color = color.silver, textcolor=color.black, style=label.style_labeldown) : na llabel := drawhl ? label.new(x = bar_index + label_location + round(sign(label_location)) * 20, y = lowestpl, text = "Lowest PL " + tostring(lowestpl), color = color.silver, textcolor=color.black, style=label.style_labelup) : na plot(r_s_level, title = "RS_level", display = display.none) alertcondition(resistance_broken, title='Resistance Broken', message='Resistance Broken, Close Price: {{close}}, Resistance level = {{plot("RS_level")}}') alertcondition(support_broken, title='Support Broken', message='Support Broken, Close Price: {{close}}, Support level = {{plot("RS_level")}}')
MACD+RSI Ferrantelli
https://www.tradingview.com/script/xxfHLch9/
mferrantelli
https://www.tradingview.com/u/mferrantelli/
5
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © mferrantelli //@version=5 indicator("MACD+RSI Ferrantelli") [_,slowlen,_] = ta.macd(close, 12, 26, 9) RSI = ta.rsi(close,14) CV = (slowlen*500000000)+RSI // plot(slowlen*500000000,color=color.red) // plot(RSI,color=color.orange) plot (CV,color=color.yellow)
Multi-Timeframe (MTF) Dashboard by RiTz
https://www.tradingview.com/script/dDbQeJwB-Multi-Timeframe-MTF-Dashboard-by-RiTz/
Keanu_ritz
https://www.tradingview.com/u/Keanu_ritz/
493
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/ // © keanu_ritz //@version=5 indicator(title="Multi-Timeframe (MTF) Dashboard by RiTz", overlay=true) // ---- Table Settings Start {----// max = 120 //Maximum Length min = 14 //Minimum Length var tooltip_Sym = "Shows Multiple Time-Frames for selected Symbol" var tooltip_Chng = "Shows change in price for Multiple TimeFrames" var tooltip_PChng = "Shows % change in price for Multiple TimeFrames" var tooltip_VWAP = "Shows the current VWAP state for Multiple TimeFrames" var tooltip_ST1 = "Shows the state of Supertrend 21-1 for Multiple TimeFrames" var tooltip_ST2 = "Shows the state of Supertrend 14-2 for Multiple TimeFrames" var tooltip_ST3 = "Shows the state of Supertrend 10-3 for Multiple TimeFrames" var tooltip_RSI = "Shows the value of RSI 14 period for Multiple TimeFrames" var tooltip_ADX = "Shows the state of ADX for Multiple TimeFrames" var tooltip_MACD = "Shows the state of MACD for Multiple TimeFrames" var tooltip_Alg = "Shows the state of Alligator indicator for Multiple TimeFrames" var tooltip_PHL = "Shows where the price is trading according to the Previous High-Low of Multiple TimeFrames" var tooltip_SmaHL = "Shows where the price is trading according to the 5 Sma High-Low of Multiple TimeFrames" var tooltip_ATR = "Shows Average True Range of Multiple TimeFrames" dash_loc = input.session("Top Right","Dashboard Location" ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"] ,group='Style Settings') text_size = input.session('Normal',"Dashboard Size" ,options=["Tiny","Small","Normal","Large"] ,group='Style Settings') cell_up = input.color(#52fd03,'Bullish Cell Color' ,group='Style Settings') cell_dn = input.color(#fd1d03,'Bearish Cell Color' ,group='Style Settings') cell_neutral = input.color(color.gray,'Neutral Cell Color' ,group='Style Settings') row_col = color.blue col_col = color.blue txt_col = color.white cell_transp = input.int(90,'Cell Transparency' ,minval=0 ,maxval=100 ,group='Style Settings') txt_transp = input.int(25,'Cell Transparency' ,minval=0 ,maxval=60 ,group='Style Settings') // ---- Table Settings End ----}// // ---- Column Settings Start {----// showChng = input.bool(defval=true, title="Show Price Change :", inline="indicator1", group="Columns Settings") showPChng = input.bool(defval=true, title="Show % Price Change", inline="indicator1", group="Columns Settings") showVwap = input.bool(defval=true, title="Show VWAP :", inline="indicator2", group="Columns Settings") showST1 = input.bool(defval=true, title="Show SuperTrend 21-1", inline="indicator2", group="Columns Settings") showST2 = input.bool(defval=true, title="Show SuperTrend 14-2 :", inline="indicator3", group="Columns Settings") showST3 = input.bool(defval=true, title="Show SuperTrend 10-3", inline="indicator3", group="Columns Settings") showRSI = input.bool(defval=true, title="Show RSI :", inline="indicator4", group="Columns Settings") showADX = input.bool(defval=true, title="Show ADX", inline="indicator4", group="Columns Settings") showMACD = input.bool(defval=true, title="Show MACD :", inline="indicator5", group="Columns Settings") showAlg = input.bool(defval=true, title="Show Alligator", inline="indicator6", group="Columns Settings") showPHL = input.bool(defval=true, title="Show Previous TimeFrame High/Low", inline="indicator5", group="Columns Settings") showSmaHL = input.bool(defval=true, title="Show 5 Sma High/Low", inline="indicator5", group="Columns Settings") showATR = input.bool(defval=true, title="Show ATR (14 period)", inline="indicator6", group="Columns Settings") // ---- Column Settings End ----}// // ---- TimeFrame Settings Start {----// showTF1 = input.bool(defval=true, title="Show TimeFrame 1", inline='TF-1', group='TimeFrame Settings') showTF2 = input.bool(defval=true, title="Show TimeFrame 2", inline='TF-2', group='TimeFrame Settings') showTF3 = input.bool(defval=true, title="Show TimeFrame 3", inline='TF-3', group='TimeFrame Settings') showTF4 = input.bool(defval=true, title="Show TimeFrame 4", inline='TF-4', group='TimeFrame Settings') showTF5 = input.bool(defval=true, title="Show TimeFrame 5", inline='TF-5', group='TimeFrame Settings') showTF6 = input.bool(defval=true, title="Show TimeFrame 6", inline='TF-6', group='TimeFrame Settings') showTF7 = input.bool(defval=true, title="Show TimeFrame 7", inline='TF-7', group='TimeFrame Settings') showTF8 = input.bool(defval=true, title="Show Daily TimeFrame", inline='TF-8', group='TimeFrame Settings') showTF9 = input.bool(defval=true, title="Show Weekly TimeFrame", inline='TF-9', group='TimeFrame Settings') showTF10 = input.bool(defval=true, title="Show Monthly TimeFrame", inline='TF-10', group='TimeFrame Settings') tf1 = input.string(defval='01', title="TimeFrame 1", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-1', group='TimeFrame Settings') tf2 = input.string(defval='03', title="TimeFrame 2", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-2', group='TimeFrame Settings') tf3 = input.string(defval='05', title="TimeFrame 3", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-3', group='TimeFrame Settings') tf4 = input.string(defval='15', title="TimeFrame 4", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-4', group='TimeFrame Settings') tf5 = input.string(defval='25', title="TimeFrame 5", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-5', group='TimeFrame Settings') tf6 = input.string(defval='75', title="TimeFrame 6", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-6', group='TimeFrame Settings') tf7 = input.string(defval='125', title="TimeFrame 7", options=['01','03','05','10','15','25','30','45','60','75','90','125','240','D', 'W', 'M'], inline='TF-7', group='TimeFrame Settings') tf8 = 'D' tf9 = 'W' tf10 = 'M' // ---- TimeFrame Settings End ----}// //---- Indicators code Start {----// var PColor = color.white var PText = '' var SmaHLColor = color.white var SmaHLText = '' //---- Alligator code Start {----// var AlgColor = color.white var AlgText = '' jawPeriod = 13 teethPeriod = 8 lipsPeriod = 5 smma(src, length) => smma = 0.0 smma := na(smma[1]) ? ta.sma(src, length) : (smma[1] * (length - 1) + src) / length smma jaw = smma(hl2, jawPeriod) teeth = smma(hl2, teethPeriod) lips = smma(hl2, lipsPeriod) //---- Alligator code end ----}// //---- SuperTrend code start {----// f1=1 f2=2 f3=3 p1=21 p2=14 p3=10 Supertrend(f1, p1) => [supertrend, trend] = ta.supertrend(f1, p1) st1State_ = trend == 1 ? false : true [st1State_] Supertrend2(f2, p2) => [supertrend, trend] = ta.supertrend(f2, p2) st2State_ = trend == 1 ? false : true [st2State_] Supertrend3(f3, p3) => [supertrend, trend] = ta.supertrend(f3, p3) st3State_ = trend == 1 ? false : true [st3State_] [st1State_] = Supertrend(f1, p1) [st2State_] = Supertrend2(f2, p2) [st3State_] = Supertrend3(f3, p3) //---- SuperTrend code end----}// //---- RSI code start {----// rsiPeriod = 14 RSI = ta.rsi(close, rsiPeriod) //---- RSI code end ----}// //---- ATR code start {----// atrPeriod = 14 ATR = ta.atr(atrPeriod) //---- ATR code end ----}// //---- 5 SMA H-L code start{----// smaH = ta.sma(high,5) smaL = ta.sma(low,5) sma20C = ta.sma(close,20) //---- 5 SMA H-L code end ----}// //---- ADX-DMI code start {----// adxP = 14 adxS = 14 var ADXColor = color.white var ADXText = '' ADXf(adxP, adxS) => [diplus, diminus, adx] = ta.dmi(adxP, adxS) [dp, dm, adxx] = ADXf(adxP, adxS) //---- ADX-DMI code end ----}// //---- MACD code start {----// flen = 12 sllen = 26 sglen = 9 var MACDColor = color.white var MACDText = '' Macdf(flen,sllen,sglen) => [macdline,sgline,histline] = ta.macd(close,flen,sllen,sglen) [ml,sl,hsl] = Macdf(flen,sllen,sglen) //---- MACD code end ----}// //---- Calculate Values of Indicators on Multiple TimeFrames {----// [ts1,ts1C,ts1PDH,ts1PDL,tf1hlc3,st1State_st1,st2State_st1,st3State_st1,RSI1,dp1,dm1,adx1,ml1,sl1,hsl1,ts1jaw,ts1teeth,ts1lips,ts1sma5H,ts1sma5L,ts1sma20,ts1atr] = request.security(syminfo.tickerid,tf1,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts2,ts2C,ts2PDH,ts2PDL,tf2hlc3,st1State_st2,st2State_st2,st3State_st2,RSI2,dp2,dm2,adx2,ml2,sl2,hsl2,ts2jaw,ts2teeth,ts2lips,ts2sma5H,ts2sma5L,ts2sma20,ts2atr] = request.security(syminfo.tickerid,tf2,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts3,ts3C,ts3PDH,ts3PDL,tf3hlc3,st1State_st3,st2State_st3,st3State_st3,RSI3,dp3,dm3,adx3,ml3,sl3,hsl3,ts3jaw,ts3teeth,ts3lips,ts3sma5H,ts3sma5L,ts3sma20,ts3atr] = request.security(syminfo.tickerid,tf3,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts4,ts4C,ts4PDH,ts4PDL,tf4hlc3,st1State_st4,st2State_st4,st3State_st4,RSI4,dp4,dm4,adx4,ml4,sl4,hsl4,ts4jaw,ts4teeth,ts4lips,ts4sma5H,ts4sma5L,ts4sma20,ts4atr] = request.security(syminfo.tickerid,tf4,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts5,ts5C,ts5PDH,ts5PDL,tf5hlc3,st1State_st5,st2State_st5,st3State_st5,RSI5,dp5,dm5,adx5,ml5,sl5,hsl5,ts5jaw,ts5teeth,ts5lips,ts5sma5H,ts5sma5L,ts5sma20,ts5atr] = request.security(syminfo.tickerid,tf5,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts6,ts6C,ts6PDH,ts6PDL,tf6hlc3,st1State_st6,st2State_st6,st3State_st6,RSI6,dp6,dm6,adx6,ml6,sl6,hsl6,ts6jaw,ts6teeth,ts6lips,ts6sma5H,ts6sma5L,ts6sma20,ts6atr] = request.security(syminfo.tickerid,tf6,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts7,ts7C,ts7PDH,ts7PDL,tf7hlc3,st1State_st7,st2State_st7,st3State_st7,RSI7,dp7,dm7,adx7,ml7,sl7,hsl7,ts7jaw,ts7teeth,ts7lips,ts7sma5H,ts7sma5L,ts7sma20,ts7atr] = request.security(syminfo.tickerid,tf7,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts8,ts8C,ts8PDH,ts8PDL,tf8hlc3,st1State_st8,st2State_st8,st3State_st8,RSI8,dp8,dm8,adx8,ml8,sl8,hsl8,ts8jaw,ts8teeth,ts8lips,ts8sma5H,ts8sma5L,ts8sma20,ts8atr] = request.security(syminfo.tickerid,tf8,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts9,ts9C,ts9PDH,ts9PDL,tf9hlc3,st1State_st9,st2State_st9,st3State_st9,RSI9,dp9,dm9,adx9,ml9,sl9,hsl9,ts9jaw,ts9teeth,ts9lips,ts9sma5H,ts9sma5L,ts9sma20,ts9atr] = request.security(syminfo.tickerid,tf9,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) [ts10,ts10C,ts10PDH,ts10PDL,tf10hlc3,st1State_st10,st2State_st10,st3State_st10,RSI10,dp10,dm10,adx10,ml10,sl10,hsl10,ts10jaw,ts10teeth,ts10lips,ts10sma5H,ts10sma5L,ts10sma20,ts10atr] = request.security(syminfo.tickerid,tf10,[close,close[1],high[1],low[1],hlc3,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,jaw,teeth,lips,smaH,smaL,sma20C,ATR]) //---- Calculate Values of Indicators on Multiple TimeFrames ----}// //---- Calculate Change & %Change {----// ts1Chng = (ts1-ts1C) ts1p = (ts1-ts1C)*100/ts1C ts2Chng = (ts2-ts2C) ts2p = (ts2-ts2C)*100/ts2C ts3Chng = (ts3-ts3C) ts3p = (ts3-ts3C)*100/ts3C ts4Chng = (ts4-ts4C) ts4p = (ts4-ts4C)*100/ts4C ts5Chng = (ts5-ts5C) ts5p = (ts5-ts5C)*100/ts5C ts6Chng = (ts6-ts6C) ts6p = (ts6-ts6C)*100/ts6C ts7Chng = (ts7-ts7C) ts7p = (ts7-ts7C)*100/ts7C ts8Chng = (ts8-ts8C) ts8p = (ts8-ts8C)*100/ts8C ts9Chng = (ts9-ts9C) ts9p = (ts9-ts9C)*100/ts9C ts10Chng = (ts10-ts10C) ts10p = (ts10-ts10C)*100/ts10C //---- Calculate Change & %Change ----}// //---- Calculate VWAP start {----// var VWAPText = '' float ts1vwap = 0.0 float ts2vwap = 0.0 float ts3vwap = 0.0 float ts4vwap = 0.0 float ts5vwap = 0.0 float ts6vwap = 0.0 float ts7vwap = 0.0 indexCurrTf = barstate.isrealtime ? 0 : 1 //Create non repainting security function nrp_function(_symbol, _res, _src) => request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0]) ts1vwap := nrp_function(syminfo.tickerid, tf1, ta.vwap(hlc3))[indexCurrTf] ts2vwap := nrp_function(syminfo.tickerid, tf2, ta.vwap(hlc3))[indexCurrTf] ts3vwap := nrp_function(syminfo.tickerid, tf3, ta.vwap(hlc3))[indexCurrTf] ts4vwap := nrp_function(syminfo.tickerid, tf4, ta.vwap(hlc3))[indexCurrTf] ts5vwap := nrp_function(syminfo.tickerid, tf5, ta.vwap(hlc3))[indexCurrTf] ts6vwap := nrp_function(syminfo.tickerid, tf6, ta.vwap(hlc3))[indexCurrTf] ts7vwap := nrp_function(syminfo.tickerid, tf7, ta.vwap(hlc3))[indexCurrTf] //---- Calculate VWAP end ----}// //---- Indicators code end ----}// //-------------- Table code Start {-------------------// //---- Table Position & Size code start {----// var table_position = dash_loc == 'Top Left' ? position.top_left : dash_loc == 'Bottom Left' ? position.bottom_left : dash_loc == 'Middle Right' ? position.middle_right : dash_loc == 'Bottom Center' ? position.bottom_center : dash_loc == 'Top Right' ? position.top_right : position.bottom_right var table_text_size = text_size == 'Tiny' ? size.tiny : text_size == 'Small' ? size.small : text_size == 'Normal' ? size.normal : size.large var t = table.new(table_position,15,math.abs(max-min)+2, frame_color=color.new(#000000,0), frame_width=1, border_color=color.new(#000000,0), border_width=1) //---- Table Position & Size code end ----}// //---- Table Column & Rows code start {----// //if (barstate.islast) //---- Table Main Column Headers code start {----// if (barstate.islast) table.cell(t,1,0,'MTF Dashboard',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) //table.cell(t,1,1,str.replace_all(syminfo.tickerid, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Sym) table.cell(t,1,1,ticker.standard(syminfo.ticker),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Sym) if showChng table.cell(t,2,1,'Chng',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Chng) if showPChng table.cell(t,3,1,'%Chng',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_PChng) if showVwap table.cell(t,4,1,'VWAP',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_VWAP) if showST1 table.cell(t,5,1,'ST 21-1',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST1) if showST2 table.cell(t,6,1,'ST 14-2',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST2) if showST3 table.cell(t,7,1,'ST 10-3',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST3) if showRSI table.cell(t,8,1,'RSI (14)',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_RSI) if showADX table.cell(t,9,1,'ADX',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ADX) if showMACD table.cell(t,10,1,'MACD',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_MACD) if showAlg table.cell(t,11,1,'Alligator',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Alg) if showPHL table.cell(t,12,1,'PH/PL',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_PHL) if showSmaHL table.cell(t,13,1,'5 Sma H/L',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_SmaHL) if showATR table.cell(t,14,1,'ATR (14)',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ATR) //---- Table Main Column Headers code end ----}// if (barstate.islast) //---- Display TimeFrame1 data code start {----// if showTF1 table.cell(t,1,2, str.tostring(tf1) +' Minute',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF1 and showChng table.cell(t,2,2, str.tostring(ts1Chng, '#.##'),text_color=color.new(ts1p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF1 and showPChng table.cell(t,3,2, str.tostring(ts1p, '#.##') +' %',text_color=color.new(ts1p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts1 >= ts1vwap VWAPText := 'Bullish' else if ts1 < ts1vwap VWAPText := 'Bearish' if showTF1 and showVwap // table.cell(t,4,2, str.tostring(ts1vwap , '#.##'),text_color=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,2, str.tostring(VWAPText),text_color=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,cell_transp)) if showTF1 and showST1 table.cell(t,5,2, st1State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st1==true ? cell_up : cell_dn ,cell_transp)) if showTF1 and showST2 table.cell(t,6,2, st2State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st1==true ? cell_up : cell_dn ,cell_transp)) if showTF1 and showST3 table.cell(t,7,2, st3State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st1==true ? cell_up : cell_dn ,cell_transp)) if showTF1 and showRSI table.cell(t,8,2, str.tostring(RSI1, '#.##'),text_color=color.new(RSI1 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI1 > 50 ? cell_up : cell_dn ,cell_transp)) if adx1 >= 75 and dp1 > dm1 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx1 >= 75 and dp1 < dm1 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx1 < 75 and adx1 >= 50 and dp1 > dm1 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx1 < 75 and adx1 >= 50 and dp1 < dm1 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx1 < 50 and adx1 >= 25 and dp1 > dm1 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx1 < 50 and adx1 >= 25 and dp1 < dm1 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx1 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF1 and showADX table.cell(t,9,2, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl1 >0 and ml1 > sl1 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl1 <0 and ml1 < sl1 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF1 and showMACD table.cell(t,10,2, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts1lips > ts1teeth and ts1teeth > ts1jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts1lips < ts1teeth and ts1teeth < ts1jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts1lips > ts1teeth and ts1teeth < ts1jaw or ts1lips < ts1teeth and ts1teeth > ts1jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF1 and showAlg table.cell(t,11,2, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts1 > ts1PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts1 < ts1PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts1 < ts1PDH and ts1 > ts1PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF1 and showPHL table.cell(t,12,2, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts1 > ts1sma20 and ts1 > ts1sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts1 < ts1sma20 and ts1 < ts1sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts1 < ts1sma5H and ts1 > ts1sma20 or ts1 > ts1sma5L and ts1 < ts1sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF1 and showSmaHL table.cell(t,13,2, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF1 and showATR table.cell(t,14,2, str.tostring(ts1atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame1 data code end ----}// if (barstate.islast) //---- Display TimeFrame2 data code start {----// if showTF2 table.cell(t,1,3, str.tostring(tf2) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF2 and showChng table.cell(t,2,3, str.tostring(ts2Chng, '#.##'),text_color=color.new(ts2p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF2 and showPChng table.cell(t,3,3, str.tostring(ts2p, '#.##') +' %',text_color=color.new(ts2p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts2 >= ts2vwap VWAPText := 'Bullish' else if ts2 < ts2vwap VWAPText := 'Bearish' if showTF2 and showVwap // table.cell(t,4,3, str.tostring(ts2vwap , '#.##'),text_color=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,3, str.tostring(VWAPText),text_color=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,cell_transp)) if showTF2 and showST1 table.cell(t,5,3, st1State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st2==true ? cell_up : cell_dn ,cell_transp)) if showTF2 and showST2 table.cell(t,6,3, st2State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st2==true ? cell_up : cell_dn ,cell_transp)) if showTF2 and showST3 table.cell(t,7,3, st3State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st2==true ? cell_up : cell_dn ,cell_transp)) if showTF2 and showRSI table.cell(t,8,3, str.tostring(RSI2, '#.##'),text_color=color.new(RSI2 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI2 > 50 ? cell_up : cell_dn ,cell_transp)) if adx2 >= 75 and dp2 > dm2 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx2 >= 75 and dp2 < dm2 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx2 < 75 and adx2 >= 50 and dp2 > dm2 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx2 < 75 and adx2 >= 50 and dp2 < dm2 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx2 < 50 and adx2 >= 25 and dp2 > dm2 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx2 < 50 and adx2 >= 25 and dp2 < dm2 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx2 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF2 and showADX table.cell(t,9,3, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl2 >0 and ml2 > sl2 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl2 <0 and ml2 < sl2 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF2 and showMACD table.cell(t,10,3, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts2lips > ts2teeth and ts2teeth > ts2jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts2lips < ts2teeth and ts2teeth < ts2jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts2lips > ts2teeth and ts2teeth < ts2jaw or ts2lips < ts2teeth and ts2teeth > ts2jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF2 and showAlg table.cell(t,11,3, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts2 > ts2PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts2 < ts2PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts2 < ts2PDH and ts2 > ts2PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF2 and showPHL table.cell(t,12,3, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts2 > ts2sma20 and ts2 > ts2sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts2 < ts2sma20 and ts2 < ts2sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts2 < ts2sma5H and ts2 > ts2sma20 or ts2 > ts2sma5L and ts2 < ts2sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF2 and showSmaHL table.cell(t,13,3, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF2 and showATR table.cell(t,14,3, str.tostring(ts2atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame2 data code end ----}// if (barstate.islast) //---- Display TimeFrame3 data code start {----// if showTF3 table.cell(t,1,4, str.tostring(tf3) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF3 and showChng table.cell(t,2,4, str.tostring(ts3Chng, '#.##'),text_color=color.new(ts3p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF3 and showPChng table.cell(t,3,4, str.tostring(ts3p, '#.##') +' %',text_color=color.new(ts3p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts3 >= ts3vwap VWAPText := 'Bullish' else if ts3 < ts3vwap VWAPText := 'Bearish' if showTF3 and showVwap // table.cell(t,4,4, str.tostring(ts3vwap , '#.##'),text_color=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,4, str.tostring(VWAPText),text_color=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,cell_transp)) if showTF3 and showST1 table.cell(t,5,4, st1State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st3==true ? cell_up : cell_dn ,cell_transp)) if showTF3 and showST2 table.cell(t,6,4, st2State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st3==true ? cell_up : cell_dn ,cell_transp)) if showTF3 and showST3 table.cell(t,7,4, st3State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st3==true ? cell_up : cell_dn ,cell_transp)) if showTF3 and showRSI table.cell(t,8,4, str.tostring(RSI3, '#.##'),text_color=color.new(RSI3 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI3 > 50 ? cell_up : cell_dn ,cell_transp)) if adx3 >= 75 and dp3 > dm3 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx3 >= 75 and dp3 < dm3 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx3 < 75 and adx3 >= 50 and dp3 > dm3 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx3 < 75 and adx3 >= 50 and dp3 < dm3 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx3 < 50 and adx3 >= 25 and dp3 > dm3 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx3 < 50 and adx3 >= 25 and dp3 < dm3 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx3 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF3 and showADX table.cell(t,9,4, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl3 >0 and ml3 > sl3 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl3 <0 and ml3 < sl3 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF3 and showMACD table.cell(t,10,4, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts3lips > ts3teeth and ts3teeth > ts3jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts3lips < ts3teeth and ts3teeth < ts3jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts3lips > ts3teeth and ts3teeth < ts3jaw or ts3lips < ts3teeth and ts3teeth > ts3jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF3 and showAlg table.cell(t,11,4, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts3 > ts3PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts3 < ts3PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts3 < ts3PDH and ts3 > ts3PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF3 and showPHL table.cell(t,12,4, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts3 > ts3sma20 and ts3 > ts3sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts3 < ts3sma20 and ts3 < ts3sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts3 < ts3sma5H and ts3 > ts3sma20 or ts3 > ts3sma5L and ts3 < ts3sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF3 and showSmaHL table.cell(t,13,4, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF3 and showATR table.cell(t,14,4, str.tostring(ts3atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame3 data code end ----}// if (barstate.islast) //---- Display TimeFrame4 data code start {----// if showTF4 table.cell(t,1,5, str.tostring(tf4) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF4 and showChng table.cell(t,2,5, str.tostring(ts4Chng, '#.##'),text_color=color.new(ts4p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF4 and showPChng table.cell(t,3,5, str.tostring(ts4p, '#.##') +' %',text_color=color.new(ts4p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts4 >= ts4vwap VWAPText := 'Bullish' else if ts4 < ts4vwap VWAPText := 'Bearish' if showTF4 and showVwap // table.cell(t,4,5, str.tostring(ts4vwap , '#.##'),text_color=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,5, str.tostring(VWAPText),text_color=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,cell_transp)) if showTF4 and showST1 table.cell(t,5,5, st1State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st4==true ? cell_up : cell_dn ,cell_transp)) if showTF4 and showST2 table.cell(t,6,5, st2State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st4==true ? cell_up : cell_dn ,cell_transp)) if showTF4 and showST3 table.cell(t,7,5, st3State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st4==true ? cell_up : cell_dn ,cell_transp)) if showTF4 and showRSI table.cell(t,8,5, str.tostring(RSI4, '#.##'),text_color=color.new(RSI4 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI4 > 50 ? cell_up : cell_dn ,cell_transp)) if adx4 >= 75 and dp4 > dm4 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx4 >= 75 and dp4 < dm4 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx4 < 75 and adx4 >= 50 and dp4 > dm4 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx4 < 75 and adx4 >= 50 and dp4 < dm4 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx4 < 50 and adx4 >= 25 and dp4 > dm4 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx4 < 50 and adx4 >= 25 and dp4 < dm4 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx4 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF4 and showADX table.cell(t,9,5, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl4 >0 and ml4 > sl4 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl4 <0 and ml4 < sl4 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF4 and showMACD table.cell(t,10,5, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts4lips > ts4teeth and ts4teeth > ts4jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts4lips < ts4teeth and ts4teeth < ts4jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts4lips > ts4teeth and ts4teeth < ts4jaw or ts4lips < ts4teeth and ts4teeth > ts4jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF4 and showAlg table.cell(t,11,5, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts4 > ts4PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts4 < ts4PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts4 < ts4PDH and ts4 > ts4PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF4 and showPHL table.cell(t,12,5, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts4 > ts4sma20 and ts4 > ts4sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts4 < ts4sma20 and ts4 < ts4sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts4 < ts4sma5H and ts4 > ts4sma20 or ts4 > ts4sma5L and ts4 < ts4sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF4 and showSmaHL table.cell(t,13,5, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF4 and showATR table.cell(t,14,5, str.tostring(ts4atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame4 data code end ----}// if (barstate.islast) //---- Display TimeFrame5 data code start {----// if showTF5 table.cell(t,1,6, str.tostring(tf5) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF5 and showChng table.cell(t,2,6, str.tostring(ts5Chng, '#.##'),text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF5 and showPChng table.cell(t,3,6, str.tostring(ts5p, '#.##') +' %',text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts5 >= ts5vwap VWAPText := 'Bullish' else if ts5 < ts5vwap VWAPText := 'Bearish' if showTF5 and showVwap // table.cell(t,4,6, str.tostring(ts5vwap , '#.##'),text_color=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,6, str.tostring(VWAPText),text_color=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,cell_transp)) if showTF5 and showST1 table.cell(t,5,6, st1State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st5==true ? cell_up : cell_dn ,cell_transp)) if showTF5 and showST2 table.cell(t,6,6, st2State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st5==true ? cell_up : cell_dn ,cell_transp)) if showTF5 and showST3 table.cell(t,7,6, st3State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st5==true ? cell_up : cell_dn ,cell_transp)) if showTF5 and showRSI table.cell(t,8,6, str.tostring(RSI5, '#.##'),text_color=color.new(RSI5 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI5 > 50 ? cell_up : cell_dn ,cell_transp)) if adx5 >= 75 and dp5 > dm5 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx5 >= 75 and dp5 < dm5 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx5 < 75 and adx5 >= 50 and dp5 > dm5 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx5 < 75 and adx5 >= 50 and dp5 < dm5 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx5 < 50 and adx5 >= 25 and dp5 > dm5 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx5 < 50 and adx5 >= 25 and dp5 < dm5 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx5 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF5 and showADX table.cell(t,9,6, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl5 >0 and ml5 > sl5 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl5 <0 and ml5 < sl5 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF5 and showMACD table.cell(t,10,6, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts5lips > ts5teeth and ts5teeth > ts5jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts5lips < ts5teeth and ts5teeth < ts5jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts5lips > ts5teeth and ts5teeth < ts5jaw or ts5lips < ts5teeth and ts5teeth > ts5jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF5 and showAlg table.cell(t,11,6, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts5 > ts5PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts5 < ts5PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts5 < ts5PDH and ts5 > ts5PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF5 and showPHL table.cell(t,12,6, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts5 > ts5sma20 and ts5 > ts5sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts5 < ts5sma20 and ts5 < ts5sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts5 < ts5sma5H and ts5 > ts5sma20 or ts5 > ts5sma5L and ts5 < ts5sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF5 and showSmaHL table.cell(t,13,6, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF5 and showATR table.cell(t,14,6, str.tostring(ts5atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame5 data code end ----}// if (barstate.islast) //---- Display TimeFrame6 data code start {----// if showTF6 table.cell(t,1,7, str.tostring(tf6) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF6 and showChng table.cell(t,2,7, str.tostring(ts6Chng, '#.##'),text_color=color.new(ts6p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF6 and showPChng table.cell(t,3,7, str.tostring(ts6p, '#.##') +' %',text_color=color.new(ts6p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts6 >= ts6vwap VWAPText := 'Bullish' else if ts6 < ts6vwap VWAPText := 'Bearish' if showTF6 and showVwap // table.cell(t,4,7, str.tostring(ts5vwap , '#.##'),text_color=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,7, str.tostring(VWAPText),text_color=color.new(ts6 >= ts6vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6 >= ts6vwap ? cell_up : cell_dn ,cell_transp)) if showTF6 and showST1 table.cell(t,5,7, st1State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st6==true ? cell_up : cell_dn ,cell_transp)) if showTF6 and showST2 table.cell(t,6,7, st2State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st6==true ? cell_up : cell_dn ,cell_transp)) if showTF6 and showST3 table.cell(t,7,7, st3State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st6==true ? cell_up : cell_dn ,cell_transp)) if showTF6 and showRSI table.cell(t,8,7, str.tostring(RSI6, '#.##'),text_color=color.new(RSI6 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI6 > 50 ? cell_up : cell_dn ,cell_transp)) if adx6 >= 75 and dp6 > dm6 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx6 >= 75 and dp6 < dm6 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx6 < 75 and adx6 >= 50 and dp6 > dm6 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx6 < 75 and adx6 >= 50 and dp6 < dm6 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx6 < 50 and adx6 >= 25 and dp6 > dm6 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx6 < 50 and adx6 >= 25 and dp6 < dm6 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx6 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF6 and showADX table.cell(t,9,7, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl6 >0 and ml6 > sl6 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl6 <0 and ml6 < sl6 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF5 and showMACD table.cell(t,10,7, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts6lips > ts6teeth and ts6teeth > ts6jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts6lips < ts6teeth and ts6teeth < ts6jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts6lips > ts6teeth and ts6teeth < ts6jaw or ts6lips < ts6teeth and ts6teeth > ts6jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF6 and showAlg table.cell(t,11,7, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts6 > ts6PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts6 < ts6PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts6 < ts6PDH and ts6 > ts6PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF6 and showPHL table.cell(t,12,7, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts6 > ts6sma20 and ts6 > ts6sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts6 < ts6sma20 and ts6 < ts6sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts6 < ts6sma5H and ts6 > ts6sma20 or ts6 > ts6sma5L and ts6 < ts6sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF6 and showSmaHL table.cell(t,13,7, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF6 and showATR table.cell(t,14,7, str.tostring(ts6atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame6 data code end ----}// if (barstate.islast) //---- Display TimeFrame7 data code start {----// if showTF7 table.cell(t,1,8, str.tostring(tf7) +' Minutes',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF7 and showChng table.cell(t,2,8, str.tostring(ts7Chng, '#.##'),text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF7 and showPChng table.cell(t,3,8, str.tostring(ts7p, '#.##') +' %',text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if ts7>= ts7vwap VWAPText := 'Bullish' else if ts7 < ts7vwap VWAPText := 'Bearish' if showTF7 and showVwap // table.cell(t,4,8, str.tostring(ts5vwap , '#.##'),text_color=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,8, str.tostring(VWAPText),text_color=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,cell_transp)) if showTF7 and showST1 table.cell(t,5,8, st1State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st7==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st7==true ? cell_up : cell_dn ,cell_transp)) if showTF7 and showST2 table.cell(t,6,8, st2State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st7==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st7==true ? cell_up : cell_dn ,cell_transp)) if showTF7 and showST3 table.cell(t,7,8, st3State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st7==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st7==true ? cell_up : cell_dn ,cell_transp)) if showTF7 and showRSI table.cell(t,8,8, str.tostring(RSI7, '#.##'),text_color=color.new(RSI7 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI7 > 50 ? cell_up : cell_dn ,cell_transp)) if adx7>= 75 and dp7 > dm7 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx7 >= 75 and dp7 < dm5 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx7 < 75 and adx7 >= 50 and dp7 > dm7 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx7 < 75 and adx7 >= 50 and dp7 < dm7 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx7 < 50 and adx7 >= 25 and dp7 > dm7 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx7 < 50 and adx7 >= 25 and dp7 < dm7 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx7 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF7 and showADX table.cell(t,9,8, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl7 >0 and ml7 > sl7 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl7 <0 and ml7 < sl7 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF7 and showMACD table.cell(t,10,8, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts7lips > ts7teeth and ts7teeth > ts7jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts7lips < ts7teeth and ts7teeth < ts7jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts7lips > ts7teeth and ts7teeth < ts7jaw or ts7lips < ts7teeth and ts7teeth > ts7jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF7 and showAlg table.cell(t,11,8, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts7 > ts7PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts7 < ts7PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts7 < ts7PDH and ts7 > ts7PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF7 and showPHL table.cell(t,12,8, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts7 > ts7sma20 and ts7 > ts7sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts7 < ts7sma20 and ts7 < ts7sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts7 < ts7sma5H and ts7 > ts7sma20 or ts7 > ts7sma5L and ts7 < ts7sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF7 and showSmaHL table.cell(t,13,8, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF7 and showATR table.cell(t,14,8, str.tostring(ts8atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame7 data code end ----}// if (barstate.islast) //---- Display TimeFrame8 data code start {----// if showTF8 table.cell(t,1,9, str.tostring(tf8),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF8 and showChng table.cell(t,2,9, str.tostring(ts8Chng, '#.##'),text_color=color.new(ts8p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF8 and showPChng table.cell(t,3,9, str.tostring(ts8p, '#.##') +' %',text_color=color.new(ts8p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF8 and showVwap // table.cell(t,4,9, str.tostring(ts8vwap , '#.##'),text_color=color.new(ts8 >= ts8vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6 >= ts8vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,9, 'N/A',text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) if showTF8 and showST1 table.cell(t,5,9, st1State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st8==true ? cell_up : cell_dn ,cell_transp)) if showTF8 and showST2 table.cell(t,6,9, st2State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st8==true ? cell_up : cell_dn ,cell_transp)) if showTF8 and showST3 table.cell(t,7,9, st3State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st8==true ? cell_up : cell_dn ,cell_transp)) if showTF8 and showRSI table.cell(t,8,9, str.tostring(RSI8, '#.##'),text_color=color.new(RSI8 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI8 > 50 ? cell_up : cell_dn ,cell_transp)) if adx8 >= 75 and dp8 > dm8 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx8 >= 75 and dp8 < dm8 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx8 < 75 and adx8 >= 50 and dp8 > dm8 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx8 < 75 and adx8 >= 50 and dp8 < dm8 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx8 < 50 and adx8 >= 25 and dp8 > dm8 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx8 < 50 and adx8 >= 25 and dp8 < dm8 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx8 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF8 and showADX table.cell(t,9,9, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl8 >0 and ml8 > sl8 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl8 <0 and ml8 < sl8 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF8 and showMACD table.cell(t,10,9, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts8lips > ts8teeth and ts8teeth > ts8jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts8lips < ts8teeth and ts8teeth < ts8jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts8lips > ts8teeth and ts8teeth < ts8jaw or ts8lips < ts8teeth and ts8teeth > ts8jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF8 and showAlg table.cell(t,11,9, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts8 > ts8PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts8 < ts8PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts8 < ts8PDH and ts8 > ts8PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF8 and showPHL table.cell(t,12,9, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts8 > ts8sma20 and ts8 > ts8sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts8 < ts8sma20 and ts8 < ts8sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts8 < ts8sma5H and ts8 > ts8sma20 or ts8 > ts8sma5L and ts8 < ts8sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF8 and showSmaHL table.cell(t,13,9, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF8 and showATR table.cell(t,14,9, str.tostring(ts8atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame8 data code end ----}// if (barstate.islast) //---- Display TimeFrame9 data code start {----// if showTF9 table.cell(t,1,10, str.tostring(tf9),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF9 and showChng table.cell(t,2,10, str.tostring(ts9Chng, '#.##'),text_color=color.new(ts9p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF9 and showPChng table.cell(t,3,10, str.tostring(ts9p, '#.##') +' %',text_color=color.new(ts9p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF9 and showVwap // table.cell(t,4,10, str.tostring(ts9vwap , '#.##'),text_color=color.new(ts9 >= ts9vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9 >= ts9vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,10, 'N/A',text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) if showTF9 and showST1 table.cell(t,5,10, st1State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st9==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st9==true ? cell_up : cell_dn ,cell_transp)) if showTF9 and showST2 table.cell(t,6,10, st2State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st9==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st9==true ? cell_up : cell_dn ,cell_transp)) if showTF9 and showST3 table.cell(t,7,10, st3State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st9==true? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st9==true? cell_up : cell_dn ,cell_transp)) if showTF9 and showRSI table.cell(t,8,10, str.tostring(RSI9, '#.##'),text_color=color.new(RSI9 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI9 > 50 ? cell_up : cell_dn ,cell_transp)) if adx9 >= 75 and dp9 > dm9 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx9 >= 75 and dp9 < dm9 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx9 < 75 and adx9 >= 50 and dp9> dm9 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx9 < 75 and adx9 >= 50 and dp9 < dm9 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx9 < 50 and adx9 >= 25 and dp9 > dm9 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx9 < 50 and adx9 >= 25 and dp9 < dm9 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx9 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF9 and showADX table.cell(t,9,10, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl9 >0 and ml9 > sl9 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl9 <0 and ml9 < sl9 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF9 and showMACD table.cell(t,10,10, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts9lips > ts9teeth and ts9teeth > ts9jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts9lips < ts9teeth and ts9teeth < ts9jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts9lips > ts9teeth and ts9teeth < ts9jaw or ts9lips < ts9teeth and ts9teeth > ts9jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF9 and showAlg table.cell(t,11,10, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts9 > ts9PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts9 < ts9PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts9 < ts9PDH and ts9 > ts9PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF9 and showPHL table.cell(t,12,10, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts9 > ts9sma20 and ts9 > ts9sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts9 < ts9sma20 and ts9 < ts9sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts9 < ts9sma5H and ts9 > ts9sma20 or ts9 > ts9sma5L and ts9 < ts9sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF9 and showSmaHL table.cell(t,13,10, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF9 and showATR table.cell(t,14,10, str.tostring(ts9atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame9 data code end ----}// if (barstate.islast) //---- Display TimeFrame10 data code start {----// if showTF10 table.cell(t,1,11, str.tostring(tf10),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showTF10 and showChng table.cell(t,2,11, str.tostring(ts10Chng, '#.##'),text_color=color.new(ts10p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF10 and showPChng table.cell(t,3,11, str.tostring(ts10p, '#.##') +' %',text_color=color.new(ts10p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10p >= 0 ? cell_up : cell_dn ,cell_transp)) if showTF10 and showVwap // table.cell(t,4,11, str.tostring(ts8vwap , '#.##'),text_color=color.new(ts10 >= ts10vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8 >= ts10vwap ? cell_up : cell_dn ,cell_transp)) table.cell(t,4,11, 'N/A',text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral,cell_transp)) if showTF10 and showST1 table.cell(t,5,11, st1State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st10==true ? cell_up : cell_dn ,cell_transp)) if showTF10 and showST2 table.cell(t,6,11, st2State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st10==true ? cell_up : cell_dn ,cell_transp)) if showTF10 and showST3 table.cell(t,7,11, st3State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st10==true ? cell_up : cell_dn ,cell_transp)) if showTF10 and showRSI table.cell(t,8,11, str.tostring(RSI10, '#.##'),text_color=color.new(RSI10 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI10 > 50 ? cell_up : cell_dn ,cell_transp)) if adx10 >= 75 and dp10 > dm10 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx10 >= 75 and dp10 < dm10 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx10 < 75 and adx10 >= 50 and dp10 > dm10 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx10 < 75 and adx10 >= 50 and dp10 < dm10 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx10 < 50 and adx10 >= 25 and dp10 > dm10 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish' else if adx10 < 50 and adx10 >= 25 and dp10 < dm10 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx10 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showTF10 and showADX table.cell(t,9,11, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl10 >0 and ml10 > sl10 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl10 <0 and ml10 < sl10 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showTF10 and showMACD table.cell(t,10,11, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts10lips > ts10teeth and ts10teeth > ts10jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts10lips < ts10teeth and ts10teeth < ts10jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts10lips > ts10teeth and ts10teeth < ts10jaw or ts10lips < ts10teeth and ts10teeth > ts10jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showTF10 and showAlg table.cell(t,11,11, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts10 > ts10PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PH' else if ts10 < ts10PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PL' else if ts10 < ts10PDH and ts10 > ts10PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PH > PL' if showTF10 and showPHL table.cell(t,12,11, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts10 > ts10sma20 and ts10 > ts10sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts10 < ts10sma20 and ts10 < ts10sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts10 < ts10sma5H and ts10 > ts10sma20 or ts10 > ts10sma5L and ts10 < ts10sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showTF10 and showSmaHL table.cell(t,13,11, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showTF10 and showATR table.cell(t,14,11, str.tostring(ts10atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display TimeFrame10 data code end ----}// //---- Table Column & Rows code end ----}// //-------------- Table code end -------------------}//
Nifty / Banknifty Dashboard by RiTz
https://www.tradingview.com/script/sfqDJtZ6-Nifty-Banknifty-Dashboard-by-RiTz/
Keanu_ritz
https://www.tradingview.com/u/Keanu_ritz/
477
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/ // © keanu_ritz //@version=5 indicator(title="Nifty / Banknifty Dashboard by RiTz", overlay=true) // ---- Table Settings Start {----// max = 160 //Maximum Length min = 10 //Minimum Length var tooltip_Sym = "Shows Symbols for the selected Index" var tooltip_LTP = "Shows LTP of symbols" var tooltip_Chng = "Shows change in price of symbols" var tooltip_PChng = "Shows % change in price of symbols" var tooltip_VWAP = "Shows the current VWAP value of symbols" var tooltip_ST1 = "Shows the state of Supertrend 21-1 of symbols for Current TimeFrame" var tooltip_ST2 = "Shows the state of Supertrend 14-2 of symbols for Current TimeFrame" var tooltip_ST3 = "Shows the state of Supertrend 10-3 of symbols for Current TimeFrame" var tooltip_RSI = "Shows the value of RSI 14 period of symbols for Current TimeFrame" var tooltip_ADX = "Shows the state of ADX of symbols for Current TimeFrame" var tooltip_MACD = "Shows the state of MACD of symbols for Current TimeFrame" var tooltip_Alg = "Shows the state of Alligator indicator of symbols for Current TimeFrame" var tooltip_PDHL = "Shows where the price is trading according to the symbols Previous Day's High-Low" var tooltip_SmaHL = "Shows where the price is trading according to the 5 Sma High-Low of Multiple TimeFrames" var tooltip_ATR = "Shows Average True Range of Multiple TimeFrames" dash_loc = input.session("Top Right","Dashboard Location" ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"] ,group='Style Settings') text_size = input.session('Normal',"Dashboard Size" ,options=["Tiny","Small","Normal","Large"] ,group='Style Settings') cell_up = input.color(#52fd03,'Bullish Cell Color' ,group='Style Settings') cell_dn = input.color(#fd1d03,'Bearish Cell Color' ,group='Style Settings') cell_neutral = input.color(color.gray,'Neutral Cell Color' ,group='Style Settings') row_col = color.blue col_col = color.blue txt_col = color.white cell_transp = input.int(90,'Cell Transparency' ,minval=0 ,maxval=100 ,group='Style Settings') txt_transp = input.int(25,'Cell Transparency' ,minval=0 ,maxval=60 ,group='Style Settings') // ---- Table Settings End ----}// // ---- Indicators Show/Hide Settings Start {----// showLTP = input.bool(defval=true, title="Show LTP :", inline='indicator1', group="Columns Settings") showChng = input.bool(defval=true, title="Show Price Change", inline='indicator1', group="Columns Settings") showPChng = input.bool(defval=true, title="Show % Price Change :", inline='indicator2', group="Columns Settings") showVwap = input.bool(defval=true, title="Show VWAP", inline='indicator2', group="Columns Settings") showST1 = input.bool(defval=true, title="Show SuperTrend 21-1 :", inline='indicator3', group="Columns Settings") showST2 = input.bool(defval=true, title="Show SuperTrend 14-2 :", inline='indicator3', group="Columns Settings") showST3 = input.bool(defval=true, title="Show SuperTrend 10-3", inline='indicator3', group="Columns Settings") showRSI = input.bool(defval=true, title="Show RSI :", inline='indicator4', group="Columns Settings") showADX = input.bool(defval=true, title="Show ADX", inline='indicator4', group="Columns Settings") showMACD = input.bool(defval=true, title="Show MACD :", inline='indicator5', group="Columns Settings") showAlg = input.bool(defval=true, title="Show Alligator", inline='indicator5', group="Columns Settings") showPHL = input.bool(defval=true, title="Show Previous Day High/Low", inline='indicator6', group="Columns Settings") showSmaHL = input.bool(defval=true, title="Show 5 Sma High/Low", inline="indicator6", group="Columns Settings") showATR = input.bool(defval=true, title="Show ATR (14 period)", inline="indicator7", group="Columns Settings") // ---- Indicators Show/Hide Settings end ----}// // ---- Symbols Show/Hide Settings Start {----// showSiv = input.bool(defval=true, title="Show India VIX", group="Rows Settings") showS1 = input.bool(defval=true, title="Show Symbol 1 :", inline='SSym1', group="Rows Settings") showS2 = input.bool(defval=true, title="Show Symbol 2", inline='SSym1', group="Rows Settings") showS3 = input.bool(defval=true, title="Show Symbol 3 :", inline='SSym2', group="Rows Settings") showS4 = input.bool(defval=true, title="Show Symbol 4", inline='SSym2', group="Rows Settings") showS5 = input.bool(defval=true, title="Show Symbol 5 :", inline='SSym3', group="Rows Settings") showS6 = input.bool(defval=true, title="Show Symbol 6", inline='SSym3', group="Rows Settings") showS7 = input.bool(defval=true, title="Show Symbol 7 :", inline='SSym4', group="Rows Settings") showS8 = input.bool(defval=true, title="Show Symbol 8", inline='SSym4', group="Rows Settings") showS9 = input.bool(defval=true, title="Show Symbol 9 :", inline='SSym5', group="Rows Settings") showS10 = input.bool(defval=true, title="Show Symbol 10", inline='SSym5', group="Rows Settings") // ---- Symbols Show/Hide Settings end ----}// // ----IndiaVIX calculation code start {----// indvixin = input.symbol("NSE:INDIAVIX","Ticker Vix", group='Symbol Settings') [indvix,indvixC,ivPDH,ivPDL] = request.security(indvixin,'D',[close,close[1],high[1],low[1]]) indvixChng = (indvix-indvixC) indvixp = (indvix - indvixC)*100/indvixC cvix = indvixp >= 0 ? cell_up : cell_dn // ----IndiaVIX calculation code end ----}// //---- Index & Symbols Selection code start {----// _Index = input.string('BankNifty', 'Dashboard for Index', options=['BankNifty', 'Nifty'], group='Symbol Settings') t1 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY', 'BNF Symbol 1', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY', 'Nifty Symbol 1', inline='Nifty Symbol', group='Symbol Settings') t2 = _Index == 'BankNifty' ? input.symbol('NSE:BANKNIFTY1!', 'BNF Symbol 2', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:NIFTY1!', 'Nifty Symbol 2', inline='Nifty Symbol', group='Symbol Settings') t3 = _Index == 'BankNifty' ? input.symbol('NSE:HDFCBANK', 'BNF Symbol 3', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:HDFCBANK', 'Nifty Symbol 3', inline='Nifty Symbol', group='Symbol Settings') t4 = _Index == 'BankNifty' ? input.symbol('NSE:ICICIBANK', 'BNF Symbol 4', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:RELIANCE', 'Nifty Symbol 4', inline='Nifty Symbol', group='Symbol Settings') t5 = _Index == 'BankNifty' ? input.symbol('NSE:KOTAKBANK', 'BNF Symbol 5', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:ICICIBANK', 'Nifty Symbol 5', inline='Nifty Symbol', group='Symbol Settings') t6 = _Index == 'BankNifty' ? input.symbol('NSE:AXISBANK', 'BNF Symbol 6', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:INFY', 'Nifty Symbol 6', inline='Nifty Symbol', group='Symbol Settings') t7 = _Index == 'BankNifty' ? input.symbol('NSE:SBIN', 'BNF Symbol 7', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:ITC', 'Nifty Symbol 7', inline='Nifty Symbol', group='Symbol Settings') t8 = _Index == 'BankNifty' ? input.symbol('NSE:INDUSINDBK', 'BNF Symbol 8', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:LT', 'Nifty Symbol 8', inline='Nifty Symbol', group='Symbol Settings') t9 = _Index == 'BankNifty' ? input.symbol('NSE:BANKBARODA', 'BNF Symbol 9', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:TCS', 'Nifty Symbol 9', inline='Nifty Symbol', group='Symbol Settings') t10 = _Index == 'BankNifty' ? input.symbol('NSE:FEDERALBNK', 'BNF Symbol 10', inline='BNF Symbol', group='Symbol Settings') : input.symbol('NSE:AXISBANK', 'Nifty Symbol 10', inline='Nifty Symbol', group='Symbol Settings') //---- Index & Symbols Selection code end ----}// //---- Indicators code Start {----// var PColor = color.white var PText = '' var SmaHLColor = color.white var SmaHLText = '' //---- Alligator code Start {----// var AlgColor = color.white var AlgText = '' jawPeriod = 13 teethPeriod = 8 lipsPeriod = 5 smma(src, length) => smma = 0.0 sma_1 = ta.sma(src, length) smma := na(smma[1]) ? sma_1 : (smma[1] * (length - 1) + src) / length smma jaw = smma(hl2, jawPeriod) teeth = smma(hl2, teethPeriod) lips = smma(hl2, lipsPeriod) //---- Alligator code end ----}// //---- SuperTrend code start {----// f1=1 f2=2 f3=3 p1=21 p2=14 p3=10 Supertrend(f1, p1) => [supertrend, trend] = ta.supertrend(f1, p1) st1State_ = trend == 1 ? false : true [st1State_] Supertrend2(f2, p2) => [supertrend, trend] = ta.supertrend(f2, p2) st2State_ = trend == 1 ? false : true [st2State_] Supertrend3(f3, p3) => [supertrend, trend] = ta.supertrend(f3, p3) st3State_ = trend == 1 ? false : true [st3State_] [st1State_] = Supertrend(f1, p1) [st2State_] = Supertrend2(f2, p2) [st3State_] = Supertrend3(f3, p3) //---- SuperTrend code end----}// vwap = ta.vwap(hlc3) //---- RSI code start {----// rsiPeriod = 14 RSI = ta.rsi(close, rsiPeriod) //---- RSI code end ----}// //---- ATR code start {----// atrPeriod = 14 ATR = ta.atr(atrPeriod) //---- ATR code end ----}// //---- 5 SMA H-L code start{----// smaH = ta.sma(high,5) smaL = ta.sma(low,5) sma20C = ta.sma(close,20) //---- 5 SMA H-L code end ----}// //---- ADX-DMI code start {----// adxP = 14 adxS = 14 var ADXColor = color.white var ADXText = '' ADXf(adxP, adxS) => [diplus, diminus, adx] = ta.dmi(adxP, adxS) [dp, dm, adxx] = ADXf(adxP, adxS) //---- ADX-DMI code end ----}// //---- MACD code start {----// flen = 12 sllen = 26 sglen = 9 var MACDColor = color.white var MACDText = '' Macdf(flen,sllen,sglen) => [macdline,sgline,histline] = ta.macd(close,flen,sllen,sglen) [ml,sl,hsl] = Macdf(flen,sllen,sglen) //---- MACD code end ----}// //---- Calculate Values of Indicators for Symbols code start {----// [IVixJaw,IVixTeeth,IVixLips,IVix1vwap,st1State_iv1,st2State_iv1,st3State_iv1,RSIiv,dpiv,dmiv,adxiv,mliv,sliv,hsliv,tsivsma5H,tsivsma5L,tsivsma20,tsivatr] = request.security(indvixin,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts1jaw,ts1teeth,ts1lips,ts1vwap,st1State_st1,st2State_st1,st3State_st1,RSI1,dp1,dm1,adx1,ml1,sl1,hsl1,ts1sma5H,ts1sma5L,ts1sma20,ts1atr] = request.security(t1,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts2jaw,ts2teeth,ts2lips,ts2vwap,st1State_st2,st2State_st2,st3State_st2,RSI2,dp2,dm2,adx2,ml2,sl2,hsl2,ts2sma5H,ts2sma5L,ts2sma20,ts2atr] = request.security(t2,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts3jaw,ts3teeth,ts3lips,ts3vwap,st1State_st3,st2State_st3,st3State_st3,RSI3,dp3,dm3,adx3,ml3,sl3,hsl3,ts3sma5H,ts3sma5L,ts3sma20,ts3atr] = request.security(t3,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts4jaw,ts4teeth,ts4lips,ts4vwap,st1State_st4,st2State_st4,st3State_st4,RSI4,dp4,dm4,adx4,ml4,sl4,hsl4,ts4sma5H,ts4sma5L,ts4sma20,ts4atr] = request.security(t4,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts5jaw,ts5teeth,ts5lips,ts5vwap,st1State_st5,st2State_st5,st3State_st5,RSI5,dp5,dm5,adx5,ml5,sl5,hsl5,ts5sma5H,ts5sma5L,ts5sma20,ts5atr] = request.security(t5,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts6jaw,ts6teeth,ts6lips,ts6vwap,st1State_st6,st2State_st6,st3State_st6,RSI6,dp6,dm6,adx6,ml6,sl6,hsl6,ts6sma5H,ts6sma5L,ts6sma20,ts6atr] = request.security(t6,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts7jaw,ts7teeth,ts7lips,ts7vwap,st1State_st7,st2State_st7,st3State_st7,RSI7,dp7,dm7,adx7,ml7,sl7,hsl7,ts7sma5H,ts7sma5L,ts7sma20,ts7atr] = request.security(t7,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts8jaw,ts8teeth,ts8lips,ts8vwap,st1State_st8,st2State_st8,st3State_st8,RSI8,dp8,dm8,adx8,ml8,sl8,hsl8,ts8sma5H,ts8sma5L,ts8sma20,ts8atr] = request.security(t8,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts9jaw,ts9teeth,ts9lips,ts9vwap,st1State_st9,st2State_st9,st3State_st9,RSI9,dp9,dm9,adx9,ml9,sl9,hsl9,ts9sma5H,ts9sma5L,ts9sma20,ts9atr] = request.security(t9,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) [ts10jaw,ts10teeth,ts10lips,ts10vwap,st1State_st10,st2State_st10,st3State_st10,RSI10,dp10,dm10,adx10,ml10,sl10,hsl10,ts10sma5H,ts10sma5L,ts10sma20,ts10atr] = request.security(t10,timeframe.period,[jaw,teeth,lips,vwap,st1State_,st2State_,st3State_,RSI,dp,dm,adxx,ml,sl,hsl,smaH,smaL,sma20C,ATR]) //---- Calculate Values of Indicators for Symbols code end ----}// //---- Calculate Change & %Change code start {----// [ts1,ts1C,ts1PDH,ts1PDL] = request.security(t1,'D',[close,close[1],high[1],low[1]]) ts1Chng = (ts1-ts1C) ts1p = (ts1-ts1C)*100/ts1C //------------------ [ts2,ts2C,ts2PDH,ts2PDL] = request.security(t2,'D',[close,close[1],high[1],low[1]]) ts2Chng = (ts2-ts2C) ts2p = (ts2-ts2C)*100/ts2C //--------------- [ts3,ts3C,ts3PDH,ts3PDL] = request.security(t3,'D',[close,close[1],high[1],low[1]]) ts3Chng = (ts3-ts3C) ts3p = (ts3-ts3C)*100/ts3C //---------------- [ts4,ts4C,ts4PDH,ts4PDL] = request.security(t4,'D',[close,close[1],high[1],low[1]]) ts4Chng = (ts4-ts4C) ts4p = (ts4-ts4C)*100/ts4C //---------------- [ts5,ts5C,ts5PDH,ts5PDL] = request.security(t5,'D',[close,close[1],high[1],low[1]]) ts5Chng = (ts5-ts5C) ts5p = (ts5-ts5C)*100/ts5C //---------------- [ts6,ts6C,ts6PDH,ts6PDL] = request.security(t6,'D',[close,close[1],high[1],low[1]]) ts6Chng = (ts6-ts6C) ts6p = (ts6-ts6C)*100/ts6C //---------------- [ts7,ts7C,ts7PDH,ts7PDL] = request.security(t7,'D',[close,close[1],high[1],low[1]]) ts7Chng = (ts7-ts7C) ts7p = (ts7-ts7C)*100/ts7C //---------------- [ts8,ts8C,ts8PDH,ts8PDL] = request.security(t8,'D',[close,close[1],high[1],low[1]]) ts8Chng = (ts8-ts8C) ts8p = (ts8-ts8C)*100/ts8C //---------------- [ts9,ts9C,ts9PDH,ts9PDL] = request.security(t9,'D',[close,close[1],high[1],low[1]]) ts9Chng = (ts9-ts9C) ts9p = (ts9-ts9C)*100/ts9C //---------------- [ts10,ts10C,ts10PDH,ts10PDL] = request.security(t10,'D',[close,close[1],high[1],low[1]]) ts10Chng = (ts10-ts10C) ts10p = (ts10-ts10C)*100/ts10C //---- Calculate Change & %Change code end----}// //---- Indicators code end ----}// //-------------- Table code Start {-------------------// //---- Table Position & Size code start {----// var table_position = dash_loc == 'Top Left' ? position.top_left : dash_loc == 'Bottom Left' ? position.bottom_left : dash_loc == 'Middle Right' ? position.middle_right : dash_loc == 'Bottom Center' ? position.bottom_center : dash_loc == 'Top Right' ? position.top_right : position.bottom_right var table_text_size = text_size == 'Tiny' ? size.tiny : text_size == 'Small' ? size.small : text_size == 'Normal' ? size.normal : size.large var t = table.new(table_position,16,math.abs(max-min)+2, frame_color=color.new(#000000,0), frame_width=1, border_color=color.new(#000000,0), border_width=1) //---- Table Position & Size code end ----}// //---- Table Column & Rows code start {----// if (barstate.islast) //---- Table Main Column Headers code start {----// table.cell(t,1,0,'Dashboard',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) // table.merge_cells(t,1,0,13,0) table.cell(t,1,1,'Symbol',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Sym) if showLTP table.cell(t,2,1,'LTP',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_LTP) if showChng table.cell(t,3,1,'Chng',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Chng) if showPChng table.cell(t,4,1,'%Chng',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_PChng) if showVwap table.cell(t,5,1,'VWAP',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_VWAP) if showST1 table.cell(t,6,1,'ST 21-1',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST1) if showST2 table.cell(t,7,1,'ST 14-2',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST2) if showST3 table.cell(t,8,1,'ST 10-3',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ST3) if showRSI table.cell(t,9,1,'RSI 14',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_RSI) if showADX table.cell(t,10,1,'ADX',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ADX) if showMACD table.cell(t,11,1,'MACD',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_MACD) if showAlg table.cell(t,12,1,'Alligator',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_Alg) if showPHL table.cell(t,13,1,'PDH-PDL',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_PDHL) if showSmaHL table.cell(t,14,1,'5 Sma H/L',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_SmaHL) if showATR table.cell(t,15,1,'ATR (14)',text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp),tooltip=tooltip_ATR) //---- Table Main Column Headers code end ----}// //---- Display IndiaVIX data code start {----// if showSiv table.cell(t,1,2, str.replace_all(indvixin, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showSiv and showLTP table.cell(t,2,2, str.tostring(indvix, '#.##') ,text_color=color.new(indvixp >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(indvixp >= 0 ? cell_up : cell_dn ,cell_transp)) if showSiv and showChng table.cell(t,3,2, str.tostring(indvixChng, '#.##'),text_color=color.new(indvixp >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(indvixp >= 0 ? cell_up : cell_dn ,cell_transp)) if showSiv and showPChng table.cell(t,4,2, str.tostring(indvixp, '#.##') +'%',text_color=color.new(indvixp >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(indvixp >= 0 ? cell_up : cell_dn ,cell_transp)) if showSiv and showVwap table.cell(t,5,2, str.tostring(IVix1vwap, '#.##'),text_color=color.new(indvix >= IVix1vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(indvix >= IVix1vwap ? cell_up : cell_dn ,cell_transp)) if showSiv and showST1 table.cell(t,6,2, st1State_iv1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_iv1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_iv1==true ? cell_up : cell_dn ,cell_transp)) if showSiv and showST2 table.cell(t,7,2, st2State_iv1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_iv1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_iv1==true ? cell_up : cell_dn ,cell_transp)) if showSiv and showST3 table.cell(t,8,2, st3State_iv1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_iv1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_iv1==true ? cell_up : cell_dn ,cell_transp)) if showSiv and showRSI table.cell(t,9,2, str.tostring(RSIiv, '#.##'),text_color=color.new(RSIiv > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSIiv > 50 ? cell_up : cell_dn ,cell_transp)) if adxiv >= 75 and dpiv > dmiv ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adxiv >= 75 and dpiv < dmiv ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adxiv < 75 and adxiv >= 50 and dpiv > dmiv ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adxiv < 75 and adxiv >= 50 and dpiv < dmiv ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adxiv < 50 and adxiv >= 25 and dpiv > dmiv ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adxiv < 25 and adxiv >= 25 and dpiv < dmiv ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adxiv < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showSiv and showADX table.cell(t,10,2, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsliv >0 and mliv > sliv MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsliv <0 and mliv < sliv MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showSiv and showMACD table.cell(t,11,2, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if IVixLips > IVixTeeth and IVixTeeth > IVixJaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if IVixLips < IVixTeeth and IVixTeeth < IVixJaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if IVixLips > IVixTeeth and IVixTeeth < IVixJaw or IVixLips < IVixTeeth and IVixTeeth > IVixJaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showSiv and showAlg table.cell(t,12,2, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if indvix > ivPDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if indvix < ivPDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if indvix < ivPDH and indvix > ivPDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showSiv and showPHL table.cell(t,13,2, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if indvix > tsivsma20 and indvix > tsivsma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if indvix < tsivsma20 and indvix < tsivsma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if indvix < tsivsma5H and indvix > tsivsma20 or indvix > tsivsma5L and indvix < tsivsma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showSiv and showSmaHL table.cell(t,14,2, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showSiv and showATR table.cell(t,15,2, str.tostring(tsivatr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display IndiaVIX data code end ----}// //---- Display Symbol-1 data code start {----// if showS1 table.cell(t,1,3, str.replace_all(t1, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS1 and showLTP table.cell(t,2,3, str.tostring(ts1, '#.##') ,text_color=color.new(ts1p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS1 and showChng table.cell(t,3,3, str.tostring(ts1Chng, '#.##'),text_color=color.new(ts1p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS1 and showPChng table.cell(t,4,3, str.tostring(ts1p, '#.##') +'%',text_color=color.new(ts1p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS1 and showVwap table.cell(t,5,3, str.tostring(ts1vwap, '#.##'),text_color=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts1 >= ts1vwap ? cell_up : cell_dn ,cell_transp)) if showS1 and showST1 table.cell(t,6,3, st1State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st1==true ? cell_up : cell_dn ,cell_transp)) if showS1 and showST2 table.cell(t,7,3, st2State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st1==true ? cell_up : cell_dn ,cell_transp)) if showS1 and showST3 table.cell(t,8,3, st3State_st1 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st1==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st1==true ? cell_up : cell_dn ,cell_transp)) if showS1 and showRSI table.cell(t,9,3, str.tostring(RSI1, '#.##'),text_color=color.new(RSI1 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI1 > 50 ? cell_up : cell_dn ,cell_transp)) if adx1 >= 75 and dp1 > dm1 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx1 >= 75 and dp1 < dm1 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx1 < 75 and adx1 >= 50 and dp1 > dm1 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx1 < 75 and adx1 >= 50 and dp1 < dm1 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx1 < 50 and adx1 >= 25 and dp1 > dm1 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx1 < 50 and adx1 >= 25 and dp1 < dm1 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx1 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS1 and showADX table.cell(t,10,3, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl1 >0 and ml1 > sl1 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl1 <0 and ml1 < sl1 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS1 and showMACD table.cell(t,11,3, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts1lips > ts1teeth and ts1teeth > ts1jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts1lips < ts1teeth and ts1teeth < ts1jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts1lips > ts1teeth and ts1teeth < ts1jaw or ts1lips < ts1teeth and ts1teeth > ts1jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS1 and showAlg table.cell(t,12,3, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts1 > ts1PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts1 < ts1PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts1 < ts1PDH and ts1 > ts1PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS1 and showPHL table.cell(t,13,3, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts1 > ts1sma20 and ts1 > ts1sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts1 < ts1sma20 and ts1 < ts1sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts1 < ts1sma5H and ts1 > ts1sma20 or ts1 > ts1sma5L and ts1 < ts1sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS1 and showSmaHL table.cell(t,14,3, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS1 and showATR table.cell(t,15,3, str.tostring(ts1atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-1 data code end ----}// //---- Display Symbol-2 data code start {----// if showS2 table.cell(t,1,4, str.replace_all(t2, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS2 and showLTP table.cell(t,2,4, str.tostring(ts2, '#.##') ,text_color=color.new(ts2p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS2 and showChng table.cell(t,3,4, str.tostring(ts2Chng, '#.##'),text_color=color.new(ts2p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS2 and showPChng table.cell(t,4,4, str.tostring(ts2p, '#.##') +'%',text_color=color.new(ts2p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS2 and showVwap table.cell(t,5,4, str.tostring(ts2vwap, '#.##'),text_color=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts2 >= ts2vwap ? cell_up : cell_dn ,cell_transp)) if showS2 and showST1 table.cell(t,6,4, st1State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st2==true ? cell_up : cell_dn ,cell_transp)) if showS2 and showST2 table.cell(t,7,4, st2State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st2==true ? cell_up : cell_dn ,cell_transp)) if showS2 and showST3 table.cell(t,8,4, st3State_st2 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st2==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st2==true ? cell_up : cell_dn ,cell_transp)) if showS2 and showRSI table.cell(t,9,4, str.tostring(RSI2, '#.##'),text_color=color.new(RSI2 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI2 > 50 ? cell_up : cell_dn ,cell_transp)) if adx2 >= 75 and dp2 > dm2 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx2 >= 75 and dp2 < dm2 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx2 < 75 and adx2 >= 50 and dp2 > dm2 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx2 < 75 and adx2 >= 50 and dp2 < dm2 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx2 < 50 and adx2 >= 25 and dp2 > dm2 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx2 < 50 and adx2 >= 25 and dp2 < dm2 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx2 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS2 and showADX table.cell(t,10,4, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl2 >0 and ml2 > sl2 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl2 <0 and ml2 < sl2 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS2 and showMACD table.cell(t,11,4, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts2lips > ts2teeth and ts2teeth > ts2jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts2lips < ts2teeth and ts2teeth < ts2jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts2lips > ts2teeth and ts2teeth < ts2jaw or ts2lips < ts2teeth and ts2teeth > ts2jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS2 and showAlg table.cell(t,12,4, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts2 > ts2PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts2 < ts2PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts2 < ts2PDH and ts2 > ts2PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS2 and showPHL table.cell(t,13,4, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts2 > ts2sma20 and ts2 > ts2sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts2 < ts2sma20 and ts2 < ts2sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts2 < ts2sma5H and ts2 > ts2sma20 or ts2 > ts2sma5L and ts2 < ts2sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS2 and showSmaHL table.cell(t,14,4, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS2 and showATR table.cell(t,15,4, str.tostring(ts2atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-2 data code end ----}// //---- Display Symbol-3 data code start {----// if showS3 table.cell(t,1,5, str.replace_all(t3, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS3 and showLTP table.cell(t,2,5, str.tostring(ts3, '#.##') ,text_color=color.new(ts3p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS3 and showChng table.cell(t,3,5, str.tostring(ts3Chng, '#.##'),text_color=color.new(ts3p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS3 and showPChng table.cell(t,4,5, str.tostring(ts3p, '#.##') +'%',text_color=color.new(ts3p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS3 and showVwap table.cell(t,5,5, str.tostring(ts3vwap, '#.##'),text_color=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts3 >= ts3vwap ? cell_up : cell_dn ,cell_transp)) if showS3 and showST1 table.cell(t,6,5, st1State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st3==true ? cell_up : cell_dn ,cell_transp)) if showS3 and showST2 table.cell(t,7,5, st2State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st3==true ? cell_up : cell_dn ,cell_transp)) if showS3 and showST3 table.cell(t,8,5, st3State_st3 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st3==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st3==true ? cell_up : cell_dn ,cell_transp)) if showS3 and showRSI table.cell(t,9,5, str.tostring(RSI3, '#.##'),text_color=color.new(RSI3 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI3 > 50 ? cell_up : cell_dn ,cell_transp)) if adx3 >= 75 and dp3 > dm3 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx3 >= 75 and dp3 < dm3 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx3 < 75 and adx3 >= 50 and dp3 > dm3 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx3 < 75 and adx3 >= 50 and dp3 < dm3 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx3 < 50 and adx3 >= 25 and dp3 > dm3 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx3 < 50 and adx3 >= 25 and dp3 < dm3 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx3 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS3 and showADX table.cell(t,10,5, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl3 >0 and ml3 > sl3 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl3 <0 and ml3 < sl3 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS3 and showMACD table.cell(t,11,5, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts3lips > ts3teeth and ts3teeth > ts3jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts3lips < ts3teeth and ts3teeth < ts3jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts3lips > ts3teeth and ts3teeth < ts3jaw or ts3lips < ts3teeth and ts3teeth > ts3jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS3 and showAlg table.cell(t,12,5, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts3 > ts3PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts3 < ts3PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts3 < ts3PDH and ts3 > ts3PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS3 and showPHL table.cell(t,13,5, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts3 > ts3sma20 and ts3 > ts3sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts3 < ts3sma20 and ts3 < ts3sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts3 < ts3sma5H and ts3 > ts3sma20 or ts3 > ts3sma5L and ts3 < ts3sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS3 and showSmaHL table.cell(t,14,5, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS3 and showATR table.cell(t,15,5, str.tostring(ts3atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-3 data code end ----}// //---- Display Symbol-4 data code start {----// if showS4 table.cell(t,1,6, str.replace_all(t4, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS4 and showLTP table.cell(t,2,6, str.tostring(ts4, '#.##') ,text_color=color.new(ts4p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS4 and showChng table.cell(t,3,6, str.tostring(ts4Chng, '#.##'),text_color=color.new(ts4p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS4 and showPChng table.cell(t,4,6, str.tostring(ts4p, '#.##') +'%',text_color=color.new(ts4p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS4 and showVwap table.cell(t,5,6, str.tostring(ts4vwap, '#.##'),text_color=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts4 >= ts4vwap ? cell_up : cell_dn ,cell_transp)) if showS4 and showST1 table.cell(t,6,6, st1State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st4==true ? cell_up : cell_dn ,cell_transp)) if showS4 and showST2 table.cell(t,7,6, st2State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st4==true ? cell_up : cell_dn ,cell_transp)) if showS4 and showST3 table.cell(t,8,6, st3State_st4 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st4==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st4==true ? cell_up : cell_dn ,cell_transp)) if showS4 and showRSI table.cell(t,9,6, str.tostring(RSI4, '#.##'),text_color=color.new(RSI4 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI4 > 50 ? cell_up : cell_dn ,cell_transp)) if adx4 >= 75 and dp4 > dm4 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx4 >= 75 and dp4 < dm4 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx4 < 75 and adx4 >= 50 and dp4 > dm4 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx4 < 75 and adx4 >= 50 and dp4 < dm4 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx4 < 50 and adx4 >= 25 and dp4 > dm4 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx4 < 50 and adx4 >= 25 and dp4 < dm4 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx4 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS4 and showADX table.cell(t,10,6, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl4 >0 and ml4 > sl4 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl4 <0 and ml4 < sl4 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS4 and showMACD table.cell(t,11,6, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts4lips > ts4teeth and ts4teeth > ts4jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts4lips < ts4teeth and ts4teeth < ts4jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts4lips > ts4teeth and ts4teeth < ts4jaw or ts4lips < ts4teeth and ts4teeth > ts4jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS4 and showAlg table.cell(t,12,6, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts4 > ts4PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts4 < ts4PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts4 < ts4PDH and ts4 > ts4PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS4 and showPHL table.cell(t,13,6, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts4 > ts4sma20 and ts4 > ts4sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts4 < ts4sma20 and ts4 < ts4sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts4 < ts4sma5H and ts4 > ts4sma20 or ts4 > ts4sma5L and ts4 < ts4sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS4 and showSmaHL table.cell(t,14,6, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS4 and showATR table.cell(t,15,6, str.tostring(ts4atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-4 data code end ----}// if (barstate.islast) //---- Display Symbol-5 data code start {----// if showS5 table.cell(t,1,7, str.replace_all(t5, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS5 and showLTP table.cell(t,2,7, str.tostring(ts5, '#.##') ,text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS5 and showChng table.cell(t,3,7, str.tostring(ts5Chng, '#.##'),text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS5 and showPChng table.cell(t,4,7, str.tostring(ts5p, '#.##') +'%',text_color=color.new(ts5p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS5 and showVwap table.cell(t,5,7, str.tostring(ts5vwap, '#.##'),text_color=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts5 >= ts5vwap ? cell_up : cell_dn ,cell_transp)) if showS5 and showST1 table.cell(t,6,7, st1State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st5==true ? cell_up : cell_dn ,cell_transp)) if showS5 and showST2 table.cell(t,7,7, st2State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st5==true ? cell_up : cell_dn ,cell_transp)) if showS5 and showST3 table.cell(t,8,7, st3State_st5 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st5==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st5==true ? cell_up : cell_dn ,cell_transp)) if showS5 and showRSI table.cell(t,9,7, str.tostring(RSI5, '#.##'),text_color=color.new(RSI5 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI5 > 50 ? cell_up : cell_dn ,cell_transp)) if adx5 >= 75 and dp5 > dm5 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx5 >= 75 and dp5 < dm5 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx5 < 75 and adx5 >= 50 and dp5 > dm5 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx5 < 75 and adx5 >= 50 and dp5 < dm5 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx5 < 50 and adx5 >= 25 and dp5 > dm5 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx5 < 50 and adx5 >= 25 and dp5 < dm5 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx5 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS5 and showADX table.cell(t,10,7, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl5 >0 and ml5 > sl5 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl5 <0 and ml5 < sl5 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS5 and showMACD table.cell(t,11,7, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts5lips > ts5teeth and ts5teeth > ts5jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts5lips < ts5teeth and ts5teeth < ts5jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts5lips > ts5teeth and ts5teeth < ts5jaw or ts5lips < ts5teeth and ts5teeth > ts5jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS5 and showAlg table.cell(t,12,7, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts5 > ts5PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts5 < ts5PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts5 < ts5PDH and ts5 > ts5PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS5 and showPHL table.cell(t,13,7, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts5 > ts5sma20 and ts5 > ts5sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts5 < ts5sma20 and ts5 < ts5sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts5 < ts5sma5H and ts5 > ts5sma20 or ts5 > ts5sma5L and ts5 < ts5sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS5 and showSmaHL table.cell(t,14,7, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS5 and showATR table.cell(t,15,7, str.tostring(ts5atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-5 data code end ----}// //---- Display Symbol-6 data code start {----// if showS6 table.cell(t,1,8, str.replace_all(t6, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS6 and showLTP table.cell(t,2,8, str.tostring(ts6, '#.##') ,text_color=color.new(ts6p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS6 and showChng table.cell(t,3,8, str.tostring(ts6Chng, '#.##'),text_color=color.new(ts6p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS6 and showPChng table.cell(t,4,8, str.tostring(ts6p, '#.##') +'%',text_color=color.new(ts6p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS6 and showVwap table.cell(t,5,8, str.tostring(ts6vwap, '#.##'),text_color=color.new(ts6 >= ts6vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts6 >= ts6vwap ? cell_up : cell_dn ,cell_transp)) if showS6 and showST1 table.cell(t,6,8, st1State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st6==true ? cell_up : cell_dn ,cell_transp)) if showS6 and showST2 table.cell(t,7,8, st2State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st6==true ? cell_up : cell_dn ,cell_transp)) if showS6 and showST3 table.cell(t,8,8, st3State_st6 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st6==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st6==true ? cell_up : cell_dn ,cell_transp)) if showS6 and showRSI table.cell(t,9,8, str.tostring(RSI6, '#.##'),text_color=color.new(RSI6 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI6 > 50 ? cell_up : cell_dn ,cell_transp)) if adx6 >= 75 and dp6 > dm6 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx6 >= 75 and dp6 < dm6 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx6 < 75 and adx6 >= 50 and dp6 > dm6 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx6 < 75 and adx6 >= 50 and dp6 < dm6 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx6 < 50 and adx6 >= 25 and dp6 > dm6 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx6 < 50 and adx6 >= 25 and dp6 < dm6 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx6 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS6 and showADX table.cell(t,10,8, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl6 >0 and ml6 > sl6 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl6 <0 and ml6 < sl6 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS6 and showMACD table.cell(t,11,8, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts6lips > ts6teeth and ts6teeth > ts6jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts6lips < ts6teeth and ts6teeth < ts6jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts6lips > ts6teeth and ts6teeth < ts6jaw or ts6lips < ts6teeth and ts6teeth > ts6jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS6 and showAlg table.cell(t,12,8, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts6 > ts6PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts6 < ts6PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts6 < ts6PDH and ts6 > ts6PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS6 and showPHL table.cell(t,13,8, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts6 > ts6sma20 and ts6 > ts6sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts6 < ts6sma20 and ts6 < ts6sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts6 < ts6sma5H and ts6 > ts6sma20 or ts6 > ts6sma5L and ts6 < ts6sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS6 and showSmaHL table.cell(t,14,8, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS6 and showATR table.cell(t,15,8, str.tostring(ts6atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-6 data code end ----}// //---- Display Symbol-7 data code start {----// if showS7 table.cell(t,1,9, str.replace_all(t7, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS7 and showLTP table.cell(t,2,9, str.tostring(ts7, '#.##') ,text_color=color.new(ts7p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS7 and showChng table.cell(t,3,9, str.tostring(ts7Chng, '#.##'),text_color=color.new(ts7p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS7 and showPChng table.cell(t,4,9, str.tostring(ts7p, '#.##') +'%',text_color=color.new(ts7p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS7 and showVwap table.cell(t,5,9, str.tostring(ts7vwap, '#.##'),text_color=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts7 >= ts7vwap ? cell_up : cell_dn ,cell_transp)) if showS7 and showST1 table.cell(t,6,9, st1State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st7==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st7==true ? cell_up : cell_dn ,cell_transp)) if showS7 and showST2 table.cell(t,7,9, st2State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st7==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st7==true ? cell_up : cell_dn ,cell_transp)) if showS7 and showST3 table.cell(t,8,9, st3State_st7 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st7==true? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st7==true? cell_up : cell_dn ,cell_transp)) if showS7 and showRSI table.cell(t,9,9, str.tostring(RSI7, '#.##'),text_color=color.new(RSI7 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI7 > 50 ? cell_up : cell_dn ,cell_transp)) if adx7 >= 75 and dp7 > dm7 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx7 >= 75 and dp7 < dm7 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx7 < 75 and adx7 >= 50 and dp7 > dm7 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx7 < 75 and adx7 >= 50 and dp7 < dm7 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx7 < 50 and adx7 >= 25 and dp7 > dm7 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx7 < 50 and adx7 >= 25 and dp7 < dm7 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx7 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS7 and showADX table.cell(t,10,9, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl7 >0 and ml7 > sl7 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl7 <0 and ml7 < sl7 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS7 and showMACD table.cell(t,11,9, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts7lips > ts7teeth and ts7teeth > ts7jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts7lips < ts7teeth and ts7teeth < ts7jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts7lips > ts7teeth and ts7teeth < ts7jaw or ts7lips < ts7teeth and ts7teeth > ts7jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS7 and showAlg table.cell(t,12,9, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts7 > ts7PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts7 < ts7PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts7 < ts7PDH and ts7 > ts7PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS7 and showPHL table.cell(t,13,9, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts7 > ts7sma20 and ts7 > ts7sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts7 < ts7sma20 and ts7 < ts7sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts7 < ts7sma5H and ts7 > ts7sma20 or ts7 > ts7sma5L and ts7 < ts7sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS7 and showSmaHL table.cell(t,14,9, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS7 and showATR table.cell(t,15,9, str.tostring(ts7atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-7 data code end ----}// //---- Display Symbol-8 data code start {----// if showS8 table.cell(t,1,10, str.replace_all(t8, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS8 and showLTP table.cell(t,2,10, str.tostring(ts8, '#.##') ,text_color=color.new(ts8p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS8 and showChng table.cell(t,3,10, str.tostring(ts8Chng, '#.##'),text_color=color.new(ts8p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS8 and showPChng table.cell(t,4,10, str.tostring(ts8p, '#.##') +'%',text_color=color.new(ts8p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS8 and showVwap table.cell(t,5,10, str.tostring(ts8vwap, '#.##'),text_color=color.new(ts8 >= ts8vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts8 >= ts8vwap ? cell_up : cell_dn ,cell_transp)) if showS8 and showST1 table.cell(t,6,10, st1State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st8==true ? cell_up : cell_dn ,cell_transp)) if showS8 and showST2 table.cell(t,7,10, st2State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st8==true ? cell_up : cell_dn ,cell_transp)) if showS8 and showST3 table.cell(t,8,10, st3State_st8 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st8==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st8==true ? cell_up : cell_dn ,cell_transp)) if showS8 and showRSI table.cell(t,9,10, str.tostring(RSI8, '#.##'),text_color=color.new(RSI8 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI8 > 50 ? cell_up : cell_dn ,cell_transp)) if adx8 >= 75 and dp8 > dm8 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx8 >= 75 and dp8 < dm8 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx8 < 75 and adx8 >= 50 and dp8 > dm8 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx8 < 75 and adx8 >= 50 and dp8 < dm8 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx8 < 50 and adx8 >= 25 and dp8 > dm8 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx8 < 50 and adx8 >= 25 and dp8 < dm8 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx8 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS8 and showADX table.cell(t,10,10, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl8 >0 and ml8 > sl8 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl8 <0 and ml8 < sl8 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS8 and showMACD table.cell(t,11,10, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts8lips > ts8teeth and ts8teeth > ts8jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts8lips < ts8teeth and ts8teeth < ts8jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts8lips > ts8teeth and ts8teeth < ts8jaw or ts8lips < ts8teeth and ts8teeth > ts8jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS8 and showAlg table.cell(t,12,10, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts8 > ts8PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts8 < ts8PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts8 < ts8PDH and ts8 > ts8PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS8 and showPHL table.cell(t,13,10, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts8 > ts8sma20 and ts8 > ts8sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts8 < ts8sma20 and ts8 < ts8sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts8 < ts8sma5H and ts8 > ts8sma20 or ts8 > ts8sma5L and ts8 < ts8sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS8 and showSmaHL table.cell(t,14,10, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS8 and showATR table.cell(t,15,10, str.tostring(ts8atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-8 data code end ----}// //---- Display Symbol-9 data code start {----// if showS9 table.cell(t,1,11, str.replace_all(t9, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS9 and showLTP table.cell(t,2,11, str.tostring(ts9, '#.##') ,text_color=color.new(ts9p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS9 and showChng table.cell(t,3,11, str.tostring(ts9Chng, '#.##'),text_color=color.new(ts9p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS9 and showPChng table.cell(t,4,11, str.tostring(ts9p, '#.##') +'%',text_color=color.new(ts9p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS9 and showVwap table.cell(t,5,11, str.tostring(ts9vwap, '#.##'),text_color=color.new(ts9 >= ts9vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts9 >= ts9vwap ? cell_up : cell_dn ,cell_transp)) if showS9 and showST1 table.cell(t,6,11, st1State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st9==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st9==true ? cell_up : cell_dn ,cell_transp)) if showS9 and showST2 table.cell(t,7,11, st2State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st9==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st9==true ? cell_up : cell_dn ,cell_transp)) if showS9 and showST3 table.cell(t,8,11, st3State_st9 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st9==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st9==true ? cell_up : cell_dn ,cell_transp)) if showS9 and showRSI table.cell(t,9,11, str.tostring(RSI9, '#.##'),text_color=color.new(RSI9 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI9 > 50 ? cell_up : cell_dn ,cell_transp)) if adx9 >= 75 and dp9 > dm9 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx9 >= 75 and dp9 < dm9 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx9 < 75 and adx9 >= 50 and dp9 > dm9 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx9 < 75 and adx9 >= 50 and dp9 < dm9 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx9 < 50 and adx9 >= 25 and dp9 > dm9 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx9 < 50 and adx9 >= 25 and dp9 < dm9 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx9 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS9 and showADX table.cell(t,10,11, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl9 >0 and ml9 > sl9 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl9 <0 and ml9 < sl9 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS9 and showMACD table.cell(t,11,11, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts9lips > ts9teeth and ts9teeth > ts9jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts9lips < ts9teeth and ts9teeth < ts9jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts9lips > ts9teeth and ts9teeth < ts9jaw or ts9lips < ts9teeth and ts9teeth > ts9jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS9 and showAlg table.cell(t,12,11, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts9 > ts9PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts9 < ts9PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts9 < ts9PDH and ts9 > ts9PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS9 and showPHL table.cell(t,13,11, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts9 > ts9sma20 and ts9 > ts9sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts9 < ts9sma20 and ts9 < ts9sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts9 < ts9sma5H and ts9 > ts9sma20 or ts9 > ts9sma5L and ts9 < ts9sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS9 and showSmaHL table.cell(t,14,11, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS9 and showATR table.cell(t,15,11, str.tostring(ts9atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-9 data code end ----}// //---- Display Symbol-10 data code start {----// if showS10 table.cell(t,1,12, str.replace_all(t10, 'NSE:', ''),text_color=color.new(col_col,txt_transp),text_size=table_text_size,bgcolor=color.new(color.blue,cell_transp)) if showS10 and showLTP table.cell(t,2,12, str.tostring(ts10, '#.##') ,text_color=color.new(ts10p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS10 and showChng table.cell(t,3,12, str.tostring(ts10Chng, '#.##'),text_color=color.new(ts10p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS10 and showPChng table.cell(t,4,12, str.tostring(ts10p, '#.##') +'%',text_color=color.new(ts10p >= 0 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10p >= 0 ? cell_up : cell_dn ,cell_transp)) if showS10 and showVwap table.cell(t,5,12, str.tostring(ts10vwap, '#.##'),text_color=color.new(ts10 >= ts10vwap ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(ts10 >= ts10vwap ? cell_up : cell_dn ,cell_transp)) if showS10 and showST1 table.cell(t,6,12, st1State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st1State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st1State_st10==true ? cell_up : cell_dn ,cell_transp)) if showS10 and showST2 table.cell(t,7,12, st2State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st2State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st2State_st10==true ? cell_up : cell_dn ,cell_transp)) if showS10 and showST3 table.cell(t,8,12, st3State_st10 ? str.tostring('Bullish') : str.tostring('Bearish'),text_color=color.new(st3State_st10==true ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(st3State_st10==true ? cell_up : cell_dn ,cell_transp)) if showS10 and showRSI table.cell(t,9,12, str.tostring(RSI10, '#.##'),text_color=color.new(RSI10 > 50 ? cell_up : cell_dn ,txt_transp),text_size=table_text_size, bgcolor=color.new(RSI10 > 50 ? cell_up : cell_dn ,cell_transp)) if adx10 >= 75 and dp10 > dm10 ADXColor:= color.new( cell_up ,cell_transp) ADXText:= 'Bullish ++' else if adx10 >= 75 and dp10 < dm10 ADXColor:= color.new( cell_dn ,cell_transp) ADXText:= 'Bearish ++' else if adx10 < 75 and adx10 >= 50 and dp10 > dm10 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish +' else if adx10 < 75 and adx10 >= 50 and dp10 < dm10 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish +' else if adx10 < 50 and adx10 >= 25 and dp10 > dm10 ADXColor:= color.new(cell_up ,cell_transp) ADXText:= 'Bullish' else if adx10 < 50 and adx10 >= 25 and dp10 < dm10 ADXColor:= color.new(cell_dn ,cell_transp) ADXText:= 'Bearish' else if adx10 < 25 ADXColor:= color.new( cell_neutral ,cell_transp) ADXText:= 'Neutral' if showS10 and showADX table.cell(t,10,12, str.tostring(ADXText),text_color=color.new(ADXColor,txt_transp),text_size=table_text_size, bgcolor=color.new(ADXColor,cell_transp)) if hsl10 >0 and ml10 > sl10 MACDColor:= color.new( cell_up ,cell_transp) MACDText:= 'Bullish' else if hsl10 <0 and ml10 < sl10 MACDColor:= color.new( cell_dn ,cell_transp) MACDText:= 'Bearish' if showS10 and showMACD table.cell(t,11,12, str.tostring(MACDText),text_color=color.new(MACDColor,txt_transp),text_size=table_text_size, bgcolor=color.new(MACDColor,cell_transp)) if ts10lips > ts10teeth and ts10teeth > ts10jaw AlgColor:= color.new( cell_up ,cell_transp) AlgText:= 'Bullish' else if ts10lips < ts10teeth and ts10teeth < ts10jaw AlgColor:= color.new( cell_dn ,cell_transp) AlgText:= 'Bearish' else if ts10lips > ts10teeth and ts10teeth < ts10jaw or ts10lips < ts10teeth and ts10teeth > ts10jaw AlgColor:= color.new( cell_neutral ,cell_transp) AlgText:= 'Neutral' if showS10 and showAlg table.cell(t,12,12, str.tostring(AlgText),text_color=color.new(AlgColor,txt_transp),text_size=table_text_size, bgcolor=color.new(AlgColor,cell_transp)) if ts10 > ts10PDH PColor:= color.new( cell_up ,cell_transp) PText:= '> PDH' else if ts10 < ts10PDL PColor:= color.new( cell_dn ,cell_transp) PText:= '< PDL' else if ts10 < ts10PDH and ts10 > ts10PDL PColor:= color.new( cell_neutral ,cell_transp) PText:= '< PDH > PDL' if showS10 and showPHL table.cell(t,13,12, str.tostring(PText),text_color=color.new(PColor,txt_transp),text_size=table_text_size, bgcolor=color.new(PColor,cell_transp)) if ts10 > ts10sma20 and ts10 > ts10sma5H SmaHLColor:= color.new( cell_up ,cell_transp) SmaHLText:= 'Bullish' else if ts10 < ts10sma20 and ts10 < ts10sma5L SmaHLColor:= color.new( cell_dn ,cell_transp) SmaHLText:= 'Bearish' else if ts10 < ts10sma5H and ts10 > ts10sma20 or ts10 > ts10sma5L and ts10 < ts10sma20 SmaHLColor:= color.new( cell_neutral ,cell_transp) SmaHLText:= 'Neutral' if showS10 and showSmaHL table.cell(t,14,12, str.tostring(SmaHLText),text_color=color.new(SmaHLColor,txt_transp),text_size=table_text_size, bgcolor=color.new(SmaHLColor,cell_transp)) if showS10 and showATR table.cell(t,15,12, str.tostring(ts10atr, '#.##'),text_color=color.new(cell_neutral ,txt_transp),text_size=table_text_size, bgcolor=color.new(cell_neutral ,cell_transp)) //---- Display Symbol-10 data code end ----}// //---- Table Column & Rows code end ----}// //-------------- Table code end -------------------}//
Zigzag Volume Bars
https://www.tradingview.com/script/lInQUv2i-Zigzag-Volume-Bars/
Trendoscope
https://www.tradingview.com/u/Trendoscope/
478
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("Zigzag Volume Bars", max_boxes_count=500) import HeWhoMustNotBeNamed/zigzag/14 as zg import HeWhoMustNotBeNamed/enhanced_ta/13 as eta import HeWhoMustNotBeNamed/arrayutils/17 as pa length = input.int(5, 'Length', step=5, group='Zigzag') displayTooltip = 'REGULAR : green bars for upswing and red bars for downswing volume. Moiving average can be applied to this type of display\n\n'+ 'PLUS/MINUS - STACKED : both upswing and downswing will have positive and negative volumne bars stacked on each other. If the first bar is green or red depends on stacking style\n\n'+ 'PLUS/MINUS - OVERLAPPING : both positive and negative volume bars are shown. But, both starts from zero and overlaps each other.\n\n'+ 'PLUS/MINUS - OPPOSITE SIDES : positive volume is shown from 0 to upside whereas negative volume bars are shown from 0 to downwards\n' displayType = input.string('regular', 'Bar Style', options=['regular', 'plus/minus - stacked', 'plus/minus - overlapping', 'plus/minus - opposite sides'], group='Display', tooltip=displayTooltip) stackingTooltop = 'DIRECTION-BASED : Up volume(green) bar is placed first on upswing and down volume(red) bar is placed. first on downswing\n\n'+ 'GREEN-FIRST : Up volume(green) bar is always placed first\n\n'+ 'RED-FIRST : Down volume(red) bar is always placed first\n\n'+ 'HIGHEST-FIRST : Bar with highest portion of volume is placed first\n\n'+ 'LOWEST-FIRST : Bar with lowest portion of volume is placed first' stackedStyle = input.string('direction-based', 'Stack Style', options=['direction-based', 'green-first', 'red-first', 'highest-first', 'lowest-first'], group='Display', tooltip=stackingTooltop) //Ma is only applicable for few display styles applyMa = input.bool(true, 'Show MA', group='Moving Average', inline='ma') maType = input.string('sma', '', options=["sma", "ema", "hma", "rma", "wma"], group='Moving Average', inline='ma') maLength = input.int(20, '', step=10, group='Moving Average', inline='ma', tooltip='Moving average is applied only for display types - REGULAR, PLUS/MINUS - OPPOSITE SIDES') //Volume plot style - boolean flags plotDifferentialVolume = displayType != 'regular' plotOnDifferentSides = displayType == 'plus/minus - opposite sides' overlap = displayType == 'plus/minus - overlapping' stacked = displayType == 'plus/minus - stacked' displayMaRegular = applyMa and not plotDifferentialVolume displayMaBiDirectional = applyMa and plotDifferentialVolume and plotOnDifferentSides //Stacking style if plot style is stacked bars directionalStacking = stackedStyle == 'direction-based' greenFirst = stackedStyle == 'green-first' redFirst = stackedStyle == 'red-first' highestFirst = stackedStyle == 'highest-first' lowestFirst = stackedStyle == 'lowest-first' [zigzagpivots, zigzagpivotbars, zigzagpivotdirs, _, _, _, _, _, _, newPivot, doublePivot] = zg.czigzag(length) var volumeArray = array.new_float() var uVolumeArray = array.new_float() var lVolumeArray = array.new_float() var int lastBar = na if(array.size(zigzagpivots)>1) currentBar = array.get(zigzagpivotbars, 0) lastBar := array.get(zigzagpivotbars, 1) currentDir = array.get(zigzagpivotdirs, 0) zvolumeplus = 0.0 zvolumeminus = 0.0 for i=lastBar==currentBar? na : lastBar+1 to currentBar-1 zvolumeminus += (open[bar_index-i] > close[bar_index-i] ? volume[bar_index-i] : 0) zvolumeplus += (open[bar_index-i] > close[bar_index-i] ? 0 : volume[bar_index-i]) zvolumeminus += (open[bar_index-currentBar] > close[bar_index-currentBar] ? volume[bar_index-currentBar] : 0) zvolumeplus += (open[bar_index-currentBar] > close[bar_index-currentBar] ? 0 : volume[bar_index-currentBar]) zvolumeminus += (open[bar_index-lastBar] > close[bar_index-lastBar] ? volume[bar_index-lastBar] : 0) zvolumeplus += (open[bar_index-lastBar] > close[bar_index-lastBar] ? 0 : volume[bar_index-lastBar]) zvolume = zvolumeplus + zvolumeminus zvolumeminus := plotOnDifferentSides? -zvolumeminus : zvolumeminus if(plotDifferentialVolume) var box ubar = na var box lbar = na if(lastBar == lastBar[1] and currentBar != lastBar) box.delete(ubar) box.delete(lbar) array.shift(uVolumeArray) array.shift(lVolumeArray) else box.set_right(ubar, lastBar) box.set_right(lbar, lastBar) box.set_bgcolor(ubar, color.new(color.green, 70)) box.set_bgcolor(lbar, color.new(color.red, 70)) uStart = plotOnDifferentSides or overlap? 0 : directionalStacking? (currentDir > 0? 0 : zvolumeminus) : greenFirst ? 0 : redFirst ? zvolumeminus : highestFirst ? (zvolumeplus > zvolumeminus ? 0 : zvolumeminus) : lowestFirst ? (zvolumeplus > zvolumeminus ? zvolumeminus : 0) : na uEnd = uStart + zvolumeplus lStart = plotOnDifferentSides or overlap? 0 : directionalStacking? (currentDir > 0? zvolumeplus : 0) : greenFirst ? zvolumeplus : redFirst ? 0 : highestFirst ? (zvolumeplus > zvolumeminus ? zvolumeplus : 0) : lowestFirst ? (zvolumeplus > zvolumeminus ? 0 : zvolumeplus) : na lEnd = lStart + zvolumeminus ubar := box.new(left=lastBar, top=uEnd, right=currentBar, bottom=uStart, bgcolor = color.new(color.green, 20)) pa.unshift(uVolumeArray, zvolumeplus, maLength) lbar := box.new(left=lastBar, top=lEnd, right=currentBar, bottom=lStart, bgcolor = color.new(color.red, 20)) pa.unshift(lVolumeArray, zvolumeminus, maLength) else var box vbar = na barColor = currentDir>0? color.green: color.red if(lastBar == lastBar[1] and currentBar != lastBar) box.delete(vbar) array.shift(volumeArray) else box.set_right(vbar, lastBar) box.set_bgcolor(vbar, color.new(barColor[1], 70)) vbar := box.new(left=lastBar, top=zvolume, right=currentBar, bottom=0, bgcolor = color.new(barColor, 20)) pa.unshift(volumeArray, zvolume, maLength) vma = pa.ma(volumeArray, maType, maLength) vmaPlus = pa.ma(uVolumeArray, maType, maLength) vmaMinus = pa.ma(lVolumeArray, maType, maLength) plot(displayMaRegular?vma:na, 'Volume moving average') plot(displayMaBiDirectional?vmaPlus:na, 'Plus Volume moving average', color=color.green) plot(displayMaBiDirectional?vmaMinus:na, 'Minus Volume moving average', color=color.red)
100W sma/200W sma
https://www.tradingview.com/script/mMaLhEu1-100W-sma-200W-sma/
EdIrfan786xLin
https://www.tradingview.com/u/EdIrfan786xLin/
4
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/ // © aliaman351 //@version=4 study("100W sma/200W sma",overlay=false,resolution="W") source = input(close,title="source") sma1Len = 100 sma2Len = 200 sma1 = sma(source,input(int(sma1Len) , title="Moving average 1")) sma2 = sma(source,input(int(sma2Len) , title="Moving average 2")) outSma1 = security(syminfo.tickerid, "W", sma1) outSma2 = security(syminfo.tickerid, "W", sma2) reqdiv = outSma1/outSma2 reqPlot = plot(reqdiv, color=color.yellow, title="smadivision")
Volatility indicator based on ATR
https://www.tradingview.com/script/rOXGN31r-Volatility-indicator-based-on-ATR/
JuicY-trading
https://www.tradingview.com/u/JuicY-trading/
38
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © JuicyWolf //@version=5 indicator("Volatility indicator", overlay=true) ////////////////////////////// INPUTS ///////////////////////// INPUTS ///////////////////////////////////// INPUTS ////////////////////////////// WEInput = input.bool(title="weekend overlay", defval=true) TradingStyle = input.string(defval="normal", title="Change signals sensibility", options=["greedy","normal","safe"]) InputAtrBands = input.bool(title="atr bands", defval=true) atr = ta.atr(14) [middle, upper, lower] = ta.bb(close, 20, 2) f_bb(src, length, mult) => float basis = ta.sma(src, length) float dev = mult * ta.stdev(src, length) [basis, basis + dev, basis - dev] [PineMiddle, PineUpper, PineLower] = f_bb(close, 20, 2) tfDurationSeconds = (timeframe.multiplier*(timeframe.isminutes?60:timeframe.isseconds?1:timeframe.isdaily?(86400):timeframe.isweekly?(86400*7):(86400*30))) nbCandlesPerDay = 60*60*24 / tfDurationSeconds HighestAtr = ta.highest(atr, nbCandlesPerDay) HighestAtr1 = ta.highest(atr[nbCandlesPerDay], nbCandlesPerDay) HighestAtr2 = ta.highest(atr[nbCandlesPerDay*2], nbCandlesPerDay) HighestAtr3 = ta.highest(atr[nbCandlesPerDay*3], nbCandlesPerDay) HighestAtr4 = ta.highest(atr[nbCandlesPerDay*4], nbCandlesPerDay) HighestAtr5 = ta.highest(atr[nbCandlesPerDay*5], nbCandlesPerDay) HighestAtr6 = ta.highest(atr[nbCandlesPerDay*6], nbCandlesPerDay) HighestAtr7 = ta.highest(atr[nbCandlesPerDay*7], nbCandlesPerDay) LowestAtr = ta.lowest(atr, nbCandlesPerDay) LowestAtr1 = ta.lowest(atr[nbCandlesPerDay], nbCandlesPerDay) LowestAtr2 = ta.lowest(atr[nbCandlesPerDay*2], nbCandlesPerDay) LowestAtr3 = ta.lowest(atr[nbCandlesPerDay*3], nbCandlesPerDay) LowestAtr4 = ta.lowest(atr[nbCandlesPerDay*4], nbCandlesPerDay) LowestAtr5 = ta.lowest(atr[nbCandlesPerDay*5], nbCandlesPerDay) LowestAtr6 = ta.lowest(atr[nbCandlesPerDay*6], nbCandlesPerDay) LowestAtr7 = ta.lowest(atr[nbCandlesPerDay*7], nbCandlesPerDay) ///////////////// HIGHEST ATR ///////////////////// HIGHEST ATR //////////////////////////// HIGHEST ATR /////////////////////////// HIGHEST ATR ///////////////////////// AverageAtrHigh = if dayofweek == dayofweek.monday math.avg(HighestAtr3, HighestAtr4, HighestAtr5, HighestAtr6, HighestAtr7) else if dayofweek == dayofweek.tuesday math.avg(HighestAtr, HighestAtr3, HighestAtr4, HighestAtr5, HighestAtr6) else if dayofweek == dayofweek.wednesday math.avg(HighestAtr, HighestAtr1, HighestAtr4, HighestAtr5, HighestAtr6) else if dayofweek == dayofweek.thursday math.avg(HighestAtr, HighestAtr1, HighestAtr2, HighestAtr5, HighestAtr6) else if dayofweek == dayofweek.friday math.avg(HighestAtr, HighestAtr1, HighestAtr2, HighestAtr3, HighestAtr6) else if dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday 0 //////////////////////// LOWEST ATR ////////////////////////////// LOWEST ATR //////////////////////////////////////// LOWEST ATR //////////////////////////////////////// AverageAtrLow = if dayofweek == dayofweek.monday math.avg(LowestAtr3, LowestAtr4, LowestAtr5, LowestAtr6, LowestAtr7) else if dayofweek == dayofweek.tuesday math.avg(LowestAtr, LowestAtr3, LowestAtr4, LowestAtr5, LowestAtr6) else if dayofweek == dayofweek.wednesday math.avg(LowestAtr, LowestAtr1, LowestAtr4, LowestAtr5, LowestAtr6) else if dayofweek == dayofweek.thursday math.avg(LowestAtr, LowestAtr1, LowestAtr2, LowestAtr5, LowestAtr6) else if dayofweek == dayofweek.friday math.avg(LowestAtr, LowestAtr1, LowestAtr2, LowestAtr3, LowestAtr6) AverageAtrHighStyle = if TradingStyle == "greedy" (AverageAtrHigh/10)*9 else if TradingStyle == "normal" (AverageAtrHigh/10)*10 else if TradingStyle == "safe" (AverageAtrHigh/10)*11 Time = time(timeframe.period, "0000-0000:23456") OverVolat = if atr > AverageAtrHighStyle and Time and close > PineMiddle true OverVolat1 = if atr > AverageAtrHighStyle and Time and close < PineMiddle true UnderVolat = if atr < AverageAtrLow and Time and close > PineMiddle true UnderVolat1 = if atr < AverageAtrLow and Time and close < PineMiddle true Color = if dayofweek == 1 and WEInput == true color.new(color=color.aqua, transp=80) else color.new(color=color.aqua, transp=100) Color1 = if dayofweek == 7 and WEInput == true color=color.new(color=color.aqua, transp=80) else color.new(color=color.aqua, transp=100) bgcolor(color=Color) bgcolor(color=Color1) plot(InputAtrBands == true?ta.sma(AverageAtrHigh+close, 15):na) plot(InputAtrBands == true?ta.sma(close - AverageAtrHigh, 15):na) a = InputAtrBands == true?ta.sma(((AverageAtrHigh+close)+(close-AverageAtrHigh))/2, 15):na plot(a, color=color.purple) plot(AverageAtrHigh) plotshape(series=OverVolat, style=shape.cross, color=color.red, text="", size=size.tiny, location=location.abovebar) plotshape(series=OverVolat1, style=shape.cross, color=color.red, text="", size=size.tiny, location=location.belowbar) plotshape(series=UnderVolat, style=shape.cross, color=color.green, text="", size=size.tiny, location=location.abovebar) plotshape(series=UnderVolat1, style=shape.cross, color=color.green, text="", size=size.tiny, location=location.belowbar)
CPR PIVOT, 2ST, 5MA, VWAP
https://www.tradingview.com/script/P5A7KAvW-CPR-PIVOT-2ST-5MA-VWAP/
AdnynSabir
https://www.tradingview.com/u/AdnynSabir/
90
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/ // © AdnynSabir //@version=4 study(title="CPR PIVOT, 2ST, 5MA, VWAP", shorttitle="A I O I", overlay=true) pivottimeframe = input(title="Pivot Resolution", defval="D", options=["D","W","M"]) dp = input(true, title="Show Pivot Ranges") sp = input(true, title="Show Pivot Support Levels") rp = input(true, title="Show Pivot Resistance Levels") cp = input(true, title="Show Camarilla Pivots") showTodaysCamarilla = input(title="Show Today's Camarilla", type=input.bool, defval=true) //dp in the prefix implies daily pivot calculation dpopen = security(syminfo.tickerid, pivottimeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on) dphigh = security(syminfo.tickerid, pivottimeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on) dplow = security(syminfo.tickerid, pivottimeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on) dpclose = security(syminfo.tickerid, pivottimeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on) dprange = dphigh - dplow //Pivot Boss Pivots Formula pivot = (dphigh + dplow + dpclose) / 3.0 bc = (dphigh + dplow) / 2.0 tc = pivot - bc + pivot r1 = (pivot*2)-dplow r2 = pivot + (dphigh - dplow) r3 = dphigh + 2*(pivot - dplow) s1 = (pivot*2) - dphigh s2 = pivot - (dphigh - dplow) s3 = dplow - 2*(dphigh - pivot) r4 = r3 + (r2 - r1) s4 = s3 - (s1 - s2) //Expanded Camarilla Pivots Formula h3 = dpclose + dprange * (1.1 / 4) h4 = dpclose + dprange * (1.1 / 2) l3 = dpclose - dprange * (1.1 / 4) l4 = dpclose - dprange * (1.1 / 2) //m,w,d in the prefix implies daily and hourly dhigh = security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on) dlow = security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on) dclose = security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on) dopen = security(syminfo.tickerid, "D", open, lookahead=barmerge.lookahead_on) //Plotting plot(dp and pivot ? pivot : na, title="Pivot", color=pivot != pivot[1] ? na : color.blue, transp=0) plot(dp and bc ? bc : na, title="BC", color=bc != bc[1] ? na : color.blue, transp=0) plot(dp and tc ? tc : na, title="TC", color=tc != tc[1] ? na : color.blue, transp=0) plot(rp and r1 ? r1 : na, title="R1", color=r1 != r1[1] ? na : color.red, transp=0) plot(rp and r2 ? r2 : na, title="R2", color=r2 != r2[1] ? na : color.red, transp=0) plot(rp and r3 ? r3 : na, title="R3", color=r3 != r3[1] ? na : color.red, transp=0) plot(rp and r4 ? r4 : na, title="R4", color=r4 != r4[1] ? na : color.red, transp=0) plot(sp and s1 ? s1 : na, title="S1", color=s1 != s1[1] ? na : color.green, transp=0) plot(sp and s2 ? s2 : na, title="S2", color=s2 != s2[1] ? na : color.green, transp=0) plot(sp and s3 ? s3 : na, title="S3", color=s3 != s3[1] ? na : color.green, transp=0) plot(sp and s4 ? s4 : na, title="S4", color=s4 != s4[1] ? na : color.green, transp=0) plot(cp and h4 ? h4 : na, title="H4", color=h4 != h4[1] ? na : color.black, transp=0, linewidth=2) plot(cp and h3 ? h3 : na, title="H3", color=h3 != h3[1] ? na : color.black, transp=0, linewidth=2) plot(cp and l3 ? l3 : na, title="L3", color=l3 != l3[1] ? na : color.black, transp=0, linewidth=2) plot(cp and l4 ? l4 : na, title="L4", color=l4 != l4[1] ? na : color.black, transp=0, linewidth=2) // Global Variables & Flags // TODO : Update the No of Holidays noOfHolidays = 13 // Global Functions // TODO : Update the list of Holiday here in format YYYY, MM, DD, 09, 15 // **09, 15 are session start hour & minutes IsHoliday(_date) => iff(_date == timestamp(2021, 02, 21, 09, 15), true, iff(_date == timestamp(2021, 01, 26, 09, 15), true, iff(_date == timestamp(2021, 03, 11, 09, 15), true, iff(_date == timestamp(2021, 03, 29, 09, 15), true, iff(_date == timestamp(2021, 04, 02, 09, 15), true, iff(_date == timestamp(2021, 04, 14, 09, 15), true, iff(_date == timestamp(2021, 04, 21, 09, 15), true, iff(_date == timestamp(2021, 05, 13, 09, 15), true, iff(_date == timestamp(2021, 07, 21, 09, 15), true, iff(_date == timestamp(2021, 08, 19, 09, 15), true, iff(_date == timestamp(2021, 09, 10, 09, 15), true, iff(_date == timestamp(2021, 10, 15, 09, 15), true, iff(_date == timestamp(2021, 11, 05, 09, 15), true, iff(_date == timestamp(2021, 11, 19, 09, 15), true, false)))))))))))))) // Note: Week of Sunday=1...Saturday=7 IsWeekend(_date) => dayofweek(_date) == 7 or dayofweek(_date) == 1 // Skip Weekend SkipWeekend(_date) => _d = dayofweek(_date) _mul = _d == 6 ? 3 : _d == 7 ? 2 : 1 _date + (_mul * 86400000) // Get Next Working Day GetNextWorkingDay(_date) => _dt = SkipWeekend(_date) for i = 1 to noOfHolidays if IsHoliday(_dt) _dt := SkipWeekend(_dt) continue else break _dt /// VWAP /// vw = input(false,"VWAP") vwaplength= input(title="Length", type=input.integer, defval=1) cvwap = ema(vwap,vwaplength) plotvwap = plot(vw ? cvwap : na ,color= color.yellow, transp=0, title = "VWAP", linewidth=1) // EMA len11 = input(21, minval=1, title="Length") src11 = input(high, title="Source") out11 = ema(src11, len11) plot(out11, color=#ffff00, transp=0, linewidth=2, title="1MA") len22 = input(21, minval=1, title="Length") src22 = input(low, title="Source") out22 = ema(src22, len22) plot(out22, color=#33ccff, transp=0, linewidth=2, title="2MA") len33 = input(8, minval=1, title="Length") src33 = input(close, title="Source") out33 = ema(src33, len33) plot(out33, color=#ff66ff, transp=0, linewidth=2, title="3MA") len44 = input(50, minval=1, title="Length") src44 = input(close, title="Source") out44 = ema(src44, len44) plot(out44, color=#ff66ff, transp=0, linewidth=2, title="4MA") len55 = input(200, minval=1, title="Length") src55 = input(close, title="Source") out55 = ema(src55, len55) plot(out55, color=#ffffff, transp=0, linewidth=2, title="5MA") // SUPERTREND Periods1 = input(title="ATR Period", type=input.integer, defval=10) src1 = input(hl2, title="Source") Multiplier1 = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) changeATR1= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true) showsignals1 = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true) highlighting1 = input(title="Highlighter On/Off ?", type=input.bool, defval=true) atr1 = sma(tr, Periods1) atr2= changeATR1 ? atr(Periods1) : atr1 up=src1-(Multiplier1*atr2) up1 = nz(up[1],up) up := close[1] > up1 ? max(up,up1) : up dn=src1+(Multiplier1*atr2) dn1 = nz(dn[1], dn) dn := close[1] < dn1 ? min(dn, dn1) : dn trend = 1 trend := nz(trend[1], trend) trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green) buySignal = trend == 1 and trend[1] == -1 plotshape(buySignal ? up : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal and showsignals1 ? up : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red) sellSignal = trend == -1 and trend[1] == 1 plotshape(sellSignal ? dn : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal and showsignals1 ? dn : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) longFillColor = highlighting1 ? (trend == 1 ? color.green : color.white) : color.white shortFillColor = highlighting1 ? (trend == -1 ? color.red : color.white) : color.white fill(mPlot, upPlot, title="UpTrend Highligter", color=longFillColor) fill(mPlot, dnPlot, title="DownTrend Highligter", color=shortFillColor) alertcondition(buySignal, title="SuperTrend Buy", message="SuperTrend Buy!") alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!") changeCond = trend != trend[1] alertcondition(changeCond, title="SuperTrend Direction Change", message="SuperTrend has changed direction!") Periods2 = input(title="ATR Period", type=input.integer, defval=10) src2 = input(hl2, title="Source") Multiplier2 = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0) changeATR2= input(title="Change ATR Calculation Method ?", type=input.bool, defval=true) showsignals2 = input(title="Show Buy/Sell Signals ?", type=input.bool, defval=true) highlighting2 = input(title="Highlighter On/Off ?", type=input.bool, defval=true) atr3 = sma(tr, Periods2) atr4= changeATR2 ? atr(Periods2) : atr3 up2=src1-(Multiplier2*atr4) up3 = nz(up2[1],up2) up2 := close[1] > up3 ? max(up2,up3) : up2 dn2=src1+(Multiplier2*atr4) dn3 = nz(dn2[1], dn2) dn2 := close[1] < dn3 ? min(dn2, dn3) : dn2 trend1 = 1 trend1 := nz(trend1[1], trend1) trend1 := trend1 == -1 and close > dn3 ? 1 : trend1 == 1 and close < up3 ? -1 : trend1 up2Plot = plot(trend1 == 1 ? up2 : na, title="Up Trend", style=plot.style_linebr, linewidth=2, color=color.green) buySignal1 = trend1 == 1 and trend1[1] == -1 plotshape(buySignal1 ? up2 : na, title="UpTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.green, transp=0) plotshape(buySignal1 and showsignals1 ? up2 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white, transp=0) dn2Plot = plot(trend1 == 1 ? na : dn2, title="Down Trend", style=plot.style_linebr, linewidth=2, color=color.red) sellSignal1 = trend1 == -1 and trend1[1] == 1 plotshape(sellSignal1 ? dn2 : na, title="DownTrend Begins", location=location.absolute, style=shape.circle, size=size.tiny, color=color.red, transp=0) plotshape(sellSignal1 and showsignals1 ? dn2 : na, title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white, transp=0) mPlot1 = plot(ohlc4, title="", style=plot.style_circles, linewidth=0) longFillColor1 = highlighting1 ? (trend1 == 1 ? color.green : color.white) : color.white shortFillColor1 = highlighting1 ? (trend1 == -1 ? color.red : color.white) : color.white fill(mPlot1, up2Plot, title="UpTrend Highligter", color=longFillColor1) fill(mPlot1, dn2Plot, title="DownTrend Highligter", color=shortFillColor1) alertcondition(buySignal1, title="SuperTrend Buy", message="SuperTrend Buy!") alertcondition(sellSignal, title="SuperTrend Sell", message="SuperTrend Sell!") changeCond1 = trend1 != trend1[1] alertcondition(changeCond1, title="SuperTrend Direction Change", message="SuperTrend has changed direction!")
Top 5 Power Momentum Indicator
https://www.tradingview.com/script/grHjjVJe-Top-5-Power-Momentum-Indicator/
bigk777
https://www.tradingview.com/u/bigk777/
59
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator("Top 5 Power Momentum Indicator") resu = input.timeframe("","Timeframe") sym1 = input.symbol("AAPL","Ticker 1",group="Symbol") sym2 = input.symbol("AMZN","Ticker 2",group="Symbol") sym3 = input.symbol("TSLA","Ticker 3",group="Symbol") sym4 = input.symbol("MSFT","Ticker 4",group="Symbol") sym5 = input.symbol("GOOGL","Ticker 5",group="Symbol") [price1,price2] = request.security(sym1 , resu , [close[1],close],gaps=barmerge.gaps_off,lookahead=barmerge.lookahead_on) [price3,price4] = request.security(sym2 , resu , [close[1],close],gaps=barmerge.gaps_off,lookahead=barmerge.lookahead_on) [price5,price6] = request.security(sym3 , resu , [close[1],close],gaps=barmerge.gaps_off,lookahead=barmerge.lookahead_on) [price7,price8] = request.security(sym4 , resu , [close[1],close],gaps=barmerge.gaps_off,lookahead=barmerge.lookahead_on) [price9,price10]= request.security(sym5 , resu , [close[1],close],gaps=barmerge.gaps_off,lookahead=barmerge.lookahead_on) PercentChg3 = ((price2 - price1)+ (price4 - price3)+ (price6 - price5)+ (price8 - price7)+ (price10 - price9))/(price1+price3+price5+price7+price9)*100 plot(0) plot(PercentChg3,style=plot.style_columns,color=PercentChg3>0 ? color.lime : color.red )
FULL MA Optimization Script
https://www.tradingview.com/script/SS6qPhkl-FULL-MA-Optimization-Script/
KioseffTrading
https://www.tradingview.com/u/KioseffTrading/
448
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 customSource 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) crossUnderOver = input.string(defval = "Crossover", group = "Necessary Parameters", title = "Crossover : Crossunder", options = ["Crossover", "Crossunder"], tooltip = "Select Whether to Measure the Performance of MA/Price Corssovers or MA/Price Crossunders") dataType = input.string(defval = "Custom", title = "MA Data Type", options = ["Benchmark", "Custom"], tooltip = "Select Whether to Test customSource Benchmark MA, or customSource Custom MA. Both Options Allow For Personal Modifications; However, Setting the Parameters for Benchmark MA and Custom MA Allows for Quick Comparison Between Two Moving Average Lengths and Data Sources. Both Work the Same - The Titles Are Different") instructions = input.string(defval = "Off", title = "Indicator Instructions", options = ["Off", "On"], tooltip = "Additional Indicator Instructions") benchmarkSource = input.source(close, title = "Benchmark MA Source", group = "Benchmark Parameters", tooltip = "Adjust Benchmark MA Data Source") benchmarkLength = input.int(50, title = "Benchmark MA Length", minval = 2, tooltip = "Adjust Benchmark MA Length") customSource = input.source(close, title = "Custom MA Source", group = "Custom MA Parameters", tooltip = "Adjust Custom MA Data Source") customLength = input.int(50, title = "Custom MA Length", minval = 2, tooltip = "Adjust Custom MA Length") MA = input.string(defval = "Best Performing", title = "Plot MA?", tooltip = "Modify How Averages Are Plotted, and What Averages Are Plotted", group = "MA Plot" , options = ["Best Performing", "SMA", "EMA", "ALMA", "HMA", "WMA", "VWMA", "LSMA", "DEMA", "TEMA", "T3", "OFF"]) show = input.string(title = "Show Other MAs ? (If Best Performing Is Selected)", tooltip = 'Additional Plot Modificants for When "Best Performing" Is Selected', defval = "Gradient", options = ["Light", "Full", "Off", "Gradient"], group = "Best Performing MA Customization") seriesPlot = input.string(title = "Series Plot", defval = "Highest Average Gain", options = ["Highest Average Gain", "Cumulative Gain"], tooltip = 'When "Best Performing MA" Is Selected, Choose Whether to Plot the MA That Achieves the Highest Average Gain, or the MA Which Achieves the Highest Cumulative Gain') smaBenchmark = ta.sma(benchmarkSource, benchmarkLength) emaBenchmark = ta.ema(benchmarkSource, benchmarkLength) almaBenchmark = ta.alma(benchmarkSource, benchmarkLength, 0.85, 6) hmaBenchmark = ta.hma(benchmarkSource, benchmarkLength) wmaBenchmark = ta.wma(benchmarkSource, benchmarkLength) vwmaBenchmark = ta.vwma(benchmarkSource, benchmarkLength) lsmaBenchmark = ta.linreg(benchmarkSource, benchmarkLength, 0) demaBenchmark = (2 * (emaBenchmark)) - (ta.ema(emaBenchmark, benchmarkLength)) tem(x) => j = ta.ema(benchmarkSource, x) j1 = ta.ema(j, x) j2 = 3 * (j - j1) + ta.ema(j1, x) j2 temaBenchmark = tem(benchmarkLength) t(x) => y1 = ta.ema(benchmarkSource,x) y2 = ta.ema(y1, x) y3 = ta.ema(y2, x) y4 = ta.ema(y3, x) y5 = ta.ema(y4, x) y6 = ta.ema(y5, x) v = -0.7 * math.pow(0.7,2) v2 = 3 * math.pow(0.7,2) + 3 * math.pow(0.7,3) v3 = -6 * math.pow(0.7, 2) - 3 * 0.7 - 3 * math.pow(0.7, 3) v4 = 1 + 3 * 0.7 + 0.7 * math.pow(0.7, 2) + 3 * math.pow(0.7, 2) v1 = v * y6 + v2 * y5 + v3 * y4 + v4 * y3 v1 Tilson3Benchmark = t(benchmarkLength) smaCustom = ta.sma(customSource, customLength) emaCustom = ta.ema(customSource, customLength) almaCustom = ta.alma(customSource, customLength, 0.85, 6) hmaCustom = ta.hma(customSource, customLength) wmaCustom = ta.wma(customSource, customLength) vwmaCustom = ta.vwma(customSource, customLength) rmaCustom = ta.rma(customSource, customLength) lsmaCustom = ta.linreg(customSource, customLength, 0) demaCustom = (2 * (emaCustom)) - (ta.ema(emaCustom, customLength)) temaCustom = tem(customLength) Tilson3Average = t(customLength) // // SMA var int smaCounter = 0 var int smaCounter1 = 0 var float smaPerformance = 0.0 var float smaPerformance1 = 0.0 var int smaBarCounter = 0 var int smaBarCounter1 = 0 if ta.crossover(benchmarkSource, smaBenchmark) and smaCounter == 0 and crossUnderOver == "Crossover" smaPerformance := close smaCounter := 1 smaBarCounter := bar_index if ta.crossunder(benchmarkSource, smaBenchmark) and smaCounter == 1 and crossUnderOver == "Crossover" smaCounter := 0 smaPerformance1 := ((close / smaPerformance) - 1) * 100 smaPerformance1 := smaPerformance1[1] + smaPerformance1 smaCounter1 += 1 smaBarCounter1 := bar_index - smaBarCounter smaBarCounter1 := smaBarCounter1[1] + smaBarCounter1 smaCalculation = smaPerformance1 / smaCounter1 smaCalculationBar = smaBarCounter1 / smaCounter1 // EMA var int emaCounter = 0 var int emaCounter1 = 0 var float emaPerformance = 0.0 var float emaPerformance1 = 0.0 var int emaBarCounter = 0 var int emaBarCounter1 = 0 if ta.crossover(benchmarkSource, emaBenchmark) and emaCounter == 0 and crossUnderOver == "Crossover" emaPerformance := close emaCounter := 1 emaBarCounter := bar_index if ta.crossunder(benchmarkSource, emaBenchmark) and emaCounter == 1 and crossUnderOver == "Crossover" emaCounter := 0 emaPerformance1 := ((close / emaPerformance) - 1) * 100 emaPerformance1 := emaPerformance1[1] + emaPerformance1 emaCounter1 += 1 emaBarCounter1 := bar_index - emaBarCounter emaBarCounter1 := emaBarCounter1[1] + emaBarCounter1 emaCalculation = emaPerformance1 / emaCounter1 emaCalculationBar = emaBarCounter1 / emaCounter1 // ALMA var int almaCounter = 0 var int almaCounter1 = 0 var float almaPerformance = 0.0 var float almaPerformance1 = 0.0 var int almaBarCounter = 0 var int almaBarCounter1 = 0 if ta.crossover(benchmarkSource, almaBenchmark) and almaCounter == 0 and crossUnderOver == "Crossover" almaPerformance := close almaCounter := 1 almaBarCounter := bar_index if ta.crossunder(benchmarkSource, almaBenchmark) and almaCounter == 1 and crossUnderOver == "Crossover" almaCounter := 0 almaPerformance1 := ((close / almaPerformance) - 1) * 100 almaPerformance1 := almaPerformance1[1] + almaPerformance1 almaCounter1 += 1 almaBarCounter1 := bar_index - almaBarCounter almaBarCounter1 := almaBarCounter1[1] + almaBarCounter1 almaCalculation = almaPerformance1 / almaCounter1 almaCalculationBar = almaBarCounter1 / almaCounter1 // HMA var int hmaCounter = 0 var int hmaCounter1 = 0 var float hmaPerformance = 0.0 var float hmaPerformance1 = 0.0 var int hmaBarCounter = 0 var int hmaBarCounter1 = 0 if ta.crossover(benchmarkSource, hmaBenchmark) and hmaCounter == 0 and crossUnderOver == "Crossover" hmaPerformance := close hmaCounter := 1 hmaBarCounter := bar_index if ta.crossunder(benchmarkSource, hmaBenchmark) and hmaCounter == 1 and crossUnderOver == "Crossover" hmaCounter := 0 hmaPerformance1 := ((close / hmaPerformance) - 1) * 100 hmaPerformance1 := hmaPerformance1[1] + hmaPerformance1 hmaCounter1 += 1 hmaBarCounter1 := bar_index - hmaBarCounter hmaBarCounter1 := hmaBarCounter1[1] + hmaBarCounter1 hmaCalculation = hmaPerformance1 / hmaCounter1 hmaCalculationBar = hmaBarCounter1 / hmaCounter1 // WMA var int wmaCounter = 0 var int wmaCounter1 = 0 var float wmaPerformance = 0.0 var float wmaPerformance1 = 0.0 var int wmaBarCounter = 0 var int wmaBarCounter1 = 0 if ta.crossover(benchmarkSource, wmaBenchmark) and wmaCounter == 0 and crossUnderOver == "Crossover" wmaPerformance := close wmaCounter := 1 wmaBarCounter := bar_index if ta.crossunder(benchmarkSource, wmaBenchmark) and wmaCounter == 1 and crossUnderOver == "Crossover" wmaCounter := 0 wmaPerformance1 := ((close / wmaPerformance) - 1) * 100 wmaPerformance1 := wmaPerformance1[1] + wmaPerformance1 wmaCounter1 += 1 wmaBarCounter1 := bar_index - wmaBarCounter wmaBarCounter1 := wmaBarCounter1[1] + wmaBarCounter1 wmaCalculation = wmaPerformance1 / wmaCounter1 wmaCalculationBar = wmaBarCounter1 / wmaCounter1 // VWMA var int vwmaCounter = 0 var int vwmaCounter1 = 0 var float vwmaPerformance = 0.0 var float vwmaPerformance1 = 0.0 var int vwmaBarCounter = 0 var int vwmaBarCounter1 = 0 if ta.crossover(benchmarkSource, vwmaBenchmark) and vwmaCounter == 0 and crossUnderOver == "Crossover" vwmaPerformance := close vwmaCounter := 1 vwmaBarCounter := bar_index if ta.crossunder(benchmarkSource, vwmaBenchmark) and vwmaCounter == 1 and crossUnderOver == "Crossover" vwmaCounter := 0 vwmaPerformance1 := ((close / vwmaPerformance) - 1) * 100 vwmaPerformance1 := vwmaPerformance1[1] + vwmaPerformance1 vwmaCounter1 += 1 vwmaBarCounter1 := bar_index - vwmaBarCounter vwmaBarCounter1 := vwmaBarCounter1[1] + vwmaBarCounter1 vwmaCalculation = vwmaPerformance1 / vwmaCounter1 vwmaCalculationBar = vwmaBarCounter1 / vwmaCounter1 // ls var int lsmaCounter = 0 var int lsmaCounter1 = 0 var float lsmaPerformance = 0.0 var float lsmaPerformance1 = 0.0 var int lsmaBarCounter = 0 var int lsmaBarCounter1 = 0 if ta.crossover(benchmarkSource, lsmaBenchmark) and lsmaCounter == 0 and crossUnderOver == "Crossover" lsmaPerformance := close lsmaCounter := 1 lsmaBarCounter := bar_index if ta.crossunder(benchmarkSource, lsmaBenchmark) and lsmaCounter == 1 and crossUnderOver == "Crossover" lsmaCounter := 0 lsmaPerformance1 := ((close / lsmaPerformance) - 1) * 100 lsmaPerformance1 := lsmaPerformance1[1] + lsmaPerformance1 lsmaCounter1 += 1 lsmaBarCounter1 := bar_index - lsmaBarCounter lsmaBarCounter1 := lsmaBarCounter1[1] + lsmaBarCounter1 lsmaCalculation = lsmaPerformance1 / lsmaCounter1 lsmaCalculationBar = lsmaBarCounter1 / lsmaCounter1 // DEMA var int demaCounter = 0 var int demaCounter1 = 0 var float demaPerformance = 0.0 var float demaPerformance1 = 0.0 var int demaBarCounter = 0 var int demaBarCounter1 = 0 if ta.crossover(benchmarkSource, demaBenchmark) and demaCounter == 0 and crossUnderOver == "Crossover" demaPerformance := close demaCounter := 1 demaBarCounter := bar_index if ta.crossunder(benchmarkSource, demaBenchmark) and demaCounter == 1 and crossUnderOver == "Crossover" demaCounter := 0 demaPerformance1 := ((close / demaPerformance) - 1) * 100 demaPerformance1 := demaPerformance1[1] + demaPerformance1 demaCounter1 += 1 demaBarCounter1 := bar_index - demaBarCounter demaBarCounter1 := demaBarCounter1[1] + demaBarCounter1 demaCalculation = demaPerformance1 / demaCounter1 demaCalculationBar = demaBarCounter1 / demaCounter1 // TEMA var int temaCounter = 0 var int temaCounter1 = 0 var float temaPerformance = 0.0 var float temaPerformance1 = 0.0 var int temaBarCounter = 0 var int temaBarCounter1 = 0 if ta.crossover(benchmarkSource, temaBenchmark) and temaCounter == 0 and crossUnderOver == "Crossover" temaPerformance := close temaCounter := 1 temaBarCounter := bar_index if ta.crossunder(benchmarkSource, temaBenchmark) and temaCounter == 1 and crossUnderOver == "Crossover" temaCounter := 0 temaPerformance1 := ((close / temaPerformance) - 1) * 100 temaPerformance1 := temaPerformance1[1] + temaPerformance1 temaCounter1 += 1 temaBarCounter1 := bar_index - temaBarCounter temaBarCounter1 := temaBarCounter1[1] + temaBarCounter1 temaCalculation = temaPerformance1 / temaCounter1 temaCalculationBar = temaBarCounter1 / temaCounter1 // T3 var int Tilson3Counter = 0 var int Tilson3Counter1 = 0 var float Tilson3Performance = 0.0 var float Tilson3Performance1 = 0.0 var int Tislon3BarCounter = 0 var int Tislon3BarCounter1 = 0 if ta.crossover(benchmarkSource, Tilson3Benchmark) and Tilson3Counter == 0 and crossUnderOver == "Crossover" Tilson3Performance := close Tilson3Counter := 1 Tislon3BarCounter := bar_index if ta.crossunder(benchmarkSource, Tilson3Benchmark) and Tilson3Counter == 1 and crossUnderOver == "Crossover" Tilson3Counter := 0 Tilson3Performance1 := ((close / Tilson3Performance) - 1) * 100 Tilson3Performance1 := Tilson3Performance1[1] + Tilson3Performance1 Tilson3Counter1 += 1 Tislon3BarCounter1 := bar_index - Tislon3BarCounter Tislon3BarCounter1 := Tislon3BarCounter1[1] + Tislon3BarCounter1 Tilson3Calculation = Tilson3Performance1 / Tilson3Counter1 Tilson3CalculationBar = Tislon3BarCounter1 / Tilson3Counter1 // SMA var int smaCounterx = 0 var int smaCounter2x = 0 var float smaPerformanceX = 0.0 var float smaPerformance1X = 0.0 var int smaCounterBarx = 0 var int smaCounterBarx1 = 0 if ta.crossover(customSource, smaCustom) and smaCounterx == 0 and crossUnderOver == "Crossover" smaPerformanceX := close smaCounterx := 1 smaCounterBarx := bar_index if ta.crossunder(customSource, smaCustom) and smaCounterx == 1 and crossUnderOver == "Crossover" smaCounterx := 0 smaPerformance1X := ((close / smaPerformanceX) - 1) * 100 smaPerformance1X := smaPerformance1X[1] + smaPerformance1X smaCounter2x += 1 smaCounterBarx1 := bar_index - smaCounterBarx smaCounterBarx1 := smaCounterBarx1[1] + smaCounterBarx1 smaCalculationx = smaPerformance1X / smaCounter2x smaCalculationBarx = smaCounterBarx1 / smaCounter2x // EMA var int emaCounterx = 0 var int emaCounter2x = 0 var float emaPerformanceX = 0.0 var float emaPerformance1X = 0.0 var int emaBarCounterx = 0 var int emaBarCounterx1 = 0 if ta.crossover(customSource, emaCustom) and emaCounterx == 0 and crossUnderOver == "Crossover" emaPerformanceX := close emaCounterx := 1 emaBarCounterx := bar_index if ta.crossunder(customSource, emaCustom) and emaCounterx == 1 and crossUnderOver == "Crossover" emaCounterx := 0 emaPerformance1X := ((close / emaPerformanceX) - 1) * 100 emaPerformance1X := emaPerformance1X[1] + emaPerformance1X emaCounter2x += 1 emaBarCounterx1 := bar_index - emaBarCounterx emaBarCounterx1 := emaBarCounterx1[1] + emaBarCounterx1 emaCaculationx = emaPerformance1X / emaCounter2x emaCaculationBarx = emaBarCounterx1 / emaCounter2x // ALMA var int almaCounterx = 0 var int almaCounter2x = 0 var float almaPerformanceX = 0.0 var float almaPerformance1X = 0.0 var int almaBarCounterx = 0 var int almaBarCounterx1 = 0 if ta.crossover(customSource, almaCustom) and almaCounterx == 0 and crossUnderOver == "Crossover" almaPerformanceX := close almaCounterx := 1 almaBarCounterx := bar_index if ta.crossunder(customSource, almaCustom) and almaCounterx == 1 and crossUnderOver == "Crossover" almaCounterx := 0 almaPerformance1X := ((close / almaPerformanceX) - 1) * 100 almaPerformance1X := almaPerformance1X[1] + almaPerformance1X almaCounter2x += 1 almaBarCounterx1 := bar_index - almaBarCounterx almaBarCounterx1 := almaBarCounterx1[1] + almaBarCounterx1 almaCalculationx = almaPerformance1X / almaCounter2x almaBarCalculationx = almaBarCounterx1 / almaCounter2x // HMA var int hmaCounterx = 0 var int hmaCounter2x = 0 var float hmaPerformanceX = 0.0 var float hmaPerformance1X = 0.0 var int hmaBarCounterx = 0 var int hmaBarCounterx1 = 0 if ta.crossover(customSource, hmaCustom) and hmaCounterx == 0 and crossUnderOver == "Crossover" hmaPerformanceX := close hmaCounterx := 1 hmaBarCounterx := bar_index if ta.crossunder(customSource, hmaCustom) and hmaCounterx == 1 and crossUnderOver == "Crossover" hmaCounterx := 0 hmaPerformance1X := ((close / hmaPerformanceX) - 1) * 100 hmaPerformance1X := hmaPerformance1X[1] + hmaPerformance1X hmaCounter2x += 1 hmaBarCounterx1 := bar_index - hmaBarCounterx hmaBarCounterx1 := hmaBarCounterx1[1] + hmaBarCounterx1 hmaCalculationx = (hmaPerformance1X / hmaCounter2x) hmaCalculationBarx = hmaBarCounterx1 / hmaCounter2x // WMA var int wmaCounterx = 0 var int wmaCounter2x = 0 var float wmaPerformanceX = 0.0 var float wmaPerformance1X = 0.0 var int wmaBarCounterx = 0 var int wmaBarCounterx1 = 0 if ta.crossover(customSource, wmaCustom) and wmaCounterx == 0 and crossUnderOver == "Crossover" wmaPerformanceX := close wmaCounterx := 1 wmaBarCounterx := bar_index if ta.crossunder(customSource, wmaCustom) and wmaCounterx == 1 and crossUnderOver == "Crossover" wmaCounterx := 0 wmaPerformance1X := ((close / wmaPerformanceX) - 1) * 100 wmaPerformance1X := wmaPerformance1X[1] + wmaPerformance1X wmaCounter2x += 1 wmaBarCounterx1 := bar_index - wmaBarCounterx wmaBarCounterx1 := wmaBarCounterx1[1] + wmaBarCounterx1 wmaCalculationx = wmaPerformance1X / wmaCounter2x wmaCalculationBarx = wmaBarCounterx1 / wmaCounter2x // VWMA var int vwmaCounterx = 0 var int vwmaCounter2x = 0 var float vwmaPerformanceX = 0.0 var float vwmaPerformance1X = 0.0 var int vwmaBarCounterx = 0 var int vwmaBarCounterx1 = 0 if ta.crossover(customSource, vwmaCustom) and vwmaCounterx == 0 and crossUnderOver == "Crossover" vwmaPerformanceX := close vwmaCounterx := 1 vwmaBarCounterx := bar_index if ta.crossunder(customSource, vwmaCustom) and vwmaCounterx == 1 and crossUnderOver == "Crossover" vwmaCounterx := 0 vwmaPerformance1X := ((close / vwmaPerformanceX) - 1) * 100 vwmaPerformance1X := vwmaPerformance1X[1] + vwmaPerformance1X vwmaCounter2x += 1 vwmaBarCounterx1 := bar_index - vwmaBarCounterx vwmaBarCounterx1 := vwmaBarCounterx1[1] + vwmaBarCounterx1 vwmaCalculationx = vwmaPerformance1X / vwmaCounter2x vwmaCalculationBarx = vwmaBarCounterx1 / vwmaCounter2x // ls var int lsCounterx = 0 var int lsCounter2x = 0 var float lsPerformanceX = 0.0 var float lsPerformance1X = 0.0 var int lsmaBarCounterx = 0 var int lsmaBarCounterx1 = 0 if ta.crossover(customSource, lsmaCustom) and lsCounterx == 0 and crossUnderOver == "Crossover" lsPerformanceX := close lsCounterx := 1 lsmaBarCounterx := bar_index if ta.crossunder(customSource, lsmaCustom) and lsCounterx == 1 and crossUnderOver == "Crossover" lsCounterx := 0 lsPerformance1X := ((close / lsPerformanceX) - 1) * 100 lsPerformance1X := lsPerformance1X[1] + lsPerformance1X lsCounter2x += 1 lsmaBarCounterx1 := bar_index - lsmaBarCounterx lsmaBarCounterx1 := lsmaBarCounterx1[1] + lsmaBarCounterx1 lsmaCalculationx = lsPerformance1X / lsCounter2x lsmaCalculationBarx = lsmaBarCounterx1 / lsCounter2x // DEMA var int dCounterx = 0 var int dCounter2x = 0 var float dPerformanceX = 0.0 var float dPerformance1X = 0.0 var int demaBarCounterx = 0 var int demaBarCounterx1 = 0 if ta.crossover(customSource, demaCustom) and dCounterx == 0 and crossUnderOver == "Crossover" dPerformanceX := close dCounterx := 1 demaBarCounterx := bar_index if ta.crossunder(customSource, demaCustom) and dCounterx == 1 and crossUnderOver == "Crossover" dCounterx := 0 dPerformance1X := ((close / dPerformanceX) - 1) * 100 dPerformance1X := dPerformance1X[1] + dPerformance1X dCounter2x += 1 demaBarCounterx1 := bar_index - demaBarCounterx demaBarCounterx1 := demaBarCounterx1[1] + demaBarCounterx1 demaCalculationx = dPerformance1X / dCounter2x demaCalculationBarx = demaBarCounterx1 / dCounter2x // TEMA var int tCounterx = 0 var int tCounter2x = 0 var float tPerformanceX = 0.0 var float tPerformance1X = 0.0 var int temaBarCounterx = 0 var int temaBarCounterx1 = 0 if ta.crossover(customSource, temaCustom) and tCounterx == 0 and crossUnderOver == "Crossover" tPerformanceX := close tCounterx := 1 temaBarCounterx := bar_index if ta.crossunder(customSource, temaCustom) and tCounterx == 1 and crossUnderOver == "Crossover" tCounterx := 0 tPerformance1X := ((close / tPerformanceX) - 1) * 100 tPerformance1X := tPerformance1X[1] + tPerformance1X tCounter2x += 1 temaBarCounterx1 := bar_index - temaBarCounterx temaBarCounterx1 := temaBarCounterx1[1] + temaBarCounterx1 temaCalculationx = tPerformance1X / tCounter2x temaCalculationBarx = temaBarCounterx1 / tCounter2x // T3 var int t5Counterx = 0 var int t5Counter2x = 0 var float t5PerformanceX = 0.0 var float t5Performance1X = 0.0 var int Tilson3BarCounterx = 0 var int Tilson3BarCounterx1 = 0 if ta.crossover(customSource, Tilson3Average) and t5Counterx == 0 and crossUnderOver == "Crossover" t5PerformanceX := close t5Counterx := 1 Tilson3BarCounterx := bar_index if ta.crossunder(customSource, Tilson3Average) and t5Counterx == 1 and crossUnderOver == "Crossover" t5Counterx := 0 t5Performance1X := ((close / t5PerformanceX) - 1) * 100 t5Performance1X := t5Performance1X[1] + t5Performance1X t5Counter2x += 1 Tilson3BarCounterx1 := bar_index - Tilson3BarCounterx Tilson3BarCounterx1 := Tilson3BarCounterx1[1] + Tilson3BarCounterx1 calculationTilson3x = t5Performance1X / t5Counter2x calculationTilson3Barx = Tilson3BarCounterx1 / t5Counter2x // Crossunders ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // SMA if ta.crossunder(benchmarkSource, smaBenchmark) and smaCounter == 0 and crossUnderOver == "Crossunder" smaPerformance := close smaCounter := 1 smaBarCounter := bar_index if ta.crossover(benchmarkSource, smaBenchmark) and smaCounter == 1 and crossUnderOver == "Crossunder" smaCounter := 0 smaPerformance1 := ((close / smaPerformance) - 1) * 100 smaPerformance1 := smaPerformance1[1] + smaPerformance1 smaCounter1 += 1 smaBarCounter1 := bar_index - smaBarCounter smaBarCounter1 := smaBarCounter1[1] + smaBarCounter1 finsmapU = smaPerformance1 / smaCounter1 fincountsU = smaBarCounter1 / smaCounter1 // EMA if ta.crossunder(benchmarkSource, emaBenchmark) and emaCounter == 0 and crossUnderOver == "Crossunder" emaPerformance := close emaCounter := 1 emaBarCounter := bar_index if ta.crossover(benchmarkSource, emaBenchmark) and emaCounter == 1 and crossUnderOver == "Crossunder" emaCounter := 0 emaPerformance1 := ((close / emaPerformance) - 1) * 100 emaPerformance1 := emaPerformance1[1] + emaPerformance1 emaCounter1 += 1 emaBarCounter1 := bar_index - emaBarCounter emaBarCounter1 := emaBarCounter1[1] + emaBarCounter1 finemapU = emaPerformance1 / emaCounter1 fincounteU = emaBarCounter1 / emaCounter1 // ALMA if ta.crossunder(benchmarkSource, almaBenchmark) and almaCounter == 0 and crossUnderOver == "Crossunder" almaPerformance := close almaCounter := 1 almaBarCounter := bar_index if ta.crossover(benchmarkSource, almaBenchmark) and almaCounter == 1 and crossUnderOver == "Crossunder" almaCounter := 0 almaPerformance1 := ((close / almaPerformance) - 1) * 100 almaPerformance1 := almaPerformance1[1] + almaPerformance1 almaCounter1 += 1 almaBarCounter1 := bar_index - almaBarCounter almaBarCounter1 := almaBarCounter1[1] + almaBarCounter1 finalmapU = (almaPerformance1 / almaCounter1) fincountaU = almaBarCounter1 / almaCounter1 // HMA if ta.crossunder(benchmarkSource, hmaBenchmark) and hmaCounter == 0 and crossUnderOver == "Crossunder" hmaPerformance := close hmaCounter := 1 hmaBarCounter := bar_index if ta.crossover(benchmarkSource, hmaBenchmark) and hmaCounter == 1 and crossUnderOver == "Crossunder" hmaCounter := 0 hmaPerformance1 := ((close / hmaPerformance) - 1) * 100 hmaPerformance1 := hmaPerformance1[1] + hmaPerformance1 hmaCounter1 += 1 hmaBarCounter1 := bar_index - hmaBarCounter hmaBarCounter1 := hmaBarCounter1[1] + hmaBarCounter1 finhmapU = (hmaPerformance1 / hmaCounter1) fincounthU = hmaBarCounter1 / hmaCounter1 // WMA if ta.crossunder(benchmarkSource, wmaBenchmark) and wmaCounter == 0 and crossUnderOver == "Crossunder" wmaPerformance := close wmaCounter := 1 wmaBarCounter := bar_index if ta.crossover(benchmarkSource, wmaBenchmark) and wmaCounter == 1 and crossUnderOver == "Crossunder" wmaCounter := 0 wmaPerformance1 := ((close / wmaPerformance) - 1) * 100 wmaPerformance1 := wmaPerformance1[1] + wmaPerformance1 wmaCounter1 += 1 wmaBarCounter1 := bar_index - wmaBarCounter wmaBarCounter1 := wmaBarCounter1[1] + wmaBarCounter1 finwmapU = (wmaPerformance1 / wmaCounter1) fincountwU = wmaBarCounter1 / wmaCounter1 // VWMA if ta.crossunder(benchmarkSource, vwmaBenchmark) and vwmaCounter == 0 and crossUnderOver == "Crossunder" vwmaPerformance := close vwmaCounter := 1 vwmaBarCounter := bar_index if ta.crossover(benchmarkSource, vwmaBenchmark) and vwmaCounter == 1 and crossUnderOver == "Crossunder" vwmaCounter := 0 vwmaPerformance1 := ((close / vwmaPerformance) - 1) * 100 vwmaPerformance1 := vwmaPerformance1[1] + vwmaPerformance1 vwmaCounter1 += 1 vwmaBarCounter1 := bar_index - vwmaBarCounter vwmaBarCounter1 := vwmaBarCounter1[1] + vwmaBarCounter1 finvwmapU = (vwmaPerformance1 / vwmaCounter1) fincountvwU = vwmaBarCounter1 / vwmaCounter1 // ls if ta.crossunder(benchmarkSource, lsmaBenchmark) and lsmaCounter == 0 and crossUnderOver == "Crossunder" lsmaPerformance := close lsmaCounter := 1 lsmaBarCounter := bar_index if ta.crossover(benchmarkSource, lsmaBenchmark) and lsmaCounter == 1 and crossUnderOver == "Crossunder" lsmaCounter := 0 lsmaPerformance1 := ((close / lsmaPerformance) - 1) * 100 lsmaPerformance1 := lsmaPerformance1[1] + lsmaPerformance1 lsmaCounter1 += 1 lsmaBarCounter1 := bar_index - lsmaBarCounter lsmaBarCounter1 := lsmaBarCounter1[1] + lsmaBarCounter1 finlspU = (lsmaPerformance1 / lsmaCounter1) fincountlsU = lsmaBarCounter1 / lsmaCounter1 // DEMA if ta.crossunder(benchmarkSource, demaBenchmark) and demaCounter == 0 and crossUnderOver == "Crossunder" demaPerformance := close demaCounter := 1 demaBarCounter := bar_index if ta.crossover(benchmarkSource, demaBenchmark) and demaCounter == 1 and crossUnderOver == "Crossunder" demaCounter := 0 demaPerformance1 := ((close / demaPerformance) - 1) * 100 demaPerformance1 := demaPerformance1[1] + demaPerformance1 demaCounter1 += 1 demaBarCounter1 := bar_index - demaBarCounter demaBarCounter1 := demaBarCounter1[1] + demaBarCounter1 findpU = (demaPerformance1 / demaCounter1) fincountdU = demaBarCounter1 / demaCounter1 // TEMA if ta.crossunder(benchmarkSource, temaBenchmark) and temaCounter == 0 and crossUnderOver == "Crossunder" temaPerformance := close temaCounter := 1 temaBarCounter := bar_index if ta.crossover(benchmarkSource, temaBenchmark) and temaCounter == 1 and crossUnderOver == "Crossunder" temaCounter := 0 temaPerformance1 := ((close / temaPerformance) - 1) * 100 temaPerformance1 := temaPerformance1[1] + temaPerformance1 temaCounter1 += 1 temaBarCounter1 := bar_index - temaBarCounter temaBarCounter1 := temaBarCounter1[1] + temaBarCounter1 fintpU = (temaPerformance1 / temaCounter1) fincounttU = temaBarCounter1 / temaCounter1 // T3 if ta.crossunder(benchmarkSource, Tilson3Benchmark) and Tilson3Counter == 0 and crossUnderOver == "Crossunder" Tilson3Performance := close Tilson3Counter := 1 Tislon3BarCounter := bar_index if ta.crossover(benchmarkSource, Tilson3Benchmark) and Tilson3Counter == 1 and crossUnderOver == "Crossunder" Tilson3Counter := 0 Tilson3Performance1 := ((close / Tilson3Performance) - 1) * 100 Tilson3Performance1 := Tilson3Performance1[1] + Tilson3Performance1 Tilson3Counter1 += 1 Tislon3BarCounter1 := bar_index - Tislon3BarCounter Tislon3BarCounter1 := Tislon3BarCounter1[1] + Tislon3BarCounter1 fint5pU = (Tilson3Performance1 / Tilson3Counter1) fincountt5U = Tislon3BarCounter1 / Tilson3Counter1 // SMA if ta.crossunder(customSource, smaCustom) and smaCounterx == 0 and crossUnderOver == "Crossunder" smaPerformanceX := close smaCounterx := 1 smaCounterBarx := bar_index if ta.crossover(customSource, smaCustom) and smaCounterx == 1 and crossUnderOver == "Crossunder" smaCounterx := 0 smaPerformance1X := ((close / smaPerformanceX) - 1) * 100 smaPerformance1X := smaPerformance1X[1] + smaPerformance1X smaCounter2x += 1 smaCounterBarx1 := bar_index - smaCounterBarx smaCounterBarx1 := smaCounterBarx1[1] + smaCounterBarx1 smaCalculationxU = (smaPerformance1X / smaCounter2x) fincountsxU = smaCounterBarx1 / smaCounter2x // EMA if ta.crossunder(customSource, emaCustom) and emaCounterx == 0 and crossUnderOver == "Crossunder" emaPerformanceX := close emaCounterx := 1 emaBarCounterx := bar_index if ta.crossover(customSource, emaCustom) and emaCounterx == 1 and crossUnderOver == "Crossunder" emaCounterx := 0 emaPerformance1X := ((close / emaPerformanceX) - 1) * 100 emaPerformance1X := emaPerformance1X[1] + emaPerformance1X emaCounter2x += 1 emaBarCounterx1 := bar_index - emaBarCounterx emaBarCounterx1 := emaBarCounterx1[1] + emaBarCounterx1 emaCaculationxU = (emaPerformance1X / emaCounter2x) finemaBarCounterxU = emaBarCounterx1 / emaCounter2x // ALMA if ta.crossunder(customSource, almaCustom) and almaCounterx == 0 and crossUnderOver == "Crossunder" almaPerformanceX := close almaCounterx := 1 almaBarCounterx := bar_index if ta.crossover(customSource, almaCustom) and almaCounterx == 1 and crossUnderOver == "Crossunder" almaCounterx := 0 almaPerformance1X := ((close / almaPerformanceX) - 1) * 100 almaPerformance1X := almaPerformance1X[1] + almaPerformance1X almaCounter2x += 1 almaBarCounterx1 := bar_index - almaBarCounterx almaBarCounterx1 := almaBarCounterx1[1] + almaBarCounterx1 finalmaPerformanceXU = (almaPerformance1X / almaCounter2x) fincountaxU = almaBarCounterx1 / almaCounter2x // HMA if ta.crossunder(customSource, hmaCustom) and hmaCounterx == 0 and crossUnderOver == "Crossunder" hmaPerformanceX := close hmaCounterx := 1 hmaBarCounterx := bar_index if ta.crossover(customSource, hmaCustom) and hmaCounterx == 1 and crossUnderOver == "Crossunder" hmaCounterx := 0 hmaPerformance1X := ((close / hmaPerformanceX) - 1) * 100 hmaPerformance1X := hmaPerformance1X[1] + hmaPerformance1X hmaCounter2x += 1 hmaBarCounterx1 := bar_index - hmaBarCounterx hmaBarCounterx1 := hmaBarCounterx1[1] + hmaBarCounterx1 finhmaPerformanceXU = (hmaPerformance1X / hmaCounter2x) fincounthxU = hmaBarCounterx1 / hmaCounter2x // WMA if ta.crossunder(customSource, wmaCustom) and wmaCounterx == 0 and crossUnderOver == "Crossunder" wmaPerformanceX := close wmaCounterx := 1 wmaBarCounterx := bar_index if ta.crossover(customSource, wmaCustom) and wmaCounterx == 1 and crossUnderOver == "Crossunder" wmaCounterx := 0 wmaPerformance1X := ((close / wmaPerformanceX) - 1) * 100 wmaPerformance1X := wmaPerformance1X[1] + wmaPerformance1X wmaCounter2x += 1 wmaBarCounterx1 := bar_index - wmaBarCounterx wmaBarCounterx1 := wmaBarCounterx1[1] + wmaBarCounterx1 finwmaPerformanceXU = (wmaPerformance1X / wmaCounter2x) fincountwxU = wmaBarCounterx1 / wmaCounter2x // VWMA if ta.crossunder(customSource, vwmaCustom) and vwmaCounterx == 0 and crossUnderOver == "Crossunder" vwmaPerformanceX := close vwmaCounterx := 1 vwmaBarCounterx := bar_index if ta.crossover(customSource, vwmaCustom) and vwmaCounterx == 1 and crossUnderOver == "Crossunder" vwmaCounterx := 0 vwmaPerformance1X := ((close / vwmaPerformanceX) - 1) * 100 vwmaPerformance1X := vwmaPerformance1X[1] + vwmaPerformance1X vwmaCounter2x += 1 vwmaBarCounterx1 := bar_index - vwmaBarCounterx vwmaBarCounterx1 := vwmaBarCounterx1[1] + vwmaBarCounterx1 finvwmaPerformanceXU = (vwmaPerformance1X / vwmaCounter2x) fincountvwxU = vwmaBarCounterx1 / vwmaCounter2x // ls if ta.crossunder(customSource, lsmaCustom) and lsCounterx == 0 and crossUnderOver == "Crossunder" lsPerformanceX := close lsCounterx := 1 lsmaBarCounterx := bar_index if ta.crossover(customSource, lsmaCustom) and lsCounterx == 1 and crossUnderOver == "Crossunder" lsCounterx := 0 lsPerformance1X := ((close / lsPerformanceX) - 1) * 100 lsPerformance1X := lsPerformance1X[1] + lsPerformance1X lsCounter2x += 1 lsmaBarCounterx1 := bar_index - lsmaBarCounterx lsmaBarCounterx1 := lsmaBarCounterx1[1] + lsmaBarCounterx1 finlsPerformanceXU = (lsPerformance1X / lsCounter2x) fincountlsxU = lsmaBarCounterx1 / lsCounter2x // DEMA if ta.crossunder(customSource, demaCustom) and dCounterx == 0 and crossUnderOver == "Crossunder" dPerformanceX := close dCounterx := 1 demaBarCounterx := bar_index if ta.crossover(customSource, demaCustom) and dCounterx == 1 and crossUnderOver == "Crossunder" dCounterx := 0 dPerformance1X := ((close / dPerformanceX) - 1) * 100 dPerformance1X := dPerformance1X[1] + dPerformance1X dCounter2x += 1 demaBarCounterx1 := bar_index - demaBarCounterx demaBarCounterx1 := demaBarCounterx1[1] + demaBarCounterx1 findPerformanceXU = (dPerformance1X / dCounter2x) fincountdxU = demaBarCounterx1 / dCounter2x // TEMA if ta.crossunder(customSource, temaCustom) and tCounterx == 0 and crossUnderOver == "Crossunder" tPerformanceX := close tCounterx := 1 temaBarCounterx := bar_index if ta.crossover(customSource, temaCustom) and tCounterx == 1 and crossUnderOver == "Crossunder" tCounterx := 0 tPerformance1X := ((close / tPerformanceX) - 1) * 100 tPerformance1X := tPerformance1X[1] + tPerformance1X tCounter2x += 1 temaBarCounterx1 := bar_index - temaBarCounterx temaBarCounterx1 := temaBarCounterx1[1] + temaBarCounterx1 fintPerformanceXU = (tPerformance1X / tCounter2x) fincounttxU = temaBarCounterx1 / tCounter2x // T3 if ta.crossunder(customSource, Tilson3Average) and t5Counterx == 0 and crossUnderOver == "Crossunder" t5PerformanceX := close t5Counterx := 1 Tilson3BarCounterx := bar_index if ta.crossover(customSource, Tilson3Average) and t5Counterx == 1 and crossUnderOver == "Crossunder" t5Counterx := 0 t5Performance1X := ((close / t5PerformanceX) - 1) * 100 t5Performance1X := t5Performance1X[1] + t5Performance1X t5Counter2x += 1 Tilson3BarCounterx1 := bar_index - Tilson3BarCounterx Tilson3BarCounterx1 := Tilson3BarCounterx1[1] + Tilson3BarCounterx1 fint5PerformanceXU = (t5Performance1X / t5Counter2x) fincountt5xU = Tilson3BarCounterx1 / t5Counter2x // FixNan if na(smaCalculation) smaCalculation := 0.0 if na(emaCalculation) emaCalculation := 0.0 if na(almaCalculation) almaCalculation := 0.0 if na(hmaCalculation) hmaCalculation := 0.0 if na(wmaCalculation) wmaCalculation := 0.0 if na(vwmaCalculation) wmaCalculation := 0.0 if na(lsmaCalculation) lsmaCalculation := 0.0 if na(demaCalculation) demaCalculation := 0.0 if na(temaCalculation) temaCalculation := 0.0 if na(Tilson3Calculation) Tilson3Calculation := 0.0 if na(smaCalculationx) smaCalculationx := 0.0 if na(emaCaculationx) emaCaculationx := 0.0 if na(almaCalculationx) almaCalculationx := 0.0 if na(hmaCalculationx) hmaCalculationx := 0.0 if na(wmaCalculationx) wmaCalculationx := 0.0 if na(vwmaCalculationx) wmaCalculationx := 0.0 if na(lsmaCalculationx) lsmaCalculationx := 0.0 if na(demaCalculationx) demaCalculationx := 0.0 if na(temaCalculationx) temaCalculationx := 0.0 if na(calculationTilson3x) calculationTilson3x := 0.0 if na(finsmapU) finsmapU := 0.0 if na(finemapU) finemapU := 0.0 if na(finalmapU) finalmapU := 0.0 if na(finhmapU) finhmapU := 0.0 if na(finwmapU) finwmapU := 0.0 if na(finvwmapU) finwmapU := 0.0 if na(finlspU) finlspU := 0.0 if na(findpU) findpU := 0.0 if na(fintpU) fintpU := 0.0 if na(fint5pU) fint5pU := 0.0 if na(smaCalculationxU) smaCalculationxU := 0.0 if na(emaCaculationxU) emaCaculationxU := 0.0 if na(finalmaPerformanceXU) finalmaPerformanceXU := 0.0 if na(finhmaPerformanceXU) finhmaPerformanceXU := 0.0 if na(finwmaPerformanceXU) finwmaPerformanceXU := 0.0 if na(finvwmaPerformanceXU) finwmaPerformanceXU := 0.0 if na(finlsPerformanceXU) finlsPerformanceXU := 0.0 if na(findPerformanceXU) findPerformanceXU := 0.0 if na(fintPerformanceXU) fintPerformanceXU := 0.0 if na(fint5PerformanceXU) fint5PerformanceXU := 0.0 // Array Sortment f_sort_by_array(_array1, _array2, _array3, _array4) => a1s = array.size(_array1) a1so = array.new_string(a1s) a3so = array.copy(_array3) a4so = array.copy(_array4) a2so = array.copy(_array2) if a1s == array.size(_array2) and a1s == array.size(_array2) array.sort(a2so, order.descending) for i = 0 to a1s - 1 sv = array.get(a2so, i) ui = math.max(0, array.indexof(_array2, sv)) uv = array.get (_array1, ui) uv2 = array.get(_array3, ui) uv3 = array.get(_array4, ui) array.set(a1so, i, uv) array.set(a3so, i, uv2) array.set(a4so, i, uv3) [a1so, a2so, a3so, a4so] f_sort_by_array(_array1x, _array2x) => a1sx = array.size(_array1x) a1sox = array.new_string(a1sx) a2sox = array.copy(_array2x) if a1sx == array.size(_array2x) array.sort(a2sox, order.descending) for i = 0 to a1sx - 1 svx = array.get(a2sox, i) uix = math.max(0, array.indexof(_array2x, svx)) uvx = array.get (_array1x, uix) array.set(a1sox, i, uvx) [a1sox, a2sox] // Array Set best = array.new_float(10) array.set(best, 0, dataType == "Benchmark" ? smaPerformance1 : smaPerformance1X) array.set(best, 1, dataType == "Benchmark" ? emaPerformance1 : emaPerformance1X) array.set(best, 2,dataType == "Benchmark" ? almaPerformance1 : almaPerformance1X) array.set(best, 3, dataType == "Benchmark" ? hmaPerformance1 : hmaPerformance1X) array.set(best, 4, dataType == "Benchmark" ? wmaPerformance1 : wmaPerformance1X) array.set(best, 5, dataType == "Benchmark" ? vwmaPerformance1 : vwmaPerformance1X) array.set(best, 6, dataType == "Benchmark" ? lsmaPerformance1 : lsPerformance1X) array.set(best, 7, dataType == "Benchmark" ? demaPerformance1 : dPerformance1X) array.set(best, 8, dataType == "Benchmark" ? temaPerformance1 : tPerformance1X) array.set(best, 9, dataType == "Benchmark" ? Tilson3Performance1 : t5Performance1X) best1 = array.new_string(10) 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") array.set(best1, 7, "DEMA") array.set(best1, 8, "TEMA") array.set(best1, 9, "T3") [cumulativePerformanceNameSorted, cumulativePerformanceSorted] = f_sort_by_array(best1, best) array.reverse(cumulativePerformanceSorted) array.reverse(cumulativePerformanceNameSorted) // Array Set 2 orgname = array.new_string(10) org = array.new_float(10) org1 = array.new_float(10) org2 = array.new_int(10) if crossUnderOver == "Crossover" sma = smaCalculation, array.set(orgname, 0, "SMA"), array.set(org, 0, dataType == "Benchmark" ? smaCalculation : smaCalculationx), array.set(org1, 0, dataType == "Benchmark" ? smaCalculationBar : smaCalculationBarx), array.set(org2, 0, dataType == "Benchmark" ? smaCounter1 : smaCounter2x) if crossUnderOver == "Crossunder" smaU = finsmapU, array.set(orgname, 0, "SMA"), array.set(org, 0, dataType == "Benchmark" ? finsmapU : smaCalculationxU), array.set(org1, 0, dataType == "Benchmark" ? fincountsU : fincountsxU), array.set(org2, 0, dataType == "Benchmark" ? smaCounter1 : smaCounter2x) if crossUnderOver == "Crossover" ema = emaCalculation, array.set(orgname, 1, "EMA"), array.set(org, 1, dataType == "Benchmark" ? emaCalculation : emaCaculationx), array.set(org1, 1, dataType == "Benchmark" ? emaCalculationBar : emaCaculationBarx), array.set(org2, 1, dataType == "Benchmark" ? emaCounter1 : emaCounter2x) if crossUnderOver == "Crossover" alma = almaCalculation, array.set(orgname, 2, "ALMA"), array.set(org, 2, dataType == "Benchmark" ? almaCalculation : almaCalculationx), array.set(org1, 2, dataType == "Benchmark" ? almaCalculationBar : almaBarCalculationx), array.set(org2, 2, dataType == "Benchmark" ? almaCounter1 : almaCounter2x) if crossUnderOver == "Crossover" hma = hmaCalculation, array.set(orgname, 3, "HMA"), array.set(org, 3, dataType == "Benchmark" ? hmaCalculation : hmaCalculationx), array.set(org1, 3, dataType == "Benchmark" ? hmaCalculationBar : hmaCalculationBarx), array.set(org2, 3, dataType == "Benchmark" ? hmaCounter1 : hmaCounter2x) if crossUnderOver == "Crossover" wma = wmaCalculation, array.set(orgname, 4, "WMA"), array.set(org, 4, dataType == "Benchmark" ? wmaCalculation : wmaCalculationx), array.set(org1, 4, dataType == "Benchmark" ? wmaCalculationBar : wmaCalculationBarx), array.set(org2, 4, dataType == "Benchmark" ? wmaCounter1 : wmaCounter2x) if crossUnderOver == "Crossover" vwma = vwmaCalculation, array.set(orgname, 5, "VWMA"), array.set(org, 5, dataType == "Benchmark" ? vwmaCalculation : vwmaCalculationx), array.set(org1, 5, dataType == "Benchmark" ? vwmaCalculationBar : vwmaCalculationBarx), array.set(org2, 5, dataType == "Benchmark" ? vwmaCounter1 : vwmaCounter2x) if crossUnderOver == "Crossover" lsma = lsmaCalculation, array.set(orgname, 6, "LSMA"), array.set(org, 6,dataType == "Benchmark" ? lsmaCalculation : lsmaCalculationx), array.set(org1, 6, dataType == "Benchmark" ? lsmaCalculationBar : lsmaCalculationBarx), array.set(org2, 6, dataType == "Benchmark" ? lsmaCounter1 : lsCounter2x) if crossUnderOver == "Crossover" dema = demaCalculation, array.set(orgname, 7, "DEMA"), array.set(org, 7, dataType == "Benchmark" ? demaCalculation : demaCalculationx), array.set(org1, 7, dataType == "Benchmark" ? demaCalculationBar : demaCalculationBarx), array.set(org2, 7, dataType == "Benchmark" ? demaCounter1 : dCounter2x) if crossUnderOver == "Crossover" tema = temaCalculation, array.set(orgname, 8, "TEMA"), array.set(org, 8, dataType == "Benchmark" ? temaCalculation : temaCalculationx), array.set(org1, 8, dataType == "Benchmark" ? temaCalculationBar : temaCalculationBarx), array.set(org2, 8, dataType == "Benchmark" ? temaCounter1 : tCounter2x) if crossUnderOver == "Crossover" T3 = Tilson3Calculation, array.set(orgname, 9, "T3"), array.set(org, 9,dataType == "Benchmark" ? Tilson3Calculation : calculationTilson3x), array.set(org1, 9, dataType == "Benchmark" ? Tilson3CalculationBar : calculationTilson3Barx), array.set(org2, 9, dataType == "Benchmark" ? Tilson3Counter1 : t5Counter2x) if crossUnderOver == "Crossunder" smaU = finsmapU, array.set(orgname, 0, "SMA"), array.set(org, 0, dataType == "Benchmark" ? finsmapU : smaCalculationxU), array.set(org1, 0, dataType == "Benchmark" ? fincountsU : fincountsxU), array.set(org2, 0, dataType == "Benchmark" ? smaCounter1 : smaCounter2x) if crossUnderOver == "Crossunder" emaU = finemapU, array.set(orgname, 1, "EMA"), array.set(org, 1, dataType == "Benchmark" ? finemapU : emaCaculationxU), array.set(org1, 1, dataType == "Benchmark" ? fincounteU : finemaBarCounterxU), array.set(org2, 1, dataType == "Benchmark" ? emaCounter1 : emaCounter2x) if crossUnderOver == "Crossunder" almaU = finalmapU, array.set(orgname, 2, "ALMA"), array.set(org, 2, dataType == "Benchmark" ? finalmapU : finalmaPerformanceXU), array.set(org1, 2, dataType == "Benchmark" ? fincountaU : fincountaxU), array.set(org2, 2, dataType == "Benchmark" ? almaCounter1 : almaCounter2x) if crossUnderOver == "Crossunder" hmaU = finhmapU, array.set(orgname, 3, "HMA"), array.set(org, 3, dataType == "Benchmark" ? finhmapU : finhmaPerformanceXU), array.set(org1, 3, dataType == "Benchmark" ? fincounthU : fincounthxU), array.set(org2, 3, dataType == "Benchmark" ? hmaCounter1 : hmaCounter2x) if crossUnderOver == "Crossunder" wmaU = finwmapU, array.set(orgname, 4, "WMA"), array.set(org, 4, dataType == "Benchmark" ? finwmapU : finwmaPerformanceXU), array.set(org1, 4, dataType == "Benchmark" ? fincountwU : fincountwxU), array.set(org2, 4, dataType == "Benchmark" ? wmaCounter1 : wmaCounter2x) if crossUnderOver == "Crossunder" vwmaU = finvwmapU, array.set(orgname, 5, "VWMA"), array.set(org, 5, dataType == "Benchmark" ? finvwmapU : finvwmaPerformanceXU), array.set(org1, 5, dataType == "Benchmark" ? fincountvwU : fincountvwxU), array.set(org2, 5, dataType == "Benchmark" ? vwmaCounter1 : vwmaCounter2x) if crossUnderOver == "Crossunder" lsmaU = finlspU, array.set(orgname, 6, "LSMA"), array.set(org, 6,dataType == "Benchmark" ? finlspU : finlsPerformanceXU), array.set(org1, 6, dataType == "Benchmark" ? fincountlsU : fincountlsxU), array.set(org2, 6, dataType == "Benchmark" ? lsmaCounter1 : lsCounter2x) if crossUnderOver == "Crossunder" demaU = findpU, array.set(orgname, 7, "DEMA"), array.set(org, 7, dataType == "Benchmark" ? findpU : findPerformanceXU), array.set(org1, 7, dataType == "Benchmark" ? fincountdU : fincountdxU), array.set(org2, 7, dataType == "Benchmark" ? demaCounter1 : dCounter2x) if crossUnderOver == "Crossunder" temaU = fintpU, array.set(orgname, 8, "TEMA"), array.set(org, 8, dataType == "Benchmark" ? fintpU : fintPerformanceXU), array.set(org1, 8, dataType == "Benchmark" ? fincounttU : fincounttxU), array.set(org2, 8, dataType == "Benchmark" ? temaCounter1 : tCounter2x) if crossUnderOver == "Crossunder" T3U = fint5pU, array.set(orgname, 9, "T3"), array.set(org, 9,dataType == "Benchmark" ? fint5pU : fint5PerformanceXU), array.set(org1, 9, dataType == "Benchmark" ? fincountt5U : fincountt5xU), array.set(org2, 9, dataType == "Benchmark" ? Tilson3Counter1 : t5Counter2x) [performanceNameSorted, performanceSorted, barsSorted, crossesSorted] = f_sort_by_array(orgname, org, org1, org2) // Math Assignments MAmax = math.max(smaCustom, emaCustom, almaCustom, hmaCustom, wmaCustom, vwmaCustom, lsmaCustom, demaCustom, temaCustom, Tilson3Average) MAmin = math.min(smaCustom, emaCustom, almaCustom, hmaCustom, wmaCustom, vwmaCustom, lsmaCustom, demaCustom, temaCustom, Tilson3Average) MAmaxBenchmark = math.max(smaBenchmark, emaBenchmark, almaBenchmark, hmaBenchmark, wmaBenchmark, vwmaBenchmark, lsmaBenchmark, demaBenchmark, temaBenchmark, Tilson3Benchmark) MAminBenchmark = math.min(smaBenchmark, emaBenchmark, almaBenchmark, hmaBenchmark, wmaBenchmark, vwmaBenchmark, lsmaBenchmark, demaBenchmark, temaBenchmark, Tilson3Benchmark) averageMax = math.max(smaCalculation, emaCalculation, almaCalculation, hmaCalculation, wmaCalculation, vwmaCalculation, lsmaCalculation, demaCalculation, temaCalculation, Tilson3Calculation) averageMaxx = math.max(smaCalculationx, emaCaculationx, almaCalculationx, hmaCalculationx, wmaCalculationx, vwmaCalculationx, lsmaCalculationx, demaCalculationx, temaCalculationx, calculationTilson3x) averageMin = math.min(smaCalculation, emaCalculation, almaCalculation, hmaCalculation, wmaCalculation, vwmaCalculation, lsmaCalculation, demaCalculation, temaCalculation, Tilson3Calculation) averageMinx = math.min(smaCalculationx, emaCaculationx, almaCalculationx, hmaCalculationx, wmaCalculationx, vwmaCalculationx, lsmaCalculationx, demaCalculationx, temaCalculationx, calculationTilson3x) // MA Plot xx = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? smaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? smaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 0) ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,0) and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,0) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == smaCalculation ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != smaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != smaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == smaCalculationx ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != smaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != smaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x1 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? emaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? emaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 1) ? color.from_gradient(close, emaCustom - 10, emaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,1) and show == "Full" ? color.orange : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,1) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == emaCalculation ? color.from_gradient(close, emaCustom - 10, emaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != emaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != emaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == emaCaculationx ? color.from_gradient(close, emaCustom - 10, emaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != emaCaculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != emaCaculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x2 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? almaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? almaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 2) ? color.from_gradient(close, almaCustom - 10, almaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,2) and show == "Full" ? color.yellow : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,2) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == almaCalculation ? color.from_gradient(close, almaCustom - 10, almaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != almaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != almaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == almaCalculationx ? color.from_gradient(close, almaCustom - 10, almaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != almaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != almaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x3 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? hmaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? hmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 3) ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,3) and show == "Full" ? color.blue : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,3) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == hmaCalculation ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != hmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != hmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == hmaCalculationx ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != hmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != hmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x4 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? wmaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? wmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 4) ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,4) and show == "Full" ? color.purple : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,4) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == wmaCalculation ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != wmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != wmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == wmaCalculationx ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != wmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != wmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x5 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? vwmaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? vwmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 5) ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,5) and show == "Full" ? color.gray : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,5) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == vwmaCalculation ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != vwmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != vwmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == vwmaCalculationx ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != vwmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != vwmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x6 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? lsmaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? lsmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 6) ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,6) and show == "Full" ? color.teal : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,6) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == lsmaCalculation ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != lsmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != lsmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == lsmaCalculationx ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != lsmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != lsmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x7 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? demaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? demaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 7) ? color.from_gradient(close, demaCustom - 10, demaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,7) and show == "Full" ? color.red : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,7) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == demaCalculation ? color.from_gradient(close, demaCustom - 10, demaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != demaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != demaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == demaCalculationx ? color.from_gradient(close, demaCustom - 10, demaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != demaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != demaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x8 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? temaCustom : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? temaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 8) ? color.from_gradient(close, temaCustom - 10, temaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,8) and show == "Full" ? color.black : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,8) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == temaCalculation ? color.from_gradient(close, temaCustom - 10, temaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != temaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != temaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == temaCalculationx ? color.from_gradient(close, temaCustom - 10, temaCustom + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != temaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != temaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x9 = plot(MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Custom" ? Tilson3Average : MA == "Best Performing" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? Tilson3Benchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) == array.get(best, 9) ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,9) and show == "Full" ? color.white : MA == "Best Performing"and seriesPlot == "Cumulative Gain" and array.max(best) != array.get(best,9) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax == Tilson3Calculation ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != Tilson3Calculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMax != Tilson3Calculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx == calculationTilson3x ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10, #ff0500, #03ff00) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != calculationTilson3x and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMaxx != calculationTilson3x and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) xx1 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? smaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? smaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 0) ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,0) and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,0) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == smaCalculation ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != smaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != smaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == smaCalculationx ? color.from_gradient(close, smaCustom - 10, smaCustom + 10, #03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != smaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != smaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x11 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? emaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? emaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 1) ? color.from_gradient(close, emaCustom - 10, emaCustom + 10, #03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,1) and show == "Full" ? color.orange : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,1) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == emaCalculation ? color.from_gradient(close, emaCustom - 10, emaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != emaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != emaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == emaCaculationx ? color.from_gradient(close, emaCustom - 10, emaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != emaCaculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != emaCaculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x21 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? almaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? almaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 2) ? color.from_gradient(close, almaCustom - 10, almaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,2) and show == "Full" ? color.yellow : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,2) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == almaCalculation ? color.from_gradient(close, almaCustom - 10, almaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != almaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != almaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == almaCalculationx ? color.from_gradient(close, almaCustom - 10, almaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != almaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != almaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x31 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? hmaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? hmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 3) ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,3) and show == "Full" ? color.blue : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,3) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == hmaCalculation ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != hmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != hmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == hmaCalculationx ? color.from_gradient(close, hmaCustom - 10, hmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != hmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != hmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x41 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? wmaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? wmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 4) ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,4) and show == "Full" ? color.purple : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,4) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == wmaCalculation ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != wmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != wmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == wmaCalculationx ? color.from_gradient(close, wmaCustom - 10, wmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != wmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != wmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x51 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? vwmaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? vwmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 5) ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,5) and show == "Full" ? color.gray : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,5) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == vwmaCalculation ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != vwmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != vwmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == vwmaCalculationx ? color.from_gradient(close, vwmaCustom - 10, vwmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != vwmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != vwmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x61 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? lsmaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? lsmaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 6) ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,6) and show == "Full" ? color.teal : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,6) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == lsmaCalculation ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != lsmaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != lsmaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == lsmaCalculationx ? color.from_gradient(close, lsmaCustom - 10, lsmaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != lsmaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != lsmaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x71 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? demaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? demaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 7) ? color.from_gradient(close, demaCustom - 10, demaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,7) and show == "Full" ? color.red : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,7) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == demaCalculation ? color.from_gradient(close, demaCustom - 10, demaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != demaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != demaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == demaCalculationx ? color.from_gradient(close, demaCustom - 10, demaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != demaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != demaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x81 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? temaCustom : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? temaBenchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 8) ? color.from_gradient(close, temaCustom - 10, temaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,8) and show == "Full" ? color.black : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,8) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == temaCalculation ? color.from_gradient(close, temaCustom - 10, temaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != temaCalculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != temaCalculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == temaCalculationx ? color.from_gradient(close, temaCustom - 10, temaCustom + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != temaCalculationx and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != temaCalculationx and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) x91 = plot(MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Custom" ? Tilson3Average : MA == "Best Performing" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? Tilson3Benchmark : na, color = MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) == array.get(best, 9) ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,9) and show == "Full" ? color.white : MA == "Best Performing"and seriesPlot == "Cumulative Gain" and array.min(best) != array.get(best,9) and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin == Tilson3Calculation ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != Tilson3Calculation and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Benchmark" and averageMin != Tilson3Calculation and show == "Light" ? color.new(color.black, 50) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx == calculationTilson3x ? color.from_gradient(close, Tilson3Average - 10, Tilson3Average + 10,#03ff00, #ff0500) : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != calculationTilson3x and show == "Full" ? color.green : MA == "Best Performing" and seriesPlot == "Highest Average Gain" and dataType == "Custom" and averageMinx != calculationTilson3x and show == "Light" ? color.new(color.black, 50): color.new(color.black, 100), linewidth = 2 ) // Upper Right Table MA Plot var table t2 = na if MA == "Best Performing" and barstate.islast t2 := table.new(position.top_right, 10, 10, bgcolor = crossUnderOver == "Crossover" and dataType == "Custom" ? color.from_gradient(close, averageMaxx - 10, averageMaxx + 10, color.new(#03ff00, 33), color.new(#03ff00, 33)) : crossUnderOver == "Crossover" and dataType == "Benchmark" ? color.from_gradient(close, averageMax - 10, averageMax + 10, color.new(#03ff00, 33), color.new(#ff0500, 33)) : crossUnderOver == "Crossunder" and dataType == "Custom" ? color.from_gradient(close, averageMinx - 10, averageMinx + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : crossUnderOver == "Crossunder" and dataType == "Benchmark" ? color.from_gradient(close, averageMin - 10, averageMin + 10, color.new(#ff0500, 33), color.new(#03ff00, 33)) : na ) // Source String sourceS = customSource == close ? "Close" : customSource == open ? "Open" : customSource == high ? "High" : customSource == low ? "Low" : customSource == hl2 ? "HL" : customSource == hlc3 ? "HLC" : customSource == ohlc4 ? "OHLC" : customSource == hlcc4 ? "HLCC" : customSource == ta.obv ? "OBV" : " Other" // Table Header if MA == "Best Performing" and crossUnderOver == "Crossover" and seriesPlot == "Cumulative Gain" and barstate.islast table.cell(t2, 0, 0, text = dataType == "Benchmark" ? "Plotted: " + array.get(cumulativePerformanceNameSorted, 9) + " " + str.tostring(benchmarkLength) + " (" + sourceS + ")" : "Plotted: " + array.get(cumulativePerformanceNameSorted, 9) + " " + str.tostring(customLength) + " (" + sourceS + ")", bgcolor = MA != "Best Performing" ? color.new(color.white, 100) : na, text_color = color.white ) else if MA == "Best Performing" and crossUnderOver == "Crossover" and seriesPlot == "Highest Average Gain" and barstate.islast table.cell(t2, 0, 0, text = dataType == "Custom" ? "Plotted: " + array.get(performanceNameSorted, 0) + " " + str.tostring(customLength) + " (" + sourceS + ")" : "Plotted: " + array.get(performanceNameSorted,0) + " " + str.tostring(benchmarkLength) + " (" + sourceS + ")", bgcolor = na, text_color = color.white ) if MA == "Best Performing" and crossUnderOver == "Crossunder" and seriesPlot == "Cumulative Gain" and barstate.islast table.cell(t2, 0, 0, text = dataType == "Benchmark" ? "Plotted: " + array.get(cumulativePerformanceNameSorted, 0) + " " + str.tostring(benchmarkLength) + " (" + sourceS + ")" : "Plotted: " + array.get(cumulativePerformanceNameSorted, 0) + " " + str.tostring(customLength) + " (" + sourceS + ")", bgcolor = MA != "Best Performing" ? color.new(color.white, 100) : na, text_color = color.white ) else if MA == "Best Performing" and crossUnderOver == "Crossunder" and seriesPlot == "Highest Average Gain" and barstate.islast table.cell(t2, 0, 0, text = dataType == "Custom" ? "Plotted: " + array.get(performanceNameSorted, 9) + " " + str.tostring(customLength) + " (" + sourceS + ")" : "Plotted: " + array.get(performanceNameSorted, 9) + " " + str.tostring(benchmarkLength) + " (" + sourceS + ")", bgcolor = na, text_color = color.white ) // Main Table Plot orgText = "" orgText1 = "" orgText2 = "" bestText = "" worstText = "" tablePerformance = table.new(position.bottom_right, 10, 10, bgcolor = color.new(color.white, 100)) if barstate.islast and dataType == "Custom" and crossUnderOver == "Crossover" table.cell(tablePerformance, 0,0,text = "Price Crossover Performance" + "\n" + "\n" + str.tostring(sourceS) + "/" + str.tostring(customLength) + " (MA)", text_color = color.blue, text_size = size.normal) for i = 0 to array.size(org) - 1 orgText := "Upper-Tier \n \n" + array.get(performanceNameSorted, 0) + ": " + str.tostring(array.get(performanceSorted, 0), format.percent) + " (" +str.tostring(array.get(barsSorted, 0), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 0), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 1) + ": " + str.tostring(array.get(performanceSorted, 1), format.percent) + " (" +str.tostring(array.get(barsSorted, 1), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 1), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 2) + ": " + str.tostring(array.get(performanceSorted, 2), format.percent) + " (" +str.tostring(array.get(barsSorted, 2), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 2), "#") + " Crosses)" orgText1 := "\nMid-Tier \n \n" + array.get(performanceNameSorted, 3) + ": " + str.tostring(array.get(performanceSorted, 3), format.percent) + " (" +str.tostring(array.get(barsSorted, 3), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 3), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 4) + ": " + str.tostring(array.get(performanceSorted, 4), format.percent) + " (" +str.tostring(array.get(barsSorted, 4), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 4), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 5) + ": " + str.tostring(array.get(performanceSorted, 5), format.percent) + " (" +str.tostring(array.get(barsSorted, 5), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 5), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 6) + ": " + str.tostring(array.get(performanceSorted, 6), format.percent) + " (" +str.tostring(array.get(barsSorted, 6), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 6), "#") + " Crosses)" orgText2 := "\nLower-Tier \n \n" + array.get(performanceNameSorted, 7) + ": " + str.tostring(array.get(performanceSorted, 7), format.percent) + " (" +str.tostring(array.get(barsSorted, 7), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 7), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 8) + ": " + str.tostring(array.get(performanceSorted, 8), format.percent) + " (" +str.tostring(array.get(barsSorted, 8), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 8), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 9) + ": " + str.tostring(array.get(performanceSorted, 9), format.percent) + " (" +str.tostring(array.get(barsSorted, 9), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 9), "#") + " Crosses)" + "\n" +"\n" table.cell(tablePerformance, 0,1,text = orgText, text_color = color.white, bgcolor = color.new(color.green, 75)) table.cell(tablePerformance, 0,2, text = orgText1, text_color = color.white, bgcolor = color.new(color.blue, 75), height = 23) table.cell(tablePerformance, 0, 3, text = orgText2, text_color = color.white, bgcolor = color.new(color.red, 75), height = 20) for i = 0 to array.size(best) - 1 bestText := array.get(cumulativePerformanceSorted, 9) >= 0.0 ? "Highest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,i) + ")" + "\n" + "\n" : "Highest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,i) + ")" + "\n(Long Position Loss!)" + "\n" worstText := array.get(cumulativePerformanceSorted, 0) >= 0.0 ? "Lowest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 0) + ")" : "Lowest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 0) + ")\n (Long Position Loss!)" table.cell(tablePerformance, 0, 4, text = bestText, text_color = color.green) table.cell(tablePerformance, 0, 5, text = worstText, text_color = color.red) else if barstate.islast and dataType == "Benchmark" and crossUnderOver == "Crossover" table.cell(tablePerformance, 0,0,text = "Price Crossover Performance (Benchmark) \n \n" + str.tostring(sourceS) + "/" + str.tostring(benchmarkLength) +" (MA)", text_color = color.blue, text_size = size.normal) for i = 0 to array.size(org) - 1 orgText := "Upper-Tier \n \n" + array.get(performanceNameSorted, 0) + ": " + str.tostring(array.get(performanceSorted, 0), format.percent) + " (" +str.tostring(array.get(barsSorted, 0), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 0), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 1) + ": " + str.tostring(array.get(performanceSorted, 1), format.percent) + " (" +str.tostring(array.get(barsSorted, 1), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 1), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 2) + ": " + str.tostring(array.get(performanceSorted, 2), format.percent) + " (" +str.tostring(array.get(barsSorted, 2), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 2), "#") + " Crosses)" orgText1 := "\nMid-Tier \n \n" + array.get(performanceNameSorted, 3) + ": " + str.tostring(array.get(performanceSorted, 3), format.percent) + " (" +str.tostring(array.get(barsSorted, 3), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 3), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 4) + ": " + str.tostring(array.get(performanceSorted, 4), format.percent) + " (" +str.tostring(array.get(barsSorted, 4), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 4), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 5) + ": " + str.tostring(array.get(performanceSorted, 5), format.percent) + " (" +str.tostring(array.get(barsSorted, 5), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 5), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 6) + ": " + str.tostring(array.get(performanceSorted, 6), format.percent) + " (" +str.tostring(array.get(barsSorted, 6), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 6), "#") + " Crosses)" orgText2 := "\nLower-Tier \n \n" + array.get(performanceNameSorted, 7) + ": " + str.tostring(array.get(performanceSorted, 7), format.percent) + " (" +str.tostring(array.get(barsSorted, 7), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 7), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 8) + ": " + str.tostring(array.get(performanceSorted, 8), format.percent) + " (" +str.tostring(array.get(barsSorted, 8), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 8), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 9) + ": " + str.tostring(array.get(performanceSorted, 9), format.percent) + " (" +str.tostring(array.get(barsSorted, 9), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 9), "#") + " Crosses)" + "\n" +"\n" table.cell(tablePerformance, 0,1,text = orgText, text_color = color.white, bgcolor = color.new(color.green, 75)) table.cell(tablePerformance, 0,2, text = orgText1, text_color = color.white, bgcolor = color.new(color.blue, 75), height = 23) table.cell(tablePerformance, 0,3, text = orgText2, text_color = color.white, bgcolor = color.new(color.red, 75), height = 20) for i = 0 to array.size(best) - 1 bestText := array.get(cumulativePerformanceSorted, 9) >= 0.0 ? "Highest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,i) + ")" + "\n" + "\n" : "Highest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, i), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,i) + ")" + "\n(Long Position Loss!)" + "\n" worstText := array.get(cumulativePerformanceSorted, 0) >= 0.0 ? "Lowest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 0) + ")" : "Lowest Cumulative Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 0) + ")\n (Long Position Loss!)" table.cell(tablePerformance, 0, 4, text = bestText, text_color = color.green) table.cell(tablePerformance, 0, 5, text = worstText, text_color = color.red) else if barstate.islast and dataType == "Custom" and crossUnderOver == "Crossunder" table.cell(tablePerformance, 0,0,text = "Price Crossunder Performance" + "\n" + "\n" + str.tostring(sourceS) + "/" + str.tostring(customLength) + " (MA)", text_color = #ff6d00, text_size = size.normal) for i = 0 to array.size(org) - 1 orgText := "Upper-Tier \n \n" + array.get(performanceNameSorted, 9) + ": " + str.tostring(array.get(performanceSorted, 9), format.percent) + " (" +str.tostring(array.get(barsSorted, 9), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 9), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 8) + ": " + str.tostring(array.get(performanceSorted, 8), format.percent) + " (" +str.tostring(array.get(barsSorted, 8), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 8), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 7) + ": " + str.tostring(array.get(performanceSorted, 7), format.percent) + " (" +str.tostring(array.get(barsSorted, 7), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 7), "#") + " Crosses)" orgText1 := "\nMid-Tier \n \n" + array.get(performanceNameSorted, 6) + ": " + str.tostring(array.get(performanceSorted, 6), format.percent) + " (" +str.tostring(array.get(barsSorted, 6), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 6), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 5) + ": " + str.tostring(array.get(performanceSorted, 5), format.percent) + " (" +str.tostring(array.get(barsSorted, 5), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 5), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 4) + ": " + str.tostring(array.get(performanceSorted, 4), format.percent) + " (" +str.tostring(array.get(barsSorted, 4), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 4), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 3) + ": " + str.tostring(array.get(performanceSorted, 3), format.percent) + " (" +str.tostring(array.get(barsSorted, 3), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 3), "#") + " Crosses)" orgText2 := "\nLower-Tier \n \n" + array.get(performanceNameSorted, 2) + ": " + str.tostring(array.get(performanceSorted, 2), format.percent) + " (" +str.tostring(array.get(barsSorted, 2), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 2), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 1) + ": " + str.tostring(array.get(performanceSorted, 1), format.percent) + " (" +str.tostring(array.get(barsSorted, 1), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 1), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 0) + ": " + str.tostring(array.get(performanceSorted, 0), format.percent) + " (" +str.tostring(array.get(barsSorted, 0), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 0), "#") + " Crosses)" + "\n" +"\n" table.cell(tablePerformance, 0,1,text = orgText, text_color = color.white, bgcolor = color.new(color.green, 75)) table.cell(tablePerformance, 0,2, text = orgText1, text_color = color.white, bgcolor = color.new(color.blue, 75), height = 23) table.cell(tablePerformance, 0, 3, text = orgText2, text_color = color.white, bgcolor = color.new(color.red, 75), height = 20) for i = 0 to array.size(best) - 1 bestText := array.get(cumulativePerformanceSorted, 0) <= 0.0 ? "Highest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,0) + ")" + "\n" + "\n" : "Highest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,0) + ")" + "\n(Short Position Loss!)" + "\n" worstText := array.get(cumulativePerformanceSorted, 9) <= 0.0 ? "Lowest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 9), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 9) + ")" : "Lowest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 9), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 9) + ")" + "\n(Short Position Loss!)" table.cell(tablePerformance, 0, 4, text = bestText, text_color = color.green) table.cell(tablePerformance, 0, 5, text = worstText, text_color = color.red) else if barstate.islast and dataType == "Benchmark" and crossUnderOver == "Crossunder" table.cell(tablePerformance, 0,0,text = "Price Crossunder Performance (Benchmark)" + "\n" + "\n" + str.tostring(sourceS) + "/" + str.tostring(benchmarkLength) + " (MA)", text_color = #ff6d00, text_size = size.normal) for i = 0 to array.size(org) - 1 orgText := "Upper-Tier \n \n" + array.get(performanceNameSorted, 9) + ": " + str.tostring(array.get(performanceSorted, 9), format.percent) + " (" +str.tostring(array.get(barsSorted, 9), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 9), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 8) + ": " + str.tostring(array.get(performanceSorted, 8), format.percent) + " (" +str.tostring(array.get(barsSorted, 8), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 8), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 7) + ": " + str.tostring(array.get(performanceSorted, 7), format.percent) + " (" +str.tostring(array.get(barsSorted, 7), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 7), "#") + " Crosses)" orgText1 := "\nMid-Tier \n \n" + array.get(performanceNameSorted, 6) + ": " + str.tostring(array.get(performanceSorted, 6), format.percent) + " (" +str.tostring(array.get(barsSorted, 6), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 6), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 5) + ": " + str.tostring(array.get(performanceSorted, 5), format.percent) + " (" +str.tostring(array.get(barsSorted, 5), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 5), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 4) + ": " + str.tostring(array.get(performanceSorted, 4), format.percent) + " (" +str.tostring(array.get(barsSorted, 4), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 4), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 3) + ": " + str.tostring(array.get(performanceSorted, 3), format.percent) + " (" +str.tostring(array.get(barsSorted, 3), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 3), "#") + " Crosses)" orgText2 := "\nLower-Tier \n \n" + array.get(performanceNameSorted, 2) + ": " + str.tostring(array.get(performanceSorted, 2), format.percent) + " (" +str.tostring(array.get(barsSorted, 2), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 2), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 1) + ": " + str.tostring(array.get(performanceSorted, 1), format.percent) + " (" +str.tostring(array.get(barsSorted, 1), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 1), "#") + " Crosses)" + "\n" +"\n" + array.get(performanceNameSorted, 0) + ": " + str.tostring(array.get(performanceSorted, 0), format.percent) + " (" +str.tostring(array.get(barsSorted, 0), '#') + " Candles" + ")" + " (" + str.tostring(array.get(crossesSorted, 0), "#") + " Crosses)" + "\n" +"\n" table.cell(tablePerformance, 0,1,text = orgText, text_color = color.white, bgcolor = color.new(color.green, 75)) table.cell(tablePerformance, 0,2, text = orgText1, text_color = color.white, bgcolor = color.new(color.blue, 75), height = 23) table.cell(tablePerformance, 0, 3, text = orgText2, text_color = color.white, bgcolor = color.new(color.red, 75), height = 20) for i = 0 to array.size(best) - 1 bestText := array.get(cumulativePerformanceSorted, 0) <= 0.0 ? "Highest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,0) + ")" + "\n" + "\n" : "Highest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 0), format.percent) + " (" + array.get(cumulativePerformanceNameSorted,0) + ")" + "\n(Short Position Loss!)" + "\n" worstText := array.get(cumulativePerformanceSorted, 9) <= 0.0 ? "Lowest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 9), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 9) + ")" : "Lowest Cumulative Downside Gains: " + str.tostring(array.get(cumulativePerformanceSorted, 9), format.percent) + " (" + array.get(cumulativePerformanceNameSorted, 9) + ")" + "\n(Short Position Loss!)" table.cell(tablePerformance, 0, 4, text = bestText, text_color = color.green) table.cell(tablePerformance, 0, 5, text = worstText, text_color = color.red) // MA Plot Overrides plot(MA == "SMA" ? smaCustom : MA == "EMA" ? emaCustom : MA == "ALMA" ? almaCustom : MA == "HMA" ? hmaCustom : MA == "WMA" ? wmaCustom : MA == "VWMA" ? vwmaCustom : MA == "LSMA" ? lsmaCustom : MA == "DEMA" ? demaCustom : MA == "TEMA" ? temaCustom : MA == "T3" ? Tilson3Average : 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 : MA == "DEMA" ? color.red : MA == "TEMA" ? color.maroon : MA == "T3" ? color.white : na, linewidth = 2) // Gradient Plot upperPlot = plot(MAmax, color = color.new(#222123, 100)) lowerPlot = plot(MAmin, color = color.new(#222123, 100)) upperColor = input.color(color.green, title = "Upper Value Gradient", group = "Gradient Colors", tooltip = 'Modify the Upper Value Gradient Color When "Best Performing Ma” and “Gradient” Are Selected') lowerColor = input.color(color.red, title = "Lower Value Gradient", tooltip = 'Modify the Lower Value Gradient Color When "Best Performing Ma" and "Gradient" Are Selected') fill(upperPlot, lowerPlot, color = MA == "Best Performing" and show == "Gradient" and crossUnderOver == "Crossover" and dataType == "Custom" ? color.from_gradient(close, MAmin, MAmax, color.new(lowerColor, 85), color.new(upperColor, 85)) : MA == "Best Performing" and show == "Gradient" and crossUnderOver == "Crossunder" and dataType == "Custom" ? color.from_gradient(close, MAmin, MAmax, color.new(upperColor, 85), color.new(lowerColor, 85)) : color.new(#222123, 100)) upperPlotx= plot(MAmaxBenchmark, color = color.new(#222123, 100)) lowerPlotx = plot(MAminBenchmark, color = color.new(#222123, 100)) fill(upperPlotx, lowerPlotx, color = MA == "Best Performing" and show == "Gradient" and crossUnderOver == "Crossover" and dataType == "Benchmark" ? color.from_gradient(close, MAminBenchmark, MAmaxBenchmark, color.new(lowerColor, 85), color.new(upperColor, 85)) : MA == "Best Performing" and show == "Gradient" and crossUnderOver == "Crossunder" and dataType == "Benchmark" ? color.from_gradient(close, MAminBenchmark, MAmaxBenchmark, color.new(upperColor, 85), color.new(lowerColor, 85)) : color.new(#222123, 100))
Moving Average Convergence Divergence and Momentum
https://www.tradingview.com/script/w6CGgsX0-Moving-Average-Convergence-Divergence-and-Momentum/
Teji_Singh
https://www.tradingview.com/u/Teji_Singh/
20
study
5
MPL-2.0
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Teji_Singh //@version=5 indicator(title="Moving Average Convergence Divergence and Momentum", shorttitle="MACD_MOM", timeframe="", timeframe_gaps=true) //Use MACD line for Trend identifiaiton and Histogram for Momentum // Getting inputs fast_length = input(title="Fast Length", defval=20) slow_length = input(title="Slow Length", defval=100) src = input(title="Source", defval=close) signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 20) // Plot colors col_macd = input(#2962FF, "MACD Line  ", group="Color Settings", inline="MACD") col_signal = input(#FF6D00, "Signal Line  ", group="Color Settings", inline="Signal") col_grow_above = input(#26A69A, "Above   Grow", group="Histogram", inline="Above") col_fall_above = input(#B2DFDB, "Fall", group="Histogram", inline="Above") col_grow_below = input(#FFCDD2, "Below Grow", group="Histogram", inline="Below") col_fall_below = input(#FF5252, "Fall", group="Histogram", inline="Below") // Calculating fast_ma = ta.ema(src, fast_length) slow_ma = ta.ema(src, slow_length) macd = fast_ma - slow_ma signal = ta.ema(macd, signal_length) hist = macd - signal Momentum = ta.sma(hist,signal_length) //Rules Buy = macd > 0 and hist > Momentum Positive = macd > 0 and hist < Momentum Sell = macd < 0 and hist < Momentum Negative = macd < 0 and hist > Momentum // Plot plot(hist, title="Histogram", style=plot.style_columns, color=(Buy ? col_grow_above : Positive ? col_fall_above : Sell ? col_fall_below : Negative ? col_grow_below : na)) plot(macd, title="MACD", color=col_macd) //plot(signal, title="Signal", color=col_signal) plot(Momentum, title = "Hist Momentum", color = color.yellow)
S and R (618-382)
https://www.tradingview.com/script/ijl8p7dV-S-and-R-618-382/
jacobfabris
https://www.tradingview.com/u/jacobfabris/
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/ // © jacobfabris //@version=5 indicator("S and R (618-382)",overlay=true) P1=input(defval=17) a1=ta.highest(high,P1) b1=ta.lowest(low,P1) c1=b1+(a1-b1)*0.618 d1=b1+(a1-b1)*0.382 cor6181 = close>c1 ? color.lime : #FF000000 cor3821 = close<d1 ? color.green: #FF000000 plot(c1,color=cor6181,linewidth=2) plot(d1,color=cor3821,linewidth=2) //--- P2=input(defval=72) a2=ta.highest(high,P2) b2=ta.lowest(low,P2) c2=b2+(a2-b2)*0.618 d2=b2+(a2-b2)*0.382 cor6182 = close>c2 ? color.yellow : #FF000000 cor3822 = close<d2 ? color.orange: #FF000000 plot(c2,color=cor6182,linewidth=2) plot(d2,color=cor3822,linewidth=2) //--- P3=input(defval=305) a3=ta.highest(high,P3) b3=ta.lowest(low,P3) c3=b3+(a3-b3)*0.618 d3=b3+(a3-b3)*0.382 cor6183 = close>c3 ? color.red : #FF000000 cor3823 = close<d3 ? color.maroon: #FF000000 plot(c3,color=cor6183,linewidth=2) plot(d3,color=cor3823,linewidth=2)
HHV and LLV
https://www.tradingview.com/script/0Jrz4GBO-HHV-and-LLV/
muratd
https://www.tradingview.com/u/muratd/
15
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/ // Matriksde bulunan HHV ve LLV fonksiyonunu çizer. // ©muratd //@version=4 // study("HHV and LLV", overlay=true) highBAR = input(10, title="HHV BAR") lowBAR = input(10, title="LLV BAR") srcHHV= input(high, title="HHV Source") srcLLV= input(low, title="LLV Source") HHV = highest(srcHHV, highBAR) LLV = lowest(srcLLV, highBAR) plot(HHV[1], color=#009BFF, linewidth=2, title="HHV", transp=0) plot(LLV[1], color=#E000FF, linewidth=2, title="HHV", transp=0)
jeetesh G 2.35
https://www.tradingview.com/script/iqTUR8IL-jeetesh-G-2-35/
jeeteshghumnani
https://www.tradingview.com/u/jeeteshghumnani/
224
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/ // © jeetesh ghumnani //////i copied the code and made it as per mine not my orignal code and rights reseved to admin@ TRADEMASTER EDUTECH //@version=4 study(title="TRADEMASTER 2.35", shorttitle=" TRADEMASTER 2.35 ", overlay=true) up15on = input(true, title="15 Minute Opening Range High") down15on = input(true, title="15 Minute Opening Range Low") is_newbar(res) => change(time(res)) != 0 adopt(r, s) => security(syminfo.tickerid, r, s) //high_range = valuewhen(is_newbar('D'),high,0) //low_range = valuewhen(is_newbar('D'),low,0) high_rangeL = valuewhen(is_newbar('D'),high,0) low_rangeL = valuewhen(is_newbar('D'),low,0) diff = (high_rangeL-low_rangeL)/2.35 up15 = plot(up15on ? adopt('15', high_rangeL): na, color = #009900, linewidth=1,style=plot.style_line) down15 = plot(down15on ? adopt('15', low_rangeL): na, color = #ff0000, linewidth=1,style=plot.style_line) diffup15 = plot(up15on ? adopt('15', (high_rangeL+diff)): na, color = #009900, linewidth=1,style=plot.style_line) diffdown15 = plot(down15on ? adopt('15', (low_rangeL-diff)): na, color = #ff0000, linewidth=1,style=plot.style_line)
Candle Color by Volume
https://www.tradingview.com/script/WcDbGbQT-Candle-Color-by-Volume/
the_MarketWhisperer
https://www.tradingview.com/u/the_MarketWhisperer/
738
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/ // © the_MarketWhisperer // Version 1.0 // (Based on a code that I found somewhere in the TV world) // A simple indicator that paints candles with different shades of colors based on the volume transacted. // Supports 6 levels of sensitivity at present. // Darkest indicates the most volume transacted. Lightest, the least. // Use it for your Volume Spread Analysis and/or in conjunction with any other strategies that you employ. // Relative volume is calculated based on EMA (set to 20 period by default) //@version=4 study(title="Candle Color by Volume", shorttitle="VolumeColoredCandles", overlay=true) emaPeriod = input(20,'Volume EMA Period') volumeRatio = volume/ema(volume,emaPeriod) isUp = close > open //{ //============================================================================================================================= //Green and red color repository. 6 is darkest. 1 is lightest. g_01 = #dff5df, g_02 = #c8e6c9, g_03 = #03f703, g_04 = #44c649, g_05 = #0ca80c, g_06 = #006700 r_01 = #f4e5e5, r_02 = #f9cdcd, r_03 = #f79b9b, r_04 = #e66161, r_05 = #F30000, r_06 = #9F0000 //----------------------------------------------------------------------------------------------------------------------------- //} color candleColor = na if (volume and isUp) candleColor := (volumeRatio > 2)? g_06: (volumeRatio > 1.5)? g_05: (volumeRatio > 1.2)? g_04: (volumeRatio > 0.8)? g_03: (volumeRatio > 0.4)? g_02:g_01 else if(volume) candleColor := (volumeRatio > 2)? r_06: (volumeRatio > 1.5)? r_05: (volumeRatio > 1.2)? r_04: (volumeRatio > 0.8)? r_03: (volumeRatio > 0.4)? r_02:r_01 barcolor(candleColor)