TeamTaurus

[TT] Master

Jun 20th, 2021 (edited)
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.85 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. // © TaurusTeam
  3.  
  4. //@version=4
  5. study("[TT] Master", shorttitle="ॐ" ,overlay=true)
  6. fibpivots = input(false,"Fib Pivots")
  7. Camarilla = input(false,"Cam Pivots")
  8. SelectColor(c_)=> c_ == "aqua" ? color.aqua : c_ == "black" ? color.black : c_ == "blue" ? color.blue : c_ == "fuchsia" ? color.fuchsia : c_ == "gray" ? color.gray : c_ == "green" ? color.green : c_ == "lime" ? color.lime : c_ == "maroon" ? color.maroon : c_ == "navy" ? color.navy : c_ == "olive" ? color.olive : c_ == "orange" ? color.orange : c_ == "purple" ? color.purple : c_ == "red" ? color.red : c_ == "silver" ? color.silver : c_ == "teal" ? color.teal : c_ == "white" ? color.white : c_ == "yellow" ? color.yellow : color.black
  9.  
  10. res = input("12M", type=input.resolution)
  11. Ln_color = input(title="Line Color", defval="maroon", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  12. Ltx_color = input(title="Text Color", defval="gray", options=["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"])
  13. showlast = input(title = "Show Only Last Period", defval = true, tooltip = "Shows only Today levels bar by bar")
  14. On = input(true, "Day Range", group = "Settings ॐ",tooltip="Day Range")
  15. OrB = input(false,"ORB", group ="Settings ॐ", tooltip = "ORB")
  16. sr = input(false,"Show Reversal",group="Settings ॐ")
  17. PAB = input(true, "Price Action Bars",group="Price Action",tooltip="Price Action Bars")
  18. //DarkCloudCoverInput = input(true,title="DCC",group="Price Action")
  19. //PiercingInput = input(false,"Piercing",group="Price Action")
  20. HammerInput = input(true,"Hammer",group="Price Action")
  21. HangingManInput = input(true,"Hanging Man",group="Price Action")
  22. InvertedHammerInput = input(true,"Inverted Hammer",group="Price Action")
  23. //EngulfingInput = input(true,"Engulfing",group="Price Action")
  24. RTbearish = input(true,title="Railway Track Bearish",group="Price Action")
  25. RTbullish = input(true,title="Railway Track Bullish",group="Price Action")
  26. TTbullish = input(true,title="Tweezer Top Bullish",group="Price Action")
  27. TTbearish = input(true,title="Tweezer Top Bearish",group="Price Action")
  28. up = input(defval = color.blue, title="Bullish", group="Settings ॐ", tooltip="Reversal Signal Color")
  29. down = input(defval = color.orange, title="Bearish", group="Settings ॐ", tooltip="Down Reversal SIgnal Color")
  30. sl = input(30, title="Show Last", group="Settings ॐ", tooltip ="Show RR in the last Num of bars")
  31. sig = input(5,"SL length",group="Settings ॐ",tooltip="Length of SL line")
  32. Ecandle = input(false, "Indecisive-Candle", group="Settings ॐ", tooltip="Shows Indecisive Candle")
  33. PDHL = input(false,title="Previous Day Levels",group="Settings ॐ",tooltip="Previous Day High/Low")
  34. ATRTsl = input(false,title="Trailing SL",group="Settings ॐ",tooltip="ATR Trailing SL")
  35. cprturnon = input(false,"CPR", group="Settings ॐ", tooltip="Plot CPR")
  36. chtf = security(syminfo.tickerid, res, close[1], lookahead=true)
  37. hhtf = security(syminfo.tickerid, res, high[1], lookahead=true)
  38. lhtf = security(syminfo.tickerid, res, low[1], lookahead=true)
  39. islast = showlast ? security(syminfo.tickerid, res, barstate.islast, lookahead = true) : true
  40. //Barstate
  41. confirm = barstate.isconfirmed
  42. //Label Settings
  43. mndr = time - time[1]
  44. mndr := change(mndr) > 0 ? mndr[1] : mndr
  45. //Yesterday High/Low
  46. plot(islast and PDHL ? hhtf : na, title = "Day High", color = color.black, linewidth = 2, style = plot.style_line )
  47. plot(islast and PDHL ? lhtf : na, title = "Day Low", color = color.black, linewidth = 2, style = plot.style_line )
  48. if PDHL
  49. var label pdhlabel = na
  50. var label pdllabel = na
  51.  
  52. label.delete(pdhlabel)
  53. label.delete(pdllabel)
  54. pdhlabel := label.new(x = time + mndr * 20, y = hhtf, text = "PDH", textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  55. pdllabel := label.new(x = time + mndr * 20, y = lhtf, text = "PDL", textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  56.  
  57.  
  58. //CPR Pivot {
  59. //////Central Pivot
  60. Pivot = (hhtf + lhtf + chtf)/3
  61. BC = (hhtf + lhtf)/2
  62. TC = (Pivot - BC) + Pivot
  63. //LineStyle
  64. linestylee = plot.style_line
  65.  
  66.  
  67. plot(islast and cprturnon ? TC : na, title = "TC", color = color.blue, linewidth = 1, style = linestylee )
  68. plot(islast and cprturnon ? Pivot : na, title = "Pivot", color = color.red, linewidth = 1, style = linestylee )
  69. plot(islast and cprturnon ? BC : na, title = "BC", color = color.blue, linewidth = 1, style = linestylee )
  70. // }
  71. //Dayly Fibonacci Settings:
  72.  
  73. rng = hhtf-lhtf
  74. //Pivot = (hhtf + lhtf + chtf) / 3
  75.  
  76. FR1 = Pivot + 0.382*rng
  77. FS1 = Pivot - 0.382*rng
  78.  
  79. FR2 = Pivot + 0.618*rng
  80. FS2 = Pivot - 0.618*rng
  81.  
  82. FR3 = Pivot + rng
  83. FS3 = Pivot - rng
  84.  
  85. FR4 = Pivot + 1.272*rng
  86. FS4 = Pivot - 1.272*rng
  87.  
  88. DR5 = Pivot + 1.618*rng
  89. FS5 = Pivot - 1.618*rng
  90.  
  91. FR6 = Pivot + 2.058*rng
  92. FS6 = Pivot - 2.058*rng
  93.  
  94. FR7 = Pivot + 2.618*rng
  95. FS7 = Pivot - 2.618*rng
  96.  
  97. if fibpivots
  98. var line FR1L = na
  99. var line FpLine = na
  100. var line FS1L = na
  101. var line FR2L = na
  102. var line FS2L = na
  103. var line FR3L = na
  104. var line FS3L = na
  105. var line FR4L = na
  106. var line FS4L = na
  107. var line DR5L = na
  108. var line FS5L = na
  109. var line FR6L = na
  110. var line FS6L = na
  111. var line FR7L = na
  112. var line FS7L = na
  113.  
  114. var label FR1LA = na
  115. var label FpL = na
  116. var label FS1LA = na
  117. var label FR2LA = na
  118. var label FS2LA = na
  119. var label FR3LA = na
  120. var label FS3LA = na
  121. var label FR4LA = na
  122. var label FS4LA = na
  123. var label DR5LA = na
  124. var label FS5LA = na
  125. var label FR6LA = na
  126. var label FS6LA = na
  127. var label FR7LA = na
  128. var label FS7LA = na
  129.  
  130.  
  131. if Pivot[1] != Pivot
  132. line.set_x2(FR1L, bar_index)
  133. line.set_x2(FS1L, bar_index)
  134. line.set_x2(FR2L, bar_index)
  135. line.set_x2(FS2L, bar_index)
  136. line.set_x2(FR3L, bar_index)
  137. line.set_x2(FS3L, bar_index)
  138. line.set_x2(FR4L, bar_index)
  139. line.set_x2(FS4L, bar_index)
  140. line.set_x2(DR5L, bar_index)
  141. line.set_x2(FS5L, bar_index)
  142. line.set_x2(FR6L, bar_index)
  143. line.set_x2(FS6L, bar_index)
  144. line.set_x2(FR7L, bar_index)
  145. line.set_x2(FS7L, bar_index)
  146. line.set_extend(FR1L, extend.none)
  147. line.set_extend(FpLine, extend.none)
  148. line.set_extend(FS1L, extend.none)
  149. line.set_extend(FR2L, extend.none)
  150. line.set_extend(FS2L, extend.none)
  151. line.set_extend(FR3L, extend.none)
  152. line.set_extend(FS3L, extend.none)
  153. line.set_extend(FR4L,extend.none)
  154. line.set_extend(FS4L,extend.none)
  155. line.set_extend(DR5L,extend.none)
  156. line.set_extend(FS5L,extend.none)
  157. line.set_extend(FR6L,extend.none)
  158. line.set_extend(FS6L,extend.none)
  159. line.set_extend(FR7L,extend.none)
  160. line.set_extend(FS7L,extend.none)
  161.  
  162.  
  163. FR1L := line.new(bar_index, FR1, bar_index, FR1, width=1, extend=extend.none, style=line.style_dotted, color=SelectColor(Ln_color))
  164. FpLine := line.new(bar_index, Pivot, bar_index, Pivot, width=2, extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  165. FS1L := line.new(bar_index, FS1, bar_index, FS1, width=1,extend=extend.none, style=line.style_dotted, color=SelectColor(Ln_color))
  166. FR2L := line.new(bar_index, FR2, bar_index, FR2, width=2, extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  167. FS2L := line.new(bar_index, FS2, bar_index, FS2, width=2,extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  168. FR3L := line.new(bar_index, FR3, bar_index, FR3, width=2, extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  169. FS3L := line.new(bar_index, FS3, bar_index, FS3, width=2,extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  170. FR4L := line.new(bar_index, FR4, bar_index, FR4, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  171. FS4L := line.new(bar_index, FS4, bar_index, FS4, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  172. DR5L := line.new(bar_index, DR5, bar_index, DR5, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  173. FS5L := line.new(bar_index, FS5, bar_index, FS5, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  174.  
  175. FR6L := line.new(bar_index, FR6, bar_index, FR6, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  176. FS6L := line.new(bar_index, FS6, bar_index, FS6, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  177. FR7L := line.new(bar_index, FR7, bar_index, FR7, width=2,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  178. FS7L := line.new(bar_index, FS7, bar_index, FS7, width=2,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  179.  
  180. FR1LA := label.new(bar_index, FR1, "38",textcolor=SelectColor(Ltx_color), style=label.style_none)
  181. FpL := label.new(bar_index, Pivot, "Pivot", textcolor=SelectColor(Ltx_color), style=label.style_none)
  182. FS1LA := label.new(bar_index, FS1, "38",textcolor=SelectColor(Ltx_color), style=label.style_none)
  183. FR2LA := label.new(bar_index, FR2, "61",textcolor=SelectColor(Ltx_color), style=label.style_none)
  184. FS2LA := label.new(bar_index, FS2, "61",textcolor=SelectColor(Ltx_color), style=label.style_none)
  185. FR3LA := label.new(bar_index, FR3, "Resistance",textcolor=SelectColor(Ltx_color), style=label.style_none)
  186. FS3LA := label.new(bar_index, FS3, "Support",textcolor=SelectColor(Ltx_color), style=label.style_none)
  187. FR4LA := label.new(bar_index, FR4, "1.2",textcolor=SelectColor(Ltx_color), style=label.style_none)
  188. FS4LA := label.new(bar_index, FS4, "1.2",textcolor=SelectColor(Ltx_color), style=label.style_none)
  189. DR5LA := label.new(bar_index, DR5, "1.6",textcolor=SelectColor(Ltx_color), style=label.style_none)
  190. FS5LA := label.new(bar_index, FS5, "1.6",textcolor=SelectColor(Ltx_color), style=label.style_none)
  191.  
  192. FR6LA := label.new(bar_index, FR6, "2",textcolor=SelectColor(Ltx_color), style=label.style_none)
  193. FS6LA := label.new(bar_index, FS6, "2",textcolor=SelectColor(Ltx_color), style=label.style_none)
  194.  
  195. FR7LA := label.new(bar_index, FR7, "2.6",textcolor=SelectColor(Ltx_color), style=label.style_none)
  196. FS7LA := label.new(bar_index, FS7, "2.6",textcolor=SelectColor(Ltx_color), style=label.style_none)
  197.  
  198. label.delete(FR1LA[1])
  199. label.delete(FS1LA[1])
  200. label.delete(FR2LA[1])
  201. label.delete(FS2LA[1])
  202. label.delete(FpL[1])
  203. label.delete(FR3LA[1])
  204. label.delete(FS3LA[1])
  205. label.delete(FR4LA[1])
  206. label.delete(FS4LA[1])
  207. label.delete(DR5LA[1])
  208. label.delete(FS5LA[1])
  209.  
  210. label.delete(FR6LA[1])
  211. label.delete(FS6LA[1])
  212. label.delete(FR7LA[1])
  213. label.delete(FS7LA[1])
  214.  
  215. line.delete(FR1L[1])
  216. line.delete(FS1L[1])
  217. line.delete(FR2L[1])
  218. line.delete(FS2L[1])
  219. line.delete(FpLine[1])
  220. line.delete(FR3L[1])
  221. line.delete(FS3L[1])
  222. line.delete(FR4L[1])
  223. line.delete(FS4L[1])
  224. line.delete(DR5L[1])
  225. line.delete(FS5L[1])
  226.  
  227. line.delete(FR6L[1])
  228. line.delete(FS6L[1])
  229. line.delete(FR7L[1])
  230. line.delete(FS7L[1])
  231.  
  232. if not na(FpLine) and line.get_x2(FpLine) != bar_index
  233. line.set_x2(FR1L, bar_index)
  234. line.set_x2(FpLine, bar_index)
  235. line.set_x2(FS1L, bar_index)
  236. line.set_x2(FR2L, bar_index)
  237. line.set_x2(FS2L, bar_index)
  238. line.set_x2(FR3L, bar_index)
  239. line.set_x2(FS3L, bar_index)
  240. line.set_x2(FR4L, bar_index)
  241. line.set_x2(FS4L, bar_index)
  242. line.set_x2(DR5L, bar_index)
  243. line.set_x2(FS5L, bar_index)
  244.  
  245. line.set_x2(FR6L, bar_index)
  246. line.set_x2(FS6L, bar_index)
  247. line.set_x2(FR7L, bar_index)
  248. line.set_x2(FS7L, bar_index)
  249.  
  250. ///Camarilla Calculation
  251. H4 = chtf + rng * 1.1/2
  252. H3 = chtf + rng * 1.1/4
  253. H2 = chtf + rng * 1.1/6
  254. H1 = chtf + rng * 1.1/12
  255. L1 = chtf - rng * 1.1/12
  256. L2 = chtf - rng * 1.1/6
  257. L3 = chtf - rng * 1.1/4
  258. L4 = chtf - rng * 1.1/2
  259. L5 = L4 - 1.168 * (L3 - L4) //L5 = chtf - (H5 - chtf)
  260. H5 = H4 + 1.168 * (H4 - H3) //H5 = (hhtf / lhtf) * chtf
  261. H6 = (hhtf/lhtf) * chtf //H6 = H5 + 1.168 * (H5 - H4)
  262. L6 = chtf - (H6 - chtf) //L6 = chtf - (H6 - chtf)
  263. SLbull = (H4 + H3) / 2
  264. SLbear = (L4 + L3) / 2
  265. mid = (H3 + L3) / 2
  266.  
  267. if Camarilla
  268. var line CR1L = na
  269. var line CS1L = na
  270. var line CR2L = na
  271. var line CS2L = na
  272. var line CR3L = na
  273. var line CS3L = na
  274. var line CR4L = na
  275. var line CS4L = na
  276. var line CSLB = na
  277. var line CSLr = na
  278. var line CSm = na
  279.  
  280. var label CR1LA = na
  281. var label CS1LA = na
  282. var label CR2LA = na
  283. var label CS2LA = na
  284. var label CR3LA = na
  285. var label CS3LA = na
  286. var label CR4LA = na
  287. var label CS4LA = na
  288.  
  289.  
  290.  
  291. if Pivot[1] != Pivot
  292. line.set_x2(CR1L, bar_index)
  293. line.set_x2(CS1L, bar_index)
  294. line.set_x2(CR2L, bar_index)
  295. line.set_x2(CS2L, bar_index)
  296. line.set_x2(CR3L, bar_index)
  297. line.set_x2(CS3L, bar_index)
  298. line.set_x2(CR4L, bar_index)
  299. line.set_x2(CS4L, bar_index)
  300. line.set_x2(CSLB, bar_index)
  301. line.set_x2(CSLr, bar_index)
  302. line.set_x2(CSm, bar_index)
  303. line.set_extend(CR1L, extend.none)
  304. line.set_extend(CS1L, extend.none)
  305. line.set_extend(CR2L, extend.none)
  306. line.set_extend(CS2L, extend.none)
  307. line.set_extend(CR3L, extend.none)
  308. line.set_extend(CS3L, extend.none)
  309. line.set_extend(CR4L, extend.none)
  310. line.set_extend(CS4L, extend.none)
  311. line.set_extend(CSLB, extend.none)
  312. line.set_extend(CSLr, extend.none)
  313. line.set_extend(CSm, extend.none)
  314.  
  315.  
  316.  
  317. CR1L := line.new(bar_index, H3, bar_index, H3, width=2, extend=extend.none, style=line.style_solid, color=SelectColor(Ln_color))
  318. CS1L := line.new(bar_index, L3, bar_index, L3, width=2,extend=extend.none, style=line.style_solid, color=SelectColor(Ln_color))
  319. CR2L := line.new(bar_index, H4, bar_index, H4, width=2, extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  320. CS2L := line.new(bar_index, L4, bar_index, L4, width=2,extend=extend.none,style=line.style_solid, color=SelectColor(Ln_color))
  321. CR3L := line.new(bar_index, H5, bar_index, H5, width=1, extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  322. CS3L := line.new(bar_index, L5, bar_index, L5, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  323. CR4L := line.new(bar_index, H6, bar_index, H6, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  324. CS4L := line.new(bar_index, L6, bar_index, L6, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  325. CSLB := line.new(bar_index, SLbull, bar_index, SLbull, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  326. CSLr := line.new(bar_index, SLbear, bar_index, SLbear, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  327. CSm := line.new(bar_index, mid, bar_index, mid, width=1,extend=extend.none,style=line.style_dotted, color=SelectColor(Ln_color))
  328.  
  329. CR1LA := label.new(bar_index, H3, "Sell Reversal",textcolor=SelectColor(Ltx_color), style=label.style_none)
  330. CS1LA := label.new(bar_index, L3, "Buy Reversal",textcolor=SelectColor(Ltx_color), style=label.style_none)
  331. CR2LA := label.new(bar_index, H4, "BreakOut",textcolor=SelectColor(Ltx_color), style=label.style_none)
  332. CS2LA := label.new(bar_index, L4, "BreakOut",textcolor=SelectColor(Ltx_color), style=label.style_none)
  333. CR3LA := label.new(bar_index, H5, "Target",textcolor=SelectColor(Ltx_color), style=label.style_none)
  334. CS3LA := label.new(bar_index, L5, "Target",textcolor=SelectColor(Ltx_color), style=label.style_none)
  335. CR4LA := label.new(bar_index, H6, "Target",textcolor=SelectColor(Ltx_color), style=label.style_none)
  336. CS4LA := label.new(bar_index, L6, "Target",textcolor=SelectColor(Ltx_color), style=label.style_none)
  337.  
  338.  
  339. label.delete(CR1LA[1])
  340. label.delete(CS1LA[1])
  341. label.delete(CR2LA[1])
  342. label.delete(CS2LA[1])
  343. label.delete(CR3LA[1])
  344. label.delete(CS3LA[1])
  345. label.delete(CR4LA[1])
  346. label.delete(CS4LA[1])
  347.  
  348. line.delete(CR1L[1])
  349. line.delete(CS1L[1])
  350. line.delete(CR2L[1])
  351. line.delete(CS2L[1])
  352. line.delete(CR3L[1])
  353. line.delete(CS3L[1])
  354. line.delete(CR4L[1])
  355. line.delete(CS4L[1])
  356. line.delete(CSLB[1])
  357. line.delete(CSLr[1])
  358. line.delete(CSm[1])
  359.  
  360.  
  361. if not na(CR1L) and line.get_x2(CR1L) != bar_index
  362. line.set_x2(CR1L, bar_index)
  363. line.set_x2(CS1L, bar_index)
  364. line.set_x2(CR2L, bar_index)
  365. line.set_x2(CS2L, bar_index)
  366. line.set_x2(CR3L, bar_index)
  367. line.set_x2(CS3L, bar_index)
  368. line.set_x2(CR4L, bar_index)
  369. line.set_x2(CS4L, bar_index)
  370. line.set_x2(CSLB, bar_index)
  371. line.set_x2(CSLr, bar_index)
  372. line.set_x2(CSm, bar_index)
  373.  
  374. ///Ema
  375. width = input(2, "Line Width")
  376. show = input(false, "Ema On/Off")
  377. show2 = input(false,"Show two Ema's")
  378. show3 = input(false,"Show three Ema's")
  379. len = input(9, minval=1, title="Fast length")
  380. len2 = input(27, minval=1, title="Mid Length")
  381. len3 = input(111, minval=1, title="Slow Length")
  382. src = input(close, title="Source")
  383. offset = input(title="Offset", type=input.integer, defval=0, minval=-500, maxval=500)
  384. out = ema(src, len)
  385. out1 = ema(src,len2)
  386. out2 = ema(src, len3)
  387. plot(show ? out : na, title="EMA", color=color.green,linewidth = width, offset=offset,editable=false)
  388. plot(show2 ? out1 : na, title="EMA 2", color=color.silver, linewidth = width,offset=offset,editable=false)
  389. plot(show2 and show3 ? out2 : na, title="EMA 3", color=color.red,linewidth = width, offset=offset,editable=false)
  390. ///Day Range
  391.  
  392.  
  393. newDay = dayofweek != dayofweek[1]
  394. fill(plot1=plot(On and islast ? H4 : na, color=na, editable=false),
  395. plot2=plot(On and islast ? FR2 : na, color=na, editable=false),
  396. color=newDay ? na : color.new(#ff7700,75))
  397. fill(plot1=plot(On and islast ? L4 : na, color=na, editable=false),
  398. plot2=plot(On and islast ? FS2 : na, color=na,editable=false),
  399. color=newDay ? na : color.new(#000000,75))
  400.  
  401. ///////////////Orb
  402.  
  403. colBars = input(defval = true, title = 'Colorize Bars') // color or gray bars
  404. colWicks = input(defval = true, title = 'Colorize Wicks') // color or gray wicks
  405. shoPush = input(defval = true, title = 'Show Pressure') // color top wicks red and bottom wicks green
  406. shoFills = input(defval = true, title = 'Show Fills') // fill space with color or off
  407. shoClose = input(defval = true, title = 'Show Close') // show or hide the first bar of day close
  408. shoOpen = input(defval = true, title = 'Show Open') // show or hide the first bar of day open
  409. shoHigh = input(defval = true, title = 'Show High') // show or hide the first bar of day high
  410. shoHL2 = input(defval = false, title = 'Show HL2') // show or hide the first bar of day mid
  411. shoLow = input(defval = true, title = 'Show Low') // show or hide the first bar of day low
  412. shoPLow = input(defval = false, title = 'Show Previous Low',group="Previous Day") // show or hide the first bar of previous day low
  413. shoprvH = input(defval = false, title = 'Show Previous day High', group = "Previous Day") // Show or hide the first bar of previous day high
  414. shoprvC = input(defval = false, title = 'Show Previous day Close', group = "Previous Day")// Show or hide the first bar of previous day close
  415. SLabels = input(defval = false, title = 'Show Labels', group="Previous Day")
  416. // === PRICE LOGIC ===
  417. dayOpen = 0.0, dayOpen := newDay ? open : nz(dayOpen[1])
  418. dayHigh = 0.0, dayHigh := newDay ? high : nz(dayHigh[1])
  419. prvHigh = 0.0, prvHigh := newDay ? dayHigh[1] : nz(prvHigh[1])
  420. dayLow = 0.0, dayLow := newDay ? low : nz(dayLow[1])
  421. prvLow = 0.0, prvLow := newDay ? dayLow[1] : nz(prvLow[1])
  422. dayClose = 0.0, dayClose := newDay ? close : nz(dayClose[1])
  423. prvClose = 0.0, prvClose := newDay ? dayClose[1] : nz(prvClose[1])
  424. dayHL2 = 0.0, dayHL2 := newDay ? hl2 : nz(dayHL2[1])
  425.  
  426. // === COLOR LOGIC ===
  427. isUpDay = dayClose > dayOpen // is first bar of day up or down?
  428. isColBS = not colBars ? color.new(#787b86, 75) : isUpDay ? color.new(#26a69a, 75) : color.new(#ef5350, 75) // bar color is gray, green or red
  429. isColWD = not colWicks ? color.new(#787b86, 75) : shoPush ? color.new(#ef5350, 75) : isUpDay ? color.new(#26a69a, 75) : color.new(#ef5350, 75) // top wick color is gray, red, green or red
  430. isColWU = not colWicks ? color.new(#787b86, 75) : shoPush ? color.new(#26a69a, 75) : isUpDay ? color.new(#26a69a, 75) : color.new(#ef5350, 75) // bot wick color is gray, green, green or red
  431.  
  432. // === PLOTS LOGIC ===
  433. plotDO = plot(OrB and shoOpen ? dayOpen : na, title = 'Open', color = not shoOpen or newDay ? na : isColBS, linewidth = 2, style = plot.style_line)
  434. plotDH = plot(OrB and shoHigh ? dayHigh : na, title = 'High', color = not shoHigh or newDay ? na : isColWD, linewidth = 1, style = plot.style_line)
  435. plotDM = plot(OrB and shoHL2 ? dayHL2 : na, title = 'HL2', color = not shoHL2 or newDay ? na : #ffeb3a, linewidth = 1, style = plot.style_line)
  436. plotDL = plot(OrB and shoLow ? dayLow : na, title = 'Low', color = not shoLow or newDay ? na : isColWU, linewidth = 1, style = plot.style_line)
  437. plotPL = plot(OrB and shoPLow ? prvLow : na, title = 'P-Low', color = not shoPLow or newDay ? na : #e041fb, linewidth = 2, style = plot.style_line)
  438. plotDC = plot(OrB and shoClose ? dayClose : na, title = 'Close', color = not shoClose or newDay ? na : isColBS, linewidth = 2, style = plot.style_line)
  439. plot(OrB and shoprvC ? prvClose : na, title = 'P-Close', color = not shoprvC or newDay ? na : isColBS, linewidth = 1, style = plot.style_line)
  440. plot(OrB and shoprvH ? prvHigh : na, title = 'P-High', color = not shoprvH or newDay ? na : isColBS, linewidth = 1, style = plot.style_line)
  441.  
  442.  
  443. pushDN = plot(OrB and isUpDay ? dayClose : dayOpen, title = 'Push Dn', color = na) // lo of top wick
  444. pushUP = plot(OrB and isUpDay ? dayOpen : dayClose, title = 'Push Up', color = na) // hi of bot wick
  445. fill(plotDH, pushDN, color = not shoFills or newDay ? na : isColWD,title="Top Wick Dn Pressure") // fill color top wick dn pressure
  446. fill(plotDO, plotDC, color = not shoFills or newDay ? na : isColBS,title="First Bar Up/DN") // fill color bar up or down
  447. fill(plotDL, pushUP, color = not shoFills or newDay ? na : isColWU,title="Bot Wick Up Pressure") // fill color bot wick up pressure
  448.  
  449. /////////Labels
  450.  
  451. if SLabels and shoPLow
  452. var label pvrLowLBL = na
  453.  
  454. label.delete(pvrLowLBL)
  455.  
  456. pvrLowLBL := label.new(x = time + mndr * 20, y = prvLow, text = "P Low ", color = color.lime, textcolor=color.green, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  457.  
  458.  
  459. if SLabels and shoClose
  460. var label DcLbl = na
  461. label.delete(DcLbl)
  462. DcLbl := label.new(x = time + mndr * 20, y = dayClose, text = "T Close ", color = color.lime, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  463.  
  464.  
  465. if SLabels and shoprvC
  466. var label pvrClvl = na
  467. label.delete(pvrClvl)
  468. pvrClvl := label.new(x = time + mndr * 20, y = prvClose, text = "Y Close ", color = color.lime, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  469.  
  470. if SLabels and shoprvH
  471. var label pvrHlvl = na
  472. label.delete(pvrHlvl)
  473. pvrHlvl := label.new(x = time + mndr * 20, y = prvHigh, text = "Y High ", color = color.lime, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  474.  
  475. //////////////
  476. TR1 = input(27, title= "SMA to determine Trend", minval = 1, maxval = 500)
  477. TR2 = input(111, title= "SMA to determine Trend", minval = 1, maxval = 500)
  478. CS = input(14,title="Candle Strength", minval=14,maxval=50)
  479. C_DownTrend = true
  480. C_UpTrend = true
  481. var trendRule1 = "EMA50"
  482. var trendRule2 = "EMA50, EMA200"
  483. var trendRule = input(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"])
  484.  
  485. if trendRule == trendRule1
  486. priceAvg = ema(close, TR1)
  487. C_DownTrend := close < priceAvg
  488. C_UpTrend := close > priceAvg
  489.  
  490. if trendRule == trendRule2
  491. sma200 = ema(close, TR2)
  492. sma50 = ema(close, TR1)
  493. C_DownTrend := close < sma50 and sma50 < sma200
  494. C_UpTrend := close > sma50 and sma50 > sma200
  495. C_Len = CS // ema depth for bodyAvg
  496. C_ShadowPercent = 5.0 // size of shadows
  497. C_ShadowEqualsPercent = 100.0
  498. C_DojiBodyPercent = 5.0
  499. C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body
  500.  
  501. C_BodyHi = max(close, open)
  502. C_BodyLo = min(close, open)
  503. C_Body = C_BodyHi - C_BodyLo
  504. C_BodyAvg = ema(C_Body, C_Len)
  505. C_SmallBody = C_Body < C_BodyAvg
  506. C_LongBody = C_Body > C_BodyAvg
  507. C_UpShadow = high - C_BodyHi
  508. C_DnShadow = C_BodyLo - low
  509. C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
  510. C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
  511. C_WhiteBody = open < close
  512. C_BlackBody = open > close
  513. C_Range = high-low
  514. C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
  515. C_BodyMiddle = C_Body / 2 + C_BodyLo
  516. C_ShadowEquals = C_UpShadow == C_DnShadow or (abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent
  517. C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
  518. C_Doji = C_IsDojiBody and C_ShadowEquals
  519.  
  520. patternLabelPosLow = low - (atr(30) * 0.99)
  521. patternLabelPosHigh = high + (atr(30) * 0.99)
  522.  
  523. label_color_bullish = input(color.blue, "Label Color Bullish")
  524. label_color_bearish = input(color.red, "Label Color Bearish")
  525. label_color_neutral = input(color.gray, "Label Color Neutral")
  526. text_color_bullish = input(color.green, "Text Color Bull")
  527. text_color_bearish = input(color.red, "Text color Bear")
  528. CandleType = input(title = "Pattern Type", defval="Both", options=["Bullish", "Bearish", "Both"])
  529.  
  530.  
  531. C_HammerBullishNumberOfCandles = 1
  532. C_HammerBullish = false
  533. if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow and confirm
  534. if C_DownTrend
  535. C_HammerBullish := true
  536. alertcondition(C_HammerBullish, title = "Hammer – Bullish", message = "New Hammer – Bullish pattern detected")
  537. if C_HammerBullish and HammerInput and (("Bullish" == CandleType) or CandleType == "Both")
  538.  
  539. var ttBullishHammer = "Hammer\nHammer candlesticks form when a security moves lower after the open, but continues to rally into close above the intraday low. The candlestick that you are left with will look like a square attached to a long stick-like figure. This candlestick is called a Hammer if it happens to form during a decline."
  540. label.new(bar_index, patternLabelPosLow, text="H", style=label.style_none, color = label_color_bullish, textcolor=text_color_bullish, tooltip = ttBullishHammer)
  541.  
  542.  
  543. C_HangingManBearishNumberOfCandles = 1
  544. C_HangingManBearish = false
  545. if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow and confirm
  546. if C_UpTrend
  547. C_HangingManBearish := true
  548. alertcondition(C_HangingManBearish, title = "Hanging Man – Bearish", message = "New Hanging Man – Bearish pattern detected")
  549. if C_HangingManBearish and HangingManInput and (("Bearish" == CandleType) or CandleType == "Both")
  550.  
  551. var ttBearishHangingMan = "Hanging Man\nWhen a specified security notably moves lower after the open, but continues to rally to close above the intraday low, a Hanging Man candlestick will form. The candlestick will resemble a square, attached to a long stick-like figure. It is referred to as a Hanging Man if the candlestick forms during an advance."
  552. label.new(bar_index, patternLabelPosHigh, text="HM", style=label.style_none, color = label_color_bearish, textcolor=text_color_bearish, tooltip = ttBearishHangingMan)
  553.  
  554.  
  555. C_InvertedHammerBullishNumberOfCandles = 1
  556. C_InvertedHammerBullish = false
  557. if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow and confirm
  558. if C_DownTrend
  559. C_InvertedHammerBullish := true
  560. alertcondition(C_InvertedHammerBullish, title = "Inverted Hammer – Bullish", message = "New Inverted Hammer – Bullish pattern detected")
  561. if C_InvertedHammerBullish and InvertedHammerInput and (("Bullish" == CandleType) or CandleType == "Both")
  562.  
  563. var ttBullishInvertedHammer = "Inverted Hammer\nIf in a downtrend, then the open is lower. When it eventually trades higher, but closes near its open, it will look like an inverted version of the Hammer Candlestick. This is a one-day bullish reversal pattern."
  564. label.new(bar_index, patternLabelPosLow, text="IH", style=label.style_none, color = label_color_bullish, textcolor=text_color_bullish, tooltip = ttBullishInvertedHammer)
  565.  
  566.  
  567. C_RailwayTrackNumberOfCandles = 2
  568. C_RailwayTrackBearish = false
  569. if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and (open > C_BodyMiddle[1] ) and close < C_BodyMiddle[1] and C_LongBody) and confirm
  570. C_RailwayTrackBearish := true
  571. alertcondition(C_RailwayTrackBearish, title = "Railway Track – Bearish", message = "New Railway Track – Bearish pattern detected")
  572. if C_RailwayTrackBearish and RTbearish and (("Bearish" == CandleType) or CandleType == "Both")
  573.  
  574. var ttRailwayTrackBearish = "RailwayTrack bearish\nRailway Track Bearish Effective in uptrend and pullback."
  575. label.new(bar_index, patternLabelPosHigh, text="RT", style=label.style_none, color = label_color_bearish, textcolor=text_color_bearish, tooltip = ttRailwayTrackBearish)
  576.  
  577.  
  578. C_RailwayTrackBullishNumberOfCandles = 2
  579. C_RailwayTrackBullish = false
  580. if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and ( open < C_BodyMiddle[1]) and close > C_BodyMiddle[1] and C_LongBody) and confirm
  581. C_RailwayTrackBullish := true
  582. alertcondition(C_RailwayTrackBullish, title = "Railway Track – Bullish", message = "Railway Track – Bullish pattern detected")
  583. if C_RailwayTrackBullish and RTbullish and (("Bullish" == CandleType) or CandleType == "Both")
  584.  
  585. var ttRailwayTrackBullish = "Railway Track Bullish\nRailway Track Bullish Effective in Downtrend and Pullback."
  586. label.new(bar_index, patternLabelPosLow, text="RT", style=label.style_none, color = label_color_bearish, textcolor=text_color_bullish, tooltip = ttRailwayTrackBullish)
  587. //////////////////////////////////////////////////////////////////////////
  588.  
  589. bustyle = input(title = "Bull Signal", options = ['Arrow', 'Triangle', 'Label'], defval ='Label', group = "Style", tooltip = "Change Shape")
  590. brstyle = input(title = "Bear Signal", options = ['Arrow', 'Triangle', 'Label'], defval ='Label', group = "Style", tooltip = "Change Shape")
  591.  
  592.  
  593. ////Styling
  594. Bearstyle = brstyle == 'Arrow' ? shape.arrowdown :
  595. brstyle == 'Triangle' ? shape.triangledown :
  596. brstyle == 'Label' ? shape.labeldown : na
  597.  
  598. Bullstyle = bustyle == 'Arrow' ? shape.arrowup :
  599. bustyle == 'Triangle' ? shape.triangleup :
  600. bustyle == 'Label' ? shape.labelup : na
  601. ////5 Bars
  602. C01_O = open[4]
  603. C01_C = close[4]
  604. C01_H = high[4]
  605. C01_L = low[4]
  606. C0_O = open[3]
  607. C0_C = close[3]
  608. C0_H = high[3]
  609. C0_L = low[3]
  610. C1_O = open[2]
  611. C1_C = close [2]
  612. C1_H = high[2]
  613. C1_L = low[2]
  614. C2_O = open[1]
  615. C2_C = close[1]
  616. C2_L = low[1]
  617. C2_H = high[1]
  618. C3_O = open
  619. C3_C = close
  620. C3_H = high
  621. C3_L = low
  622. //bullish calc first
  623. candle01_BuB = C01_O - C01_C
  624. candle01_BuW = C01_H - C01_L
  625. candle01 = (candle01_BuB*100/candle01_BuW)
  626. candle0_BuB = C0_O - C0_C
  627. candle0_BuW = C0_H - C0_L
  628. candle0 = (candle0_BuB*100/candle0_BuW)
  629. candle1_BuB = C1_O - C1_C
  630. candle1_BuW = C1_H - C1_L
  631. candle1 = (candle1_BuB*100/candle1_BuW)
  632. candle2_BuB = C2_O - C2_C
  633. candle2_BuW = C2_H - C2_L
  634. candle2 = (candle2_BuB*100/candle2_BuW)
  635. candle3_BuB = C3_C - C3_O
  636. candle3_BuW = C3_H - C3_L
  637. candle3 = (candle3_BuB*100/candle3_BuW)
  638. ////////Plot Reversal Pattern
  639. per = input(50,title="1st Candle",minval=50, maxval=90)
  640. perc = input(50,title="1st Candle",minval=50, maxval=90)
  641.  
  642. bool bullTypeA = (candle1 > per) and (candle2 < 50) and (candle2 > -50) and (C2_L < C1_L) and (candle3 > perc) and (C2_L < C3_L or C3_H > C2_H) and (confirm)
  643. bool bullTypeB = (candle0 > per) and (candle1 < 50) and (candle1 > -50) and (candle2 < 50) and (candle2 > -50) and (candle3 > perc) and ( C2_L < C3_L or C3_H > C2_H) and (confirm)
  644. bool bullTypeC = (candle01 > per) and (candle0 < 50) and (candle0 > -50) and (candle1 < 50) and (candle1 > -50) and (candle2 < 50) and (candle2 > -50) and (candle3 > perc) and ( C2_L < C3_L or C3_H > C2_H) and (confirm)
  645. bool bullStar = (bullTypeA or bullTypeB or bullTypeC) ? 1 : 0
  646.  
  647. //plotshape(bullTypeA, title="Bull Type A", style = linestyle, location = location.belowbar, color = color.green, size = Sstyle)
  648. //plotshape(bullTypeB, title="Bull Type B", style = linestyle, location = location.belowbar, color = color.blue, size = Sstyle)
  649. //plotshape(bullTypeC, title="Bull Type C", style = linestyle, location = location.belowbar, color = color.purple, size = Sstyle)
  650.  
  651. /////////////////////////////////Bearish Calc
  652. candle01_BrB = C01_C - C01_O
  653. candle01_BrW = C01_H - C01_L
  654. candle01br = (candle01_BrB*100/candle01_BrW)
  655.  
  656. candle0_BrB = C0_C - C0_O
  657. candle0_BrW = C0_H - C0_L
  658. candle0br = (candle0_BrB*100/candle0_BrW)
  659.  
  660. candle1_BrB = C1_C - C1_O
  661. candle1_BrW = C1_H - C1_L
  662. candle1_Br = (candle1_BrB*100/candle1_BrW)
  663.  
  664. candle2_BrB = C2_C - C2_O
  665. candle2_BrW = C2_H - C2_L
  666. candle2_Br = (candle2_BrB*100/candle2_BrW)
  667.  
  668. candle3_BrB = C3_O - C3_C
  669. candle3_BrW = C3_H - C3_L
  670. candle3_Br = (candle3_BrB*100/candle3_BrW)
  671.  
  672. bool bearTypeA = (candle1_Br > per) and (candle2_Br < 50) and (candle2_Br > -50)and (candle3_Br > perc) and (C3_L < C2_L) and (confirm)
  673. bool bearTypeB = (candle0br > per) and (candle1_Br < 50) and (candle1_Br > -50) and (candle2_Br < 50) and (candle2_Br > -50) and (candle3_Br > perc) and (C2_H > C3_H or C3_L < C2_L) and (confirm)
  674. bool bearTypeC = (candle01br > per) and (candle0br < 50) and (candle0br > -50) and (candle1_Br < 50) and (candle1_Br > -50) and (candle2_Br < 50) and (candle2_Br > -50) and (candle3_Br > perc ) and (C2_H > C3_H or C3_L < C2_L) and (confirm)
  675. bool bearStar = (bearTypeA or bearTypeB or bearTypeC) ? 1 : 0
  676.  
  677. prev = 0
  678. prev := bullStar ? 1: bearStar ? 1 : prev[1]
  679.  
  680. bull_final = bullStar and prev[1] == 1
  681. bear_final = bearStar and prev[1] == 1
  682.  
  683. plotshape(sr and bull_final, title="3 Bar Bull", style = Bullstyle, location = location.belowbar, color = up, size = size.small, show_last=sl, editable=false)
  684. plotshape(sr and bear_final, title="Bearish Reverse", style = Bearstyle, location = location.abovebar, color = down, size = size.small, show_last=sl, editable=false)
  685. //plotshape(bullTypeBA, title="Bear Type A", style = linestyle, location = location.abovebar, color = color.green, size = Sstyle)
  686. //plotshape(bullTypeBB, title="Bear Type B", style = linestyle, location = location.abovebar, color = color.blue, size = Sstyle)
  687. //plotshape(bullTypeBC, title="Bear Type C", style = linestyle, location = location.abovebar, color = color.purple, size = Sstyle)
  688.  
  689.  
  690. lineLength=sig
  691. f_timeDelta() =>
  692. var timeDelta = 10e15
  693. timeDelta := min(time - nz(time[1]), timeDelta)
  694. ofst = int(time + f_timeDelta() * lineLength)
  695. haBull = ohlc4
  696. mn = min ( low[1],low[3],low[2])
  697. hl = max (high[1], high[3],high[2])
  698. var line _mn = na, var line _hl = na, var line _ha = na
  699. var label l_mn = na, var label l_hl = na, var label l_ha = na
  700.  
  701. if sr and bull_final== 1
  702. _mn := line.new(time, mn , ofst, mn , xloc = xloc.bar_time, color = color.aqua, width=2)
  703. line.delete(_mn[1])
  704. l_mn := label.new(x = time + mndr * sig, y = mn, text = "SL ", color = color.lime, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  705. label.delete(l_mn[1])
  706.  
  707. if sr and bear_final== 1
  708. _hl := line.new(time, hl , ofst, hl , xloc = xloc.bar_time, color = color.orange, width=2)
  709. line.delete(_hl[1])
  710. l_hl := label.new(x = time + mndr * sig, y = hl, text = "SL ", color = color.red, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price)
  711. label.delete(l_hl[1])
  712. ///////////////
  713. if C_RailwayTrackBullish or C_RailwayTrackBearish
  714.  
  715. _ha := line.new(time, haBull, ofst, haBull, xloc = xloc.bar_time, color = color.red, width=1)
  716. line.delete(_ha[1])
  717.  
  718. l_ha := label.new(x = time + mndr * sig, y = haBull, text = "SL ", color = color.red, textcolor=color.black, style=label.style_none, xloc = xloc.bar_time, yloc=yloc.price,tooltip="If a bar closes below this line Railway track is invalid.")
  719. label.delete(l_ha[1])
  720.  
  721. ////////
  722. DRKC = open[1] < close[1] ? open > high[1] ? close < close[1] - ((close[1] - open[1]) / 2) ? close > open[1] ? #dbff01 :na :na :na :na
  723. barcolor(PAB ? DRKC : na, title="Dark Cloud" )
  724.  
  725. //Bearish Engulfing
  726. BrEng = close < open[1] ? low < low[1] ? high > high[1] ? open >= open[1] ? #FF7000 : na: na: na: na
  727. barcolor(PAB ? BrEng : na, title="Bearish Engulf")
  728.  
  729.  
  730. //Bullish Engulfing
  731. BuEng = low < low[1] ? high > high[1] ? open <= open[1] ? close > open[1] ? #00FF00 : na: na: na: na
  732. barcolor(PAB ? BuEng : na, title="Bullish Engulf")
  733.  
  734. //Three White Soldiers
  735. TWS = close > open ? close[1] > open[1] ? close[2] > open[2] ? close > high[1] ? close[1] > high[2] ? open < close[1] ? open[1] < close[2] ? (high - close ) * 3 < close - open ? (high[1] - close[1]) * 3 < close[1] - open[1] ? (high[2] - close[2]) * 3 < close[2] - open[2] ? #66ff00 : na : na : na : na : na : na:na : na : na : na
  736. barcolor(PAB ? TWS : na, title="Three white soliders")
  737. TBC = close < open ? close[1] < open[1] ? close[2] < open[2] ? close < low[1] ? close[1] < low[2] ? open > close[1] ? open[1] > close[2] ? (close - low) * 3 < open - close ? (close[1] - low[1]) * 3 < open[1] - close[1] ? (close[2] - low[2]) * 3 < open[2] - close[2] ? #ff6600 : na : na : na : na : na : na:na : na : na : na
  738. barcolor (PAB ? TBC : na, title = "Three Black Crows")
  739. BearishENG = open[1] < close[1] ? close < open[1] ? open > close[1] ? #ff0000 : na : na : na
  740. barcolor(PAB ? BearishENG : na, title="Bearish 2 Engulf" )
  741. BullishENG = open[1] > close[1] ? close > open[1] ? open < close[1] ? #00ff0a : na : na : na
  742. barcolor(PAB ? BullishENG : na, title="Bullish 2 Engulf" )
  743. ///
  744.  
  745.  
  746. cand = high-low
  747. bodyr = open-close
  748.  
  749. candle = (bodyr*100/cand)
  750.  
  751. barcolor (Ecandle and candle>-50 and candle < 50 ? #26c6da : na)
  752. /////
  753. ////////////Volume Based Support Resistance
  754. vsr = input(false,"Sup/Res Vol based", group ="Settings ॐ", tooltip="Volume Based S/r for stocks")
  755. Vlength = input(20, minval=1, group = "Volume S/R Settings")
  756. Vchange = volume/volume[1] - 1
  757. stdev = stdev(Vchange, Vlength)
  758. difference = Vchange / stdev[1]
  759. Treshold = input(5)
  760. zero = 0
  761. signal = abs(difference)
  762. vstylee = plot.style_circles
  763.  
  764. leveluphi = valuewhen(signal > Treshold,high[1],0)
  765. leveluplo = valuewhen(signal > Treshold,low[1],0)
  766.  
  767. //plot(UpperTreshold, color=black)
  768. p1=plot(vsr and leveluphi ? leveluphi : na, title="LevelHi",style=vstylee,color=color.blue)
  769. p2=plot(vsr and leveluplo ? leveluplo : na,title="Levello",style=vstylee,color=color.blue)
  770. fill(p1,p2,color=color.new(color.black,50),title="Fill")
  771. /////// Tweezer top & Bottom
  772. //enable_tweezer = input(defval = true, title = "Enable Tweezer", group ="Settings ॐ", tooltip = "Tweezertop & Bottom Activation")
  773. maxrate = input(defval = 150., title = "Max Rate % Between Wick Sizes") / 100.
  774. leveldiff = input(defval = 20., title = "Max Difference in level %") / 100.
  775. prd =input(defval = 5, title = "Highest/Lowest Period")
  776. apartprd = input(defval = 12, title = "Max Distance between Tweezers", minval = 1)
  777.  
  778. topwick = high - max(close, open)
  779. bottomwick = min(close, open) - low
  780. body = abs(close - open)
  781. ishb = highestbars(prd) == 0
  782. islb = lowestbars(prd) == 0
  783. aparttweezers_top(len)=>
  784. ret = 0
  785. if topwick > 0
  786. for x = 1 to apartprd
  787. if nz(topwick[x]) == 0
  788. break
  789. if (max(topwick, topwick[x]) / min(topwick, topwick[x])) <= maxrate and abs(high - high[x]) < max(topwick, topwick[x]) * leveldiff and ishb[x]
  790. ret := x
  791. break
  792. else
  793. if high[x] >= high
  794. ret := 0
  795. break
  796. ret
  797.  
  798. aparttweezers_bottom(len)=>
  799. ret = 0
  800. if bottomwick > 0
  801. for x = 1 to apartprd
  802. if nz(bottomwick[x]) == 0
  803. break
  804. if (max(bottomwick, bottomwick[x]) / min(bottomwick, bottomwick[x])) <= maxrate and abs(low - low[x]) < max(bottomwick, bottomwick[x]) * leveldiff and islb[x]
  805. ret := x
  806. break
  807. else
  808. if low[x] <= low
  809. ret := 0
  810. break
  811. ret
  812.  
  813. top_tweezer = false
  814. if C_UpTrend[1] and aparttweezers_top(apartprd)
  815. top_tweezer := true
  816. alertcondition(top_tweezer, title = "Tweezer Top – Bearish", message = "TT Bearish – Bearish pattern detected")
  817. if top_tweezer and TTbearish and (("Bearish" == CandleType) or CandleType == "Both")
  818. var tttweezertop = "Tweezer Top bearish\n Tweezer Top Bearish Effective in uptrend and pullback."
  819. label.new(bar_index, patternLabelPosHigh, text="TT", style=label.style_none, color = label_color_bearish, textcolor=text_color_bearish, tooltip = tttweezertop)
  820.  
  821. bottom_tweezer = false
  822. if C_DownTrend[1] and aparttweezers_bottom(apartprd)
  823. bottom_tweezer := true
  824. alertcondition(bottom_tweezer, title = "Tweezer Bottom – Bullish", message = "TT Bullish – Bullish pattern detected")
  825. if bottom_tweezer and TTbullish and (("Bullish" == CandleType) or CandleType == "Both")
  826. var tttweezerbot = "Tweezer Bottom bullish\n Tweezer Top Bullish Effective in uptrend and pullback."
  827. label.new(bar_index, patternLabelPosLow, text="TT", style=label.style_none, color = label_color_bullish, textcolor=text_color_bullish, tooltip = tttweezerbot)
  828.  
  829. // ATR Trailing SL {
  830. nATRPeriod = input(5)
  831. nATRMultip = input(3.5)
  832. xATR = atr(nATRPeriod)
  833. nLoss = nATRMultip * xATR
  834. xATRTrailingStop = 0.0
  835. xATRTrailingStop :=iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - nLoss),
  836. iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + nLoss),
  837. iff(close > nz(xATRTrailingStop[1], 0), close - nLoss, close + nLoss)))
  838. col=close < xATRTrailingStop[1] ? color.silver : color.black
  839. plot(ATRTsl ? xATRTrailingStop[1]: na, color=col, title="ATR Trailing Stop") //}
  840. //Table {
  841. var table info = table.new(position.top_right , 1, 1)
  842. var table logo = table.new(position.bottom_right, 1, 1)
  843. if barstate.islast
  844. table.cell(logo, 0, 0, "ॐ" , text_size = size.normal, text_color = color.orange)
  845. table.cell(info, 0, 0, "@TeamTaurus", text_size = size.small , text_color = color.black)
  846. //}
Advertisement
Add Comment
Please, Sign In to add comment