Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- //###########################################################################
- //#QuickCheck - Automatically Validate Basic Criteria For Stock Selection
- //#Creator: u/Brilliant_Candy_3744
- //#Version: 1.6
- //#Last Updated: 06.12.23
- //#Attributtion:
- //#RealRelativeStrength: u/WorkPiece
- //#RelativeVolume: u/HurlTeaInTheSea
- //#Quickcheck: u/--SubZer0--
- //#############################################################################
- indicator(title="QuickCheck", overlay=false)
- //----------------------------------------------
- //User Configuration
- var string G1 = "Display"
- string tableYposInput = input.string("top", "Indicator position...........", inline = "1", options = ["top", "middle", "bottom"], group = G1)
- string tableXposInput = input.string("right", "", inline = "1", options = ["left", "center", "right"], group = G1)
- bool plotRvol = input.bool(true, "Plot Rvol", inline = "1",group = G1)
- var UP_COLOR = input.color(#70ccbd,"Up color>Thrs", inline = "1",group = G1)
- var DOWN_COLOR =input.color( #ff4352,"Down color>Thrs", inline = "1",group = G1)
- var UP_DIM_COLOR = input.color(#00606488,"Up color<Thrs", inline = "1",group = G1)
- var DOWN_DIM_COLOR =input.color( #a8393d86,"Down color<Thrs", inline = "1",group = G1)
- rVolThres = input.float(1.25, minval=0.0, step=0.1, title="RVol Highlight Thres.")
- string symbolUpString = input.string("▲", title="Symbol Prefix............. ↑", inline = "2", group=G1)
- var symbolDownString = input.string("▼", title=" ↓", inline = "2", group=G1)
- StockUpColor = input.color(#00ff00, title="Ticker Color............... ↑", inline = "3", group=G1)
- StockDownColor = input.color(color.red, title=" ↓", inline = "3", group=G1)
- meetCriteriaStateColor = input.color(#00feff, title="Meets Criteria?........... Y", inline = "4", group=G1)
- doesNotMeetCriteriaStateColor = input.color(#e6e6e6, title="N", inline = "4", group=G1)
- warningStateColor = input.color(#f67c30, title="Warn", inline = "4", group=G1)
- TableBorderColor = input.color(#d1d4dc, title="Table Border Color.........", inline="6", group=G1)
- SeparatorRowColor = input.color(color.white, title="Separator Row Color.......", inline="5", group=G1)
- string G2 = "Indicator Inputs"
- comparedWithSecurity = input.symbol(title="Compare With", defval="NIFTY", group=G2)
- var minPriceThreshold = input.int(12, title="Min Price", group=G2)
- //var desiredMinATR = input.float(2, title="Desired Min ATR", group=G2)
- var rrsLength = input.int(12, title="RRS Length", group=G2)
- //var atrLength = input.int(14, title="ATR Length", group=G2)
- var nDayAverageForRVOL = input.int(20, title="N Day Average (For RVOL)", group=G2)
- //var minVolumeForToday = input.int(1500000, title="Min Required Vol Today", group=G2)
- var nDayAverageForDailyVol = nDayAverageForRVOL//input.int(20, title="N Day Average (For Daily Volume)", group=G2)
- //var desiredAvgVolume = input.int(2000000, title="Desired Min Daily Avg Vol", group=G2)
- //----------------------------------------------
- // defaults
- tableRows = 22
- tableColumns = 4
- tableCellWidth1 = 4
- tableCellWidth2 = 3
- nCurrentRow = 0
- symbolMark = ""
- cellBG = color.black
- textSize = size.small
- //----------------------------------------------
- //Get relevant metrics for the ticker representing the Market
- tM = ticker.new(syminfo.prefix(symbol=comparedWithSecurity), syminfo.ticker(symbol=comparedWithSecurity))
- YCloseM = request.security(tM, 'D', close[1], lookahead = barmerge.lookahead_on)
- TCurrentPriceM = request.security(tM, 'D', close, lookahead = barmerge.lookahead_on)
- DAvgVolM = request.security(tM, 'D', ta.sma(volume, nDayAverageForDailyVol))
- TVolumeM = request.security(tM, 'D', volume, lookahead = barmerge.lookahead_on)
- TVolFillM = TVolumeM / DAvgVolM
- dMarketDayChange = TCurrentPriceM - YCloseM
- isMarketUp = dMarketDayChange > 0
- //----------------------------------------------
- //Get relevant metrics for current stock
- tS = ticker.new(syminfo.prefix, syminfo.ticker)
- TCurrentPriceS = request.security(tS, 'D', close, lookahead = barmerge.lookahead_on)
- YCloseS = request.security(tS, 'D', close[1], lookahead = barmerge.lookahead_on)
- YHighS = request.security(tS, 'D', high[1], lookahead = barmerge.lookahead_on)
- YLowS = request.security(tS, 'D', low[1], lookahead = barmerge.lookahead_on)
- TwentyDayHighS = request.security(tS, timeframe='D', expression=ta.highest(source=high, length=20))
- TwentyDayLowS = request.security(tS, timeframe='D', expression=ta.lowest(source=low, length=20))
- TOpenS = request.security(tS, 'D', open, lookahead = barmerge.lookahead_on)
- TVWAPS = request.security(tS, timeframe="", expression=ta.vwap(hlc3))
- DAvgVolS = request.security(tS, 'D', ta.sma(volume, nDayAverageForDailyVol))
- TVolumeS = request.security(tS, 'D', volume, lookahead = barmerge.lookahead_on)
- TVolFillS = TVolumeS / DAvgVolS
- D50SMA = request.security(tS, 'D', ta.sma(close, 50))
- D100SMA = request.security(tS, 'D', ta.sma(close, 100))
- D200SMA = request.security(tS, 'D', ta.sma(close, 200))
- //DCurrentATR = request.security(tS, 'D', ta.atr(atrLength))
- dStockDayChange = TCurrentPriceS - YCloseS
- isStockUp = dStockDayChange > 0
- //----------------------------------------------
- // Calculate Relative Strength
- // © WorkPiece 12.28.21
- //##########Rolling Price Change##########
- comparedClose = request.security(tM, timeframe="", expression=close)
- comparedRollingMove = comparedClose - comparedClose[rrsLength]
- sClose = request.security(tS, timeframe="", expression=close)
- symbolRollingMove = sClose - sClose[rrsLength]
- //##########Rolling ATR Change##########
- symbolRollingATR = request.security(tS, timeframe="", expression=ta.atr(rrsLength)[1])
- comparedRollingATR = request.security(tM, timeframe="", expression=ta.atr(rrsLength)[1])
- //##########Calculations##########
- powerIndex = comparedRollingMove / comparedRollingATR
- TRRS = (symbolRollingMove - powerIndex * symbolRollingATR) / symbolRollingATR
- //plot(TRRS, color=color.orange,linewidth = 1)
- //----------------------------------------------
- // Calculate RVOL
- // /u/HurlTeaInTheSea v1.0
- // Intraday Relative Volume (RVol) indicator:
- // still works on higher timeframe but it's not a "day" average anymore, so throw error to avoid confusion
- if not (timeframe.isintraday or timeframe.isdaily)
- runtime.error("RVol is only valid for daily timeframe or lower")
- var cVolS = 0.0
- var cVolM = 0.0
- var newDayBars = array.new_int()
- // detect new session of day
- isNewDay() =>
- t = time('D') // by default, time() follows symbol's session
- na(t[1]) and not na(t) or t[1] < t
- if isNewDay()
- // reset cumulative volume
- cVolS := 0
- cVolM := 0
- // save new bars in circular array of length nDayAverageForRVOL + 1
- array.push(newDayBars, bar_index)
- if (array.size(newDayBars) > nDayAverageForRVOL + 1)
- array.shift(newDayBars)
- // cumulative volume
- cVolS := cVolS + volume
- cVolM := cVolM + request.security(tM, timeframe.period, volume, lookahead = barmerge.lookahead_on)
- // calculate relative volume
- aVolS = 0.0
- aVolM = 0.0
- // check enough nDayAverageForRVOL saved in history to run (current day also saved)
- len = array.size(newDayBars)
- if len >= nDayAverageForRVOL + 1
- // SMA of historical cumulative volume up to but not including current time of day
- for i = 0 to len - 2
- b1 = array.get(newDayBars, i)
- b2 = array.get(newDayBars, i + 1)
- // use historical date but carry over current hour, minutes, seconds (this method is exact and avoids DST bugs)
- t1 = time[bar_index - b1]
- tLookup = timestamp(year(t1), month(t1), dayofmonth(t1), hour(time), minute(time), second(time))
- // get latest bar clamped in range [b1, b2) that is equal to or precedes given time (binary search for speed)
- int lo = math.max(0, b1) - 1
- int hi = math.max(0, b2)
- while 1 + lo < hi
- int mi = lo + math.floor((hi - lo) / 2)
- if (tLookup < time[bar_index - mi])
- hi := mi
- else
- lo := mi
- lo := lo < b1 ? hi : lo
- bClosest = b1 < b2 ? lo : -1
- // add cumulative volume to SMA calculation
- tClosest = time[bar_index - bClosest]
- aVolS := aVolS + (tLookup >= tClosest ? cVolS[bar_index - bClosest] / nDayAverageForRVOL : 0)
- aVolM := aVolM + (tLookup >= tClosest ? cVolM[bar_index - bClosest] / nDayAverageForRVOL : 0)
- rVolS = aVolS > 0 ? cVolS / aVolS : 0
- rVolM = aVolM > 0 ? cVolM / aVolM : 0
- color highlightColor=na
- if plotRvol
- // visuals
- colorPrevClose=true //convert to input if needed
- upColorCondition = colorPrevClose ? close >= close[1] : close >= open
- //hline(1.0, title="Reference", color=color.silver, linestyle=hline.style_dotted)
- highlightColor := rVolS >= rVolThres ? (upColorCondition ? UP_COLOR : DOWN_COLOR) : (upColorCondition ? UP_DIM_COLOR : DOWN_DIM_COLOR)
- plot(plotRvol?rVolS:na, style=plot.style_columns, color=highlightColor)
- //plot(plotRvol?rVolS:na, style=plot.style_line, color=color.rgb(158, 153, 153))
- //----------------------------------------------
- var dataTable = table.new(tableYposInput + "_" + tableXposInput, tableColumns, tableRows, bgcolor=color.white, frame_width=1, frame_color=TableBorderColor)
- //----------------------------------------------
- //Show Market Status
- symbolMark := isMarketUp ? symbolUpString : symbolDownString
- cellBG := isMarketUp ? StockUpColor : StockDownColor
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " " + syminfo.ticker(symbol=comparedWithSecurity), text_halign=text.align_left, bgcolor = cellBG, text_color = isMarketUp ? color.black : color.white)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(TCurrentPriceM, "#.##") + " (" + str.tostring(dMarketDayChange, "#.##") + ")", text_halign=text.align_left, bgcolor = cellBG, text_color = isMarketUp ? color.black : color.white)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Stock Status
- symbolMark := isStockUp ? symbolUpString : symbolDownString
- cellBG := isStockUp ? StockUpColor : StockDownColor
- //nCurrentRow := nCurrentRow + 1
- table.cell( dataTable, 2, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? (symbolMark + " " + syminfo.ticker) : "", text_halign=text.align_left, bgcolor = (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? cellBG : SeparatorRowColor, text_color = isStockUp ? color.black : color.white)
- table.cell(dataTable, 3, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? (str.tostring(TCurrentPriceS, "#.##") + " (" + str.tostring(dStockDayChange, "#.##") + ")") : "", text_halign=text.align_left, bgcolor = (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? cellBG : SeparatorRowColor, text_color = isStockUp ? color.black : color.white)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Net Change %
- deltaYCloseMPercentage = (dMarketDayChange / YCloseM) * 100
- deltaYCloseSPercentage = (dStockDayChange / YCloseS) * 100
- symbolMark := deltaYCloseSPercentage > deltaYCloseSPercentage ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > minPriceThreshold
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > minPriceThreshold
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if isStockUp
- if TCurrentPriceS > minPriceThreshold
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > minPriceThreshold
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " NET CHG %", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow,((syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? ( str.tostring(deltaYCloseMPercentage, "#.##") + "%" + " / ") : "") + str.tostring(deltaYCloseSPercentage, "#.##") + "%" , text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Daily ATR Status
- // symbolMark := DCurrentATR > desiredMinATR ? symbolUpString : symbolDownString
- // if isMarketUp
- // if isStockUp
- // if DCurrentATR > desiredMinATR
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if DCurrentATR > desiredMinATR
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if isStockUp
- // if DCurrentATR > desiredMinATR
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if DCurrentATR > desiredMinATR
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, symbolMark + " ATR(" + str.tostring(atrLength) + "D)", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell(dataTable, 1, nCurrentRow, str.tostring(DCurrentATR, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Day Type
- //symbolMark := TCurrentPriceS > minPriceThreshold ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > YHighS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS < YLowS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if isStockUp
- if TCurrentPriceS > YHighS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS < YLowS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- strDayType = (TCurrentPriceS > YHighS) ? "UP" : (TCurrentPriceS >= YLowS) ? "INSIDE" : "DOWN"
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, " DAY TYPE", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, strDayType, text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Add empty row as separator
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
- // table.cell(dataTable, 1, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show RRS Status
- symbolMark := TRRS > 0 ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TRRS > 0
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TRRS > 0
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TRRS > 0
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TRRS > 0
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? symbolMark + " RRS" : " RRS", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? (str.tostring(TRRS, "#.##")) : "NA", text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show RVOL Status
- symbolMark := (rVolS > rVolM and rVolS > 1.25) ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if (rVolS > rVolM and rVolS > 1.25)
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if (rVolS > rVolM and rVolS > 1.25)
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if isStockUp
- if (rVolS > rVolM and rVolS > 1.25)
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if (rVolS > rVolM and rVolS > 1.25)
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, symbolMark + " RVOL(" + str.tostring(nDayAverageForRVOL) + "D)", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, str.tostring(rVolS*100, "#") + "%" + ((syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? ( " / " + str.tostring(rVolM*100, "#") + "%") : ""), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //#################################################
- //Show Daily Average Volume
- // symbolMark := DAvgVolS > desiredAvgVolume? symbolUpString : symbolDownString
- // if isMarketUp
- // if isStockUp
- // if DAvgVolS > desiredAvgVolume
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if DAvgVolS > desiredAvgVolume
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if isStockUp
- // if DAvgVolS > desiredAvgVolume
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if DAvgVolS > desiredAvgVolume
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- //table.cell(dataTable, 0, nCurrentRow, symbolMark + " AvVOL(" + str.tostring(nDayAverageForDailyVol) + "D)", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell(dataTable, 1, nCurrentRow, str.tostring(DAvgVolS/1000000, "#.#") + "M", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Current Volume
- // symbolMark := TVolumeS > minVolumeForToday? symbolUpString : symbolDownString
- // if isMarketUp
- // if isStockUp
- // if TVolumeS > minVolumeForToday
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TVolumeS > minVolumeForToday
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if isStockUp
- // if TVolumeS > minVolumeForToday
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TVolumeS > minVolumeForToday
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, symbolMark + " VOLUME", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell(dataTable, 1, nCurrentRow, str.tostring(TVolumeS/1000000, "#.#") + "M", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Volume Fill
- symbolMark := (TVolFillS > 1 and TVolFillS > TVolFillM) ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TVolFillS > TVolFillM
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TVolFillS > TVolFillM
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if isStockUp
- if TVolFillS > TVolFillM
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TVolFillS > TVolFillM
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " VOL % of ADV", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(TVolFillS*100, "#") + "%" , text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //uncomment below to see vol/adv at that time
- //plot(cVolS/DAvgVolS*100,color=color.green)
- //----------------------------------------------
- //Add empty row to separate from volume metrics
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
- // table.cell(dataTable, 1, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show VWAP Status
- deltaVWAPS = TCurrentPriceS - TVWAPS
- symbolMark := TCurrentPriceS > TVWAPS ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > TVWAPS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > TVWAPS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > TVWAPS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > TVWAPS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, symbolMark + " VWAP", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaVWAPS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Show YClose Status
- symbolMark := TCurrentPriceS > YCloseS ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > YCloseS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YCloseS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > YCloseS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YCloseS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " YCLOSE", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(dStockDayChange, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show Open Status
- deltaOpenS = TCurrentPriceS - TOpenS
- symbolMark := TCurrentPriceS > TOpenS ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > TOpenS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > TOpenS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > TOpenS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > TOpenS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, symbolMark + " OPEN", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaOpenS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Show YHigh Status
- deltaYHighS = TCurrentPriceS - YHighS
- symbolMark := TCurrentPriceS > YHighS ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > YHighS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YHighS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > YHighS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YHighS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " YHIGH", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaYHighS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show YLow Status
- deltaYLowS = TCurrentPriceS - YLowS
- symbolMark := TCurrentPriceS > YLowS ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > YLowS
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YLowS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > YLowS
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > YLowS
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, symbolMark + " YLOW", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaYLowS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Show 20 Day High Status
- // delta20HighS = TCurrentPriceS - TwentyDayHighS
- // symbolMark := TCurrentPriceS > TwentyDayHighS ? symbolUpString : symbolDownString
- // if isMarketUp
- // if isStockUp
- // if TCurrentPriceS > TwentyDayHighS
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TCurrentPriceS > TwentyDayHighS
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // cellBG := warningStateColor
- // else
- // if isStockUp
- // if TCurrentPriceS > TwentyDayHighS
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TCurrentPriceS > TwentyDayHighS
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // cellBG := meetCriteriaStateColor
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, symbolMark + " D20 HIGH", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell(dataTable, 1, nCurrentRow, str.tostring(delta20HighS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show 20 Day Low Status
- // delta20LowS = TCurrentPriceS - TwentyDayLowS
- // symbolMark := TCurrentPriceS > TwentyDayLowS ? symbolUpString : symbolDownString
- // if isMarketUp
- // if isStockUp
- // if TCurrentPriceS > TwentyDayLowS
- // cellBG := meetCriteriaStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TCurrentPriceS > TwentyDayLowS
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // cellBG := warningStateColor
- // else
- // if isStockUp
- // if TCurrentPriceS > TwentyDayLowS
- // cellBG := warningStateColor
- // else
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // if TCurrentPriceS > TwentyDayLowS
- // cellBG := doesNotMeetCriteriaStateColor
- // else
- // cellBG := meetCriteriaStateColor
- // nCurrentRow := nCurrentRow + 1
- // table.cell(dataTable, 0, nCurrentRow, symbolMark + " D20 LOW", text_halign=text.align_left, bgcolor=cellBG)
- // table.cell(dataTable, 1, nCurrentRow, str.tostring(delta20LowS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show 200SMA(D) Status
- deltaSMA200S = TCurrentPriceS - D200SMA
- symbolMark := TCurrentPriceS > D200SMA ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > D200SMA
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D200SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > D200SMA
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D200SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " 200SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaSMA200S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
- //----------------------------------------------
- //Show 100SMA(D) Status
- deltaSMA100S = TCurrentPriceS - D100SMA
- symbolMark := TCurrentPriceS > D100SMA ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > D100SMA
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D100SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > D100SMA
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D100SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- //nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 2, nCurrentRow, symbolMark + " 100SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaSMA100S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
- //----------------------------------------------
- //Show 50SMA(D) Status
- //https://www.tradingview.com/script/NxVJbviK-Daily-Moving-Averages-on-Intraday-Chart/
- deltaSMA50S = TCurrentPriceS - D50SMA
- symbolMark := TCurrentPriceS > D50SMA ? symbolUpString : symbolDownString
- if isMarketUp
- if isStockUp
- if TCurrentPriceS > D50SMA
- cellBG := meetCriteriaStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D50SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := warningStateColor
- else
- if isStockUp
- if TCurrentPriceS > D50SMA
- cellBG := warningStateColor
- else
- cellBG := doesNotMeetCriteriaStateColor
- else
- if TCurrentPriceS > D50SMA
- cellBG := doesNotMeetCriteriaStateColor
- else
- cellBG := meetCriteriaStateColor
- nCurrentRow := nCurrentRow + 1
- table.cell(dataTable, 0, nCurrentRow, symbolMark + " 50SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
- table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaSMA50S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
- table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
- table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement