ajiim

🎁

Sep 30th, 2026
2,223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.80 KB | None | 0 0
  1. //@version=6
  2. indicator("2022 Model Pro+ | ICTKESIK", shorttitle = "2022 Model Pro+ | ICTKESIK", overlay = true,
  3. max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500, max_bars_back = 5000)
  4.  
  5.  
  6. grpGen = "General"
  7. grpLiq = "Liquidity"
  8. grpSMT = "SMT (Triton)"
  9. grpStr = "Structure / PD Arrays"
  10. grpHtf = "HTF Fair Value Gaps"
  11. grpKey = "Key Levels (PDH / PDL / Sessions)"
  12. grpTime = "Time Lines"
  13. grpTrd = "Trade Management"
  14. grpTbl = "Checklist"
  15. grpWm = "Watermark"
  16. grpSty = "Style"
  17.  
  18. biasMode = input.string("Neutral", "Bias", options = ["Neutral", "Bullish", "Bearish"], group = grpGen, inline = "g1", tooltip = "Neutral = both directions. Bullish = only ICTKESIK+ setups. Bearish = only ICTKESIK- setups.")
  19. setupGrade = input.string("B+", "Min Grade", options = ["A+", "B+", "Any"], group = grpGen, inline = "g1", tooltip = "A+ = SMT + FVG + within PD zone + inside session. B+ = FVG required. Any = every MSS.")
  20. swingLen = input.int(3, "Swing Length", minval = 1, maxval = 10, group = grpGen, inline = "g2", tooltip = "Pivot strength used to build swing highs/lows. Lower = more sensitive.")
  21. showHist = input.int(3, "Setups Kept On Chart", minval = 1, maxval = 20, group = grpGen, inline = "g2")
  22. onlySession = input.bool(true, "Only Trade Inside Killzones", group = grpGen)
  23.  
  24. showSweep = input.bool(true, "Show Liquidity Sweeps ($$$)", group = grpLiq, inline = "lq1")
  25. sweepBars = input.int(60, "Max Bars Between Swing & Sweep", minval = 5, maxval = 500, group = grpLiq, inline = "lq1")
  26. maxSweepShow = input.int(5, "Max Sweeps Displayed On Chart", minval = 1, maxval = 100, group = grpLiq)
  27.  
  28. showSMT = input.bool(true, "Show SMT Divergences", group = grpSMT, inline = "sm1")
  29. smtSens = input.string("Normal", "Sensitivity", options = ["Sensitive", "Normal", "Strict"], group = grpSMT, inline = "sm1", tooltip = "Sensitive = every SMT. Normal = medium swings. Strict = major swings only.")
  30. smtAuto = input.bool(true, "Automatic Correlated Asset", group = grpSMT, inline = "sm2")
  31. smtManual = input.symbol("CME_MINI:ES1!", "", group = grpSMT, inline = "sm2")
  32. smtRealtime = input.bool(false, "Real-time SMTs", group = grpSMT, inline = "sm3", tooltip = "Plots SMT before the divergence candle closes and trails it in real time.")
  33. smtLook = input.int(6, "Lookback (bars)", minval = 1, maxval = 50, group = grpSMT, inline = "sm3")
  34. cSmtBull = input.color(#2962ff, "Bullish", group = grpSMT, inline = "sm4")
  35. cSmtBear = input.color(#ef5350, "Bearish", group = grpSMT, inline = "sm4")
  36. smtWidth = input.string("Thin", "Width", options = ["Thin", "Medium", "Thick"], group = grpSMT, inline = "sm5", tooltip = "Shared line width/style for both Bullish and Bearish SMT lines.")
  37. smtStyle = input.string("Dotted", "Style", options = ["Solid", "Dashed", "Dotted"], group = grpSMT, inline = "sm5")
  38. smtLabelOn = input.bool(true, "Label", group = grpSMT, inline = "sm6")
  39. smtSymbolOn = input.bool(true, "Show symbol", group = grpSMT, inline = "sm6")
  40. smtMax = input.int(3, "Max Displayed", minval = 1, maxval = 20, group = grpSMT, inline = "sm6")
  41.  
  42. showMSS = input.bool(true, "Show MSS", group = grpStr, inline = "st1")
  43. mssType = input.string("Close", "Confirmation", options = ["Close", "Wick"], group = grpStr, inline = "st1")
  44. mssLeft = input.int(5, "MSS Pivot Left", minval = 1, inline = "st2", group = grpStr)
  45. mssRight = input.int(5, "Right", minval = 1, inline = "st2", group = grpStr)
  46. mssMaxWait = input.int(20, "Max Waiting Bars", minval = 1, maxval = 500, inline = "st2", group = grpStr, tooltip = "Maximum number of bars to wait after a sweep for the MSS to confirm, before the attempt expires.")
  47. showFVG = input.bool(true, "Show Displacement FVG", group = grpStr, inline = "st3")
  48. fvgMinAtr = input.float(0.0, "Min Size (× ATR14)", minval = 0, step = 0.1, group = grpStr, inline = "st3")
  49. showBB = input.bool(true, "Show Breaker Block (BB)", group = grpStr)
  50.  
  51. showHTF = input.bool(true, "Show HTF FVGs", group = grpHtf)
  52. htfMode = input.string("Automatic", "HTF Selection", options = ["Automatic", "Manual"], group = grpHtf, tooltip = "Automatic: 1m→M5+M15, 3m→M15+H1, 5m→M15+H1, 15m→H1+H4, 1H→H4+D, else D+W.")
  53. htf1Man = input.timeframe("5", "Manual HTF 1", group = grpHtf, inline = "ht1")
  54. htf2Man = input.timeframe("15", "Manual HTF 2", group = grpHtf, inline = "ht1")
  55. htfCount = input.int(1, "FVGs Per Timeframe", minval = 1, maxval = 10, group = grpHtf, inline = "ht2")
  56. htfExtend = input.int(10, "Extension (bars)", minval = 0, maxval = 500, group = grpHtf, inline = "ht2")
  57. htfMitig = input.string("Close through", "Remove HTF FVG When", options = ["Close through", "Wick through", "Never"], group = grpHtf)
  58. htfShowCE = input.bool(true, "Show HTF FVG Consequent Encroachment (●)", group = grpHtf)
  59.  
  60. showPD = input.bool(true, "PDH / PDL", group = grpKey, inline = "kl1")
  61. showPWK = input.bool(false, "PWH / PWL", group = grpKey, inline = "kl1")
  62. showSessHL = input.bool(true, "Session H/L", group = grpKey, inline = "kl1")
  63. keyExt = input.int(10, "Extension (bars past current bar)", minval = 0, maxval = 300, group = grpKey, inline = "kl2")
  64. keyStopHit = input.bool(true, "Stop Line When Swept", group = grpKey, inline = "kl2")
  65.  
  66. showTimes = input.bool(true, "Show Time Lines", group = grpTime, inline = "tl0")
  67. tz = input.string("America/New_York", "Timezone", options = ["America/New_York", "Europe/London", "UTC", "Asia/Tokyo", "Exchange"], group = grpTime, inline = "tl0")
  68. tLine1 = input.session("0000-0001", "Midnight Open (0:00 AM)", group = grpTime)
  69. tLine2 = input.session("0830-0831", "8:30 AM", group = grpTime)
  70. tShow3 = input.bool(false, "9:30 AM", group = grpTime, inline = "tl3")
  71. tLine3 = input.session("0930-0931", "", group = grpTime, inline = "tl3")
  72. tExt = input.int(60, "Time Line Length (bars)", minval = 5, maxval = 500, group = grpTime)
  73. sessAsia = input.session("2000-0000", "Asia Killzone", group = grpTime, inline = "ks1")
  74. sessLondon = input.session("0200-0500", "London Killzone", group = grpTime, inline = "ks1")
  75. sessNYAM = input.session("0830-1100", "NY AM Killzone", group = grpTime, inline = "ks2")
  76. sessNYPM = input.session("1330-1600", "NY PM Killzone", group = grpTime, inline = "ks2")
  77.  
  78. entryMode = input.string("FVG CE", "Entry Level", options = ["FVG CE", "FVG Edge", "Breaker Block", "MSS Retest"], group = grpTrd)
  79. slMode = input.string("Sweep + Buffer", "Stop Loss", options = ["Sweep + Buffer", "Sweep", "FVG Far Edge"], group = grpTrd, inline = "tr1")
  80. slBufTicks = input.int(4, "Buffer (ticks)", minval = 0, maxval = 200, group = grpTrd, inline = "tr1")
  81. tpMode = input.string("Liquidity", "Take Profit", options = ["Liquidity", "Fixed RR"], group = grpTrd, tooltip = "Liquidity: TP1/TP2 = next opposing swing liquidity pools. Fixed RR: uses RR inputs.")
  82. tp1RR = input.float(1.0, "TP1 RR (Fixed)", minval = 0.5, step = 0.5, group = grpTrd, inline = "tr2")
  83. tp2RR = input.float(2.0, "TP2 RR (Fixed)", minval = 0.5, step = 0.5, group = grpTrd, inline = "tr2")
  84. minRR = input.float(0.5, "Minimum RR to TP1", minval = 0, step = 0.1, group = grpTrd)
  85. tradeExt = input.int(15, "Entry / SL / TP Extension (bars)", minval = 1, maxval = 200, group = grpTrd)
  86. showRRBox = input.bool(false, "Show Risk / Reward Boxes", group = grpTrd, inline = "tr3")
  87. invalidateB = input.bool(true, "Invalidate on SL Hit", group = grpTrd, inline = "tr3")
  88.  
  89. showTable = input.bool(true, "Show Checklist", group = grpTbl, inline = "tb0")
  90. tblPos = input.string("Bottom Right", "", options = ["Bottom Right", "Top Right", "Bottom Left", "Top Left", "Middle Right"], group = grpTbl, inline = "tb0")
  91. tblSize = input.string("Small", "Checklist Size", options = ["Tiny", "Small", "Normal"], group = grpTbl)
  92. rowSweep = input.bool(true, "Row: Liquidity Sweep", group = grpTbl, inline = "tb1")
  93. rowMSS = input.bool(true, "Row: Structure Shift", group = grpTbl, inline = "tb1")
  94. rowFVG = input.bool(true, "Row: Fair Value Gap", group = grpTbl, inline = "tb2")
  95. rowBB = input.bool(true, "Row: Breaker Block", group = grpTbl, inline = "tb2")
  96. rowPDA = input.bool(true, "Row: Within Premium/Discount", group = grpTbl, inline = "tb3")
  97. rowFilled = input.bool(true, "Row: PDA Delivery", group = grpTbl, inline = "tb3")
  98. rowPrevDay = input.bool(true, "Row: Prev Day Sweep", group = grpTbl, inline = "tb4")
  99. rowSMT = input.bool(true, "Row: SMT", group = grpTbl, inline = "tb4")
  100. rowSession = input.bool(true, "Row: Session", group = grpTbl, inline = "tb5")
  101. rowStatus = input.bool(true, "Row: Status", group = grpTbl, inline = "tb5")
  102.  
  103. showWM = input.bool(true, "Show Watermark", group = grpWm, inline = "wm1")
  104. wmSub = input.bool(true, "Show Ticker + Date", group = grpWm, inline = "wm1")
  105. wmTitle = input.string("2022 Model Pro+ | ICTKESIK", "Watermark Title", group = grpWm)
  106.  
  107. cBull = input.color(#2962ff, "Bullish (ICTKESIK+)", group = grpSty, inline = "c1")
  108. cBear = input.color(#ef5350, "Bearish (ICTKESIK-)", group = grpSty, inline = "c1")
  109. cText = input.color(#787b86, "Labels", group = grpSty, inline = "c2")
  110. cLine = input.color(#787b86, "Lines", group = grpSty, inline = "c2")
  111. cFVG = input.color(color.new(#787b86, 78), "FVG / Range Fill", group = grpSty, inline = "c3")
  112. cBB = input.color(color.new(#787b86, 75), "Breaker Fill", group = grpSty, inline = "c3")
  113. cHTF = input.color(color.new(#787b86, 80), "HTF FVG Fill", group = grpSty, inline = "c4")
  114. cOK = input.color(#26a69a, "Checklist ✓", group = grpSty, inline = "c5")
  115. cNO = input.color(#ef5350, "Checklist ✗", group = grpSty, inline = "c5")
  116. lblSize = input.string("Tiny", "Label Size", options = ["Tiny", "Small", "Normal"], group = grpSty, inline = "viz", tooltip = "One shared control for label size, secondary line width, and secondary line style (Sweep / Key Levels / Time Lines / HTF CE / SL-TP) across the whole indicator.")
  117. lineW = input.int(1, "Line Width", minval = 1, maxval = 3, group = grpSty, inline = "viz")
  118. auxLineStyle = input.string("Dotted", "Line Style", options = ["Dotted", "Dashed", "Solid"], group = grpSty, inline = "viz")
  119.  
  120.  
  121.  
  122. f_size(string s) => s == "Tiny" ? size.tiny : s == "Small" ? size.small : size.normal
  123. f_lsty(string s) => s == "Dotted" ? line.style_dotted : s == "Dashed" ? line.style_dashed : line.style_solid
  124. f_tz() => tz == "Exchange" ? syminfo.timezone : tz
  125. f_pos(string p) =>
  126. switch p
  127. "Bottom Right" => position.bottom_right
  128. "Top Right" => position.top_right
  129. "Bottom Left" => position.bottom_left
  130. "Top Left" => position.top_left
  131. => position.middle_right
  132.  
  133. f_widthOf(string s) =>
  134. switch s
  135. "Thin" => 1
  136. "Medium" => 2
  137. "Thick" => 3
  138. => 1
  139.  
  140. LBL_SIZE = f_size(lblSize)
  141.  
  142. f_lbl(int x, float y, string txt, string sty, color tc) =>
  143. label.new(x, y, txt, style = sty, color = color.new(color.white, 100), textcolor = tc, size = LBL_SIZE)
  144. AUX_STY = f_lsty(auxLineStyle)
  145. SMT_STY = f_lsty(smtStyle)
  146. SMT_W = f_widthOf(smtWidth)
  147. TZ = f_tz()
  148. atr = ta.atr(14)
  149. tick = syminfo.mintick
  150.  
  151. f_barAtTime(int t) =>
  152. int idx = na
  153. for i = 0 to math.min(bar_index, 4999)
  154. if time[i] <= t
  155. idx := bar_index - i
  156. break
  157. idx
  158.  
  159. f_tfName(string tf) =>
  160. string out = tf
  161. if str.contains(tf, "D") or str.contains(tf, "W") or str.contains(tf, "M") and not str.contains(tf, "m")
  162. out := tf
  163. else
  164. int mins = int(str.tonumber(tf))
  165. out := na(mins) ? tf : mins >= 60 ? "H" + str.tostring(mins / 60) : "M" + str.tostring(mins)
  166. out
  167.  
  168. f_chartTf() =>
  169. int s = timeframe.in_seconds()
  170. s < 3600 ? "(" + str.tostring(s / 60) + "m)" : s < 86400 ? "(" + str.tostring(s / 3600) + "H)" : timeframe.isdaily ? "(D)" : timeframe.isweekly ? "(W)" : "(" + timeframe.period + ")"
  171.  
  172. f_autoHTF() =>
  173. int s = timeframe.in_seconds()
  174. string a = "5"
  175. string b = "15"
  176. if s <= 60
  177. a := "5", b := "15"
  178. else if s <= 300
  179. a := "15", b := "60"
  180. else if s <= 900
  181. a := "60", b := "240"
  182. else if s <= 3600
  183. a := "240", b := "D"
  184. else
  185. a := "D", b := "W"
  186. [a, b]
  187.  
  188. f_resolvePair() =>
  189. string sym = smtManual
  190. if smtAuto
  191. string mapped = switch syminfo.ticker
  192. "ES1!" => "NQ1!"
  193. "NQ1!" => "ES1!"
  194. "YM1!" => "ES1!"
  195. "RTY1!" => "ES1!"
  196. "GC1!" => "SI1!"
  197. "SI1!" => "GC1!"
  198. "CL1!" => "RB1!"
  199. "RB1!" => "CL1!"
  200. "6E1!" => "6B1!"
  201. "6B1!" => "6E1!"
  202. "6A1!" => "6N1!"
  203. "6N1!" => "6A1!"
  204. "BTC1!" => "ETH1!"
  205. "ETH1!" => "BTC1!"
  206. "BTCUSD" => "ETHUSD"
  207. "ETHUSD" => "BTCUSD"
  208. "BTCUSDT" => "ETHUSDT"
  209. "ETHUSDT" => "BTCUSDT"
  210. "USDJPY" => "DXY"
  211. "USDCHF" => "DXY"
  212. "USDCAD" => "DXY"
  213. "DXY" => "USDJPY"
  214. "EURUSD" => "GBPUSD"
  215. "GBPUSD" => "EURUSD"
  216. "AUDUSD" => "NZDUSD"
  217. "NZDUSD" => "AUDUSD"
  218. "AUDCAD" => "NZDCAD"
  219. "NZDCAD" => "AUDCAD"
  220. "EURCAD" => "GBPCAD"
  221. "GBPCAD" => "EURCAD"
  222. "EURAUD" => "GBPAUD"
  223. "GBPAUD" => "EURAUD"
  224. "EURNZD" => "GBPNZD"
  225. "GBPNZD" => "EURNZD"
  226. "EURJPY" => "GBPJPY"
  227. "GBPJPY" => "EURJPY"
  228. "AUDJPY" => "NZDJPY"
  229. "NZDJPY" => "AUDJPY"
  230. "XAUUSD" => "XAGUSD"
  231. "XAGUSD" => "XAUUSD"
  232. => ""
  233. if mapped != ""
  234. sym := syminfo.prefix + ":" + mapped
  235. sym
  236.  
  237. corrSym = f_resolvePair()
  238. corrShort = str.replace_all(str.substring(corrSym, na(str.pos(corrSym, ":")) ? 0 : str.pos(corrSym, ":") + 1), "1!", "")
  239. [corrHigh, corrLow] = request.security(corrSym, timeframe.period, [high, low], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_off)
  240.  
  241. int smtLen = switch smtSens
  242. "Sensitive" => 2
  243. "Normal" => 5
  244. "Strict" => 10
  245. => 5
  246.  
  247. float smtPh = ta.pivothigh(high, smtLen, smtLen)
  248. float smtPl = ta.pivotlow(low, smtLen, smtLen)
  249.  
  250. inAsia = not na(time(timeframe.period, sessAsia, TZ))
  251. inLondon = not na(time(timeframe.period, sessLondon, TZ))
  252. inNYAM = not na(time(timeframe.period, sessNYAM, TZ))
  253. inNYPM = not na(time(timeframe.period, sessNYPM, TZ))
  254. inKZ = inAsia or inLondon or inNYAM or inNYPM
  255. sessName = inNYAM ? "NY AM" : inNYPM ? "NY PM" : inLondon ? "London" : inAsia ? "Asia" : "Off-Session"
  256. newDay = ta.change(time("D")) != 0
  257. newWeek = ta.change(time("W")) != 0
  258.  
  259. type Swing
  260. int idx
  261. float price
  262. bool swept
  263.  
  264. var array<Swing> swHighs = array.new<Swing>()
  265. var array<Swing> swLows = array.new<Swing>()
  266.  
  267. ph = ta.pivothigh(high, swingLen, swingLen)
  268. pl = ta.pivotlow(low, swingLen, swingLen)
  269.  
  270. var array<float> mssHighPrices = array.new<float>()
  271. var array<int> mssHighBars = array.new<int>()
  272. var array<float> mssLowPrices = array.new<float>()
  273. var array<int> mssLowBars = array.new<int>()
  274. var bool waitingForBullMSS = false
  275. var bool waitingForBearMSS = false
  276.  
  277. phMSS = ta.pivothigh(high, mssLeft, mssRight)
  278. plMSS = ta.pivotlow(low, mssLeft, mssRight)
  279.  
  280. if not na(phMSS)
  281. mssHighPrices.push(phMSS)
  282. mssHighBars.push(bar_index - mssRight)
  283. if mssHighPrices.size() > 50
  284. mssHighPrices.shift()
  285. mssHighBars.shift()
  286.  
  287. if not na(plMSS)
  288. mssLowPrices.push(plMSS)
  289. mssLowBars.push(bar_index - mssRight)
  290. if mssLowPrices.size() > 50
  291. mssLowPrices.shift()
  292. mssLowBars.shift()
  293.  
  294. if not na(ph)
  295. swHighs.push(Swing.new(bar_index - swingLen, ph, false))
  296. if swHighs.size() > 60
  297. swHighs.shift()
  298. if not na(pl)
  299. swLows.push(Swing.new(bar_index - swingLen, pl, false))
  300. if swLows.size() > 60
  301. swLows.shift()
  302.  
  303. f_lastUnswept(array<Swing> arr) =>
  304. Swing out = na
  305. if arr.size() > 0
  306. for i = arr.size() - 1 to 0
  307. Swing s = arr.get(i)
  308. if not s.swept
  309. out := s
  310. break
  311. out
  312.  
  313. f_nextLiq(array<Swing> arr, float lvl, bool below) =>
  314. float o1 = na
  315. float o2 = na
  316. if arr.size() > 0
  317. array<float> cand = array.new<float>()
  318. for i = arr.size() - 1 to 0
  319. Swing s = arr.get(i)
  320. if (below ? s.price < lvl : s.price > lvl) and not s.swept
  321. cand.push(s.price)
  322. if cand.size() > 0
  323. if below
  324. cand.sort(order.descending)
  325. else
  326. cand.sort(order.ascending)
  327. o1 := cand.get(0)
  328. o2 := cand.get(math.min(1, cand.size() - 1))
  329. [o1, o2]
  330.  
  331. var int sweepHiBar = na
  332. var float sweepHiPrice = na
  333. var int sweepHiSwing = na
  334. var bool sweepHiSMT = false
  335. var int sweepLoBar = na
  336. var float sweepLoPrice = na
  337. var int sweepLoSwing = na
  338. var bool sweepLoSMT = false
  339.  
  340. bool newSweepHi = false
  341. bool newSweepLo = false
  342.  
  343. var array<line> smtLines = array.new<line>()
  344. var array<label> smtLbls = array.new<label>()
  345.  
  346. f_trimDraw(array<line> ls, array<label> lb, int maxN) =>
  347. while ls.size() > maxN
  348. line.delete(ls.shift())
  349. while lb.size() > maxN
  350. label.delete(lb.shift())
  351.  
  352. f_drawSmt(bool bull, int b1, float p1, int b2, float p2) =>
  353. if showSMT
  354. color col = bull ? cSmtBull : cSmtBear
  355. smtLines.push(line.new(b1, p1, b2, p2, color = col, style = SMT_STY, width = SMT_W))
  356. if smtLabelOn
  357. string smtTxt = smtSymbolOn ? "SMT (" + corrShort + ")" : "SMT"
  358. smtLbls.push(f_lbl(math.round(math.avg(b1, b2)), bull ? math.min(p1, p2) : math.max(p1, p2), smtTxt, bull ? label.style_label_up : label.style_label_down, cText))
  359. f_trimDraw(smtLines, smtLbls, smtMax)
  360.  
  361. var float lastPlPx = na
  362. var int lastPlBar = na
  363. var float lastCmpPlPx = na
  364. var float lastPhPx = na
  365. var int lastPhBar = na
  366. var float lastCmpPhPx = na
  367. var int lastBullSmtBar = -10000
  368. var int lastBearSmtBar = -10000
  369.  
  370. if not na(smtPl)
  371. int thisBar = bar_index - smtLen
  372. float thisPx = smtPl
  373. float cmpPx = corrLow[smtLen]
  374. if not na(lastPlPx) and not na(lastCmpPlPx)
  375. bool divA = thisPx > lastPlPx and cmpPx < lastCmpPlPx
  376. bool divB = thisPx < lastPlPx and cmpPx > lastCmpPlPx
  377. if divA or divB
  378. lastBullSmtBar := thisBar
  379. f_drawSmt(true, lastPlBar, lastPlPx, thisBar, thisPx)
  380. lastPlPx := thisPx
  381. lastPlBar := thisBar
  382. lastCmpPlPx := cmpPx
  383.  
  384. if not na(smtPh)
  385. int thisBar2 = bar_index - smtLen
  386. float thisPx2 = smtPh
  387. float cmpPx2 = corrHigh[smtLen]
  388. if not na(lastPhPx) and not na(lastCmpPhPx)
  389. bool divA2 = thisPx2 < lastPhPx and cmpPx2 > lastCmpPhPx
  390. bool divB2 = thisPx2 > lastPhPx and cmpPx2 < lastCmpPhPx
  391. if divA2 or divB2
  392. lastBearSmtBar := thisBar2
  393. f_drawSmt(false, lastPhBar, lastPhPx, thisBar2, thisPx2)
  394. lastPhPx := thisPx2
  395. lastPhBar := thisBar2
  396. lastCmpPhPx := cmpPx2
  397.  
  398. var line rtSmtLine = na
  399. if smtRealtime and showSMT and barstate.islast
  400. bool rtBull = low < low[1] and corrLow > corrLow[1]
  401. bool rtBear = high > high[1] and corrHigh < corrHigh[1]
  402. if not na(rtSmtLine)
  403. line.delete(rtSmtLine)
  404. rtSmtLine := na
  405. if rtBull
  406. rtSmtLine := line.new(bar_index - 1, low[1], bar_index, low, color = cSmtBull, style = SMT_STY, width = SMT_W)
  407. else if rtBear
  408. rtSmtLine := line.new(bar_index - 1, high[1], bar_index, high, color = cSmtBear, style = SMT_STY, width = SMT_W)
  409.  
  410. bool smtRecentBull = bar_index - lastBullSmtBar <= (smtLook + smtLen)
  411. bool smtRecentBear = bar_index - lastBearSmtBar <= (smtLook + smtLen)
  412.  
  413. Swing liqHi = f_lastUnswept(swHighs)
  414. Swing liqLo = f_lastUnswept(swLows)
  415.  
  416. if not na(liqHi) and bar_index - liqHi.idx <= sweepBars and high > liqHi.price and close < liqHi.price and bar_index > liqHi.idx
  417. liqHi.swept := true
  418. sweepHiBar := bar_index
  419. sweepHiPrice := high
  420. sweepHiSwing := liqHi.idx
  421. sweepHiSMT := showSMT and smtRecentBear
  422. newSweepHi := true
  423. if not na(liqLo) and bar_index - liqLo.idx <= sweepBars and low < liqLo.price and close > liqLo.price and bar_index > liqLo.idx
  424. liqLo.swept := true
  425. sweepLoBar := bar_index
  426. sweepLoPrice := low
  427. sweepLoSwing := liqLo.idx
  428. sweepLoSMT := showSMT and smtRecentBull
  429. newSweepLo := true
  430.  
  431. f_markSwept(array<Swing> arr, bool isHighArr) =>
  432. if arr.size() > 0
  433. for i = 0 to arr.size() - 1
  434. Swing s = arr.get(i)
  435. bool crossed = isHighArr ? high > s.price : low < s.price
  436. if not s.swept and crossed and s.idx < bar_index
  437. s.swept := true
  438.  
  439. f_markSwept(swHighs, true)
  440. f_markSwept(swLows, false)
  441.  
  442. var array<line> liqLines = array.new<line>()
  443. var array<label> liqLbls = array.new<label>()
  444.  
  445. if newSweepHi and showSweep
  446. liqLines.push(line.new(sweepHiSwing, liqHi.price, bar_index, liqHi.price, color = cLine, style = AUX_STY, width = lineW))
  447. liqLbls.push(f_lbl(bar_index, high, "$$$", label.style_label_down, cText))
  448. if newSweepLo and showSweep
  449. liqLines.push(line.new(sweepLoSwing, liqLo.price, bar_index, liqLo.price, color = cLine, style = AUX_STY, width = lineW))
  450. liqLbls.push(f_lbl(bar_index, low, "$$$", label.style_label_up, cText))
  451. f_trimDraw(liqLines, liqLbls, maxSweepShow)
  452.  
  453. type Setup
  454. int dir
  455. int mssBar
  456. float mssLevel
  457. int fvgBar
  458. float fvgTop
  459. float fvgBot
  460. float bbTop
  461. float bbBot
  462. int bbBar
  463. float entry
  464. float sl
  465. float tp1
  466. float tp2
  467. bool smt
  468. bool pdaOK
  469. bool prevDaySweep
  470. string session
  471. string grade
  472. string status
  473. bool filled
  474. line lMSS
  475. label lbMSS
  476. box bFVG
  477. box bBB
  478. line lEntry
  479. label lbEntry
  480. line lSL
  481. label lbSL
  482. line lTP1
  483. label lbTP1
  484. line lTP2
  485. label lbTP2
  486. box bRisk
  487. box bReward
  488.  
  489. var array<Setup> setups = array.new<Setup>()
  490. var Setup cur = na
  491.  
  492. var float pdh = na
  493. var float pdl = na
  494. var float dayHi = na
  495. var float dayLo = na
  496. var int dayHiBar = na
  497. var int dayLoBar = na
  498. var int pdhBarF = na
  499. var int pdlBarF = na
  500. var bool pdhSwept = false
  501. var bool pdlSwept = false
  502.  
  503. if newDay
  504. pdh := dayHi
  505. pdl := dayLo
  506. pdhBarF := dayHiBar
  507. pdlBarF := dayLoBar
  508. pdhSwept := false
  509. pdlSwept := false
  510. dayHi := high
  511. dayLo := low
  512. dayHiBar := bar_index
  513. dayLoBar := bar_index
  514. else
  515. if high >= dayHi or na(dayHi)
  516. dayHi := high
  517. dayHiBar := bar_index
  518. if low <= dayLo or na(dayLo)
  519. dayLo := low
  520. dayLoBar := bar_index
  521. if not na(pdh) and high > pdh
  522. pdhSwept := true
  523. if not na(pdl) and low < pdl
  524. pdlSwept := true
  525.  
  526. f_findDisplacementFVG(int fromBar, int toBar, bool bullish) =>
  527. int fb = na
  528. float ft = na
  529. float fbt = na
  530. int start = bar_index - toBar
  531. int stop = bar_index - fromBar
  532. if start >= 0 and stop >= start
  533. for o = start to stop
  534. if o + 2 < 4900
  535. float top = bullish ? low[o] : low[o + 2]
  536. float bot = bullish ? high[o + 2] : high[o]
  537. bool dispOK = bullish ? close[o + 1] > open[o + 1] : close[o + 1] < open[o + 1]
  538. if top > bot and (top - bot) >= fvgMinAtr * atr and dispOK
  539. fb := bar_index - o - 1
  540. ft := top
  541. fbt := bot
  542. break
  543. [fb, ft, fbt]
  544.  
  545.  
  546. f_breakerFromSwing(int swingBar, float swingPrice, bool isShort) =>
  547. int off = bar_index - swingBar
  548. float opp = isShort ? high[off] : low[off]
  549. [swingBar, isShort ? opp : swingPrice, isShort ? swingPrice : opp]
  550.  
  551. f_delSetup(Setup s) =>
  552. line.delete(s.lMSS), label.delete(s.lbMSS)
  553. box.delete(s.bFVG)
  554. box.delete(s.bBB)
  555. line.delete(s.lEntry), label.delete(s.lbEntry)
  556. line.delete(s.lSL), label.delete(s.lbSL)
  557. line.delete(s.lTP1), label.delete(s.lbTP1)
  558. line.delete(s.lTP2), label.delete(s.lbTP2)
  559. box.delete(s.bRisk), box.delete(s.bReward)
  560.  
  561. bool bearMSS = false
  562. bool bullMSS = false
  563. Swing refLo = na
  564. Swing refHi = na
  565.  
  566. allowShort = biasMode != "Bullish"
  567. allowLong = biasMode != "Bearish"
  568.  
  569. if allowShort and newSweepHi
  570. waitingForBearMSS := true
  571. if allowLong and newSweepLo
  572. waitingForBullMSS := true
  573.  
  574. if waitingForBearMSS and not na(sweepHiBar) and bar_index - sweepHiBar > mssMaxWait
  575. waitingForBearMSS := false
  576. if waitingForBullMSS and not na(sweepLoBar) and bar_index - sweepLoBar > mssMaxWait
  577. waitingForBullMSS := false
  578.  
  579. f_findMssPivot(array<int> barsArr, array<float> pricesArr) =>
  580. int tBar = na
  581. float tPrice = na
  582. if barsArr.size() > 0
  583. for k = barsArr.size() - 1 to 0
  584. int b = barsArr.get(k)
  585. if b < bar_index and (bar_index - b <= mssMaxWait + mssRight)
  586. tBar := b
  587. tPrice := pricesArr.get(k)
  588. break
  589. [tBar, tPrice]
  590.  
  591. if waitingForBearMSS and not na(sweepHiBar) and bar_index > sweepHiBar and bar_index - sweepHiBar <= mssMaxWait
  592. [targetLBar, targetLPrice] = f_findMssPivot(mssLowBars, mssLowPrices)
  593. if not na(targetLBar)
  594. float brk = mssType == "Close" ? close : low
  595. if brk < targetLPrice and bar_index > targetLBar
  596. bearMSS := true
  597. refLo := Swing.new(targetLBar, targetLPrice, false)
  598. waitingForBearMSS := false
  599.  
  600. if waitingForBullMSS and not na(sweepLoBar) and bar_index > sweepLoBar and bar_index - sweepLoBar <= mssMaxWait and not bearMSS
  601. [targetHBar, targetHPrice] = f_findMssPivot(mssHighBars, mssHighPrices)
  602. if not na(targetHBar)
  603. float brk = mssType == "Close" ? close : high
  604. if brk > targetHPrice and bar_index > targetHBar
  605. bullMSS := true
  606. refHi := Swing.new(targetHBar, targetHPrice, false)
  607. waitingForBullMSS := false
  608.  
  609. f_grade(bool smt, bool hasFvg, bool pda, bool kz) =>
  610. (smt and hasFvg and pda and kz) ? "A+" : hasFvg ? "B+" : "C"
  611.  
  612. f_gradeOK(string g) =>
  613. setupGrade == "Any" ? true : setupGrade == "B+" ? (g == "A+" or g == "B+") : g == "A+"
  614.  
  615. bool newSetup = false
  616.  
  617. if bearMSS and (not onlySession or inKZ)
  618. [fb, ft, fbt] = f_findDisplacementFVG(sweepHiBar, bar_index, false)
  619. [bbb, bbt, bbbt] = f_breakerFromSwing(refLo.idx, refLo.price, true)
  620. bool hasFvg = not na(fb)
  621. float rTop = sweepHiPrice
  622. float rBot = refLo.price
  623. float eq = (rTop + rBot) / 2
  624. float ent = hasFvg ? (entryMode == "FVG CE" ? (ft + fbt) / 2 : entryMode == "FVG Edge" ? fbt : entryMode == "Breaker Block" and not na(bbbt) ? bbbt : refLo.price) : (entryMode == "Breaker Block" and not na(bbbt) ? bbbt : refLo.price)
  625. bool pda = ent >= eq
  626. float sl = slMode == "Sweep" ? sweepHiPrice : slMode == "FVG Far Edge" and hasFvg ? ft + slBufTicks * tick : sweepHiPrice + slBufTicks * tick
  627. float risk = sl - ent
  628. [liqA, liqB] = f_nextLiq(swLows, ent - risk * 0.5, true)
  629. float tp1 = tpMode == "Fixed RR" ? ent - risk * tp1RR : liqA
  630. float tp2 = tpMode == "Fixed RR" ? ent - risk * tp2RR : liqB
  631. tp1 := na(tp1) ? ent - risk * tp1RR : tp1
  632. tp2 := na(tp2) or tp2 >= tp1 ? ent - risk * tp2RR : tp2
  633. string g = f_grade(sweepHiSMT, hasFvg, pda, inKZ)
  634. if risk > 0 and f_gradeOK(g) and (ent - tp1) / risk >= minRR
  635. Setup s = Setup.new()
  636. s.dir := -1
  637. s.mssBar := bar_index, s.mssLevel := refLo.price
  638. s.fvgBar := fb, s.fvgTop := ft, s.fvgBot := fbt
  639. s.bbBar := bbb, s.bbTop := bbt, s.bbBot := bbbt
  640. s.entry := ent, s.sl := sl, s.tp1 := tp1, s.tp2 := tp2
  641. s.smt := sweepHiSMT, s.pdaOK := pda, s.prevDaySweep := pdhSwept
  642. s.session := sessName, s.grade := g, s.status := "Pending", s.filled := false
  643. setups.push(s)
  644. cur := s
  645. newSetup := true
  646. sweepHiBar := na
  647.  
  648. if bullMSS and (not onlySession or inKZ) and not newSetup
  649. [fb, ft, fbt] = f_findDisplacementFVG(sweepLoBar, bar_index, true)
  650. [bbb, bbt, bbbt] = f_breakerFromSwing(refHi.idx, refHi.price, false)
  651. bool hasFvg = not na(fb)
  652. float rBot = sweepLoPrice
  653. float rTop = refHi.price
  654. float eq = (rTop + rBot) / 2
  655. float ent = hasFvg ? (entryMode == "FVG CE" ? (ft + fbt) / 2 : entryMode == "FVG Edge" ? ft : entryMode == "Breaker Block" and not na(bbt) ? bbt : refHi.price) : (entryMode == "Breaker Block" and not na(bbt) ? bbt : refHi.price)
  656. bool pda = ent <= eq
  657. float sl = slMode == "Sweep" ? sweepLoPrice : slMode == "FVG Far Edge" and hasFvg ? fbt - slBufTicks * tick : sweepLoPrice - slBufTicks * tick
  658. float risk = ent - sl
  659. [liqA, liqB] = f_nextLiq(swHighs, ent + risk * 0.5, false)
  660. float tp1 = tpMode == "Fixed RR" ? ent + risk * tp1RR : liqA
  661. float tp2 = tpMode == "Fixed RR" ? ent + risk * tp2RR : liqB
  662. tp1 := na(tp1) ? ent + risk * tp1RR : tp1
  663. tp2 := na(tp2) or tp2 <= tp1 ? ent + risk * tp2RR : tp2
  664. string g = f_grade(sweepLoSMT, hasFvg, pda, inKZ)
  665. if risk > 0 and f_gradeOK(g) and (tp1 - ent) / risk >= minRR
  666. Setup s = Setup.new()
  667. s.dir := 1
  668. s.mssBar := bar_index, s.mssLevel := refHi.price
  669. s.fvgBar := fb, s.fvgTop := ft, s.fvgBot := fbt
  670. s.bbBar := bbb, s.bbTop := bbt, s.bbBot := bbbt
  671. s.entry := ent, s.sl := sl, s.tp1 := tp1, s.tp2 := tp2
  672. s.smt := sweepLoSMT, s.pdaOK := pda, s.prevDaySweep := pdlSwept
  673. s.session := sessName, s.grade := g, s.status := "Pending", s.filled := false
  674. setups.push(s)
  675. cur := s
  676. newSetup := true
  677. sweepLoBar := na
  678.  
  679. if newSetup
  680. Setup s = cur
  681. color dirC = s.dir == 1 ? cBull : cBear
  682. string tag = s.dir == 1 ? "ICTKESIK+" : "ICTKESIK-"
  683. int xEnd = bar_index + tradeExt
  684. Swing ref = s.dir == -1 ? refLo : refHi
  685. int mssCenterX = math.round((ref.idx + bar_index) / 2)
  686. if showMSS
  687. s.lMSS := line.new(ref.idx, s.mssLevel, bar_index, s.mssLevel, color = dirC, width = lineW)
  688. s.lbMSS := f_lbl(mssCenterX, s.mssLevel, "MSS", s.dir == -1 ? label.style_label_up : label.style_label_down, dirC)
  689. if showFVG and not na(s.fvgBar)
  690. s.bFVG := box.new(s.fvgBar, s.fvgTop, xEnd, s.fvgBot, border_color = color.new(cLine, 100), bgcolor = cFVG)
  691. if showBB
  692. s.bBB := box.new(s.bbBar, s.bbTop, bar_index, s.bbBot, border_color = color.new(cLine, 100), bgcolor = cBB)
  693. s.lEntry := line.new(bar_index, s.entry, xEnd, s.entry, color = dirC, width = lineW + 1)
  694. s.lbEntry := f_lbl(xEnd, s.entry, tag, label.style_label_left, dirC)
  695. s.lSL := line.new(bar_index, s.sl, xEnd, s.sl, color = cLine, style = AUX_STY, width = lineW)
  696. s.lbSL := f_lbl(xEnd, s.sl, "SL", label.style_label_left, cText)
  697. s.lTP1 := line.new(bar_index, s.tp1, bar_index + 1, s.tp1, color = cLine, style = AUX_STY, width = lineW)
  698. s.lbTP1 := f_lbl(bar_index + 1, s.tp1, "TP1", label.style_label_left, cText)
  699. s.lTP2 := line.new(bar_index, s.tp2, bar_index + 1, s.tp2, color = cLine, style = AUX_STY, width = lineW)
  700. s.lbTP2 := f_lbl(bar_index + 1, s.tp2, "TP2", label.style_label_left, cText)
  701. if showRRBox
  702. s.bRisk := box.new(bar_index, s.dir == -1 ? s.sl : s.entry, xEnd, s.dir == -1 ? s.entry : s.sl, border_color = color.new(cLine, 100), bgcolor = color.new(dirC, 88))
  703. s.bReward := box.new(bar_index, s.dir == -1 ? s.entry : s.tp1, xEnd, s.dir == -1 ? s.tp1 : s.entry, border_color = color.new(cLine, 100), bgcolor = color.new(cLine, 92))
  704. if s.dir == -1
  705. liqLbls.push(f_lbl(bar_index, s.tp1, "Sellside Liquidity", label.style_label_upper_right, cText))
  706. else
  707. liqLbls.push(f_lbl(bar_index, s.tp1, "Buyside Liquidity", label.style_label_lower_right, cText))
  708. while setups.size() > showHist
  709. f_delSetup(setups.shift())
  710.  
  711. bool alertFill = false
  712. bool alertTP1 = false
  713. bool alertTP2 = false
  714. bool alertSL = false
  715.  
  716. if setups.size() > 0
  717. for i = 0 to setups.size() - 1
  718. Setup s = setups.get(i)
  719. if s.status == "Stopped" or s.status == "TP2" or s.status == "Expired"
  720. continue
  721. if not s.filled
  722. bool touched = s.dir == -1 ? high >= s.entry : low <= s.entry
  723. if touched and bar_index > s.mssBar
  724. s.filled := true
  725. s.status := "Active"
  726. alertFill := true
  727. label.set_text(s.lbEntry, (s.dir == 1 ? "ICTKESIK+" : "ICTKESIK-") + " ✓")
  728. if s.filled
  729. bool hitSL = s.dir == -1 ? high >= s.sl : low <= s.sl
  730. bool hitTP1 = s.dir == -1 ? low <= s.tp1 : high >= s.tp1
  731. bool hitTP2 = s.dir == -1 ? low <= s.tp2 : high >= s.tp2
  732. if hitSL and invalidateB and s.status == "Active"
  733. s.status := "Stopped"
  734. alertSL := true
  735. label.set_text(s.lbSL, "SL ✗")
  736. label.set_textcolor(s.lbSL, cNO)
  737. else
  738. if hitTP1 and s.status == "Active"
  739. s.status := "TP1"
  740. alertTP1 := true
  741. label.set_text(s.lbTP1, "TP1 ✓")
  742. label.set_textcolor(s.lbTP1, cOK)
  743. if hitTP2 and (s.status == "TP1" or s.status == "Active")
  744. s.status := "TP2"
  745. alertTP2 := true
  746. label.set_text(s.lbTP2, "TP2 ✓")
  747. label.set_textcolor(s.lbTP2, cOK)
  748. if not s.filled and bar_index > s.mssBar + tradeExt
  749. s.status := "Expired"
  750.  
  751. [autoA, autoB] = f_autoHTF()
  752. htf1 = htfMode == "Automatic" ? autoA : htf1Man
  753. htf2 = htfMode == "Automatic" ? autoB : htf2Man
  754.  
  755. type HtfFVG
  756. box bx
  757. label lb
  758. line ce
  759. float top
  760. float bot
  761. bool bull
  762. string tf
  763.  
  764. var array<HtfFVG> htfFVGs = array.new<HtfFVG>()
  765.  
  766. [h1H, h1L, h3H, h3L, h1T] = request.security(syminfo.tickerid, htf1, [high[1], low[1], high[3], low[3], time[1]], lookahead = barmerge.lookahead_on)
  767. [g1H, g1L, g3H, g3L, g1T] = request.security(syminfo.tickerid, htf2, [high[1], low[1], high[3], low[3], time[1]], lookahead = barmerge.lookahead_on)
  768.  
  769. f_addHtf(string tf, float c1H, float c1L, float c3H, float c3L, int t1) =>
  770. bool bullG = c1L > c3H
  771. bool bearG = c1H < c3L
  772. if (bullG or bearG) and showHTF
  773. float top = bullG ? c1L : c3L
  774. float bot = bullG ? c3H : c1H
  775. int x0 = f_barAtTime(t1)
  776. x0 := na(x0) ? bar_index : x0
  777. bool dup = false
  778. if htfFVGs.size() > 0
  779. for i = 0 to htfFVGs.size() - 1
  780. HtfFVG f = htfFVGs.get(i)
  781. if f.tf == tf and math.abs(f.top - top) < tick and math.abs(f.bot - bot) < tick
  782. dup := true
  783. break
  784. if not dup
  785. string name = f_tfName(tf) + " FVG"
  786. box b = box.new(x0, top, bar_index + htfExtend, bot, border_color = color.new(cLine, 100), bgcolor = cHTF)
  787. label l = f_lbl(bar_index + htfExtend, (top + bot) / 2, name + (htfShowCE ? " ●" : ""), label.style_label_left, cText)
  788. line c = htfShowCE ? line.new(x0, (top + bot) / 2, bar_index + htfExtend, (top + bot) / 2, color = color.new(cLine, 60), style = AUX_STY, width = lineW) : na
  789. htfFVGs.push(HtfFVG.new(b, l, c, top, bot, bullG, tf))
  790. int cnt = 0
  791. for i = htfFVGs.size() - 1 to 0
  792. HtfFVG f = htfFVGs.get(i)
  793. if f.tf == tf
  794. cnt += 1
  795. if cnt > htfCount
  796. box.delete(f.bx), label.delete(f.lb), line.delete(f.ce)
  797. htfFVGs.remove(i)
  798.  
  799. if showHTF and ta.change(time(htf1)) != 0 and timeframe.in_seconds(htf1) > timeframe.in_seconds()
  800. f_addHtf(htf1, h1H, h1L, h3H, h3L, h1T)
  801. if showHTF and ta.change(time(htf2)) != 0 and timeframe.in_seconds(htf2) > timeframe.in_seconds()
  802. f_addHtf(htf2, g1H, g1L, g3H, g3L, g1T)
  803.  
  804. if htfFVGs.size() > 0
  805. for i = htfFVGs.size() - 1 to 0
  806. HtfFVG f = htfFVGs.get(i)
  807. bool gone = false
  808. if htfMitig == "Close through"
  809. gone := f.bull ? close < f.bot : close > f.top
  810. else if htfMitig == "Wick through"
  811. gone := f.bull ? low < f.bot : high > f.top
  812. if gone
  813. box.delete(f.bx), label.delete(f.lb), line.delete(f.ce)
  814. htfFVGs.remove(i)
  815. else
  816. box.set_right(f.bx, bar_index + htfExtend)
  817. label.set_x(f.lb, bar_index + htfExtend)
  818. if not na(f.ce)
  819. line.set_x2(f.ce, bar_index + htfExtend)
  820.  
  821. type KeyLvl
  822. line ln
  823. label lb
  824. float price
  825. bool isHigh
  826. bool done
  827.  
  828. var array<KeyLvl> keyLvls = array.new<KeyLvl>()
  829.  
  830. f_addKey(float price, int fromBar, bool isHigh, string name) =>
  831. if not na(price) and not na(fromBar)
  832. line l = line.new(fromBar, price, bar_index + keyExt, price, color = cLine, style = AUX_STY, width = lineW)
  833. label b = f_lbl(bar_index + keyExt, price, name, label.style_label_left, cText)
  834. keyLvls.push(KeyLvl.new(l, b, price, isHigh, false))
  835. while keyLvls.size() > 12
  836. KeyLvl k = keyLvls.shift()
  837. line.delete(k.ln), label.delete(k.lb)
  838.  
  839. if showPD and newDay and not na(pdh)
  840. f_addKey(pdh, pdhBarF, true, "PDH")
  841. f_addKey(pdl, pdlBarF, false, "PDL")
  842.  
  843. var float wkHi = na
  844. var float wkLo = na
  845. var int wkHiBar = na
  846. var int wkLoBar = na
  847. if newWeek
  848. if showPWK and not na(wkHi)
  849. f_addKey(wkHi, wkHiBar, true, "PWH")
  850. f_addKey(wkLo, wkLoBar, false, "PWL")
  851. wkHi := high, wkLo := low, wkHiBar := bar_index, wkLoBar := bar_index
  852. else
  853. if high >= wkHi or na(wkHi)
  854. wkHi := high, wkHiBar := bar_index
  855. if low <= wkLo or na(wkLo)
  856. wkLo := low, wkLoBar := bar_index
  857.  
  858. type SessHL
  859. float h
  860. float l
  861. int hb
  862. int lb
  863.  
  864. var SessHL sAsia = SessHL.new()
  865. var SessHL sLondon = SessHL.new()
  866. var SessHL sNYAM = SessHL.new()
  867.  
  868. f_sessTrack(SessHL t, bool inS, string name) =>
  869. if inS and not inS[1]
  870. t.h := high
  871. t.l := low
  872. t.hb := bar_index
  873. t.lb := bar_index
  874. else if inS
  875. if high >= t.h
  876. t.h := high
  877. t.hb := bar_index
  878. if low <= t.l
  879. t.l := low
  880. t.lb := bar_index
  881. else if inS[1] and showSessHL and not na(t.h)
  882. f_addKey(t.h, t.hb, true, name + " High")
  883. f_addKey(t.l, t.lb, false, name + " Low")
  884. t
  885.  
  886. f_sessTrack(sAsia, inAsia, "Asia")
  887. f_sessTrack(sLondon, inLondon, "London")
  888. f_sessTrack(sNYAM, inNYAM, "NY AM")
  889.  
  890. if keyLvls.size() > 0
  891. for i = 0 to keyLvls.size() - 1
  892. KeyLvl k = keyLvls.get(i)
  893. if k.done
  894. continue
  895. bool swept = k.isHigh ? high > k.price : low < k.price
  896. if swept and keyStopHit and bar_index > line.get_x1(k.ln)
  897. k.done := true
  898. line.set_x2(k.ln, bar_index)
  899. label.set_x(k.lb, bar_index)
  900. label.set_text(k.lb, label.get_text(k.lb) + " ✓")
  901. else
  902. line.set_x2(k.ln, bar_index + keyExt)
  903. label.set_x(k.lb, bar_index + keyExt)
  904.  
  905. var array<line> tLines = array.new<line>()
  906. var array<label> tLbls = array.new<label>()
  907.  
  908. f_timeLine(string sess, string name) =>
  909. int tSess = time(timeframe.period, sess, TZ)
  910. bool hit = not na(tSess) and na(tSess[1])
  911. if hit and showTimes
  912. tLines.push(line.new(bar_index, open, bar_index + tExt, open, color = color.new(cLine, 40), style = AUX_STY, width = lineW))
  913. tLbls.push(f_lbl(bar_index + tExt, open, name, label.style_label_left, cText))
  914. f_trimDraw(tLines, tLbls, 6)
  915.  
  916. f_timeLine(tLine1, "0:00 AM")
  917. f_timeLine(tLine2, "8:30 AM")
  918. if tShow3
  919. f_timeLine(tLine3, "9:30 AM")
  920.  
  921. var table tbl = na
  922. tSize = f_size(tblSize)
  923. cHead = color.new(#5d606b, 0)
  924. cRow = color.new(#9598a1, 70)
  925. cRowT = color.new(#f0f3fa, 0)
  926.  
  927. f_row(int r, string name, bool ok) =>
  928. table.cell(tbl, 0, r, name, text_color = cRowT, text_size = tSize, bgcolor = cRow, text_halign = text.align_left)
  929. table.cell(tbl, 1, r, ok ? "✅" : "❌", text_color = ok ? cOK : cNO, text_size = tSize, bgcolor = cRow)
  930.  
  931. if showTable
  932. if na(tbl)
  933. int totalRows = 1 + (rowSweep ? 1 : 0) + (rowMSS ? 1 : 0) + (rowFVG ? 1 : 0) + (rowBB ? 1 : 0) + (rowPDA ? 1 : 0) + (rowFilled ? 1 : 0) + (rowPrevDay ? 1 : 0) + (rowSMT ? 1 : 0) + (rowSession ? 1 : 0) + (rowStatus ? 1 : 0)
  934. tbl := table.new(f_pos(tblPos), 2, totalRows, frame_color = color.new(cLine, 60), frame_width = 1, border_color = color.new(cLine, 80), border_width = 1)
  935. table.cell(tbl, 0, 0, "Checklist", text_color = cRowT, text_size = tSize, bgcolor = cHead)
  936. table.cell(tbl, 1, 0, "Status", text_color = cRowT, text_size = tSize, bgcolor = cHead)
  937. if barstate.islast
  938. bool has = not na(cur)
  939. bool isShort = has and cur.dir == -1
  940. int r = 1
  941. if rowSweep
  942. f_row(r, "Liquidity Sweep", has)
  943. r += 1
  944. if rowMSS
  945. f_row(r, "Structure Shift", has)
  946. r += 1
  947. if rowFVG
  948. f_row(r, "Fair Value Gap", has and not na(cur.fvgBar))
  949. r += 1
  950. if rowBB
  951. f_row(r, "Breaker Block", has and not na(cur.bbBar))
  952. r += 1
  953. if rowPDA
  954. f_row(r, isShort ? "Within Premium" : "Within Discount", has and cur.pdaOK)
  955. r += 1
  956. if rowFilled
  957. f_row(r, "PDA Delivery", has and cur.filled)
  958. r += 1
  959. if rowPrevDay
  960. f_row(r, "Prev Day Sweep", has and cur.prevDaySweep)
  961. r += 1
  962. if rowSMT
  963. f_row(r, "SMT w/ " + corrShort, has and cur.smt)
  964. r += 1
  965. if rowSession
  966. table.cell(tbl, 0, r, "Session", text_color = cRowT, text_size = tSize, bgcolor = cRow, text_halign = text.align_left)
  967. table.cell(tbl, 1, r, has ? cur.session : sessName, text_color = cRowT, text_size = tSize, bgcolor = cRow)
  968. r += 1
  969. if rowStatus
  970. string st = has ? cur.status + (cur.grade == "A+" ? " • Unicorn" : cur.grade == "B+" ? " • B+" : "") : "Waiting"
  971. color stC = has ? (cur.status == "Stopped" ? cNO : cur.status == "TP1" or cur.status == "TP2" ? cOK : cur.dir == 1 ? cBull : cBear) : cRowT
  972. table.cell(tbl, 0, r, "Status", text_color = cRowT, text_size = tSize, bgcolor = cHead, text_halign = text.align_left)
  973. table.cell(tbl, 1, r, st, text_color = stC, text_size = tSize, bgcolor = cHead)
  974.  
  975. var table wm = na
  976. if showWM and barstate.islast
  977. if na(wm)
  978. wm := table.new(position.bottom_center, 1, 3)
  979. table.cell(wm, 0, 0, wmTitle + f_chartTf(), text_color = color.new(cText, 20), text_size = size.normal, text_font_family = font.family_monospace)
  980. if wmSub
  981. table.cell(wm, 0, 1, syminfo.ticker, text_color = color.new(cText, 30), text_size = size.small, text_font_family = font.family_monospace)
  982. table.cell(wm, 0, 2, str.format_time(time, "d MMM yyyy", TZ), text_color = color.new(cText, 40), text_size = size.tiny, text_font_family = font.family_monospace)
  983.  
  984. bgcolor(inKZ and onlySession ? color.new(cLine, 97) : na, title = "Killzone shade")
  985.  
  986.  
  987.  
  988. alertcondition(newSetup, "ICTKESIK Setup Formed", "2022 Model Pro+ | new ICTKESIK setup on {{ticker}} {{interval}}")
  989. alertcondition(alertFill, "ICTKESIK Entry Filled", "2022 Model Pro+ | entry filled on {{ticker}} {{interval}}")
  990. alertcondition(alertTP1, "ICTKESIK TP1 Hit", "2022 Model Pro+ | TP1 reached on {{ticker}}")
  991. alertcondition(alertTP2, "ICTKESIK TP2 Hit", "2022 Model Pro+ | TP2 reached on {{ticker}}")
  992. alertcondition(alertSL, "ICTKESIK Stop Hit", "2022 Model Pro+ | stop loss hit on {{ticker}}")
  993. alertcondition(newSweepHi and sweepHiSMT or newSweepLo and sweepLoSMT, "SMT Divergence", "2022 Model Pro+ | SMT Divergence on {{ticker}}")
Advertisement
Add Comment
Please, Sign In to add comment