Advertisement
Logup

Quickcheck - Revamped

Jun 10th, 2023 (edited)
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.22 KB | None | 0 0
  1. //@version=5
  2. //###########################################################################
  3. //#QuickCheck - Automatically Validate Basic Criteria For Stock Selection
  4. //#Creator: u/Brilliant_Candy_3744
  5. //#Version: 1.6
  6. //#Last Updated: 06.12.23
  7.  
  8. //#Attributtion:
  9. //#RealRelativeStrength: u/WorkPiece
  10. //#RelativeVolume: u/HurlTeaInTheSea
  11. //#Quickcheck: u/--SubZer0--
  12. //#############################################################################
  13.  
  14.  
  15. indicator(title="QuickCheck", overlay=false)
  16.  
  17. //----------------------------------------------
  18. //User Configuration
  19. var string G1 = "Display"
  20. string tableYposInput = input.string("top", "Indicator position...........", inline = "1", options = ["top", "middle", "bottom"], group = G1)
  21. string tableXposInput = input.string("right", "", inline = "1", options = ["left", "center", "right"], group = G1)
  22.  
  23. bool plotRvol = input.bool(true, "Plot Rvol", inline = "1",group = G1)
  24. var UP_COLOR = input.color(#70ccbd,"Up color>Thrs", inline = "1",group = G1)
  25. var DOWN_COLOR =input.color( #ff4352,"Down color>Thrs", inline = "1",group = G1)
  26.  
  27.  
  28. var UP_DIM_COLOR = input.color(#00606488,"Up color<Thrs", inline = "1",group = G1)
  29. var DOWN_DIM_COLOR =input.color( #a8393d86,"Down color<Thrs", inline = "1",group = G1)
  30. rVolThres = input.float(1.25, minval=0.0, step=0.1, title="RVol Highlight Thres.")
  31.  
  32. string symbolUpString = input.string("▲", title="Symbol Prefix............. ↑", inline = "2", group=G1)
  33. var symbolDownString = input.string("▼", title=" ↓", inline = "2", group=G1)
  34.  
  35. StockUpColor = input.color(#00ff00, title="Ticker Color............... ↑", inline = "3", group=G1)
  36. StockDownColor = input.color(color.red, title=" ↓", inline = "3", group=G1)
  37.  
  38. meetCriteriaStateColor = input.color(#00feff, title="Meets Criteria?........... Y", inline = "4", group=G1)
  39. doesNotMeetCriteriaStateColor = input.color(#e6e6e6, title="N", inline = "4", group=G1)
  40. warningStateColor = input.color(#f67c30, title="Warn", inline = "4", group=G1)
  41.  
  42. TableBorderColor = input.color(#d1d4dc, title="Table Border Color.........", inline="6", group=G1)
  43. SeparatorRowColor = input.color(color.white, title="Separator Row Color.......", inline="5", group=G1)
  44.  
  45. string G2 = "Indicator Inputs"
  46. comparedWithSecurity = input.symbol(title="Compare With", defval="NIFTY", group=G2)
  47. var minPriceThreshold = input.int(12, title="Min Price", group=G2)
  48. //var desiredMinATR = input.float(2, title="Desired Min ATR", group=G2)
  49. var rrsLength = input.int(12, title="RRS Length", group=G2)
  50. //var atrLength = input.int(14, title="ATR Length", group=G2)
  51. var nDayAverageForRVOL = input.int(20, title="N Day Average (For RVOL)", group=G2)
  52. //var minVolumeForToday = input.int(1500000, title="Min Required Vol Today", group=G2)
  53. var nDayAverageForDailyVol = nDayAverageForRVOL//input.int(20, title="N Day Average (For Daily Volume)", group=G2)
  54. //var desiredAvgVolume = input.int(2000000, title="Desired Min Daily Avg Vol", group=G2)
  55.  
  56.  
  57. //----------------------------------------------
  58. // defaults
  59. tableRows = 22
  60. tableColumns = 4
  61. tableCellWidth1 = 4
  62. tableCellWidth2 = 3
  63. nCurrentRow = 0
  64. symbolMark = ""
  65. cellBG = color.black
  66. textSize = size.small
  67.  
  68. //----------------------------------------------
  69. //Get relevant metrics for the ticker representing the Market
  70. tM = ticker.new(syminfo.prefix(symbol=comparedWithSecurity), syminfo.ticker(symbol=comparedWithSecurity))
  71. YCloseM = request.security(tM, 'D', close[1], lookahead = barmerge.lookahead_on)
  72. TCurrentPriceM = request.security(tM, 'D', close, lookahead = barmerge.lookahead_on)
  73.  
  74. DAvgVolM = request.security(tM, 'D', ta.sma(volume, nDayAverageForDailyVol))
  75. TVolumeM = request.security(tM, 'D', volume, lookahead = barmerge.lookahead_on)
  76. TVolFillM = TVolumeM / DAvgVolM
  77.  
  78. dMarketDayChange = TCurrentPriceM - YCloseM
  79. isMarketUp = dMarketDayChange > 0
  80.  
  81.  
  82. //----------------------------------------------
  83. //Get relevant metrics for current stock
  84. tS = ticker.new(syminfo.prefix, syminfo.ticker)
  85. TCurrentPriceS = request.security(tS, 'D', close, lookahead = barmerge.lookahead_on)
  86. YCloseS = request.security(tS, 'D', close[1], lookahead = barmerge.lookahead_on)
  87. YHighS = request.security(tS, 'D', high[1], lookahead = barmerge.lookahead_on)
  88. YLowS = request.security(tS, 'D', low[1], lookahead = barmerge.lookahead_on)
  89. TwentyDayHighS = request.security(tS, timeframe='D', expression=ta.highest(source=high, length=20))
  90. TwentyDayLowS = request.security(tS, timeframe='D', expression=ta.lowest(source=low, length=20))
  91. TOpenS = request.security(tS, 'D', open, lookahead = barmerge.lookahead_on)
  92. TVWAPS = request.security(tS, timeframe="", expression=ta.vwap(hlc3))
  93. DAvgVolS = request.security(tS, 'D', ta.sma(volume, nDayAverageForDailyVol))
  94. TVolumeS = request.security(tS, 'D', volume, lookahead = barmerge.lookahead_on)
  95. TVolFillS = TVolumeS / DAvgVolS
  96. D50SMA = request.security(tS, 'D', ta.sma(close, 50))
  97. D100SMA = request.security(tS, 'D', ta.sma(close, 100))
  98. D200SMA = request.security(tS, 'D', ta.sma(close, 200))
  99. //DCurrentATR = request.security(tS, 'D', ta.atr(atrLength))
  100.  
  101. dStockDayChange = TCurrentPriceS - YCloseS
  102. isStockUp = dStockDayChange > 0
  103.  
  104.  
  105. //----------------------------------------------
  106. // Calculate Relative Strength
  107. // © WorkPiece 12.28.21
  108.  
  109. //##########Rolling Price Change##########
  110. comparedClose = request.security(tM, timeframe="", expression=close)
  111. comparedRollingMove = comparedClose - comparedClose[rrsLength]
  112. sClose = request.security(tS, timeframe="", expression=close)
  113. symbolRollingMove = sClose - sClose[rrsLength]
  114.  
  115.  
  116. //##########Rolling ATR Change##########
  117. symbolRollingATR = request.security(tS, timeframe="", expression=ta.atr(rrsLength)[1])
  118. comparedRollingATR = request.security(tM, timeframe="", expression=ta.atr(rrsLength)[1])
  119.  
  120. //##########Calculations##########
  121. powerIndex = comparedRollingMove / comparedRollingATR
  122. TRRS = (symbolRollingMove - powerIndex * symbolRollingATR) / symbolRollingATR
  123.  
  124. //plot(TRRS, color=color.orange,linewidth = 1)
  125. //----------------------------------------------
  126. // Calculate RVOL
  127. // /u/HurlTeaInTheSea v1.0
  128. // Intraday Relative Volume (RVol) indicator:
  129.  
  130. // still works on higher timeframe but it's not a "day" average anymore, so throw error to avoid confusion
  131. if not (timeframe.isintraday or timeframe.isdaily)
  132. runtime.error("RVol is only valid for daily timeframe or lower")
  133.  
  134. var cVolS = 0.0
  135. var cVolM = 0.0
  136.  
  137. var newDayBars = array.new_int()
  138.  
  139. // detect new session of day
  140. isNewDay() =>
  141. t = time('D') // by default, time() follows symbol's session
  142. na(t[1]) and not na(t) or t[1] < t
  143.  
  144. if isNewDay()
  145. // reset cumulative volume
  146. cVolS := 0
  147. cVolM := 0
  148.  
  149. // save new bars in circular array of length nDayAverageForRVOL + 1
  150. array.push(newDayBars, bar_index)
  151. if (array.size(newDayBars) > nDayAverageForRVOL + 1)
  152. array.shift(newDayBars)
  153.  
  154. // cumulative volume
  155. cVolS := cVolS + volume
  156. cVolM := cVolM + request.security(tM, timeframe.period, volume, lookahead = barmerge.lookahead_on)
  157.  
  158. // calculate relative volume
  159. aVolS = 0.0
  160. aVolM = 0.0
  161. // check enough nDayAverageForRVOL saved in history to run (current day also saved)
  162. len = array.size(newDayBars)
  163. if len >= nDayAverageForRVOL + 1
  164. // SMA of historical cumulative volume up to but not including current time of day
  165. for i = 0 to len - 2
  166. b1 = array.get(newDayBars, i)
  167. b2 = array.get(newDayBars, i + 1)
  168.  
  169. // use historical date but carry over current hour, minutes, seconds (this method is exact and avoids DST bugs)
  170. t1 = time[bar_index - b1]
  171. tLookup = timestamp(year(t1), month(t1), dayofmonth(t1), hour(time), minute(time), second(time))
  172.  
  173. // get latest bar clamped in range [b1, b2) that is equal to or precedes given time (binary search for speed)
  174. int lo = math.max(0, b1) - 1
  175. int hi = math.max(0, b2)
  176. while 1 + lo < hi
  177. int mi = lo + math.floor((hi - lo) / 2)
  178. if (tLookup < time[bar_index - mi])
  179. hi := mi
  180. else
  181. lo := mi
  182. lo := lo < b1 ? hi : lo
  183. bClosest = b1 < b2 ? lo : -1
  184.  
  185. // add cumulative volume to SMA calculation
  186. tClosest = time[bar_index - bClosest]
  187. aVolS := aVolS + (tLookup >= tClosest ? cVolS[bar_index - bClosest] / nDayAverageForRVOL : 0)
  188.  
  189. aVolM := aVolM + (tLookup >= tClosest ? cVolM[bar_index - bClosest] / nDayAverageForRVOL : 0)
  190.  
  191. rVolS = aVolS > 0 ? cVolS / aVolS : 0
  192. rVolM = aVolM > 0 ? cVolM / aVolM : 0
  193.  
  194. color highlightColor=na
  195. if plotRvol
  196. // visuals
  197. colorPrevClose=true //convert to input if needed
  198. upColorCondition = colorPrevClose ? close >= close[1] : close >= open
  199. //hline(1.0, title="Reference", color=color.silver, linestyle=hline.style_dotted)
  200. highlightColor := rVolS >= rVolThres ? (upColorCondition ? UP_COLOR : DOWN_COLOR) : (upColorCondition ? UP_DIM_COLOR : DOWN_DIM_COLOR)
  201.  
  202. plot(plotRvol?rVolS:na, style=plot.style_columns, color=highlightColor)
  203. //plot(plotRvol?rVolS:na, style=plot.style_line, color=color.rgb(158, 153, 153))
  204. //----------------------------------------------
  205. var dataTable = table.new(tableYposInput + "_" + tableXposInput, tableColumns, tableRows, bgcolor=color.white, frame_width=1, frame_color=TableBorderColor)
  206.  
  207.  
  208. //----------------------------------------------
  209. //Show Market Status
  210. symbolMark := isMarketUp ? symbolUpString : symbolDownString
  211. cellBG := isMarketUp ? StockUpColor : StockDownColor
  212.  
  213. table.cell(dataTable, 0, nCurrentRow, symbolMark + " " + syminfo.ticker(symbol=comparedWithSecurity), text_halign=text.align_left, bgcolor = cellBG, text_color = isMarketUp ? color.black : color.white)
  214. 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)
  215. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  216. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  217.  
  218.  
  219. //----------------------------------------------
  220. //Show Stock Status
  221. symbolMark := isStockUp ? symbolUpString : symbolDownString
  222. cellBG := isStockUp ? StockUpColor : StockDownColor
  223.  
  224. //nCurrentRow := nCurrentRow + 1
  225. 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)
  226.  
  227. 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)
  228. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  229. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  230.  
  231.  
  232. //----------------------------------------------
  233. //Show Net Change %
  234. deltaYCloseMPercentage = (dMarketDayChange / YCloseM) * 100
  235. deltaYCloseSPercentage = (dStockDayChange / YCloseS) * 100
  236.  
  237. symbolMark := deltaYCloseSPercentage > deltaYCloseSPercentage ? symbolUpString : symbolDownString
  238. if isMarketUp
  239. if isStockUp
  240. if TCurrentPriceS > minPriceThreshold
  241. cellBG := meetCriteriaStateColor
  242. else
  243. cellBG := doesNotMeetCriteriaStateColor
  244. else
  245. if TCurrentPriceS > minPriceThreshold
  246. cellBG := warningStateColor
  247. else
  248. cellBG := doesNotMeetCriteriaStateColor
  249. else
  250. if isStockUp
  251. if TCurrentPriceS > minPriceThreshold
  252. cellBG := warningStateColor
  253. else
  254. cellBG := doesNotMeetCriteriaStateColor
  255. else
  256. if TCurrentPriceS > minPriceThreshold
  257. cellBG := meetCriteriaStateColor
  258. else
  259. cellBG := doesNotMeetCriteriaStateColor
  260.  
  261. nCurrentRow := nCurrentRow + 1
  262. table.cell(dataTable, 0, nCurrentRow, symbolMark + " NET CHG %", text_halign=text.align_left, bgcolor=cellBG)
  263. table.cell(dataTable, 1, nCurrentRow,((syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? ( str.tostring(deltaYCloseMPercentage, "#.##") + "%" + " / ") : "") + str.tostring(deltaYCloseSPercentage, "#.##") + "%" , text_halign=text.align_left, bgcolor=cellBG)
  264. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  265. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  266.  
  267.  
  268. //----------------------------------------------
  269. //Show Daily ATR Status
  270.  
  271. // symbolMark := DCurrentATR > desiredMinATR ? symbolUpString : symbolDownString
  272.  
  273. // if isMarketUp
  274. // if isStockUp
  275. // if DCurrentATR > desiredMinATR
  276. // cellBG := meetCriteriaStateColor
  277. // else
  278. // cellBG := doesNotMeetCriteriaStateColor
  279. // else
  280. // if DCurrentATR > desiredMinATR
  281. // cellBG := warningStateColor
  282. // else
  283. // cellBG := doesNotMeetCriteriaStateColor
  284. // else
  285. // if isStockUp
  286. // if DCurrentATR > desiredMinATR
  287. // cellBG := warningStateColor
  288. // else
  289. // cellBG := doesNotMeetCriteriaStateColor
  290. // else
  291. // if DCurrentATR > desiredMinATR
  292. // cellBG := meetCriteriaStateColor
  293. // else
  294. // cellBG := doesNotMeetCriteriaStateColor
  295.  
  296. // nCurrentRow := nCurrentRow + 1
  297. // table.cell(dataTable, 0, nCurrentRow, symbolMark + " ATR(" + str.tostring(atrLength) + "D)", text_halign=text.align_left, bgcolor=cellBG)
  298. // table.cell(dataTable, 1, nCurrentRow, str.tostring(DCurrentATR, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  299. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  300. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  301.  
  302.  
  303. //----------------------------------------------
  304. //Show Day Type
  305. //symbolMark := TCurrentPriceS > minPriceThreshold ? symbolUpString : symbolDownString
  306. if isMarketUp
  307. if isStockUp
  308. if TCurrentPriceS > YHighS
  309. cellBG := meetCriteriaStateColor
  310. else
  311. cellBG := doesNotMeetCriteriaStateColor
  312. else
  313. if TCurrentPriceS < YLowS
  314. cellBG := warningStateColor
  315. else
  316. cellBG := doesNotMeetCriteriaStateColor
  317. else
  318. if isStockUp
  319. if TCurrentPriceS > YHighS
  320. cellBG := warningStateColor
  321. else
  322. cellBG := doesNotMeetCriteriaStateColor
  323. else
  324. if TCurrentPriceS < YLowS
  325. cellBG := meetCriteriaStateColor
  326. else
  327. cellBG := doesNotMeetCriteriaStateColor
  328.  
  329. strDayType = (TCurrentPriceS > YHighS) ? "UP" : (TCurrentPriceS >= YLowS) ? "INSIDE" : "DOWN"
  330.  
  331. //nCurrentRow := nCurrentRow + 1
  332. table.cell(dataTable, 2, nCurrentRow, " DAY TYPE", text_halign=text.align_left, bgcolor=cellBG)
  333. table.cell(dataTable, 3, nCurrentRow, strDayType, text_halign=text.align_left, bgcolor=cellBG)
  334. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  335. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  336.  
  337.  
  338. //----------------------------------------------
  339. //Add empty row as separator
  340. // nCurrentRow := nCurrentRow + 1
  341. // table.cell(dataTable, 0, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
  342. // table.cell(dataTable, 1, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
  343. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  344. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  345.  
  346.  
  347. //----------------------------------------------
  348. //Show RRS Status
  349. symbolMark := TRRS > 0 ? symbolUpString : symbolDownString
  350.  
  351. if isMarketUp
  352. if isStockUp
  353. if TRRS > 0
  354. cellBG := meetCriteriaStateColor
  355. else
  356. cellBG := doesNotMeetCriteriaStateColor
  357. else
  358. if TRRS > 0
  359. cellBG := doesNotMeetCriteriaStateColor
  360. else
  361. cellBG := warningStateColor
  362. else
  363. if isStockUp
  364. if TRRS > 0
  365. cellBG := warningStateColor
  366. else
  367. cellBG := doesNotMeetCriteriaStateColor
  368. else
  369. if TRRS > 0
  370. cellBG := doesNotMeetCriteriaStateColor
  371. else
  372. cellBG := meetCriteriaStateColor
  373.  
  374. nCurrentRow := nCurrentRow + 1
  375. table.cell(dataTable, 0, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? symbolMark + " RRS" : " RRS", text_halign=text.align_left, bgcolor=cellBG)
  376. table.cell(dataTable, 1, nCurrentRow, (syminfo.ticker(symbol=comparedWithSecurity) != syminfo.ticker) ? (str.tostring(TRRS, "#.##")) : "NA", text_halign=text.align_left, bgcolor=cellBG)
  377. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  378. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  379.  
  380.  
  381. //----------------------------------------------
  382. //Show RVOL Status
  383.  
  384. symbolMark := (rVolS > rVolM and rVolS > 1.25) ? symbolUpString : symbolDownString
  385.  
  386. if isMarketUp
  387. if isStockUp
  388. if (rVolS > rVolM and rVolS > 1.25)
  389. cellBG := meetCriteriaStateColor
  390. else
  391. cellBG := doesNotMeetCriteriaStateColor
  392. else
  393. if (rVolS > rVolM and rVolS > 1.25)
  394. cellBG := warningStateColor
  395. else
  396. cellBG := doesNotMeetCriteriaStateColor
  397. else
  398. if isStockUp
  399. if (rVolS > rVolM and rVolS > 1.25)
  400. cellBG := warningStateColor
  401. else
  402. cellBG := doesNotMeetCriteriaStateColor
  403. else
  404. if (rVolS > rVolM and rVolS > 1.25)
  405. cellBG := meetCriteriaStateColor
  406. else
  407. cellBG := doesNotMeetCriteriaStateColor
  408.  
  409. //nCurrentRow := nCurrentRow + 1
  410. table.cell(dataTable, 2, nCurrentRow, symbolMark + " RVOL(" + str.tostring(nDayAverageForRVOL) + "D)", text_halign=text.align_left, bgcolor=cellBG)
  411. 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)
  412. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  413. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  414.  
  415.  
  416.  
  417. //#################################################
  418. //Show Daily Average Volume
  419.  
  420. // symbolMark := DAvgVolS > desiredAvgVolume? symbolUpString : symbolDownString
  421.  
  422. // if isMarketUp
  423. // if isStockUp
  424. // if DAvgVolS > desiredAvgVolume
  425. // cellBG := meetCriteriaStateColor
  426. // else
  427. // cellBG := doesNotMeetCriteriaStateColor
  428. // else
  429. // if DAvgVolS > desiredAvgVolume
  430. // cellBG := warningStateColor
  431. // else
  432. // cellBG := doesNotMeetCriteriaStateColor
  433. // else
  434. // if isStockUp
  435. // if DAvgVolS > desiredAvgVolume
  436. // cellBG := warningStateColor
  437. // else
  438. // cellBG := doesNotMeetCriteriaStateColor
  439. // else
  440. // if DAvgVolS > desiredAvgVolume
  441. // cellBG := meetCriteriaStateColor
  442. // else
  443. // cellBG := doesNotMeetCriteriaStateColor
  444.  
  445.  
  446. //nCurrentRow := nCurrentRow + 1
  447. //table.cell(dataTable, 0, nCurrentRow, symbolMark + " AvVOL(" + str.tostring(nDayAverageForDailyVol) + "D)", text_halign=text.align_left, bgcolor=cellBG)
  448. // table.cell(dataTable, 1, nCurrentRow, str.tostring(DAvgVolS/1000000, "#.#") + "M", text_halign=text.align_left, bgcolor=cellBG)
  449. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  450. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  451.  
  452.  
  453. //----------------------------------------------
  454. //Show Current Volume
  455.  
  456. // symbolMark := TVolumeS > minVolumeForToday? symbolUpString : symbolDownString
  457.  
  458. // if isMarketUp
  459. // if isStockUp
  460. // if TVolumeS > minVolumeForToday
  461. // cellBG := meetCriteriaStateColor
  462. // else
  463. // cellBG := doesNotMeetCriteriaStateColor
  464. // else
  465. // if TVolumeS > minVolumeForToday
  466. // cellBG := warningStateColor
  467. // else
  468. // cellBG := doesNotMeetCriteriaStateColor
  469. // else
  470. // if isStockUp
  471. // if TVolumeS > minVolumeForToday
  472. // cellBG := warningStateColor
  473. // else
  474. // cellBG := doesNotMeetCriteriaStateColor
  475. // else
  476. // if TVolumeS > minVolumeForToday
  477. // cellBG := meetCriteriaStateColor
  478. // else
  479. // cellBG := doesNotMeetCriteriaStateColor
  480.  
  481. // nCurrentRow := nCurrentRow + 1
  482. // table.cell(dataTable, 0, nCurrentRow, symbolMark + " VOLUME", text_halign=text.align_left, bgcolor=cellBG)
  483. // table.cell(dataTable, 1, nCurrentRow, str.tostring(TVolumeS/1000000, "#.#") + "M", text_halign=text.align_left, bgcolor=cellBG)
  484. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  485. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  486.  
  487.  
  488. //----------------------------------------------
  489. //Show Volume Fill
  490. symbolMark := (TVolFillS > 1 and TVolFillS > TVolFillM) ? symbolUpString : symbolDownString
  491.  
  492. if isMarketUp
  493. if isStockUp
  494. if TVolFillS > TVolFillM
  495. cellBG := meetCriteriaStateColor
  496. else
  497. cellBG := doesNotMeetCriteriaStateColor
  498. else
  499. if TVolFillS > TVolFillM
  500. cellBG := warningStateColor
  501. else
  502. cellBG := doesNotMeetCriteriaStateColor
  503. else
  504. if isStockUp
  505. if TVolFillS > TVolFillM
  506. cellBG := warningStateColor
  507. else
  508. cellBG := doesNotMeetCriteriaStateColor
  509. else
  510. if TVolFillS > TVolFillM
  511. cellBG := meetCriteriaStateColor
  512. else
  513. cellBG := doesNotMeetCriteriaStateColor
  514.  
  515. nCurrentRow := nCurrentRow + 1
  516. table.cell(dataTable, 0, nCurrentRow, symbolMark + " VOL % of ADV", text_halign=text.align_left, bgcolor=cellBG)
  517. table.cell(dataTable, 1, nCurrentRow, str.tostring(TVolFillS*100, "#") + "%" , text_halign=text.align_left, bgcolor=cellBG)
  518. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  519. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  520. //uncomment below to see vol/adv at that time
  521. //plot(cVolS/DAvgVolS*100,color=color.green)
  522. //----------------------------------------------
  523. //Add empty row to separate from volume metrics
  524. // nCurrentRow := nCurrentRow + 1
  525. // table.cell(dataTable, 0, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
  526. // table.cell(dataTable, 1, nCurrentRow, " ", text_halign=text.align_left, bgcolor=SeparatorRowColor)
  527. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  528. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  529.  
  530. //----------------------------------------------
  531. //Show VWAP Status
  532. deltaVWAPS = TCurrentPriceS - TVWAPS
  533. symbolMark := TCurrentPriceS > TVWAPS ? symbolUpString : symbolDownString
  534.  
  535. if isMarketUp
  536. if isStockUp
  537. if TCurrentPriceS > TVWAPS
  538. cellBG := meetCriteriaStateColor
  539. else
  540. cellBG := doesNotMeetCriteriaStateColor
  541. else
  542. if TCurrentPriceS > TVWAPS
  543. cellBG := doesNotMeetCriteriaStateColor
  544. else
  545. cellBG := warningStateColor
  546. else
  547. if isStockUp
  548. if TCurrentPriceS > TVWAPS
  549. cellBG := warningStateColor
  550. else
  551. cellBG := doesNotMeetCriteriaStateColor
  552. else
  553. if TCurrentPriceS > TVWAPS
  554. cellBG := doesNotMeetCriteriaStateColor
  555. else
  556. cellBG := meetCriteriaStateColor
  557.  
  558. //nCurrentRow := nCurrentRow + 1
  559. table.cell(dataTable, 2, nCurrentRow, symbolMark + " VWAP", text_halign=text.align_left, bgcolor=cellBG)
  560. table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaVWAPS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  561. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  562. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  563.  
  564. //----------------------------------------------
  565. //Show YClose Status
  566. symbolMark := TCurrentPriceS > YCloseS ? symbolUpString : symbolDownString
  567.  
  568. if isMarketUp
  569. if isStockUp
  570. if TCurrentPriceS > YCloseS
  571. cellBG := meetCriteriaStateColor
  572. else
  573. cellBG := doesNotMeetCriteriaStateColor
  574. else
  575. if TCurrentPriceS > YCloseS
  576. cellBG := doesNotMeetCriteriaStateColor
  577. else
  578. cellBG := warningStateColor
  579. else
  580. if isStockUp
  581. if TCurrentPriceS > YCloseS
  582. cellBG := warningStateColor
  583. else
  584. cellBG := doesNotMeetCriteriaStateColor
  585. else
  586. if TCurrentPriceS > YCloseS
  587. cellBG := doesNotMeetCriteriaStateColor
  588. else
  589. cellBG := meetCriteriaStateColor
  590.  
  591. nCurrentRow := nCurrentRow + 1
  592. table.cell(dataTable, 0, nCurrentRow, symbolMark + " YCLOSE", text_halign=text.align_left, bgcolor=cellBG)
  593. table.cell(dataTable, 1, nCurrentRow, str.tostring(dStockDayChange, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  594. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  595. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  596.  
  597.  
  598.  
  599.  
  600. //----------------------------------------------
  601. //Show Open Status
  602. deltaOpenS = TCurrentPriceS - TOpenS
  603. symbolMark := TCurrentPriceS > TOpenS ? symbolUpString : symbolDownString
  604.  
  605. if isMarketUp
  606. if isStockUp
  607. if TCurrentPriceS > TOpenS
  608. cellBG := meetCriteriaStateColor
  609. else
  610. cellBG := doesNotMeetCriteriaStateColor
  611. else
  612. if TCurrentPriceS > TOpenS
  613. cellBG := doesNotMeetCriteriaStateColor
  614. else
  615. cellBG := warningStateColor
  616. else
  617. if isStockUp
  618. if TCurrentPriceS > TOpenS
  619. cellBG := warningStateColor
  620. else
  621. cellBG := doesNotMeetCriteriaStateColor
  622. else
  623. if TCurrentPriceS > TOpenS
  624. cellBG := doesNotMeetCriteriaStateColor
  625. else
  626. cellBG := meetCriteriaStateColor
  627.  
  628. //nCurrentRow := nCurrentRow + 1
  629. table.cell(dataTable, 2, nCurrentRow, symbolMark + " OPEN", text_halign=text.align_left, bgcolor=cellBG)
  630. table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaOpenS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  631. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  632. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  633.  
  634.  
  635. //----------------------------------------------
  636. //Show YHigh Status
  637. deltaYHighS = TCurrentPriceS - YHighS
  638. symbolMark := TCurrentPriceS > YHighS ? symbolUpString : symbolDownString
  639.  
  640. if isMarketUp
  641. if isStockUp
  642. if TCurrentPriceS > YHighS
  643. cellBG := meetCriteriaStateColor
  644. else
  645. cellBG := doesNotMeetCriteriaStateColor
  646. else
  647. if TCurrentPriceS > YHighS
  648. cellBG := doesNotMeetCriteriaStateColor
  649. else
  650. cellBG := warningStateColor
  651. else
  652. if isStockUp
  653. if TCurrentPriceS > YHighS
  654. cellBG := warningStateColor
  655. else
  656. cellBG := doesNotMeetCriteriaStateColor
  657. else
  658. if TCurrentPriceS > YHighS
  659. cellBG := doesNotMeetCriteriaStateColor
  660. else
  661. cellBG := meetCriteriaStateColor
  662.  
  663. nCurrentRow := nCurrentRow + 1
  664. table.cell(dataTable, 0, nCurrentRow, symbolMark + " YHIGH", text_halign=text.align_left, bgcolor=cellBG)
  665. table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaYHighS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  666. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  667. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  668.  
  669.  
  670. //----------------------------------------------
  671. //Show YLow Status
  672. deltaYLowS = TCurrentPriceS - YLowS
  673. symbolMark := TCurrentPriceS > YLowS ? symbolUpString : symbolDownString
  674.  
  675. if isMarketUp
  676. if isStockUp
  677. if TCurrentPriceS > YLowS
  678. cellBG := meetCriteriaStateColor
  679. else
  680. cellBG := doesNotMeetCriteriaStateColor
  681. else
  682. if TCurrentPriceS > YLowS
  683. cellBG := doesNotMeetCriteriaStateColor
  684. else
  685. cellBG := warningStateColor
  686. else
  687. if isStockUp
  688. if TCurrentPriceS > YLowS
  689. cellBG := warningStateColor
  690. else
  691. cellBG := doesNotMeetCriteriaStateColor
  692. else
  693. if TCurrentPriceS > YLowS
  694. cellBG := doesNotMeetCriteriaStateColor
  695. else
  696. cellBG := meetCriteriaStateColor
  697.  
  698. //nCurrentRow := nCurrentRow + 1
  699. table.cell(dataTable, 2, nCurrentRow, symbolMark + " YLOW", text_halign=text.align_left, bgcolor=cellBG)
  700. table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaYLowS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  701. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  702. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  703.  
  704.  
  705.  
  706. //----------------------------------------------
  707. //Show 20 Day High Status
  708. // delta20HighS = TCurrentPriceS - TwentyDayHighS
  709. // symbolMark := TCurrentPriceS > TwentyDayHighS ? symbolUpString : symbolDownString
  710.  
  711. // if isMarketUp
  712. // if isStockUp
  713. // if TCurrentPriceS > TwentyDayHighS
  714. // cellBG := meetCriteriaStateColor
  715. // else
  716. // cellBG := doesNotMeetCriteriaStateColor
  717. // else
  718. // if TCurrentPriceS > TwentyDayHighS
  719. // cellBG := doesNotMeetCriteriaStateColor
  720. // else
  721. // cellBG := warningStateColor
  722. // else
  723. // if isStockUp
  724. // if TCurrentPriceS > TwentyDayHighS
  725. // cellBG := warningStateColor
  726. // else
  727. // cellBG := doesNotMeetCriteriaStateColor
  728. // else
  729. // if TCurrentPriceS > TwentyDayHighS
  730. // cellBG := doesNotMeetCriteriaStateColor
  731. // else
  732. // cellBG := meetCriteriaStateColor
  733.  
  734. // nCurrentRow := nCurrentRow + 1
  735. // table.cell(dataTable, 0, nCurrentRow, symbolMark + " D20 HIGH", text_halign=text.align_left, bgcolor=cellBG)
  736. // table.cell(dataTable, 1, nCurrentRow, str.tostring(delta20HighS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  737. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  738. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  739.  
  740.  
  741. //----------------------------------------------
  742. //Show 20 Day Low Status
  743. // delta20LowS = TCurrentPriceS - TwentyDayLowS
  744. // symbolMark := TCurrentPriceS > TwentyDayLowS ? symbolUpString : symbolDownString
  745.  
  746. // if isMarketUp
  747. // if isStockUp
  748. // if TCurrentPriceS > TwentyDayLowS
  749. // cellBG := meetCriteriaStateColor
  750. // else
  751. // cellBG := doesNotMeetCriteriaStateColor
  752. // else
  753. // if TCurrentPriceS > TwentyDayLowS
  754. // cellBG := doesNotMeetCriteriaStateColor
  755. // else
  756. // cellBG := warningStateColor
  757. // else
  758. // if isStockUp
  759. // if TCurrentPriceS > TwentyDayLowS
  760. // cellBG := warningStateColor
  761. // else
  762. // cellBG := doesNotMeetCriteriaStateColor
  763. // else
  764. // if TCurrentPriceS > TwentyDayLowS
  765. // cellBG := doesNotMeetCriteriaStateColor
  766. // else
  767. // cellBG := meetCriteriaStateColor
  768.  
  769. // nCurrentRow := nCurrentRow + 1
  770. // table.cell(dataTable, 0, nCurrentRow, symbolMark + " D20 LOW", text_halign=text.align_left, bgcolor=cellBG)
  771. // table.cell(dataTable, 1, nCurrentRow, str.tostring(delta20LowS, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  772. // table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  773. // table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  774.  
  775.  
  776.  
  777.  
  778. //----------------------------------------------
  779. //Show 200SMA(D) Status
  780.  
  781. deltaSMA200S = TCurrentPriceS - D200SMA
  782. symbolMark := TCurrentPriceS > D200SMA ? symbolUpString : symbolDownString
  783.  
  784. if isMarketUp
  785. if isStockUp
  786. if TCurrentPriceS > D200SMA
  787. cellBG := meetCriteriaStateColor
  788. else
  789. cellBG := doesNotMeetCriteriaStateColor
  790. else
  791. if TCurrentPriceS > D200SMA
  792. cellBG := doesNotMeetCriteriaStateColor
  793. else
  794. cellBG := warningStateColor
  795. else
  796. if isStockUp
  797. if TCurrentPriceS > D200SMA
  798. cellBG := warningStateColor
  799. else
  800. cellBG := doesNotMeetCriteriaStateColor
  801. else
  802. if TCurrentPriceS > D200SMA
  803. cellBG := doesNotMeetCriteriaStateColor
  804. else
  805. cellBG := meetCriteriaStateColor
  806.  
  807. nCurrentRow := nCurrentRow + 1
  808. table.cell(dataTable, 0, nCurrentRow, symbolMark + " 200SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
  809. table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaSMA200S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  810. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  811. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  812. //----------------------------------------------
  813. //Show 100SMA(D) Status
  814.  
  815. deltaSMA100S = TCurrentPriceS - D100SMA
  816. symbolMark := TCurrentPriceS > D100SMA ? symbolUpString : symbolDownString
  817.  
  818. if isMarketUp
  819. if isStockUp
  820. if TCurrentPriceS > D100SMA
  821. cellBG := meetCriteriaStateColor
  822. else
  823. cellBG := doesNotMeetCriteriaStateColor
  824. else
  825. if TCurrentPriceS > D100SMA
  826. cellBG := doesNotMeetCriteriaStateColor
  827. else
  828. cellBG := warningStateColor
  829. else
  830. if isStockUp
  831. if TCurrentPriceS > D100SMA
  832. cellBG := warningStateColor
  833. else
  834. cellBG := doesNotMeetCriteriaStateColor
  835. else
  836. if TCurrentPriceS > D100SMA
  837. cellBG := doesNotMeetCriteriaStateColor
  838. else
  839. cellBG := meetCriteriaStateColor
  840.  
  841. //nCurrentRow := nCurrentRow + 1
  842. table.cell(dataTable, 2, nCurrentRow, symbolMark + " 100SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
  843. table.cell(dataTable, 3, nCurrentRow, str.tostring(deltaSMA100S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  844. table.cell_set_text_size(dataTable, 2, nCurrentRow, textSize)
  845. table.cell_set_text_size(dataTable, 3, nCurrentRow, textSize)
  846.  
  847. //----------------------------------------------
  848. //Show 50SMA(D) Status
  849. //https://www.tradingview.com/script/NxVJbviK-Daily-Moving-Averages-on-Intraday-Chart/
  850.  
  851. deltaSMA50S = TCurrentPriceS - D50SMA
  852. symbolMark := TCurrentPriceS > D50SMA ? symbolUpString : symbolDownString
  853.  
  854. if isMarketUp
  855. if isStockUp
  856. if TCurrentPriceS > D50SMA
  857. cellBG := meetCriteriaStateColor
  858. else
  859. cellBG := doesNotMeetCriteriaStateColor
  860. else
  861. if TCurrentPriceS > D50SMA
  862. cellBG := doesNotMeetCriteriaStateColor
  863. else
  864. cellBG := warningStateColor
  865. else
  866. if isStockUp
  867. if TCurrentPriceS > D50SMA
  868. cellBG := warningStateColor
  869. else
  870. cellBG := doesNotMeetCriteriaStateColor
  871. else
  872. if TCurrentPriceS > D50SMA
  873. cellBG := doesNotMeetCriteriaStateColor
  874. else
  875. cellBG := meetCriteriaStateColor
  876.  
  877. nCurrentRow := nCurrentRow + 1
  878. table.cell(dataTable, 0, nCurrentRow, symbolMark + " 50SMA(D)", text_halign=text.align_left, bgcolor=cellBG)
  879. table.cell(dataTable, 1, nCurrentRow, str.tostring(deltaSMA50S, "#.##"), text_halign=text.align_left, bgcolor=cellBG)
  880. table.cell_set_text_size(dataTable, 0, nCurrentRow, textSize)
  881. table.cell_set_text_size(dataTable, 1, nCurrentRow, textSize)
  882.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement