xmd79

ICT NY Model

Dec 10th, 2022
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.52 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © Shanxia
  3.  
  4. //@version=5
  5.  
  6. indicator("ICT NY Model", "ICT NY", overlay=true, max_lines_count=500)
  7.  
  8. ////////// INPUTS \\\\\\\\\\
  9.  
  10.  
  11. i_d4 = input.string ("GMT-4", "Timezone", options=["GMT+0", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12",
  12. "GMT-1", "GMT-2", "GMT-3","GMT-4","GMT","GMT-6","GMT-7","GMT-8","GMT-9","GMT-10","GMT-11","GMT-12"])
  13.  
  14. s1 = input.session ("0830-0931:1234567", "", inline="i1")
  15. s2 = input.session ("0930-1131:1234567", "", inline="i2")
  16. s3 = input.session ("1330-1501:1234567", "", inline="i3")
  17. s4 = input.session ("1500-1601:1234567", "", inline="i4")
  18.  
  19.  
  20. c1 = input.color (color.new(color.silver, 85), "", inline="i1")
  21. c2 = input.color (color.new(color.silver, 92), "", inline="i2")
  22. c3 = input.color (color.new(color.aqua, 92), "", inline="i3")
  23. c4 = input.color (color.new(color.aqua, 85), "", inline="i4")
  24.  
  25.  
  26. i_bool1 = input.bool (true, "NY 00.00am", group="Opens (Local Time)", inline="1")
  27. i_bool2 = input.bool (true, "NY 8.30am ", group="Opens (Local Time)", inline="2")
  28. i_bool3 = input.bool (true, "NY 9.30am ", group="Opens (Local Time)", inline="3")
  29. i_bool4 = input.bool (true, "London Open", group="Opens (Local Time)", inline="4")
  30.  
  31.  
  32. i_linecol1 = input.color (#d40c0c, "", group="Opens (Local Time)", inline="1")
  33. i_txtcol = input.color (#676767, "Text color", group="Opens (Local Time)", inline="1")
  34. i_linecol2 = input.color (#fbc02d, "", group="Opens (Local Time)", inline="2")
  35. i_llh = input.bool (true, "London H/L", group="Opens (Local Time)", inline="2")
  36. i_lonhl = input.color (#a2a2a2, "", group="Opens (Local Time)", inline="2")
  37. i_linecol3 = input.color (#00cd88, "", group="Opens (Local Time)", inline="3")
  38. i_linecol4 = input.color (#008fff, "", group="Opens (Local Time)", inline="4")
  39. lonr = input.session ("0300-0700:1234567", "London")
  40. i_linewidth = input.int (1, "Linewidth", 0, 5, inline="in0")
  41. i_vstyle = input.string ("Dashed", "Style", options=["Solid", "Dotted", "Dashed"], inline="in1")
  42. i_linestyle = input.string ("Solid", " ", options=["Solid", "Dotted", "Dashed"], inline="in1")
  43. i_dev = input.bool (false, 'Deviations', inline='x1')
  44. i_devno = input.int (2 , "", minval=1, inline='x1')
  45.  
  46.  
  47.  
  48. ////////// VARIABLES \\\\\\\\\\
  49.  
  50. ny830 = time("1", s1, i_d4)
  51. ny930 = time("1", s2, i_d4)
  52. ny130 = time("1", s3, i_d4)
  53. ny300 = time("1", s4, i_d4)
  54.  
  55. i_time = '0000-0001:1234567'
  56. i_time2 = '0830-0831:1234567'
  57. i_time3 = '0930-0931:1234567'
  58. i_time4 = '0800-0801:1234567'
  59.  
  60. linestyle = i_linestyle == "Solid" ? line.style_solid : i_linestyle == "Dotted" ? line.style_dotted : line.style_dashed
  61. vstyle = i_vstyle == "Solid" ? line.style_solid : i_vstyle == "Dotted" ? line.style_dotted : line.style_dashed
  62.  
  63.  
  64. ////////// FUNCTION DECLARATIONS \\\\\\\\\\
  65.  
  66.  
  67. in_session(sess) =>
  68. not na(time(timeframe.period, sess, i_d4))
  69.  
  70. start_time(sess) =>
  71. int startTime = na
  72. startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
  73. startTime
  74.  
  75. is_new_session(res, sess) =>
  76. t = time(res, sess, i_d4)
  77. na(t[1]) and not na(t) or t[1] < t
  78.  
  79. _hline(StartTime, EndTime, Price, Color, Style, Width) =>
  80. return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=extend.none, color=Color, style=Style, width=Width)
  81.  
  82.  
  83. f_vline(a, f, b, d, e, sess) =>
  84. var line fl1 = na
  85. var line fl2 = na
  86. var linefill lf1 = na
  87. st_vl = timestamp(i_d4, year, month, sess, a, f, 00)
  88. en_vl = timestamp(i_d4, year, month, sess, b, e, 00)
  89. fl1 := line.new(st_vl, high, st_vl, low, xloc.bar_time, extend.both, color.new(color.white, 100), line.style_solid, 1)
  90. line.delete(fl1[1])
  91. fl2 := line.new(en_vl, high, en_vl, low, xloc.bar_time, extend.both, color.new(color.white, 100), line.style_solid, 1)
  92. line.delete(fl2[1])
  93. lf1 := linefill.new(fl1, fl2, d)
  94. linefill.delete(lf1[1])
  95. for i = 0 to 100
  96. if time > line.get_x1(fl2[i])
  97. line.delete(fl2[i])
  98. line.delete(fl1[i])
  99.  
  100.  
  101. openline(sess, timezone, col, txt, st, boo) =>
  102. _open = request.security(syminfo.tickerid, "1", open, barmerge.gaps_on, barmerge.lookahead_on)
  103. nymid= time("1", sess, timezone)
  104. var openprice = 0.0
  105. var label lb = na
  106. var line lne = na
  107. if nymid
  108. if not nymid[1]
  109. openprice := _open
  110. else
  111. openprice := math.max(_open, openprice)
  112. if openprice != openprice[1] and boo
  113. if barstate.isconfirmed
  114. line.set_x2(lne, nymid)
  115. line.set_extend(lne, extend.none)
  116. lne := line.new(nymid, openprice, nymid + 86400000 , openprice, xloc.bar_time, extend.none, col, st, i_linewidth)
  117. lb := label.new(nymid + 86400000, openprice, txt, xloc.bar_time, yloc.price, na, label.style_none, i_txtcol)
  118.  
  119.  
  120.  
  121. lrange(kz, bdcol, col1)=>
  122. sesh = is_new_session('1440', kz)
  123. float kzlow = na
  124. float kzhigh = na
  125. bline = line(na)
  126. bline2 = line(na)
  127. lab1 = label(na)
  128. lab2 = label(na)
  129. kzstart = start_time(kz) + 19800000
  130. labst = start_time(kz) + 46800000
  131. kzlow := sesh ? low : in_session(kz) ? math.min(low, kzlow[1]) : na
  132. kzhigh := sesh ? high : in_session(kz) ? math.max(high, kzhigh[1]) : na
  133. devdiff = kzhigh[1] - kzlow[1]
  134.  
  135. if in_session(kz)
  136. if in_session(kz)[1]
  137. line.delete(bline[1])
  138. line.delete(bline2[1])
  139. if low < kzlow
  140. kzlow := low
  141. kzlow
  142. if high > kzhigh
  143. kzhigh := high
  144. kzhigh
  145.  
  146. bline := line.new(kzstart, kzhigh, kzstart + 27000000, kzhigh, xloc.bar_time, extend.none, bdcol, line.style_solid, 4)
  147. bline
  148. bline2 := line.new(kzstart, kzlow, kzstart + 27000000, kzlow, xloc.bar_time, extend.none, bdcol, line.style_solid, 4)
  149. bline2
  150. lab1 := label.new(labst, kzhigh, "L • High", xloc.bar_time, yloc.price, color.new(#ffffff, 100), label.style_label_down, i_txtcol)
  151. label.delete(lab1[1])
  152. lab2 := label.new(labst, kzlow, "L • Low", xloc.bar_time, yloc.price, color.new(#ffffff, 100), label.style_label_up, i_txtcol)
  153. label.delete(lab2[1])
  154. tz = time - time[1]
  155. if i_dev and not in_session(kz) and in_session(kz)[1]
  156. for s = 1 to i_devno by 1
  157. _hline(kzstart, kzstart + 27000000, kzhigh[1] + devdiff * s, col1, line.style_solid, 3)
  158. _hline(kzstart, kzstart + 27000000, kzlow[1] - devdiff * s, col1, line.style_solid, 3)
  159.  
  160.  
  161. hf(x, a, b, c) =>
  162. y = line(na)
  163. z = line(na)
  164. lf = linefill(na)
  165. st = start_time(b)
  166. if in_session(b)
  167. y := line.new(st, high, st, low, xloc.bar_time, extend.both, color.new(#ffffff, 100))
  168. z := line.new(st + c , high, st + c , low, xloc.bar_time, extend.both, color.new(#ffffff, 100))
  169. lf := linefill.new(z, y, a)
  170. line.delete(y[1])
  171. line.delete(z[1])
  172. linefill.delete(lf[1])
  173.  
  174.  
  175. ////////// FUNCTIONS \\\\\\\\\\
  176.  
  177.  
  178. if timeframe.isintraday and timeframe.multiplier <= 30
  179. openline(i_time, i_d4, i_linecol1, "00.00", vstyle, i_bool1)
  180. openline(i_time2, i_d4, i_linecol2, "08.30", linestyle, i_bool2)
  181. openline(i_time3, i_d4, i_linecol3, "09.30", linestyle, i_bool3)
  182. openline(i_time4, "GMT+1", i_linecol4, "London", linestyle, i_bool4)
  183.  
  184. if i_llh
  185.  
  186. lrange(lonr, i_lonhl, i_lonhl)
  187.  
  188. hf(ny830, c1, s1, 3600000)
  189. hf(ny930, c2, s2, 7200000)
  190. hf(ny130, c3, s3, 5400000)
  191. hf(ny300, c4, s4, 3600000)
  192.  
  193. f_vline(08, 30, 09, c1, 30, dayofmonth)
  194. f_vline(09, 30, 11, c2, 30, dayofmonth)
  195. f_vline(13, 30, 15, c3, 00, dayofmonth)
  196. f_vline(15, 00, 16, c4, 00, dayofmonth)
  197. f_vline(08, 30, 09, c1, 30, dayofmonth + 1)
  198. f_vline(09, 30, 11, c2, 30, dayofmonth + 1)
  199. f_vline(13, 30, 15, c3, 00, dayofmonth + 1)
  200. f_vline(15, 00, 16, c4, 00, dayofmonth + 1)
Advertisement
Add Comment
Please, Sign In to add comment