xmd79

EDiCrypto | Trend Lines

Apr 21st, 2021
552
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.29 KB | None | 0 0
  1.  
  2. //@version=4
  3. study("EDiCrypto | Trend Lines", overlay=true, max_bars_back = 4000)
  4. startyear = input(defval = 2020, title = "Start Year")
  5. startmonth = input(defval = 1, title = "Start Month")
  6. startday = input(defval = 1, title = "Start day")
  7. prd = input(defval = 20, title="Pivot Point Period", minval = 10, maxval = 50)
  8. PPnum = input(defval = 10, title="Number of Pivot Point to check", minval = 2, maxval = 10)
  9. linestylei= input(defval = 'Solid', title = "Line Style", options =['Solid', 'Dashed'])
  10. linewidth = input(defval = 2, title = "Line Width", minval = 1, maxval = 4)
  11. showbroken = input(defval = false, title="Show Broken Trend Lines ")
  12. extendlines = input(defval = true, title="Extend Lines")
  13. showpivot = input(defval = false, title="Show Pivot Points")
  14. chbcol = input(defval = true, title="Change Bar Colors")
  15.  
  16. float ph = na, float pl = na
  17. ph := pivothigh(prd, prd)
  18. pl := pivotlow(prd, prd)
  19.  
  20. plotshape(ph and showpivot, text="H", style=shape.labeldown, color=color.white, textcolor=color.black, location=location.abovebar, transp=0, offset = -prd)
  21. plotshape(pl and showpivot, text="L", style=shape.labeldown, color=color.white, textcolor=color.black, location=location.belowbar, transp=0, offset = -prd)
  22.  
  23. getloc(bar_i)=>
  24. _ret = bar_index + prd - bar_i
  25.  
  26. //get last 10 pivot highs - (hope to have Array in Pine version 5)
  27. t1pos = valuewhen(ph, bar_index, 0)
  28. t1val = nz(high[getloc(t1pos)])
  29. t2pos = valuewhen(ph, bar_index, 1)
  30. t2val = nz(high[getloc(t2pos)])
  31. t3pos = valuewhen(ph, bar_index, 2)
  32. t3val = nz(high[getloc(t3pos)])
  33. t4pos = valuewhen(ph, bar_index, 3)
  34. t4val = nz(high[getloc(t4pos)])
  35. t5pos = valuewhen(ph, bar_index, 4)
  36. t5val = nz(high[getloc(t5pos)])
  37. t6pos = valuewhen(ph, bar_index, 5)
  38. t6val = nz(high[getloc(t6pos)])
  39. t7pos = valuewhen(ph, bar_index, 6)
  40. t7val = nz(high[getloc(t7pos)])
  41. t8pos = valuewhen(ph, bar_index, 7)
  42. t8val = nz(high[getloc(t8pos)])
  43. t9pos = valuewhen(ph, bar_index, 8)
  44. t9val = nz(high[getloc(t9pos)])
  45. t10pos = valuewhen(ph, bar_index, 9)
  46. t10val = nz(high[getloc(t10pos)])
  47.  
  48. //get last 10 pivot lows
  49. b1pos = valuewhen(pl, bar_index, 0)
  50. b1val = nz(low[getloc(b1pos)])
  51. b2pos = valuewhen(pl, bar_index, 1)
  52. b2val = nz(low[getloc(b2pos)])
  53. b3pos = valuewhen(pl, bar_index, 2)
  54. b3val = nz(low[getloc(b3pos)])
  55. b4pos = valuewhen(pl, bar_index, 3)
  56. b4val = nz(low[getloc(b4pos)])
  57. b5pos = valuewhen(pl, bar_index, 4)
  58. b5val = nz(low[getloc(b5pos)])
  59. b6pos = valuewhen(pl, bar_index, 5)
  60. b6val = nz(low[getloc(b6pos)])
  61. b7pos = valuewhen(pl, bar_index, 6)
  62. b7val = nz(low[getloc(b7pos)])
  63. b8pos = valuewhen(pl, bar_index, 7)
  64. b8val = nz(low[getloc(b8pos)])
  65. b9pos = valuewhen(pl, bar_index, 8)
  66. b9val = nz(low[getloc(b9pos)])
  67. b10pos = valuewhen(pl, bar_index, 9)
  68. b10val = nz(low[getloc(b10pos)])
  69.  
  70. getloval(l1, l2)=>
  71. _ret1 = l1 == 1 ? b1val : l1 == 2 ? b2val : l1 ==3 ? b3val : l1 == 4 ? b4val : l1 == 5 ? b5val : l1 == 6 ? b6val : l1 == 7 ? b7val : l1 == 8 ? b8val : l1 == 9 ? b9val : l1 == 10 ? b10val : 0
  72. _ret2 = l2 == 1 ? b1val : l2 == 2 ? b2val : l2 ==3 ? b3val : l2 == 4 ? b4val : l2 == 5 ? b5val : l2 == 6 ? b6val : l2 == 7 ? b7val : l2 == 8 ? b8val : l2 == 9 ? b9val : l2 == 10 ? b10val : 0
  73. [_ret1, _ret2]
  74.  
  75. getlopos(l1, l2)=>
  76. _ret1 = l1 == 1 ? b1pos : l1 == 2 ? b2pos : l1 ==3 ? b3pos : l1 == 4 ? b4pos : l1 == 5 ? b5pos : l1 == 6 ? b6pos : l1 == 7 ? b7pos : l1 == 8 ? b8pos : l1 == 9 ? b9pos : l1 == 10 ? b10pos : 0
  77. _ret2 = l2 == 1 ? b1pos : l2 == 2 ? b2pos : l2 ==3 ? b3pos : l2 == 4 ? b4pos : l2 == 5 ? b5pos : l2 == 6 ? b6pos : l2 == 7 ? b7pos : l2 == 8 ? b8pos : l2 == 9 ? b9pos : l2 == 10 ? b10pos : 0
  78. [_ret1, _ret2]
  79.  
  80. gethival(l1, l2)=>
  81. _ret1 = l1 == 1 ? t1val : l1 == 2 ? t2val : l1 ==3 ? t3val : l1 == 4 ? t4val : l1 == 5 ? t5val : l1 == 6 ? t6val : l1 == 7 ? t7val : l1 == 8 ? t8val : l1 == 9 ? t9val : l1 == 10 ? t10val : 0
  82. _ret2 = l2 == 1 ? t1val : l2 == 2 ? t2val : l2 ==3 ? t3val : l2 == 4 ? t4val : l2 == 5 ? t5val : l2 == 6 ? t6val : l2 == 7 ? t7val : l2 == 8 ? t8val : l2 == 9 ? t9val : l2 == 10 ? t10val : 0
  83. [_ret1, _ret2]
  84.  
  85. gethipos(l1, l2)=>
  86. _ret1 = l1 == 1 ? t1pos : l1 == 2 ? t2pos : l1 ==3 ? t3pos : l1 == 4 ? t4pos : l1 == 5 ? t5pos : l1 == 6 ? t6pos : l1 == 7 ? t7pos : l1 == 8 ? t8pos : l1 == 9 ? t9pos : l1 == 10 ? t10pos : 0
  87. _ret2 = l2 == 1 ? t1pos : l2 == 2 ? t2pos : l2 ==3 ? t3pos : l2 == 4 ? t4pos : l2 == 5 ? t5pos : l2 == 6 ? t6pos : l2 == 7 ? t7pos : l2 == 8 ? t8pos : l2 == 9 ? t9pos : l2 == 10 ? t10pos : 0
  88. [_ret1, _ret2]
  89.  
  90. // line definitions
  91. var line l1 = na, var line l2 = na, var line l3 = na, var line l4 = na, var line l5 = na, var line l6 = na, var line l7 = na, var line l8 = na, var line l9 = na, var line l10 = na
  92. var line l11 = na, var line l12 = na, var line l13 = na, var line l14 = na, var line l15 = na, var line l16 = na, var line l17 = na, var line l18 = na, var line l19 = na, var line l20 = na
  93. var line t1 = na, var line t2 = na, var line t3 = na, var line t4 = na, var line t5 = na, var line t6 = na, var line t7 = na, var line t8 = na, var line t9 = na, var line t10 = na
  94. var line t11 = na, var line t12 = na, var line t13 = na, var line t14 = na, var line t15 = na, var line t16 = na, var line t17 = na, var line t18 = na, var line t19 = na, var line t20 = na
  95.  
  96. //delete old lines
  97. line.delete(l1), line.delete(l2), line.delete(l3), line.delete(l4), line.delete(l5), line.delete(l6), line.delete(l7), line.delete(l8), line.delete(l9), line.delete(l10)
  98. line.delete(l11), line.delete(l12), line.delete(l13), line.delete(l14), line.delete(l15), line.delete(l16), line.delete(l17), line.delete(l18), line.delete(l19), line.delete(l20)
  99. line.delete(t1), line.delete(t2), line.delete(t3), line.delete(t4), line.delete(t5), line.delete(t6), line.delete(t7), line.delete(t8), line.delete(t9), line.delete(t10)
  100. line.delete(t11), line.delete(t12), line.delete(t13), line.delete(t14), line.delete(t15), line.delete(t16), line.delete(t17), line.delete(t18), line.delete(t19), line.delete(t20)
  101.  
  102. // there is limitation for number of lines on chart (<=50), and we use 20 uptrend lines + 20 downtrend lines (total 40)
  103. maxline = 20
  104.  
  105. //Line coloring
  106. ulcolor = color.red
  107. dlcolor = color.blue
  108.  
  109. //Line style
  110. linestyle = linestylei == 'Solid' ? line.style_solid : line.style_dashed
  111. brokenstyle = line.style_dotted
  112.  
  113. // extend lines
  114. extln = extendlines ? extend.right : extend.none
  115.  
  116. // loop for pivot points to check if there is possible trend line
  117. countlinelo = 0
  118. countlinehi = 0
  119. brokenup = false
  120. brokendown = false
  121.  
  122. starttime = timestamp(startyear, startmonth, startday, 0, 0, 0)
  123.  
  124. if time >= starttime
  125. for p1 = 1 to PPnum - 1
  126. uv1 = 0.0
  127. uv2 = 0.0
  128. up1 = 0
  129. up2 = 0
  130. if countlinelo <= maxline
  131. for p2 = PPnum to p1 + 1
  132. [val1, val2] = getloval(p1, p2)
  133. [pos1, pos2] = getlopos(p1, p2)
  134. if val1 > val2
  135. diff = (val1 - val2) / (pos1 - pos2)
  136. hline = val2 + diff
  137. lloc = bar_index
  138. lval = low
  139. valid = true
  140. brokentrend = false
  141. xc = 0
  142. for x = pos2 + 1 - prd to bar_index
  143. xc := x
  144. if nz(close[getloc(x + prd)]) < hline
  145. valid := false
  146. if x + prd >= pos1
  147. brokentrend := true
  148. break
  149. lloc := x
  150. lval := hline
  151. hline := hline + diff
  152.  
  153. if brokentrend and xc >= bar_index
  154. brokendown := true
  155.  
  156. if valid
  157. uv1 := hline
  158. uv2 := val2
  159. up1 := lloc
  160. up2 := pos2
  161. break
  162.  
  163. if showbroken and not valid and countlinelo < maxline and brokentrend
  164. countlinelo := countlinelo + 1
  165. l1 := countlinelo == 1 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l1
  166. l2 := countlinelo == 2 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l2
  167. l3 := countlinelo == 3 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l3
  168. l4 := countlinelo == 4 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l4
  169. l5 := countlinelo == 5 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l5
  170. l6 := countlinelo == 6 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l6
  171. l7 := countlinelo == 7 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l7
  172. l8 := countlinelo == 8 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l8
  173. l9 := countlinelo == 9 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l9
  174. l10 := countlinelo == 10 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l10
  175. l11 := countlinelo == 11 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l11
  176. l12 := countlinelo == 12 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l12
  177. l13 := countlinelo == 13 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l13
  178. l14 := countlinelo == 14 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l14
  179. l15 := countlinelo == 15 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l15
  180. l16 := countlinelo == 16 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l16
  181. l17 := countlinelo == 17 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l17
  182. l18 := countlinelo == 18 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l18
  183. l19 := countlinelo == 19 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l19
  184. l20 := countlinelo == 20 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = dlcolor) : l20
  185. dv1 = 0.0
  186. dv2 = 0.0
  187. dp1 = 0
  188. dp2 = 0
  189. if countlinehi <= maxline
  190. for p2 = PPnum to p1 + 1
  191. [val1, val2] = gethival(p1, p2)
  192. [pos1, pos2] = gethipos(p1, p2)
  193. if val1 < val2
  194. diff = (val2 - val1) / (pos1 - pos2)
  195. hline = val2 - diff
  196. lloc = bar_index
  197. lval = high
  198. valid = true
  199. brokentrend = false
  200. xc = 0
  201. for x = pos2 + 1 - prd to bar_index
  202. xc := x
  203. if nz(close[getloc(x + prd)]) > hline
  204. valid := false
  205. if x + prd >= pos1
  206. brokentrend := true
  207. break
  208. lloc := x
  209. lval := hline
  210. hline := hline - diff
  211. if brokentrend and xc >= bar_index
  212. brokenup := true
  213.  
  214. brokenup
  215. if valid
  216. dv1 := hline
  217. dv2 := val2
  218. dp1 := lloc
  219. dp2 := pos2
  220. break
  221.  
  222. if showbroken and not valid and countlinehi < maxline and brokentrend
  223. countlinehi := countlinehi + 1
  224. t1 := countlinehi == 1 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t1
  225. t2 := countlinehi == 2 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t2
  226. t3 := countlinehi == 3 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t3
  227. t4 := countlinehi == 4 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t4
  228. t5 := countlinehi == 5 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t5
  229. t6 := countlinehi == 6 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t6
  230. t7 := countlinehi == 7 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t7
  231. t8 := countlinehi == 8 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t8
  232. t9 := countlinehi == 9 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t9
  233. t10 := countlinehi == 10 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t10
  234. t11 := countlinehi == 11 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t11
  235. t12 := countlinehi == 12 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t12
  236. t13 := countlinehi == 13 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t13
  237. t14 := countlinehi == 14 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t14
  238. t15 := countlinehi == 15 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t15
  239. t16 := countlinehi == 16 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t16
  240. t17 := countlinehi == 17 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t17
  241. t18 := countlinehi == 18 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t18
  242. t19 := countlinehi == 19 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t19
  243. t20 := countlinehi == 20 ? line.new(pos2 - prd, val2, lloc, lval, style = brokenstyle, color = ulcolor) : t20
  244.  
  245. // if there is continues uptrend line then draw it
  246. if up1 != 0 and up2 != 0 and countlinelo < maxline
  247. countlinelo := countlinelo + 1
  248. l1 := countlinelo == 1 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l1
  249. l2 := countlinelo == 2 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l2
  250. l3 := countlinelo == 3 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l3
  251. l4 := countlinelo == 4 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l4
  252. l5 := countlinelo == 5 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l5
  253. l6 := countlinelo == 6 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l6
  254. l7 := countlinelo == 7 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l7
  255. l8 := countlinelo == 8 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l8
  256. l9 := countlinelo == 9 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l9
  257. l10 := countlinelo == 10 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l10
  258. l11 := countlinelo == 11 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l11
  259. l12 := countlinelo == 12 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l12
  260. l13 := countlinelo == 13 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l13
  261. l14 := countlinelo == 14 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l14
  262. l15 := countlinelo == 15 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l15
  263. l16 := countlinelo == 16 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l16
  264. l17 := countlinelo == 17 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l17
  265. l18 := countlinelo == 18 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l18
  266. l19 := countlinelo == 19 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l19
  267. l20 := countlinelo == 20 ? line.new(up2 - prd, uv2, up1, uv1, style = linestyle, color = dlcolor, width = linewidth, extend = extln) : l20
  268.  
  269. // if there is continues downtrend line then draw it
  270. if dp1 != 0 and dp2 != 0 and countlinehi < maxline
  271. countlinehi := countlinehi + 1
  272. t1 := countlinehi == 1 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t1
  273. t2 := countlinehi == 2 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t2
  274. t3 := countlinehi == 3 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t3
  275. t4 := countlinehi == 4 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t4
  276. t5 := countlinehi == 5 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t5
  277. t6 := countlinehi == 6 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t6
  278. t7 := countlinehi == 7 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t7
  279. t8 := countlinehi == 8 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t8
  280. t9 := countlinehi == 9 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t9
  281. t10 := countlinehi == 10 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t10
  282. t11 := countlinehi == 11 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t11
  283. t12 := countlinehi == 12 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t12
  284. t13 := countlinehi == 13 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t13
  285. t14 := countlinehi == 14 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t14
  286. t15 := countlinehi == 15 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t15
  287. t16 := countlinehi == 16 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t16
  288. t17 := countlinehi == 17 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t17
  289. t18 := countlinehi == 18 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t18
  290. t19 := countlinehi == 19 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t19
  291. t20 := countlinehi == 20 ? line.new(dp2 - prd, dv2, dp1, dv1, style = linestyle, color = ulcolor, width = linewidth, extend = extln) : t20
  292.  
  293.  
  294. barcol = iff(chbcol, iff(brokenup, color.new(color.blue, 0), iff(brokendown,#9598a1, na)), na)
  295. barcolor(barcol)
  296.  
  297. alertcondition(brokenup, title='Trendline Broken Up', message='Trendline Broken Up')
  298. alertcondition(brokendown, title='Trendline Broken Down', message='Trendline Broken Down')
  299.  
Advertisement
Add Comment
Please, Sign In to add comment