xmd79

Elliott Wave [LuxAlgo]

Mar 14th, 2023
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.15 KB | None | 0 0
  1. // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
  2. // © LuxAlgo
  3.  
  4. //@version=5
  5. indicator("Elliott Wave [LuxAlgo]", max_lines_count=500, max_labels_count=500, overlay=true, max_bars_back=5000)
  6. //------------------------------------------------------------------------------
  7. //Settings
  8. //-----------------------------------------------------------------------------{
  9. i_hi = input.string('high' , title= '' , group='source [high - low]', inline='hl', options=['high', 'close', 'max open/close'])
  10. i_lo = input.string('low' , title= '' , group='source [high - low]', inline='hl', options=['low' , 'close', 'min open/close'])
  11.  
  12. s1 = input.bool (true , title= '' , group='ZigZag' , inline= '1' )
  13. len1 = input.int ( 4 , title= '  1 Length', group='ZigZag' , inline= '1', minval =1 )
  14. col1 = input.color (color.red , title= '' , group='ZigZag' , inline= '1' )
  15. s2 = input.bool (true , title= '' , group='ZigZag' , inline= '2' )
  16. len2 = input.int ( 8 , title= '  2 Length', group='ZigZag' , inline= '2', minval =1 )
  17. col2 = input.color (color.blue , title= '' , group='ZigZag' , inline= '2' )
  18. s3 = input.bool (true , title= '' , group='ZigZag' , inline= '3' )
  19. len3 = input.int (16 , title= '  3 Length', group='ZigZag' , inline= '3', minval =1 )
  20. col3 = input.color (color.white , title= '' , group='ZigZag' , inline= '3' )
  21.  
  22.  
  23. i_500 = input.float (0.500 , title='           level 1', group='Fibonacci values' , minval =0, maxval =1, step =0.01 )
  24. i_618 = input.float (0.618 , title='           level 2', group='Fibonacci values' , minval =0, maxval =1, step =0.01 )
  25. i_764 = input.float (0.764 , title='           level 3', group='Fibonacci values' , minval =0, maxval =1, step =0.01 )
  26. i_854 = input.float (0.854 , title='           level 4', group='Fibonacci values' , minval =0, maxval =1, step =0.01 )
  27.  
  28. shZZ = input.bool (false , title= '' , group='show ZZ' , inline='zz' )
  29.  
  30. //-----------------------------------------------------------------------------}
  31. //User Defined Types
  32. //-----------------------------------------------------------------------------{
  33. type ZZ
  34. int [] d
  35. int [] x
  36. float[] y
  37. line [] l
  38.  
  39. type Ewave
  40. line l1
  41. line l2
  42. line l3
  43. line l4
  44. line l5
  45. label b1
  46. label b2
  47. label b3
  48. label b4
  49. label b5
  50. //
  51. bool on
  52. bool br //= na
  53. //
  54. int dir
  55. //
  56. line lA
  57. line lB
  58. line lC
  59. label bA
  60. label bB
  61. label bC
  62. //
  63. bool next = false
  64. //
  65. label lb
  66. box bx
  67.  
  68. type fibL
  69. line wave1_0_500
  70. line wave1_0_618
  71. line wave1_0_764
  72. line wave1_0_854
  73. line wave1_pole_
  74. linefill l_fill_
  75. bool _break_ //= na
  76.  
  77. //-----------------------------------------------------------------------------}
  78. //Functions
  79. //-----------------------------------------------------------------------------{
  80. hi = i_hi == 'high' ? high : i_hi == 'close' ? close : math.max(open, close)
  81. lo = i_lo == 'low' ? low : i_hi == 'close' ? close : math.min(open, close)
  82.  
  83. in_out(aZZ, d, x1, y1, x2, y2, col) =>
  84. aZZ.d.unshift(d), aZZ.x.unshift(x2), aZZ.y.unshift(y2), aZZ.d.pop(), aZZ.x.pop(), aZZ.y.pop()
  85. if shZZ
  86. aZZ.l.unshift(line.new(x1, y1, x2, y2, color= col)), aZZ.l.pop().delete()
  87.  
  88. method isSame(Ewave gEW, _1x, _2x, _3x, _4x) =>
  89. t1 = _1x == gEW.l1.get_x1()
  90. t2 = _2x == gEW.l2.get_x1()
  91. t3 = _3x == gEW.l3.get_x1()
  92. t4 = _4x == gEW.l4.get_x1()
  93. t1 and t2 and t3 and t4
  94.  
  95. method isSame2(Ewave gEW, _1x, _2x, _3x) =>
  96. t1 = _1x == gEW.l3.get_x2()
  97. t2 = _2x == gEW.l4.get_x2()
  98. t3 = _3x == gEW.l5.get_x2()
  99. t1 and t2 and t3
  100.  
  101. method dot(Ewave gEW) =>
  102. gEW.l1.set_style(line.style_dotted)
  103. gEW.l2.set_style(line.style_dotted)
  104. gEW.l3.set_style(line.style_dotted)
  105. gEW.l4.set_style(line.style_dotted)
  106. gEW.l5.set_style(line.style_dotted)
  107. gEW.b1.set_textcolor (color(na))
  108. gEW.b2.set_textcolor (color(na))
  109. gEW.b3.set_textcolor (color(na))
  110. gEW.b4.set_textcolor (color(na))
  111. gEW.b5.set_textcolor (color(na))
  112. gEW.on := false
  113.  
  114. method dash(Ewave gEW) =>
  115. gEW.lA.set_style(line.style_dashed)
  116. gEW.lB.set_style(line.style_dashed)
  117. gEW.lC.set_style(line.style_dashed)
  118. gEW.bA.set_textcolor (color(na))
  119. gEW.bB.set_textcolor (color(na))
  120. gEW.bC.set_textcolor (color(na))
  121. gEW.bx.set_bgcolor (color(na))
  122. gEW.bx.set_border_color (color(na))
  123.  
  124. method sol_dot(fibL nFibL, sol_dot, col) =>
  125. style =
  126. sol_dot == 'dot' ?
  127. line.style_dotted :
  128. sol_dot == 'sol' ?
  129. line.style_solid :
  130. line.style_dashed
  131. nFibL.wave1_0_500.set_style(style)
  132. nFibL.wave1_0_618.set_style(style)
  133. nFibL.wave1_0_764.set_style(style)
  134. nFibL.wave1_0_854.set_style(style)
  135. nFibL.l_fill_.set_color(col)
  136.  
  137. method set(fibL nFibL, int x1, int x2, float max_500, float max_618, float max_764, float max_854, float y2) =>
  138. nFibL.wave1_0_500.set_xy1(x1, max_500)
  139. nFibL.wave1_0_500.set_xy2(x2, max_500)
  140. nFibL.wave1_0_618.set_xy1(x1, max_618)
  141. nFibL.wave1_0_618.set_xy2(x2, max_618)
  142. nFibL.wave1_0_764.set_xy1(x1, max_764)
  143. nFibL.wave1_0_764.set_xy2(x2, max_764)
  144. nFibL.wave1_0_854.set_xy1(x1, max_854)
  145. nFibL.wave1_0_854.set_xy2(x2, max_854)
  146. nFibL.wave1_pole_.set_xy1(x1, y2 )
  147. nFibL.wave1_pole_.set_xy2(x1, max_854)
  148. nFibL.l_fill_.get_line1().set_xy1(x1, max_764)
  149. nFibL.l_fill_.get_line1().set_xy2(x2, max_764)
  150. nFibL.l_fill_.get_line2().set_xy1(x1, max_854)
  151. nFibL.l_fill_.get_line2().set_xy2(x2, max_854)
  152.  
  153. method setNa(fibL nFibL) =>
  154. nFibL.wave1_0_500.set_xy1(na, na)
  155. nFibL.wave1_0_500.set_xy2(na, na)
  156. nFibL.wave1_0_618.set_xy1(na, na)
  157. nFibL.wave1_0_618.set_xy2(na, na)
  158. nFibL.wave1_0_764.set_xy1(na, na)
  159. nFibL.wave1_0_764.set_xy2(na, na)
  160. nFibL.wave1_0_854.set_xy1(na, na)
  161. nFibL.wave1_0_854.set_xy2(na, na)
  162. nFibL.wave1_pole_.set_xy1(na, na)
  163. nFibL.wave1_pole_.set_xy2(na, na)
  164. nFibL.l_fill_.set_color(color(na))
  165.  
  166. draw(enabled, left, col, n) =>
  167. //
  168. max_bars_back(time, 2000)
  169. var int dir = na, var int x1= na, var float y1 = na, var int x2 = na, var float y2 = na, var Ewave gEW = na
  170. var int last_0x = na , var float last_0y = na , var int last_6x = na , var float last_6y = na
  171. //
  172. if enabled
  173. var fibL nFibL = fibL.new(
  174. wave1_0_500 = line.new(na, na, na, na, color= color.new(col, 50), style= line.style_solid ),
  175. wave1_0_618 = line.new(na, na, na, na, color= color.new(col, 38), style= line.style_solid ),
  176. wave1_0_764 = line.new(na, na, na, na, color= color.new(col, 24), style= line.style_solid ),
  177. wave1_0_854 = line.new(na, na, na, na, color= color.new(col, 15), style= line.style_solid ),
  178. wave1_pole_ = line.new(na, na, na, na, color= color.new(col, 50), style= line.style_dashed),
  179. l_fill_ = linefill.new(
  180. line.new(na, na, na, na, color= color(na))
  181. , line.new(na, na, na, na, color= color(na))
  182. , color= color(na))
  183. , _break_ = na
  184. )
  185. //
  186. var ZZ aZZ = ZZ.new(array.new < int > ()
  187. , array.new < int > ()
  188. , array.new < float > ()
  189. , array.new < line > () )
  190. var Ewave[] aEW = array.new < Ewave > ()
  191. //
  192. if barstate.isfirst
  193. aEW.unshift(Ewave.new())
  194. for i = 0 to 10
  195. aZZ.d.unshift(0)
  196. aZZ.x.unshift(0)
  197. aZZ.y.unshift(0)
  198. aZZ.l.unshift(shZZ ? line.new(na, na, na, na) : na)
  199. //
  200. sz = aZZ.d.size( )
  201. x2 := bar_index -1
  202. ph = ta.pivothigh(hi, left, 1)
  203. pl = ta.pivotlow (lo, left, 1)
  204. t = n == 2 ? '\n\n' : n == 1 ? '\n' : ''
  205. //
  206. // when a new Pivot High is found
  207. if not na(ph)
  208. gEW := aEW.get (0)
  209. dir := aZZ.d.get (0)
  210. x1 := aZZ.x.get (0)
  211. y1 := aZZ.y.get (0)
  212. y2 := nz(hi[1])
  213. //
  214. if dir < 1 // if previous point was a pl, add, and change direction ( 1)
  215. in_out(aZZ, 1, x1, y1, x2, y2, col)
  216. else
  217. if dir == 1 and ph > y1
  218. aZZ.x.set(0, x2), aZZ.y.set(0, y2)
  219. if shZZ
  220. aZZ.l.get(0).set_xy2(x2, y2)
  221. //
  222. _6x = x2, _6y = y2
  223. _5x = aZZ.x.get(1), _5y = aZZ.y.get(1)
  224. _4x = aZZ.x.get(2), _4y = aZZ.y.get(2)
  225. _3x = aZZ.x.get(3), _3y = aZZ.y.get(3)
  226. _2x = aZZ.x.get(4), _2y = aZZ.y.get(4)
  227. _1x = aZZ.x.get(5), _1y = aZZ.y.get(5)
  228. //
  229. // –––––––––––––––––––––[ 12345 ]–––––––––––––––––––––
  230. _W5 = _6y - _5y
  231. _W3 = _4y - _3y
  232. _W1 = _2y - _1y
  233. min = math.min(_W1, _W3, _W5)
  234. isWave =
  235. _W3 != min and
  236. _6y > _4y and
  237. _3y > _1y and
  238. _5y > _2y
  239. //
  240. same = gEW.isSame(_1x, _2x, _3x, _4x)
  241. if isWave
  242. if same
  243. gEW.l5.set_xy2(_6x, _6y)
  244. gEW.b5.set_xy (_6x, _6y)
  245. else
  246. tx = ''
  247. if _2x == aEW.get(0).b5.get_x()
  248. tx := '(5) (1)'
  249. aEW.get(0).b5.set_text('')
  250. else
  251. tx := '(1)'
  252. //
  253. wave = Ewave.new(
  254. l1 = line.new (_1x, _1y, _2x, _2y , color=col , style= line.style_solid ),
  255. l2 = line.new (_2x, _2y, _3x, _3y , color=col , style= line.style_solid ),
  256. l3 = line.new (_3x, _3y, _4x, _4y , color=col , style= line.style_solid ),
  257. l4 = line.new (_4x, _4y, _5x, _5y , color=col , style= line.style_solid ),
  258. l5 = line.new (_5x, _5y, _6x, _6y , color=col , style= line.style_solid ),
  259. b1 = label.new(_2x, _2y, text= tx + t, textcolor=col, color= color(na), style=label.style_label_down),
  260. b2 = label.new(_3x, _3y, text= t + '(2)', textcolor=col, color= color(na), style=label.style_label_up ),
  261. b3 = label.new(_4x, _4y, text= '(3)' + t, textcolor=col, color= color(na), style=label.style_label_down),
  262. b4 = label.new(_5x, _5y, text= t + '(4)', textcolor=col, color= color(na), style=label.style_label_up ),
  263. b5 = label.new(_6x, _6y, text= '(5)' + t, textcolor=col, color= color(na), style=label.style_label_down),
  264. on = true ,
  265. br = false ,
  266. dir = 1
  267. )
  268. aEW.unshift(wave)
  269. nFibL._break_ := false
  270. alert('New EW Motive Bullish Pattern found' , alert.freq_once_per_bar_close)
  271. //
  272. if not isWave
  273. if same and gEW.on == true
  274. gEW.dot()
  275. alert('Invalidated EW Motive Bullish Pattern', alert.freq_once_per_bar_close)
  276. //
  277. // –––––––––––––––––––––[ ABC ]–––––––––––––––––––––
  278. getEW = aEW.get(0)
  279. last_0x := getEW.l1.get_x1(), last_0y := getEW.l1.get_y1()
  280. last_6x := getEW.l5.get_x2(), last_6y := getEW.l5.get_y2()
  281. diff = math.abs(last_6y - last_0y)
  282. //
  283. if getEW.dir == -1
  284. getX = getEW.l5.get_x2()
  285. getY = getEW.l5.get_y2()
  286. isSame2 = getEW.isSame2 (_1x, _2x, _3x)
  287. isValid =
  288. _3x == getX and
  289. _6y < getY + (diff * i_854) and
  290. _4y < getY + (diff * i_854) and
  291. _5y > getY
  292. //
  293. if isValid
  294. width = _6x - _2x // –––[ width (4) - (c) ]–––
  295. if isSame2 and getEW.bA.get_x() > _3x
  296. getEW.lC.set_xy1(_5x, _5y), getEW.lC.set_xy2(_6x, _6y), getEW.bC.set_xy(_6x, _6y), getEW.bx.set_lefttop(_6x, _6y), getEW.bx.set_right(_6x + width)
  297. else
  298. getEW.lA := line.new (_3x, _3y, _4x, _4y, color=col), getEW.bA := label.new(_4x, _4y, text= '(a)' + t, textcolor=col, color= color(na), style=label.style_label_down)
  299. getEW.lB := line.new (_4x, _4y, _5x, _5y, color=col), getEW.bB := label.new(_5x, _5y, text= t + '(b)', textcolor=col, color= color(na), style=label.style_label_up )
  300. getEW.lC := line.new (_5x, _5y, _6x, _6y, color=col), getEW.bC := label.new(_6x, _6y, text= '(c)' + t, textcolor=col, color= color(na), style=label.style_label_down)
  301. getEW.bx := box.new (_6x, _6y, _6x + width, _4y, bgcolor=color.new(col, 93), border_color=color.new(col, 65))
  302. alert('New EW Corrective Bullish Pattern found' , alert.freq_once_per_bar_close)
  303. else
  304. if isSame2 and getEW.bA.get_x() > _3x
  305. getEW.dash()
  306. alert('Invalidated EW Corrective Bullish Pattern', alert.freq_once_per_bar_close)
  307. //
  308. // –––––––––––––––––––––[ new (1) ? ]–––––––––––––––––––––
  309. if getEW.dir == 1
  310. if _5x == getEW.bC.get_x() and
  311. _6y > getEW.b5.get_y() and
  312. getEW.next == false
  313. getEW.next := true
  314. getEW.lb := label.new(_6x, _6y, style=label.style_circle, color=color.new(col, 65), yloc=yloc.abovebar, size=size.tiny)
  315. alert('Possible new start of EW Motive Bullish Wave', alert.freq_once_per_bar_close)
  316. //
  317. // when a new Pivot Low is found
  318. if not na(pl)
  319. gEW := aEW.get (0)
  320. dir := aZZ.d.get (0)
  321. x1 := aZZ.x.get (0)
  322. y1 := aZZ.y.get (0)
  323. y2 := nz(lo[1])
  324. //
  325. if dir > -1 // if previous point was a ph, add, and change direction (-1)
  326. in_out(aZZ, -1, x1, y1, x2, y2, col)
  327. else
  328. if dir == -1 and pl < y1
  329. aZZ.x.set(0, x2), aZZ.y.set(0, y2)
  330. if shZZ
  331. aZZ.l.get(0).set_xy2(x2, y2)
  332. //
  333. _6x = x2, _6y = y2
  334. _5x = aZZ.x.get(1), _5y = aZZ.y.get(1)
  335. _4x = aZZ.x.get(2), _4y = aZZ.y.get(2)
  336. _3x = aZZ.x.get(3), _3y = aZZ.y.get(3)
  337. _2x = aZZ.x.get(4), _2y = aZZ.y.get(4)
  338. _1x = aZZ.x.get(5), _1y = aZZ.y.get(5)
  339. //
  340. // –––––––––––––––––––––[ 12345 ]–––––––––––––––––––––
  341. _W5 = _5y - _6y
  342. _W3 = _3y - _4y
  343. _W1 = _1y - _2y
  344. min = math.min(_W1, _W3, _W5)
  345. isWave =
  346. _W3 != min and
  347. _4y > _6y and
  348. _1y > _3y and
  349. _2y > _5y
  350. //
  351. same = isSame(gEW, _1x, _2x, _3x, _4x)
  352. if isWave
  353. if same
  354. gEW.l5.set_xy2(_6x, _6y)
  355. gEW.b5.set_xy (_6x, _6y)
  356. else
  357. tx = ''
  358. if _2x == aEW.get(0).b5.get_x()
  359. tx := '(5) (1)'
  360. aEW.get(0).b5.set_text('')
  361. else
  362. tx := '(1)'
  363. //
  364. wave = Ewave.new(
  365. l1 = line.new (_1x, _1y, _2x, _2y , color=col , style= line.style_solid ),
  366. l2 = line.new (_2x, _2y, _3x, _3y , color=col , style= line.style_solid ),
  367. l3 = line.new (_3x, _3y, _4x, _4y , color=col , style= line.style_solid ),
  368. l4 = line.new (_4x, _4y, _5x, _5y , color=col , style= line.style_solid ),
  369. l5 = line.new (_5x, _5y, _6x, _6y , color=col , style= line.style_solid ),
  370. b1 = label.new(_2x, _2y, text= t + tx, textcolor=col, color= color(na), style=label.style_label_up ),
  371. b2 = label.new(_3x, _3y, text= '(2)' + t, textcolor=col, color= color(na), style=label.style_label_down),
  372. b3 = label.new(_4x, _4y, text= t + '(3)', textcolor=col, color= color(na), style=label.style_label_up ),
  373. b4 = label.new(_5x, _5y, text= '(4)' + t, textcolor=col, color= color(na), style=label.style_label_down),
  374. b5 = label.new(_6x, _6y, text= t + '(5)', textcolor=col, color= color(na), style=label.style_label_up ),
  375. on = true ,
  376. br = false ,
  377. dir =-1
  378. )
  379. aEW.unshift(wave)
  380. nFibL._break_ := false
  381. alert('New EW Motive Bearish Pattern found' , alert.freq_once_per_bar_close)
  382. //
  383. if not isWave
  384. if same and gEW.on == true
  385. gEW.dot()
  386. alert('Invalidated EW Motive Bearish Pattern', alert.freq_once_per_bar_close)
  387. //
  388. // –––––––––––––––––––––[ ABC ]–––––––––––––––––––––
  389. getEW = aEW.get(0)
  390. last_0x := getEW.l1.get_x1(), last_0y := getEW.l1.get_y1()
  391. last_6x := getEW.l5.get_x2(), last_6y := getEW.l5.get_y2()
  392. diff = math.abs(last_6y - last_0y)
  393. //
  394. if getEW.dir == 1
  395. getX = getEW.l5.get_x2()
  396. getY = getEW.l5.get_y2()
  397. isSame2 = getEW.isSame2 (_1x, _2x, _3x)
  398. isValid =
  399. _3x == getX and
  400. _6y > getY - (diff * i_854) and
  401. _4y > getY - (diff * i_854) and
  402. _5y < getY
  403. //
  404. if isValid
  405. width = _6x - _2x // –––[ width (4) - (c) ]–––
  406. if isSame2 and getEW.bA.get_x() > _3x
  407. getEW.lC.set_xy1(_5x, _5y), getEW.lC.set_xy2(_6x, _6y), getEW.bC.set_xy(_6x, _6y), getEW.bx.set_lefttop(_6x, _6y), getEW.bx.set_right(_6x + width)
  408. else
  409. getEW.lA := line.new (_3x, _3y, _4x, _4y, color=col), getEW.bA := label.new(_4x, _4y, text= t + '(a)', textcolor=col, color= color(na), style=label.style_label_up )
  410. getEW.lB := line.new (_4x, _4y, _5x, _5y, color=col), getEW.bB := label.new(_5x, _5y, text= '(b)' + t, textcolor=col, color= color(na), style=label.style_label_down)
  411. getEW.lC := line.new (_5x, _5y, _6x, _6y, color=col), getEW.bC := label.new(_6x, _6y, text= t + '(c)', textcolor=col, color= color(na), style=label.style_label_up )
  412. getEW.bx := box.new (_6x, _6y, _6x + width, _4y, bgcolor=color.new(col, 93), border_color=color.new(col, 65))
  413. alert('New EW Corrective Bearish Pattern found' , alert.freq_once_per_bar_close)
  414. else
  415. if isSame2 and getEW.bA.get_x() > _3x
  416. getEW.dash()
  417. alert('Invalidated EW Corrective Bullish Pattern', alert.freq_once_per_bar_close)
  418. //
  419. // –––[ check (only once) for a possible new (1) after an impulsive AND corrective wave ]–––
  420. if getEW.dir == -1
  421. if _5x == getEW.bC.get_x() and
  422. _6y < getEW.b5.get_y() and
  423. getEW.next == false
  424. getEW.next := true
  425. getEW.lb := label.new(_6x, _6y, style=label.style_circle, color=color.new(col, 65), yloc=yloc.belowbar, size=size.tiny)
  426. alert('Possible new start of EW Motive Bearish Wave', alert.freq_once_per_bar_close)
  427. //
  428. // –––[ check for break box ]–––
  429. if aEW.size() > 0
  430. gEW := aEW.get(0)
  431. if gEW.dir == 1
  432. if ta.crossunder(low , gEW.bx.get_bottom()) and bar_index <= gEW.bx.get_right()
  433. label.new(bar_index, low , yloc= yloc.belowbar, style= label.style_xcross, color=color.red, size=size.tiny)
  434. else
  435. if ta.crossover (high, gEW.bx.get_top ()) and bar_index <= gEW.bx.get_right()
  436. label.new(bar_index, high, yloc= yloc.abovebar, style= label.style_xcross, color=color.red, size=size.tiny)
  437. //
  438. if barstate.islast
  439. // –––[ get last 2 EW's ]–––
  440. getEW = aEW.get(0)
  441. if aEW.size() > 1
  442. getEW1 = aEW.get(1)
  443. last_0x := getEW.l1.get_x1(), last_0y := getEW.l1.get_y1()
  444. last_6x := getEW.l5.get_x2(), last_6y := getEW.l5.get_y2()
  445. //
  446. diff = math.abs(last_6y - last_0y) // –––[ max/min difference ]–––
  447. _500 = diff * i_500
  448. _618 = diff * i_618
  449. _764 = diff * i_764
  450. _854 = diff * i_854
  451. bull = getEW.dir == 1
  452. // –––[ if EW is not valid or an ABC has developed -> remove fibonacci lines ]–––
  453. if getEW.on == false or getEW.bC.get_x() > getEW.b5.get_x()
  454. nFibL.setNa()
  455. else
  456. // –––[ get.on == true ~ valid EW ]–––
  457. max_500 = last_6y + ((bull ? -1 : 1) * _500)
  458. max_618 = last_6y + ((bull ? -1 : 1) * _618)
  459. max_764 = last_6y + ((bull ? -1 : 1) * _764)
  460. max_854 = last_6y + ((bull ? -1 : 1) * _854)
  461. //
  462. nFibL.set(last_6x, bar_index + 10, max_500, max_618, max_764, max_854, last_6y)
  463. // –––[ if (2) label overlap with (C) label ]–––
  464. if getEW.b2.get_x() == getEW1.bC.get_x()
  465. getEW.b1.set_textcolor(color(na))
  466. getEW.b2.set_textcolor(color(na))
  467. strB = getEW1.bB.get_text()
  468. strC = getEW1.bC.get_text()
  469. strB_ = str.replace(strB, "(b)", "(b) (1)", 0)
  470. strC_ = str.replace(strC, "(c)", "(c) (2)", 0)
  471. getEW1.bB.set_text(strB_)
  472. getEW1.bC.set_text(strC_)
  473. //
  474. // –––[ check if fib limits are broken ]–––
  475. getP_854 = nFibL.wave1_0_854.get_y1()
  476. for i = 0 to bar_index - nFibL.wave1_0_854.get_x1()
  477. if getEW.dir == -1
  478. if high[i] > getP_854
  479. nFibL._break_ := true
  480. break
  481. else
  482. if low [i] < getP_854
  483. nFibL._break_ := true
  484. break
  485. //––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
  486. switch nFibL._break_
  487. true => nFibL.sol_dot('dot', color.new(color.red , 95))
  488. false => nFibL.sol_dot('sol', color.new(color.lime, 95))
  489. =>
  490. nFibL.wave1_0_500.set_xy1(na, na)
  491. nFibL.wave1_0_500.set_xy2(na, na)
  492. nFibL.wave1_0_618.set_xy1(na, na)
  493. nFibL.wave1_0_618.set_xy2(na, na)
  494. nFibL.wave1_0_764.set_xy1(na, na)
  495. nFibL.wave1_0_764.set_xy2(na, na)
  496. nFibL.wave1_0_854.set_xy1(na, na)
  497. nFibL.wave1_0_854.set_xy2(na, na)
  498. nFibL.wave1_pole_.set_xy1(na, na)
  499. nFibL.wave1_pole_.set_xy2(na, na)
  500. nFibL.l_fill_.set_color(color(na))
  501.  
  502. if aEW.size() > 15
  503. pop = aEW.pop()
  504. pop.l1.delete(), pop.b1.delete()
  505. pop.l2.delete(), pop.b2.delete()
  506. pop.l3.delete(), pop.b3.delete()
  507. pop.l4.delete(), pop.b4.delete()
  508. pop.l5.delete(), pop.b5.delete()
  509. pop.lA.delete(), pop.bA.delete()
  510. pop.lB.delete(), pop.bB.delete()
  511. pop.lC.delete(), pop.bC.delete()
  512. pop.lb.delete(), pop.bx.delete()
  513. //----------------------------------
  514.  
  515. //-----------------------------------------------------------------------------}
  516. //Plots
  517. //-----------------------------------------------------------------------------{
  518. draw(s1, len1, col1, 0)
  519. draw(s2, len2, col2, 1)
  520. draw(s3, len3, col3, 2)
  521.  
  522. //-----------------------------------------------------------------------------}
Advertisement
Add Comment
Please, Sign In to add comment