ajiim

🎁

Oct 3rd, 2026
3,050
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 53.15 KB | None | 1 0
  1. //@version=6
  2. indicator("iFVG Ultimate+ Deluxe | DodgysDD", shorttitle = "iFVG Ultimate+ Deluxe", overlay = true, max_bars_back = 5000, max_lines_count = 500, max_boxes_count = 500, max_labels_count = 500)
  3.  
  4. grpGeneral = "General Settings"
  5. ifvgMode = input.string("Series", "Detection", options = ["Single", "Series"], group = grpGeneral)
  6. atrStrict = input.float(0.1, "ATR Strictness", minval = 0.0, step = 0.05, group = grpGeneral)
  7. biasMode = input.string("Neutral", "Bias", options = ["Neutral", "Bullish", "Bearish"], group = grpGeneral)
  8. minGradeStr = input.string("C", "Minimum Grade Displayed", options = ["C", "B", "A", "A+"], group = grpGeneral)
  9. hideLosing = input.bool(true, "Hide Losing Setups", group = grpGeneral)
  10. allowExtIFVG = input.bool(true, "Allow 7 - 15 Candle IFVGs", group = grpGeneral)
  11. requireBEIntact = input.bool(false, "Require BE not breached on inversion", group = grpGeneral)
  12. requireMacro = input.bool(false, "Require Macro Time", group = grpGeneral)
  13. onlyShowSwept = input.bool(true, "Require Liquidity Sweep", group = grpGeneral)
  14. onlyShowHtfAlign = input.bool(true, "Require HTF PDA Delivery", group = grpGeneral)
  15. setupHistory = input.int(3, "Number of Setups Displayed", minval = 0, maxval = 50, group = grpGeneral)
  16. confWindow = input.int(30, "Confluence Lookback (bars)", minval = 5, maxval = 300, group = grpGeneral)
  17.  
  18. grpIFVG = "IFVG"
  19. showRawFvg = input.bool(false, "Show Pending FVGs", group = grpIFVG)
  20. colFvgBull = input.color(color.new(#787b86, 75), "Bullish FVG", group = grpIFVG, inline = "fvg")
  21. colFvgBear = input.color(color.new(#787b86, 75), "Bearish FVG", group = grpIFVG, inline = "fvg")
  22. colIfvgBox = input.color(color.new(#5d606b, 60), "IFVG Box", group = grpIFVG, inline = "ifvg")
  23. ifvgTransp = input.int(50, "IFVG Transparency", minval = 0, maxval = 100, group = grpIFVG)
  24. showIfvgCE = input.bool(false, "Show CE", group = grpIFVG, inline = "ifvg")
  25.  
  26. grpLiquidity = "Liquidity"
  27. htfMode = input.string("Auto", "Alignment Mode", options = ["Auto", "Custom"], group = grpLiquidity, inline = "htf")
  28. customPivot = input.int(10, "Custom Swing Length", minval = 2, maxval = 50, group = grpLiquidity, inline = "htf")
  29. showSweep = input.bool(true, "Show Sweeps", group = grpLiquidity)
  30. sweepColor = input.color(color.new(#4a4a4a, 0), "Sweep Color", group = grpLiquidity, inline = "sw")
  31. sweepStyleStr = input.string("Dotted", "Style", options = ["Dotted", "Dashed", "Solid"], group = grpLiquidity, inline = "sw")
  32. sweepLabelText = input.string("$$$", "Label Text", group = grpLiquidity)
  33. sweepKeep = input.int(5, "Sweeps Kept", minval = 1, maxval = 50, group = grpLiquidity)
  34. showEq = input.bool(true, "Show Relative Equal Highs/Lows", group = grpLiquidity, inline = "eq")
  35. eqTol = input.float(0.1, "Tolerance (ATR)", minval = 0.01, step = 0.01, group = grpLiquidity, inline = "eq")
  36. colEq = input.color(color.new(#787b86, 0), "EQ Color", group = grpLiquidity)
  37. showNearestLiq = input.bool(false, "Show Nearest BSL / SSL", group = grpLiquidity, inline = "nl")
  38. colNearestLiq = input.color(color.new(#4a4a4a, 0), "", group = grpLiquidity, inline = "nl")
  39.  
  40. grpSess = "Session Liquidity"
  41. showAsia = input.bool(true, "Asia", group = grpSess, inline = "a")
  42. asiaSess = input.session("2000-0000", "", group = grpSess, inline = "a")
  43. colAsia = input.color(color.new(#787b86, 0), "", group = grpSess, inline = "a")
  44. showLondon = input.bool(true, "London", group = grpSess, inline = "l")
  45. londonSess = input.session("0200-0500", "", group = grpSess, inline = "l")
  46. colLondon = input.color(color.new(#787b86, 0), "", group = grpSess, inline = "l")
  47. showNyAm = input.bool(true, "NY AM", group = grpSess, inline = "n")
  48. nyAmSess = input.session("0930-1100", "", group = grpSess, inline = "n")
  49. colNyAm = input.color(color.new(#4a4a4a, 0), "", group = grpSess, inline = "n")
  50. showNyPm = input.bool(true, "NY PM", group = grpSess, inline = "p")
  51. nyPmSess = input.session("1330-1600", "", group = grpSess, inline = "p")
  52. colNyPm = input.color(color.new(#787b86, 0), "", group = grpSess, inline = "p")
  53. showSessBox = input.bool(false, "Show Session Boxes", group = grpSess)
  54.  
  55. grpKey = "Key Levels & Opens"
  56. showPD = input.bool(false, "Previous Day H/L", group = grpKey, inline = "pd")
  57. colPD = input.color(color.new(#787b86, 0), "", group = grpKey, inline = "pd")
  58. showPW = input.bool(false, "Previous Week H/L", group = grpKey, inline = "pw")
  59. colPW = input.color(color.new(#787b86, 0), "", group = grpKey, inline = "pw")
  60. showOpen00 = input.bool(false, "Midnight Open", group = grpKey, inline = "o1")
  61. showOpen830 = input.bool(false, "08:30 Open", group = grpKey, inline = "o1")
  62. showOpen930 = input.bool(false, "09:30 Open", group = grpKey, inline = "o1")
  63. colOpens = input.color(color.new(#9598a1, 0), "Opens Color", group = grpKey)
  64. keyLookback = input.int(100, "Lookback (bars)", minval = 10, maxval = 2000, group = grpKey)
  65.  
  66. grpHtf = "HTF FVG"
  67. showHtfFvg = input.bool(true, "Show HTF FVG", group = grpHtf)
  68. showHtfCE = input.bool(true, "Show CE", group = grpHtf)
  69. maxHtfZones = input.int(2, "Max Zones per Timeframe", minval = 1, maxval = 10, group = grpHtf)
  70. htfOn1 = input.bool(true, "TF 1", group = grpHtf, inline = "t1")
  71. htfTf1 = input.timeframe("5", "", group = grpHtf, inline = "t1")
  72. htfOn2 = input.bool(true, "TF 2", group = grpHtf, inline = "t2")
  73. htfTf2 = input.timeframe("15", "", group = grpHtf, inline = "t2")
  74. htfOn3 = input.bool(false, "TF 3", group = grpHtf, inline = "t3")
  75. htfTf3 = input.timeframe("60", "", group = grpHtf, inline = "t3")
  76. colHtfBull = input.color(color.new(#787b86, 80), "Bullish Zone", group = grpHtf, inline = "hc")
  77. colHtfBear = input.color(color.new(#787b86, 80), "Bearish Zone", group = grpHtf, inline = "hc")
  78. colHtfText = input.color(color.new(#4a4a4a, 0), "Text", group = grpHtf, inline = "hc")
  79.  
  80. grpSmt = "SMT"
  81. smtAuto = input.bool(true, "Auto Correlated Symbol", group = grpSmt)
  82. smtManual = input.symbol("CME_MINI:ES1!", "Manual Symbol", group = grpSmt)
  83. showSmt = input.bool(true, "Show SMT Divergences", group = grpSmt)
  84. showSsmt = input.bool(true, "Show SSMTs", group = grpSmt)
  85. smtShowM = input.bool(true, "Monthly", group = grpSmt, inline = "sc")
  86. smtShowW = input.bool(true, "Weekly", group = grpSmt, inline = "sc")
  87. smtShowD = input.bool(true, "Daily", group = grpSmt, inline = "sc")
  88. smtShow90 = input.bool(true, "90m", group = grpSmt, inline = "sc")
  89. smtShowMicro = input.bool(true, "Micro", group = grpSmt, inline = "sc")
  90. colSmt = input.color(color.new(#4a4a4a, 0), "SMT Color", group = grpSmt)
  91. smtKeep = input.int(3, "SMTs Kept", minval = 1, maxval = 100, group = grpSmt)
  92.  
  93. grpEntry = "Entry Markers"
  94. colLong = input.color(#2962ff, "DD+ Color", group = grpEntry, inline = "e")
  95. colShort = input.color(#f23645, "DD- Color", group = grpEntry, inline = "e")
  96. showSL = input.bool(true, "Stoploss", group = grpEntry, inline = "sl")
  97. colSL = input.color(color.new(#4a4a4a, 0), "", group = grpEntry, inline = "sl")
  98. slPlacement = input.string("Wick", "Placement", options = ["Wick", "Body", "IFVG"], group = grpEntry, inline = "sl")
  99. showBE = input.bool(false, "Break Even", group = grpEntry, inline = "be")
  100. colBE = input.color(color.new(#ff9800, 0), "", group = grpEntry, inline = "be")
  101. showTP = input.bool(true, "Take Profits", group = grpEntry, inline = "tp")
  102. colTP1 = input.color(color.new(#ff9800, 0), "TP1", group = grpEntry, inline = "tp")
  103. colTP2 = input.color(color.new(#4a4a4a, 0), "TP2", group = grpEntry, inline = "tp")
  104. showContracts = input.bool(true, "Suggested Contracts", group = grpEntry, inline = "rk")
  105. riskUsd = input.float(350.0, "Risk $", minval = 1.0, group = grpEntry, inline = "rk")
  106.  
  107. grpVol = "Volume Footprints"
  108. requireDelta = input.bool(false, "Require Delta Imbalance", group = grpVol, inline = "d")
  109. deltaRatio = input.float(1.5, "Ratio", minval = 1.0, step = 0.1, group = grpVol, inline = "d")
  110. colorCandles = input.bool(false, "Delta Candle Coloring", group = grpVol)
  111. colDeltaBuy = input.color(color.new(#089981, 0), "Buy Imbalance", group = grpVol, inline = "dc")
  112. colDeltaSell = input.color(color.new(#f23645, 0), "Sell Imbalance", group = grpVol, inline = "dc")
  113. showCandleVA = input.bool(false, "Per-Candle Value Area Boxes", group = grpVol)
  114. showVP = input.bool(true, "Volume Profile", group = grpVol)
  115. vpBars = input.int(100, "Profile Lookback", minval = 20, maxval = 1500, group = grpVol)
  116. vpRows = input.int(70, "Rows", minval = 10, maxval = 200, group = grpVol)
  117. vpWidth = input.int(25, "Max Width (bars)", minval = 10, maxval = 200, group = grpVol)
  118. vpOffset = input.int(20, "Offset (bars)", minval = 0, maxval = 300, group = grpVol)
  119. vpVaPct = input.int(70, "Value Area %", minval = 10, maxval = 100, group = grpVol)
  120. colVpVa = input.color(color.new(#f7b32b, 10), "Value Area", group = grpVol, inline = "vp")
  121. colVpOut = input.color(color.new(#5d606b, 20), "Outside", group = grpVol, inline = "vp")
  122.  
  123. grpNwog = "New Week Opening Gaps"
  124. showNwog = input.bool(false, "Show NWOG", group = grpNwog)
  125. nwogCount = input.int(1, "Visible Count", minval = 1, maxval = 10, group = grpNwog)
  126. nwogMode = input.string("Recent", "Selection", options = ["Recent", "Closest"], group = grpNwog)
  127. nwogLookback = input.int(10, "Stored Weeks", minval = 1, maxval = 52, group = grpNwog)
  128. nwogMinTicks = input.int(4, "Min Gap (ticks)", minval = 0, group = grpNwog)
  129. colNwog = input.color(color.new(#787b86, 85), "Color", group = grpNwog)
  130.  
  131. grpTable = "Checklist"
  132. showTable = input.bool(true, "Show Checklist", group = grpTable)
  133. tablePosStr = input.string("Bottom Right", "Position", options = ["Top Right", "Middle Right", "Bottom Right", "Bottom Left", "Top Left"], group = grpTable)
  134.  
  135. grpAlerts = "Alerts"
  136. enableAlerts = input.bool(true, "Enable Alerts", group = grpAlerts)
  137. win1Enable = input.bool(true, "Window 1", group = grpAlerts, inline = "w1")
  138. win1Time = input.session("0930-1600", "", group = grpAlerts, inline = "w1")
  139. win2Enable = input.bool(false, "Window 2", group = grpAlerts, inline = "w2")
  140. win2Time = input.session("2000-0000", "", group = grpAlerts, inline = "w2")
  141. win3Enable = input.bool(false, "Window 3", group = grpAlerts, inline = "w3")
  142. win3Time = input.session("0200-0500", "", group = grpAlerts, inline = "w3")
  143. alSweep = input.bool(true, "Sweeps", group = grpAlerts, inline = "at1")
  144. alInv = input.bool(true, "Inversions", group = grpAlerts, inline = "at1")
  145. alPotInv = input.bool(false, "Potential Inversions", group = grpAlerts, inline = "at2")
  146. alInvalid = input.bool(true, "Invalidations", group = grpAlerts, inline = "at2")
  147. alMtf = input.bool(true, "MTF Confluence", group = grpAlerts, inline = "at3")
  148.  
  149. grpWm = "Watermark"
  150. showWatermark = input.bool(true, "Show?", group = grpWm, inline = "wm")
  151. wmColor = input.color(color.new(#f7b32b, 40), "", group = grpWm, inline = "wm")
  152.  
  153. const string TZ = "America/New_York"
  154. const int MAX_FVG = 40
  155. const int MAX_SWINGS = 40
  156. const int EQ_KEEP = 20
  157. const int SMT_MIN_SEP = 5
  158. const int EXT = 15
  159. noCol = color.new(color.white, 100)
  160.  
  161. sweepStyle = sweepStyleStr == "Dotted" ? line.style_dotted : sweepStyleStr == "Dashed" ? line.style_dashed : line.style_solid
  162. chartSec = timeframe.in_seconds()
  163.  
  164. type FVG
  165. float top
  166. float bot
  167. bool bull
  168. int left
  169. int created
  170. box bx
  171.  
  172. type HFVG
  173. float top
  174. float bot
  175. bool bull
  176. string tfName
  177. box bx
  178. line ce
  179.  
  180. type Liq
  181. float price
  182. int bar
  183. bool isHigh
  184. bool swept = false
  185.  
  186. type Sess
  187. string name
  188. float hi
  189. float lo
  190. int hiBar
  191. int loBar
  192. bool active = false
  193. bool hiSwept = false
  194. bool loSwept = false
  195. line lnH
  196. line lnL
  197. label lbH
  198. label lbL
  199. box bx
  200.  
  201. type Setup
  202. bool bull
  203. float entry
  204. float sl
  205. float be
  206. float tp1
  207. float tp2
  208. int start
  209. int status = 0
  210. bool tp1Hit = false
  211. string grade
  212. array<bool> checks
  213. box bx
  214. line ce
  215. line lEntry
  216. line lSl
  217. line lBe
  218. line lTp1
  219. line lTp2
  220. label lbEntry
  221. label lbSl
  222. label lbBe
  223. label lbTp1
  224. label lbTp2
  225. string txtFull
  226.  
  227. type SmtCyc
  228. string name
  229. float pHiA
  230. float pHiB
  231. int pHiBar
  232. float pLoA
  233. float pLoB
  234. int pLoBar
  235. float cHiA
  236. float cHiB
  237. int cHiBar
  238. float cLoA
  239. float cLoB
  240. int cLoBar
  241. bool bearDone = false
  242. bool bullDone = false
  243. bool inBearDone = false
  244. bool inBullDone = false
  245.  
  246. type Gap
  247. float top
  248. float bot
  249. int t
  250.  
  251. f_inSess(string s) =>
  252. not na(time(timeframe.period, s, TZ))
  253.  
  254. f_atTime(int h, int m) =>
  255. int t = timestamp(TZ, year(time, TZ), month(time, TZ), dayofmonth(time, TZ), h, m)
  256. time <= t and t < time_close
  257.  
  258. f_gradeRank(string g) =>
  259. g == "A+" ? 4 : g == "A" ? 3 : g == "B" ? 2 : 1
  260.  
  261. f_grade(int score) =>
  262. score >= 6 ? "A+" : score == 5 ? "A" : score == 4 ? "B" : "C"
  263.  
  264. f_recent(int last, int win) =>
  265. not na(last) and bar_index - last <= win
  266.  
  267. f_tfName(string tf) =>
  268. string r = tf
  269. if tf == "D" or tf == "1D"
  270. r := "D1"
  271. else if tf == "W" or tf == "1W"
  272. r := "W1"
  273. else if tf == "M" or tf == "1M"
  274. r := "MN"
  275. else
  276. float m = str.tonumber(tf)
  277. if not na(m)
  278. r := m >= 60 and m % 60 == 0 ? "H" + str.tostring(int(m / 60)) : "M" + str.tostring(int(m))
  279. r
  280.  
  281. f_delLine(line l) =>
  282. if not na(l)
  283. line.delete(l)
  284.  
  285. f_delLabel(label l) =>
  286. if not na(l)
  287. label.delete(l)
  288.  
  289. f_addLiq(array<float> ap, array<string> an, array<int> ab, float p, string n, int b) =>
  290. if not na(p)
  291. ap.push(p)
  292. an.push(n)
  293. ab.push(b)
  294.  
  295. f_target(array<float> ap, array<int> ab, bool up, float ref, int nth) =>
  296. float res = na
  297. int resBar = na
  298. float last = ref
  299. int n = ap.size()
  300. if n > 0 and not na(ref)
  301. for k = 1 to nth
  302. float tol = k == 1 ? syminfo.mintick : syminfo.mintick * 2
  303. float best = na
  304. int bestBar = na
  305. for i = 0 to n - 1
  306. float p = ap.get(i)
  307. if up ? p > last + tol : p < last - tol
  308. int pb = ab.get(i)
  309. if na(best) or (up ? p < best - syminfo.mintick * 2 : p > best + syminfo.mintick * 2)
  310. best := p
  311. bestBar := pb
  312. else if math.abs(p - best) <= syminfo.mintick * 2
  313. if up ? p < best : p > best
  314. best := p
  315. if not na(pb) and (na(bestBar) or pb < bestBar)
  316. bestBar := pb
  317. res := best
  318. resBar := bestBar
  319. if na(best)
  320. break
  321. last := best
  322. [res, resBar]
  323.  
  324. f_mergeNames(array<float> ap, array<string> an, float price) =>
  325. string s = ""
  326. if ap.size() > 0
  327. for i = 0 to ap.size() - 1
  328. if math.abs(ap.get(i) - price) <= syminfo.mintick * 2
  329. string n = an.get(i)
  330. if not str.contains(s, n)
  331. s := s == "" ? n : s + " / " + n
  332. s
  333.  
  334. method updateSess(Sess s, bool inS, bool show, color c) =>
  335. bool swLo = false
  336. bool swHi = false
  337. if show
  338. if inS and not s.active
  339. s.active := true
  340. s.hi := high
  341. s.lo := low
  342. s.hiBar := bar_index
  343. s.loBar := bar_index
  344. if showSessBox
  345. s.bx := box.new(bar_index, high, bar_index, low, border_color = color.new(c, 60), bgcolor = color.new(c, 92))
  346. else if inS and s.active
  347. if high > s.hi
  348. s.hi := high
  349. s.hiBar := bar_index
  350. if low < s.lo
  351. s.lo := low
  352. s.loBar := bar_index
  353. if not na(s.bx)
  354. box.set_top(s.bx, s.hi)
  355. box.set_bottom(s.bx, s.lo)
  356. box.set_right(s.bx, bar_index)
  357. else if not inS and s.active
  358. s.active := false
  359. f_delLine(s.lnH)
  360. f_delLine(s.lnL)
  361. f_delLabel(s.lbH)
  362. f_delLabel(s.lbL)
  363. s.hiSwept := false
  364. s.loSwept := false
  365. s.lnH := line.new(s.hiBar, s.hi, bar_index + EXT, s.hi, color = c, style = line.style_dotted)
  366. s.lnL := line.new(s.loBar, s.lo, bar_index + EXT, s.lo, color = c, style = line.style_dotted)
  367. s.lbH := label.new(bar_index + EXT, s.hi, s.name + ".H", style = label.style_label_left, color = noCol, textcolor = c, size = size.tiny)
  368. s.lbL := label.new(bar_index + EXT, s.lo, s.name + ".L", style = label.style_label_left, color = noCol, textcolor = c, size = size.tiny)
  369. if not s.active and not na(s.lnH)
  370. if not s.hiSwept
  371. if high > s.hi
  372. s.hiSwept := true
  373. swHi := close < s.hi
  374. line.set_x2(s.lnH, bar_index)
  375. label.set_x(s.lbH, bar_index)
  376. else
  377. line.set_x2(s.lnH, bar_index + EXT)
  378. label.set_x(s.lbH, bar_index + EXT)
  379. if not s.loSwept
  380. if low < s.lo
  381. s.loSwept := true
  382. swLo := close > s.lo
  383. line.set_x2(s.lnL, bar_index)
  384. label.set_x(s.lbL, bar_index)
  385. else
  386. line.set_x2(s.lnL, bar_index + EXT)
  387. label.set_x(s.lbL, bar_index + EXT)
  388. [swLo, swHi]
  389.  
  390. method addLiq(Sess s, bool show, array<float> ap, array<string> an, array<int> ab) =>
  391. if show and not s.active
  392. f_addLiq(ap, an, ab, s.hiSwept ? na : s.hi, s.name + ".H", s.hiBar)
  393. f_addLiq(ap, an, ab, s.loSwept ? na : s.lo, s.name + ".L", s.loBar)
  394.  
  395. method deleteDrawings(Setup s) =>
  396. if not na(s.bx)
  397. box.delete(s.bx)
  398. f_delLine(s.ce)
  399. f_delLine(s.lEntry)
  400. f_delLine(s.lSl)
  401. f_delLine(s.lBe)
  402. f_delLine(s.lTp1)
  403. f_delLine(s.lTp2)
  404. f_delLabel(s.lbEntry)
  405. f_delLabel(s.lbSl)
  406. f_delLabel(s.lbBe)
  407. f_delLabel(s.lbTp1)
  408. f_delLabel(s.lbTp2)
  409.  
  410. method finalize(Setup s) =>
  411. f_delLine(s.lSl)
  412. f_delLine(s.lBe)
  413. f_delLine(s.lTp1)
  414. f_delLine(s.lTp2)
  415. f_delLabel(s.lbSl)
  416. f_delLabel(s.lbBe)
  417. f_delLabel(s.lbTp1)
  418. f_delLabel(s.lbTp2)
  419. s.lSl := na
  420. s.lBe := na
  421. s.lTp1 := na
  422. s.lTp2 := na
  423. s.lbSl := na
  424. s.lbBe := na
  425. s.lbTp1 := na
  426. s.lbTp2 := na
  427. if not na(s.lbEntry)
  428. label.set_text(s.lbEntry, s.bull ? "DD+" : "DD-")
  429.  
  430. method stepSmt(SmtCyc c, bool newP, bool enabled, float aH, float aL, float bH, float bL, array<bool> drawn, array<line> lines, array<label> labels) =>
  431. bool bullS = false
  432. bool bearS = false
  433. if enabled and not na(bH) and not na(bL)
  434. if newP or na(c.cHiA)
  435. c.pHiA := c.cHiA
  436. c.pHiB := c.cHiB
  437. c.pHiBar := c.cHiBar
  438. c.pLoA := c.cLoA
  439. c.pLoB := c.cLoB
  440. c.pLoBar := c.cLoBar
  441. c.cHiA := aH
  442. c.cHiB := bH
  443. c.cHiBar := bar_index
  444. c.cLoA := aL
  445. c.cLoB := bL
  446. c.cLoBar := bar_index
  447. c.bearDone := false
  448. c.bullDone := false
  449. c.inBearDone := false
  450. c.inBullDone := false
  451. else
  452. if not c.inBearDone and bar_index - c.cHiBar >= SMT_MIN_SEP
  453. bool iA = aH > c.cHiA and bH <= c.cHiB
  454. bool iB = bH > c.cHiB and aH <= c.cHiA
  455. if iA or iB
  456. bearS := true
  457. c.inBearDone := true
  458. if showSmt and not drawn.get(1)
  459. drawn.set(1, true)
  460. lines.push(line.new(math.max(c.cHiBar, bar_index - 5000), c.cHiA, bar_index, aH, color = colSmt, width = 1))
  461. labels.push(label.new(bar_index, aH, "SMT", style = label.style_label_down, color = noCol, textcolor = colSmt, size = size.tiny))
  462. if not c.inBullDone and bar_index - c.cLoBar >= SMT_MIN_SEP
  463. bool iA = aL < c.cLoA and bL >= c.cLoB
  464. bool iB = bL < c.cLoB and aL >= c.cLoA
  465. if iA or iB
  466. bullS := true
  467. c.inBullDone := true
  468. if showSmt and not drawn.get(0)
  469. drawn.set(0, true)
  470. lines.push(line.new(math.max(c.cLoBar, bar_index - 5000), c.cLoA, bar_index, aL, color = colSmt, width = 1))
  471. labels.push(label.new(bar_index, aL, "SMT", style = label.style_label_up, color = noCol, textcolor = colSmt, size = size.tiny))
  472. if aH > c.cHiA and bH > c.cHiB
  473. c.inBearDone := false
  474. if aL < c.cLoA and bL < c.cLoB
  475. c.inBullDone := false
  476. if aH > c.cHiA
  477. c.cHiA := aH
  478. c.cHiBar := bar_index
  479. if bH > c.cHiB
  480. c.cHiB := bH
  481. if aL < c.cLoA
  482. c.cLoA := aL
  483. c.cLoBar := bar_index
  484. if bL < c.cLoB
  485. c.cLoB := bL
  486. if not na(c.pHiA) and not c.bearDone
  487. bool divA = aH > c.pHiA and c.cHiB <= c.pHiB
  488. bool divB = bH > c.pHiB and c.cHiA <= c.pHiA and aH >= c.cHiA
  489. if divA or divB
  490. bearS := true
  491. c.bearDone := true
  492. if showSsmt and not drawn.get(3)
  493. drawn.set(3, true)
  494. lines.push(line.new(math.max(c.pHiBar, bar_index - 5000), c.pHiA, bar_index, aH, color = colSmt, width = 1, style = line.style_dashed))
  495. labels.push(label.new(bar_index, aH, "SSMT", style = label.style_label_down, color = noCol, textcolor = colSmt, size = size.tiny))
  496. if not na(c.pLoA) and not c.bullDone
  497. bool divA = aL < c.pLoA and c.cLoB >= c.pLoB
  498. bool divB = bL < c.pLoB and c.cLoA >= c.pLoA and aL <= c.cLoA
  499. if divA or divB
  500. bullS := true
  501. c.bullDone := true
  502. if showSsmt and not drawn.get(2)
  503. drawn.set(2, true)
  504. lines.push(line.new(math.max(c.pLoBar, bar_index - 5000), c.pLoA, bar_index, aL, color = colSmt, width = 1, style = line.style_dashed))
  505. labels.push(label.new(bar_index, aL, "SSMT", style = label.style_label_up, color = noCol, textcolor = colSmt, size = size.tiny))
  506. [bullS, bearS]
  507.  
  508. f_htfFvgConf() =>
  509. bool bu = low[1] > high[3]
  510. bool be = high[1] < low[3]
  511. float t = bu ? low[1] : be ? low[3] : na
  512. float b = bu ? high[3] : be ? high[1] : na
  513. [bu, be, t, b, time[3]]
  514.  
  515. atr = ta.atr(14)
  516. nyH = hour(time, TZ)
  517. nyM = minute(time, TZ)
  518. inMacro = nyM >= 50 or nyM <= 10
  519.  
  520. string htf1 = htfTf1
  521. string htf2 = htfTf2
  522. string htf3 = htfTf3
  523.  
  524. int pivLen = htfMode == "Custom" ? customPivot : chartSec <= 60 ? 10 : chartSec <= 300 ? 7 : 5
  525.  
  526. string root = syminfo.root
  527. bool isFut = syminfo.type == "futures"
  528.  
  529. string corrRoot = switch root
  530. "NQ" => "ES"
  531. "MNQ" => "MES"
  532. "ES" => "NQ"
  533. "MES" => "MNQ"
  534. "YM" => "ES"
  535. "MYM" => "MES"
  536. "RTY" => "ES"
  537. "M2K" => "MES"
  538. "GC" => "SI"
  539. "MGC" => "SIL"
  540. => ""
  541.  
  542. string corrPrefix = switch corrRoot
  543. "ES" => "CME_MINI"
  544. "NQ" => "CME_MINI"
  545. "MES" => "CME_MINI"
  546. "MNQ" => "CME_MINI"
  547. "SI" => "COMEX"
  548. "SIL" => "COMEX"
  549. => syminfo.prefix
  550.  
  551. string corrFx = switch syminfo.ticker
  552. "EURUSD" => "GBPUSD"
  553. "GBPUSD" => "EURUSD"
  554. "BTCUSD" => "ETHUSD"
  555. "ETHUSD" => "BTCUSD"
  556. "BTCUSDT" => "ETHUSDT"
  557. "ETHUSDT" => "BTCUSDT"
  558. => ""
  559.  
  560. string corrTicker = not smtAuto ? smtManual : isFut and corrRoot != "" ? corrPrefix + ":" + corrRoot + "1!" : corrFx != "" ? syminfo.prefix + ":" + corrFx : smtManual
  561. array<string> corrParts = str.split(corrTicker, ":")
  562. string corrRaw = corrParts.size() > 0 ? str.replace_all(corrParts.get(corrParts.size() - 1), "1!", "") : ""
  563.  
  564. string corrShort = switch corrRaw
  565. "MES" => "ES"
  566. "MNQ" => "NQ"
  567. "MYM" => "YM"
  568. "M2K" => "RTY"
  569. "MGC" => "GC"
  570. "SIL" => "SI"
  571. => corrRaw
  572.  
  573. corrShort := corrShort == "" ? "ES" : corrShort
  574.  
  575. string fullRoot = switch root
  576. "MNQ" => "NQ"
  577. "MES" => "ES"
  578. "MYM" => "YM"
  579. "M2K" => "RTY"
  580. "MGC" => "GC"
  581. "MCL" => "CL"
  582. => ""
  583.  
  584. string fullTicker = isFut and fullRoot != "" ? syminfo.prefix + ":" + fullRoot + "1!" : syminfo.tickerid
  585. string ltfStr = chartSec > 60 ? "1" : timeframe.period
  586.  
  587. [h1Bu, h1Be, h1T, h1B, h1Tm] = request.security(syminfo.tickerid, htf1, f_htfFvgConf(), lookahead = barmerge.lookahead_on)
  588. [h2Bu, h2Be, h2T, h2B, h2Tm] = request.security(syminfo.tickerid, htf2, f_htfFvgConf(), lookahead = barmerge.lookahead_on)
  589. [h3Bu, h3Be, h3T, h3B, h3Tm] = request.security(syminfo.tickerid, htf3, f_htfFvgConf(), lookahead = barmerge.lookahead_on)
  590. [pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead = barmerge.lookahead_on)
  591. [pwh, pwl] = request.security(syminfo.tickerid, "W", [high[1], low[1]], lookahead = barmerge.lookahead_on)
  592. [corrH, corrL] = request.security(corrTicker, timeframe.period, [high, low], ignore_invalid_symbol = true)
  593. [ltH, ltL, ltC, ltV] = request.security_lower_tf(fullTicker, ltfStr, [high, low, close, volume], ignore_invalid_symbol = true)
  594.  
  595. float buyVol = 0.0
  596. float sellVol = 0.0
  597.  
  598. if ltV.size() > 0
  599. for i = 0 to ltV.size() - 1
  600. float v = nz(ltV.get(i))
  601. float h = ltH.get(i)
  602. float l = ltL.get(i)
  603. float c = ltC.get(i)
  604. if not na(h) and not na(l) and not na(c)
  605. float rng = h - l
  606. float bf = rng > 0 ? (c - l) / rng : 0.5
  607. buyVol += v * bf
  608. sellVol += v * (1.0 - bf)
  609.  
  610. bool deltaBull = buyVol > 0 and buyVol >= math.max(sellVol, 1e-10) * deltaRatio
  611. bool deltaBear = sellVol > 0 and sellVol >= math.max(buyVol, 1e-10) * deltaRatio
  612.  
  613. var array<Liq> swings = array.new<Liq>()
  614. var array<line> eqLines = array.new<line>()
  615. var array<label> eqLabels = array.new<label>()
  616. var array<line> sweepLines = array.new<line>()
  617. var array<label> sweepLabels = array.new<label>()
  618. var int lastSweepBull = na
  619. var int lastSweepBear = na
  620. bool sweepBullNow = false
  621. bool sweepBearNow = false
  622.  
  623. ph = ta.pivothigh(high, pivLen, pivLen)
  624. pl = ta.pivotlow(low, pivLen, pivLen)
  625.  
  626. f_newSwing(float p, bool isHigh) =>
  627. int b = bar_index - pivLen
  628. if showEq and swings.size() > 0
  629. for i = swings.size() - 1 to 0
  630. Liq s = swings.get(i)
  631. if s.isHigh == isHigh and not s.swept and math.abs(s.price - p) <= atr * eqTol
  632. eqLines.push(line.new(s.bar, s.price, b, p, color = colEq, style = line.style_dashed))
  633. eqLabels.push(label.new(b, p, isHigh ? "EQH" : "EQL", style = isHigh ? label.style_label_down : label.style_label_up, color = noCol, textcolor = colEq, size = size.tiny))
  634. if eqLines.size() > EQ_KEEP
  635. line.delete(eqLines.shift())
  636. if eqLabels.size() > EQ_KEEP
  637. label.delete(eqLabels.shift())
  638. break
  639. swings.push(Liq.new(p, b, isHigh))
  640. if swings.size() > MAX_SWINGS
  641. swings.shift()
  642.  
  643. if not na(ph)
  644. f_newSwing(ph, true)
  645.  
  646. if not na(pl)
  647. f_newSwing(pl, false)
  648.  
  649. if swings.size() > 0
  650. for i = swings.size() - 1 to 0
  651. Liq s = swings.get(i)
  652. if not s.swept and bar_index > s.bar + pivLen
  653. if s.isHigh ? high > s.price : low < s.price
  654. s.swept := true
  655. if s.isHigh ? close < s.price : close > s.price
  656. if s.isHigh
  657. sweepBearNow := true
  658. lastSweepBear := bar_index
  659. else
  660. sweepBullNow := true
  661. lastSweepBull := bar_index
  662. if showSweep
  663. sweepLines.push(line.new(s.bar, s.price, bar_index, s.price, color = sweepColor, style = sweepStyle))
  664. sweepLabels.push(label.new(bar_index, s.price, sweepLabelText, style = label.style_label_left, color = noCol, textcolor = sweepColor, size = size.small))
  665.  
  666. while sweepLines.size() > sweepKeep
  667. line.delete(sweepLines.shift())
  668.  
  669. while sweepLabels.size() > sweepKeep
  670. label.delete(sweepLabels.shift())
  671.  
  672. var Sess sAsia = Sess.new("ASIA")
  673. var Sess sLon = Sess.new("LON")
  674. var Sess sNyAm = Sess.new("NYAM")
  675. var Sess sNyPm = Sess.new("NYPM")
  676.  
  677. [asSwL, asSwH] = sAsia.updateSess(f_inSess(asiaSess), showAsia, colAsia)
  678. [loSwL, loSwH] = sLon.updateSess(f_inSess(londonSess), showLondon, colLondon)
  679. [amSwL, amSwH] = sNyAm.updateSess(f_inSess(nyAmSess), showNyAm, colNyAm)
  680. [pmSwL, pmSwH] = sNyPm.updateSess(f_inSess(nyPmSess), showNyPm, colNyPm)
  681.  
  682. bool pdSwL = showPD and not na(pdl) and low < pdl and close > pdl and nz(low[1], low) >= pdl
  683. bool pdSwH = showPD and not na(pdh) and high > pdh and close < pdh and nz(high[1], high) <= pdh
  684. bool pwSwL = showPW and not na(pwl) and low < pwl and close > pwl and nz(low[1], low) >= pwl
  685. bool pwSwH = showPW and not na(pwh) and high > pwh and close < pwh and nz(high[1], high) <= pwh
  686.  
  687. if asSwL or loSwL or amSwL or pmSwL or pdSwL or pwSwL
  688. lastSweepBull := bar_index
  689. sweepBullNow := true
  690.  
  691. if asSwH or loSwH or amSwH or pmSwH or pdSwH or pwSwH
  692. lastSweepBear := bar_index
  693. sweepBearNow := true
  694.  
  695. var float open00 = na
  696. var float open830 = na
  697. var float open930 = na
  698. var int open00Bar = na
  699. var int open830Bar = na
  700. var int open930Bar = na
  701.  
  702. if f_atTime(0, 0)
  703. open00 := open
  704. open00Bar := bar_index
  705.  
  706. if f_atTime(8, 30)
  707. open830 := open
  708. open830Bar := bar_index
  709.  
  710. if f_atTime(9, 30)
  711. open930 := open
  712. open930Bar := bar_index
  713.  
  714. f_buildLiq() =>
  715. liqP = array.new<float>()
  716. liqN = array.new<string>()
  717. liqB = array.new<int>()
  718. if swings.size() > 0
  719. for i = 0 to swings.size() - 1
  720. Liq s = swings.get(i)
  721. if not s.swept
  722. f_addLiq(liqP, liqN, liqB, s.price, s.isHigh ? "BSL" : "SSL", s.bar)
  723. sAsia.addLiq(showAsia, liqP, liqN, liqB)
  724. sLon.addLiq(showLondon, liqP, liqN, liqB)
  725. sNyAm.addLiq(showNyAm, liqP, liqN, liqB)
  726. sNyPm.addLiq(showNyPm, liqP, liqN, liqB)
  727. if showPD
  728. f_addLiq(liqP, liqN, liqB, pdh, "PDH", na)
  729. f_addLiq(liqP, liqN, liqB, pdl, "PDL", na)
  730. if showPW
  731. f_addLiq(liqP, liqN, liqB, pwh, "PWH", na)
  732. f_addLiq(liqP, liqN, liqB, pwl, "PWL", na)
  733. if showOpen00
  734. f_addLiq(liqP, liqN, liqB, open00, "00:00", open00Bar)
  735. if showOpen830
  736. f_addLiq(liqP, liqN, liqB, open830, "08:30", open830Bar)
  737. if showOpen930
  738. f_addLiq(liqP, liqN, liqB, open930, "09:30", open930Bar)
  739. [liqP, liqN, liqB]
  740.  
  741. var array<HFVG> htfZones = array.new<HFVG>()
  742. var int lastHtfBull = na
  743. var int lastHtfBear = na
  744.  
  745. f_addHtf(bool bu, bool be, float t, float b, int tm, string tf) =>
  746. if showHtfFvg and (bu or be) and not na(t) and not na(b)
  747. int cnt = 0
  748. int oldest = -1
  749. if htfZones.size() > 0
  750. for i = 0 to htfZones.size() - 1
  751. if htfZones.get(i).tfName == tf
  752. cnt += 1
  753. if oldest == -1
  754. oldest := i
  755. if cnt >= maxHtfZones and oldest >= 0
  756. HFVG o = htfZones.remove(oldest)
  757. box.delete(o.bx)
  758. f_delLine(o.ce)
  759. string nm = f_tfName(tf) + " FVG"
  760. box bx = box.new(tm, t, time, b, xloc = xloc.bar_time, border_color = noCol, bgcolor = bu ? colHtfBull : colHtfBear, text = nm, text_color = colHtfText, text_size = size.tiny, text_halign = text.align_right, text_valign = text.align_bottom)
  761. line ce = showHtfCE ? line.new(tm, (t + b) / 2, time, (t + b) / 2, xloc = xloc.bar_time, color = colHtfText, style = line.style_dotted) : na
  762. htfZones.push(HFVG.new(t, b, bu, tf, bx, ce))
  763.  
  764. if h1Tm != h1Tm[1] and htfOn1
  765. f_addHtf(h1Bu, h1Be, h1T, h1B, h1Tm, htf1)
  766.  
  767. if h2Tm != h2Tm[1] and htfOn2
  768. f_addHtf(h2Bu, h2Be, h2T, h2B, h2Tm, htf2)
  769.  
  770. if h3Tm != h3Tm[1] and htfOn3
  771. f_addHtf(h3Bu, h3Be, h3T, h3B, h3Tm, htf3)
  772.  
  773. int futureT = time + int(chartSec * 1000 * EXT)
  774.  
  775. if htfZones.size() > 0
  776. for i = htfZones.size() - 1 to 0
  777. HFVG z = htfZones.get(i)
  778. bool mitigated = z.bull ? close < z.bot : close > z.top
  779. if mitigated
  780. box.delete(z.bx)
  781. f_delLine(z.ce)
  782. htfZones.remove(i)
  783. else
  784. box.set_right(z.bx, futureT)
  785. if not na(z.ce)
  786. line.set_x2(z.ce, futureT)
  787. if z.bull and low <= z.top and high >= z.bot
  788. lastHtfBull := bar_index
  789. if not z.bull and high >= z.bot and low <= z.top
  790. lastHtfBear := bar_index
  791.  
  792. var array<line> smtLines = array.new<line>()
  793. var array<label> smtLabels = array.new<label>()
  794. var SmtCyc cM = SmtCyc.new("M")
  795. var SmtCyc cW = SmtCyc.new("W")
  796. var SmtCyc cD = SmtCyc.new("D")
  797. var SmtCyc c90 = SmtCyc.new("90m")
  798. var SmtCyc cMi = SmtCyc.new("Micro")
  799. var int lastSmtBull = na
  800. var int lastSmtBear = na
  801.  
  802. int nySec = nyH * 3600 + nyM * 60 + second(time, TZ)
  803. int q90 = math.floor(nySec / 5400)
  804. int qMi = math.floor(nySec / 1350)
  805. bool newM = timeframe.change("M")
  806. bool newW = timeframe.change("W")
  807. bool newD = timeframe.change("D")
  808. bool new90 = newD or q90 != q90[1]
  809. bool newMi = newD or qMi != qMi[1]
  810.  
  811. drawnSmt = array.new<bool>(4, false)
  812.  
  813. [mBu, mBe] = cM.stepSmt(newM, smtShowM, high, low, corrH, corrL, drawnSmt, smtLines, smtLabels)
  814. [wBu, wBe] = cW.stepSmt(newW, smtShowW and chartSec < 604800, high, low, corrH, corrL, drawnSmt, smtLines, smtLabels)
  815. [dBu, dBe] = cD.stepSmt(newD, smtShowD and chartSec < 86400, high, low, corrH, corrL, drawnSmt, smtLines, smtLabels)
  816. [nBu, nBe] = c90.stepSmt(new90, smtShow90 and chartSec < 5400, high, low, corrH, corrL, drawnSmt, smtLines, smtLabels)
  817. [uBu, uBe] = cMi.stepSmt(newMi, smtShowMicro and chartSec < 1350, high, low, corrH, corrL, drawnSmt, smtLines, smtLabels)
  818.  
  819. bool smtBullNow = mBu or wBu or dBu or nBu or uBu
  820. bool smtBearNow = mBe or wBe or dBe or nBe or uBe
  821.  
  822. if smtBullNow
  823. lastSmtBull := bar_index
  824.  
  825. if smtBearNow
  826. lastSmtBear := bar_index
  827.  
  828. while smtLines.size() > smtKeep
  829. line.delete(smtLines.shift())
  830.  
  831. while smtLabels.size() > smtKeep
  832. label.delete(smtLabels.shift())
  833.  
  834. var array<FVG> fvgs = array.new<FVG>()
  835. int maxAge = allowExtIFVG ? 15 : 6
  836.  
  837. bool bullGap = low > high[2] and (low - high[2]) >= atr * atrStrict
  838. bool bearGap = high < low[2] and (low[2] - high) >= atr * atrStrict
  839.  
  840. if bullGap or bearGap
  841. float t = bullGap ? low : low[2]
  842. float b = bullGap ? high[2] : high
  843. bool merged = false
  844. if ifvgMode == "Series" and fvgs.size() > 0
  845. FVG lastF = fvgs.last()
  846. if lastF.bull == bullGap and bar_index - lastF.created <= 2
  847. lastF.top := math.max(lastF.top, t)
  848. lastF.bot := math.min(lastF.bot, b)
  849. lastF.created := bar_index
  850. if not na(lastF.bx)
  851. box.set_top(lastF.bx, lastF.top)
  852. box.set_bottom(lastF.bx, lastF.bot)
  853. merged := true
  854. if not merged
  855. box bx = showRawFvg ? box.new(bar_index - 2, t, bar_index, b, border_color = noCol, bgcolor = bullGap ? colFvgBull : colFvgBear) : na
  856. fvgs.push(FVG.new(t, b, bullGap, bar_index - 2, bar_index, bx))
  857. if fvgs.size() > MAX_FVG
  858. FVG o = fvgs.shift()
  859. box.delete(o.bx)
  860.  
  861. bool invBull = false
  862. bool invBear = false
  863. bool potInv = false
  864. FVG invF = na
  865.  
  866. if fvgs.size() > 0
  867. for i = fvgs.size() - 1 to 0
  868. FVG f = fvgs.get(i)
  869. int age = bar_index - f.created
  870. if bar_index > f.created and f.bull and close < f.bot and not invBear and not invBull
  871. invBear := true
  872. invF := f
  873. fvgs.remove(i)
  874. else if bar_index > f.created and not f.bull and close > f.top and not invBull and not invBear
  875. invBull := true
  876. invF := f
  877. fvgs.remove(i)
  878. else if age > maxAge
  879. box.delete(f.bx)
  880. fvgs.remove(i)
  881. else
  882. if not na(f.bx)
  883. box.set_right(f.bx, bar_index)
  884. if close < f.top and close > f.bot
  885. potInv := true
  886.  
  887. var array<Setup> setups = array.new<Setup>()
  888. var Setup lastSetup = na
  889. bool newSetup = false
  890. bool invalidNow = false
  891. bool mtfConf = false
  892.  
  893. if invBull or invBear
  894. bool isBull = invBull
  895. int win = math.max(bar_index - invF.left + 5, confWindow)
  896. bool cSweep = f_recent(isBull ? lastSweepBull : lastSweepBear, win)
  897. bool cHtf = f_recent(isBull ? lastHtfBull : lastHtfBear, win)
  898. bool cDelta = isBull ? deltaBull : deltaBear
  899. bool cIfvg = true
  900. bool cSmt = f_recent(isBull ? lastSmtBull : lastSmtBear, win)
  901.  
  902. float entry = close
  903. int span = math.min(bar_index - invF.left, 300)
  904. float ext = na
  905. int extBar = bar_index
  906.  
  907. for k = 0 to span
  908. float v = slPlacement == "Body" ? (isBull ? math.min(open[k], close[k]) : math.max(open[k], close[k])) : (isBull ? low[k] : high[k])
  909. if na(ext) or (isBull ? v < ext : v > ext)
  910. ext := v
  911. extBar := bar_index - k
  912.  
  913. float sl = slPlacement == "IFVG" ? (isBull ? invF.bot : invF.top) : ext
  914. int slBar = slPlacement == "IFVG" ? invF.left : extBar
  915.  
  916. if (isBull and sl >= entry) or (not isBull and sl <= entry)
  917. sl := ext
  918. slBar := extBar
  919.  
  920. float risk = math.abs(entry - sl)
  921. float be = isBull ? entry + risk : entry - risk
  922.  
  923. [liqP, liqN, liqB] = f_buildLiq()
  924. [t1, t1Bar] = f_target(liqP, liqB, isBull, entry, 1)
  925. [t2, t2Bar] = f_target(liqP, liqB, isBull, entry, 2)
  926.  
  927. bool cTargets = not na(t1) and not na(t2)
  928. float tp1 = na(t1) ? (isBull ? entry + risk * 2 : entry - risk * 2) : t1
  929. int tp1B = na(t1) or na(t1Bar) ? bar_index : t1Bar
  930. float tp2 = na(t2) ? (isBull ? math.max(tp1, entry) + risk : math.min(tp1, entry) - risk) : t2
  931. int tp2B = na(t2) or na(t2Bar) ? bar_index : t2Bar
  932.  
  933. int score = (cSweep ? 1 : 0) + (cHtf ? 1 : 0) + (cDelta ? 1 : 0) + (cIfvg ? 1 : 0) + (cTargets ? 1 : 0) + (cSmt ? 1 : 0)
  934. string grade = f_grade(score)
  935. mtfConf := cHtf and cSmt
  936.  
  937. bool pass = risk > 0
  938. pass := pass and f_gradeRank(grade) >= f_gradeRank(minGradeStr)
  939. pass := pass and (biasMode == "Neutral" or (biasMode == "Bullish" and isBull) or (biasMode == "Bearish" and not isBull))
  940. pass := pass and (not requireBEIntact or (isBull ? high < be : low > be))
  941. pass := pass and (not requireMacro or inMacro)
  942. pass := pass and (not onlyShowSwept or cSweep)
  943. pass := pass and (not onlyShowHtfAlign or cHtf)
  944. pass := pass and (not requireDelta or cDelta)
  945.  
  946. if pass
  947. color dc = isBull ? colLong : colShort
  948. float ptVal = syminfo.pointvalue > 0 ? syminfo.pointvalue : 1.0
  949. float perC = risk * ptVal
  950. int contracts = perC > 0 ? math.max(1, int(math.floor(riskUsd / perC))) : 1
  951. float riskReal = contracts * perC
  952. string entryTxt = (isBull ? "DD+" : "DD-") + (showContracts ? " " + str.tostring(contracts) + " contracts = $" + str.tostring(riskReal, "#") : "")
  953. int xE = bar_index + 10
  954. int xS = bar_index + 5
  955.  
  956. Setup s = Setup.new(isBull, entry, sl, be, tp1, tp2, bar_index)
  957. s.grade := grade
  958. s.checks := array.from(cSweep, cHtf, cDelta, cIfvg, cTargets, cSmt)
  959.  
  960. if not na(invF.bx)
  961. box.delete(invF.bx)
  962.  
  963. s.bx := box.new(invF.left, invF.top, bar_index, invF.bot, border_color = noCol, bgcolor = color.new(colIfvgBox, ifvgTransp))
  964.  
  965. if showIfvgCE
  966. s.ce := line.new(invF.left, (invF.top + invF.bot) / 2, bar_index, (invF.top + invF.bot) / 2, color = color.new(#4a4a4a, 30), style = line.style_dotted)
  967.  
  968. s.lEntry := line.new(bar_index, entry, xE, entry, color = dc, width = 2)
  969. s.txtFull := entryTxt
  970. s.lbEntry := label.new(xE, entry, isBull ? "DD+" : "DD-", style = label.style_label_left, color = noCol, textcolor = dc, size = size.small)
  971.  
  972. if showSL
  973. s.lSl := line.new(slBar, sl, xS, sl, color = colSL, style = line.style_dotted)
  974. s.lbSl := label.new(xS, sl, "SL", style = label.style_label_left, color = noCol, textcolor = colSL, size = size.small)
  975.  
  976. if showBE
  977. s.lBe := line.new(bar_index, be, xE, be, color = colBE, style = line.style_dotted)
  978. s.lbBe := label.new(xE, be, "BE", style = label.style_label_left, color = noCol, textcolor = colBE, size = size.tiny)
  979.  
  980. if showTP
  981. s.lTp1 := line.new(tp1B, tp1, xE, tp1, color = colTP1, style = line.style_dotted)
  982. s.lbTp1 := label.new(xE, tp1, "TP1", style = label.style_label_left, color = noCol, textcolor = colTP1, size = size.small)
  983. s.lTp2 := line.new(tp2B, tp2, xE, tp2, color = colTP2, style = line.style_dotted)
  984. s.lbTp2 := label.new(xE, tp2, "TP2", style = label.style_label_left, color = noCol, textcolor = colTP2, size = size.small)
  985.  
  986. setups.push(s)
  987. lastSetup := s
  988. newSetup := true
  989. else if not na(invF.bx)
  990. box.delete(invF.bx)
  991.  
  992. if setups.size() > 0
  993. for i = setups.size() - 1 to 0
  994. Setup s = setups.get(i)
  995. if s.status == 0 and bar_index > s.start
  996. bool hitSl = s.bull ? low <= s.sl : high >= s.sl
  997. bool hitTp = s.bull ? high >= s.tp2 : low <= s.tp2
  998. if not s.tp1Hit and (s.bull ? high >= s.tp1 : low <= s.tp1)
  999. s.tp1Hit := true
  1000. if hitSl
  1001. s.status := -1
  1002. invalidNow := true
  1003. if hideLosing
  1004. s.deleteDrawings()
  1005. setups.remove(i)
  1006. continue
  1007. s.finalize()
  1008. else if hitTp
  1009. s.status := 1
  1010. s.finalize()
  1011.  
  1012. if setupHistory > 0
  1013. while setups.size() > setupHistory
  1014. Setup o = setups.shift()
  1015. o.deleteDrawings()
  1016.  
  1017. if barstate.islast and setups.size() > 0
  1018. for i = 0 to setups.size() - 1
  1019. Setup o2 = setups.get(i)
  1020. if not na(o2.lbEntry)
  1021. bool isLast = i == setups.size() - 1
  1022. label.set_text(o2.lbEntry, isLast and not na(o2.txtFull) ? o2.txtFull : (o2.bull ? "DD+" : "DD-"))
  1023.  
  1024. var array<Gap> gaps = array.new<Gap>()
  1025. var array<box> gapBoxes = array.new<box>()
  1026. var array<line> gapLines = array.new<line>()
  1027.  
  1028. if newW and bar_index > 0
  1029. float gT = math.max(open, close[1])
  1030. float gB = math.min(open, close[1])
  1031. if (gT - gB) >= nwogMinTicks * syminfo.mintick
  1032. gaps.push(Gap.new(gT, gB, time))
  1033. if gaps.size() > nwogLookback
  1034. gaps.shift()
  1035.  
  1036. var array<box> vaBoxes = array.new<box>()
  1037.  
  1038. if showCandleVA and ltV.size() > 1
  1039. int n = ltV.size()
  1040. float tot = ltV.sum()
  1041. float acc = 0.0
  1042. float vaHi = na
  1043. float vaLo = na
  1044. used = array.new<bool>(n, false)
  1045. while acc < tot * vpVaPct / 100.0
  1046. int best = -1
  1047. float bv = -1.0
  1048. for i = 0 to n - 1
  1049. if not used.get(i) and nz(ltV.get(i)) > bv
  1050. bv := nz(ltV.get(i))
  1051. best := i
  1052. if best < 0
  1053. break
  1054. used.set(best, true)
  1055. acc += bv
  1056. vaHi := na(vaHi) ? ltH.get(best) : math.max(vaHi, ltH.get(best))
  1057. vaLo := na(vaLo) ? ltL.get(best) : math.min(vaLo, ltL.get(best))
  1058. if bv <= 0
  1059. break
  1060. if not na(vaHi)
  1061. vaBoxes.push(box.new(bar_index, vaHi, bar_index, vaLo, border_color = color.new(#787b86, 30), bgcolor = color.new(#787b86, 85)))
  1062. if vaBoxes.size() > 100
  1063. box.delete(vaBoxes.shift())
  1064.  
  1065. barcolor(colorCandles ? (deltaBull ? colDeltaBuy : deltaBear ? colDeltaSell : na) : na, title = "Delta Candle Color")
  1066.  
  1067. var line lnPdh = na
  1068. var line lnPdl = na
  1069. var line lnPwh = na
  1070. var line lnPwl = na
  1071. var line lnO00 = na
  1072. var line lnO830 = na
  1073. var line lnO930 = na
  1074. var array<label> keyLabels = array.new<label>()
  1075. var line lnBsl = na
  1076. var line lnSsl = na
  1077. var label lbBsl = na
  1078. var label lbSsl = na
  1079. var array<line> vpLines = array.new<line>()
  1080.  
  1081. f_keyLine(line ln, bool show, float p, int x1, color c, string txt, array<label> labs) =>
  1082. line res = ln
  1083. f_delLine(res)
  1084. res := na
  1085. if show and not na(p)
  1086. res := line.new(x1, p, bar_index + EXT, p, color = c, style = line.style_dotted)
  1087. labs.push(label.new(bar_index + EXT, p, txt, style = label.style_label_left, color = noCol, textcolor = c, size = size.tiny))
  1088. res
  1089.  
  1090. if barstate.islast
  1091. for l in keyLabels
  1092. label.delete(l)
  1093. keyLabels.clear()
  1094.  
  1095. int x1 = math.max(bar_index - keyLookback, 0)
  1096. lnPdh := f_keyLine(lnPdh, showPD, pdh, x1, colPD, "PDH", keyLabels)
  1097. lnPdl := f_keyLine(lnPdl, showPD, pdl, x1, colPD, "PDL", keyLabels)
  1098. lnPwh := f_keyLine(lnPwh, showPW, pwh, x1, colPW, "PWH", keyLabels)
  1099. lnPwl := f_keyLine(lnPwl, showPW, pwl, x1, colPW, "PWL", keyLabels)
  1100. lnO00 := f_keyLine(lnO00, showOpen00, open00, nz(open00Bar, x1), colOpens, "00:00", keyLabels)
  1101. lnO830 := f_keyLine(lnO830, showOpen830, open830, nz(open830Bar, x1), colOpens, "08:30", keyLabels)
  1102. lnO930 := f_keyLine(lnO930, showOpen930, open930, nz(open930Bar, x1), colOpens, "09:30", keyLabels)
  1103.  
  1104. f_delLine(lnBsl)
  1105. f_delLine(lnSsl)
  1106. f_delLabel(lbBsl)
  1107. f_delLabel(lbSsl)
  1108. lnBsl := na
  1109. lnSsl := na
  1110. lbBsl := na
  1111. lbSsl := na
  1112.  
  1113. if showNearestLiq
  1114. [liqP, liqN, liqB] = f_buildLiq()
  1115. [bsl, bslBar] = f_target(liqP, liqB, true, close, 1)
  1116. [ssl, sslBar] = f_target(liqP, liqB, false, close, 1)
  1117. if not na(bsl)
  1118. lnBsl := line.new(nz(bslBar, bar_index - 10), bsl, bar_index + 25, bsl, color = colNearestLiq, style = line.style_dashed)
  1119. lbBsl := label.new(bar_index + 25, bsl, "BSL: " + f_mergeNames(liqP, liqN, bsl), style = label.style_label_left, color = noCol, textcolor = colNearestLiq, size = size.tiny)
  1120. if not na(ssl)
  1121. lnSsl := line.new(nz(sslBar, bar_index - 10), ssl, bar_index + 25, ssl, color = colNearestLiq, style = line.style_dashed)
  1122. lbSsl := label.new(bar_index + 25, ssl, "SSL: " + f_mergeNames(liqP, liqN, ssl), style = label.style_label_left, color = noCol, textcolor = colNearestLiq, size = size.tiny)
  1123.  
  1124. for b in gapBoxes
  1125. box.delete(b)
  1126. gapBoxes.clear()
  1127.  
  1128. for l in gapLines
  1129. line.delete(l)
  1130. gapLines.clear()
  1131.  
  1132. if showNwog and gaps.size() > 0
  1133. sel = array.new<int>()
  1134. if nwogMode == "Recent"
  1135. for i = gaps.size() - 1 to math.max(gaps.size() - nwogCount, 0)
  1136. sel.push(i)
  1137. else
  1138. dist = array.new<float>()
  1139. for g in gaps
  1140. dist.push(math.abs((g.top + g.bot) / 2 - close))
  1141. for k = 1 to math.min(nwogCount, gaps.size())
  1142. int bi = -1
  1143. float bd = 1e20
  1144. for i = 0 to dist.size() - 1
  1145. if dist.get(i) < bd and not sel.includes(i)
  1146. bd := dist.get(i)
  1147. bi := i
  1148. if bi >= 0
  1149. sel.push(bi)
  1150. int rT = time + int(chartSec * 1000 * EXT)
  1151. for i in sel
  1152. Gap g = gaps.get(i)
  1153. gapBoxes.push(box.new(g.t, g.top, rT, g.bot, xloc = xloc.bar_time, border_color = noCol, bgcolor = colNwog, text = "NWOG", text_size = size.tiny, text_color = colHtfText, text_halign = text.align_right))
  1154. gapLines.push(line.new(g.t, (g.top + g.bot) / 2, rT, (g.top + g.bot) / 2, xloc = xloc.bar_time, color = colHtfText, style = line.style_dotted))
  1155.  
  1156. for l in vpLines
  1157. line.delete(l)
  1158. vpLines.clear()
  1159.  
  1160. if showVP and bar_index > 2
  1161. int n = math.min(vpBars, bar_index)
  1162. float hi = high
  1163. float lo = low
  1164. for i = 0 to n - 1
  1165. hi := math.max(hi, high[i])
  1166. lo := math.min(lo, low[i])
  1167. float step = (hi - lo) / vpRows
  1168. if step > 0
  1169. rows = array.new<float>(vpRows, 0.0)
  1170. for i = 0 to n - 1
  1171. int r1 = math.max(0, math.min(vpRows - 1, int(math.floor((low[i] - lo) / step))))
  1172. int r2 = math.max(0, math.min(vpRows - 1, int(math.floor((high[i] - lo) / step))))
  1173. float per = nz(volume[i]) / (r2 - r1 + 1)
  1174. for r = r1 to r2
  1175. rows.set(r, rows.get(r) + per)
  1176. float mx = rows.max()
  1177. int poc = rows.indexof(mx)
  1178. float tot = rows.sum()
  1179. int vaU = poc
  1180. int vaD = poc
  1181. float acc = rows.get(poc)
  1182. while acc < tot * vpVaPct / 100.0 and (vaU < vpRows - 1 or vaD > 0)
  1183. float up = vaU < vpRows - 1 ? rows.get(vaU + 1) : -1.0
  1184. float dn = vaD > 0 ? rows.get(vaD - 1) : -1.0
  1185. if up >= dn
  1186. vaU += 1
  1187. acc += up
  1188. else
  1189. vaD -= 1
  1190. acc += dn
  1191. int xR = bar_index + vpOffset + vpWidth
  1192. for r = 0 to vpRows - 1
  1193. float v = rows.get(r)
  1194. if v > 0 and mx > 0
  1195. int len = math.max(1, int(math.round(v / mx * vpWidth)))
  1196. float y = lo + step * (r + 0.5)
  1197. vpLines.push(line.new(xR - len, y, xR, y, color = r >= vaD and r <= vaU ? colVpVa : colVpOut, width = 2))
  1198.  
  1199. tablePos = switch tablePosStr
  1200. "Top Right" => position.top_right
  1201. "Middle Right" => position.middle_right
  1202. "Bottom Right" => position.bottom_right
  1203. "Bottom Left" => position.bottom_left
  1204. => position.top_left
  1205.  
  1206. var table tbl = table.new(tablePos, 2, 8, border_width = 1, border_color = color.new(#d1d4dc, 0))
  1207. var table wm = table.new(position.bottom_center, 1, 3, bgcolor = noCol)
  1208.  
  1209. colHead = color.new(#5d606b, 0)
  1210. colCell = color.new(#9598a1, 0)
  1211. colTxt = color.new(#ffffff, 0)
  1212.  
  1213. if barstate.islast and showTable
  1214. bool hasS = not na(lastSetup)
  1215. string gradeTxt = hasS and lastSetup.status == 0 and not lastSetup.tp1Hit ? lastSetup.grade : "-"
  1216. table.cell(tbl, 0, 0, "Setup Grade", bgcolor = colHead, text_color = colTxt, text_size = size.small)
  1217. table.cell(tbl, 1, 0, gradeTxt, bgcolor = colHead, text_color = colTxt, text_size = size.small)
  1218. table.cell(tbl, 0, 1, "Checklist", bgcolor = colHead, text_color = colTxt, text_size = size.small)
  1219. table.cell(tbl, 1, 1, "Status", bgcolor = colHead, text_color = colTxt, text_size = size.small)
  1220. names = array.from("Liquidity Sweep", "HTF PDA Delivery", "Delta Imbalance", "IFVG", "Clear Targets", "SMT w/ " + corrShort)
  1221. for i = 0 to 5
  1222. bool ok = hasS ? lastSetup.checks.get(i) : false
  1223. table.cell(tbl, 0, i + 2, names.get(i), bgcolor = colCell, text_color = colTxt, text_size = size.small)
  1224. table.cell(tbl, 1, i + 2, ok ? "✅" : "❌", bgcolor = colCell, text_color = colTxt, text_size = size.small)
  1225.  
  1226. if barstate.islast and showWatermark
  1227. table.cell(wm, 0, 0, "iFVG Ultimate+ Deluxe | DodgysDD (" + timeframe.period + (timeframe.isminutes ? "m" : "") + ")", text_color = wmColor, text_size = size.normal, text_font_family = font.family_monospace)
  1228. table.cell(wm, 0, 1, syminfo.ticker, text_color = wmColor, text_size = size.normal, text_font_family = font.family_monospace)
  1229. table.cell(wm, 0, 2, str.format_time(time, "dd MMM yyyy", TZ), text_color = wmColor, text_size = size.small, text_font_family = font.family_monospace)
  1230.  
  1231. bool anyWin = win1Enable or win2Enable or win3Enable
  1232. bool inWin = not anyWin or (win1Enable and f_inSess(win1Time)) or (win2Enable and f_inSess(win2Time)) or (win3Enable and f_inSess(win3Time))
  1233. bool canAlert = enableAlerts and inWin and barstate.isconfirmed
  1234.  
  1235. if canAlert
  1236. if alSweep and sweepBullNow
  1237. alert("iFVG Ultimate+ Deluxe: Sellside liquidity swept on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1238. if alSweep and sweepBearNow
  1239. alert("iFVG Ultimate+ Deluxe: Buyside liquidity swept on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1240. if alInv and newSetup
  1241. alert("iFVG Ultimate+ Deluxe: " + (lastSetup.bull ? "Bullish" : "Bearish") + " IFVG (" + lastSetup.grade + ") on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1242. if alPotInv and potInv and not newSetup
  1243. alert("iFVG Ultimate+ Deluxe: Potential inversion forming on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1244. if alInvalid and invalidNow
  1245. alert("iFVG Ultimate+ Deluxe: Setup invalidated on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1246. if alMtf and newSetup and mtfConf
  1247. alert("iFVG Ultimate+ Deluxe: MTF confluence (HTF delivery + SMT) on " + syminfo.ticker, alert.freq_once_per_bar_close)
  1248.  
Advertisement
Comments
  • Sarkorqi
    1 hour
    # CSS 0.92 KB | 0 0
    1. ✅ Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1WhlQi8xpq819kqTE2nXcZTAeCgQ5m-ic2pm_7IZVt7w/edit?usp=sharing
    4.  
    5. This made me $12,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 50% — they will simply correct the exchange rate.
    8.  
    9. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    10.  
    11. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from Changelly — instant swap).
    12.  
    13. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment