Advertisement
Guest User

Untitled

a guest
Jan 7th, 2020
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. StudyName = "BEST Long Term Levels Breakout Screener"
  2. ShortStudyName = "BEST LT levels Breakout Screener"
  3. study(StudyName, shorttitle=ShortStudyName, overlay=false, precision=6)
  4.  
  5. prevLongTerm = input(title="⌚ Show previous Long Term Levels period", type=input.bool, defval=false)
  6.  
  7. string sec00 = input(defval="XBTUSD", type=input.symbol)
  8. string sec01 = input(defval="ETHUSD", type=input.symbol)
  9. string sec02 = input(defval="ETHBTC", type=input.symbol)
  10. //string sec03 = input(defval="XRPUSD", type=input.symbol)
  11. //string sec04 = input(defval="LTCUSD", type=input.symbol)
  12.  
  13. //////////////////////////
  14. //* COLOR CONSTANTS *//
  15. //////////////////////////
  16.  
  17. AQUA = #00FFFFFF
  18. BLUE = #0000FFFF
  19. RED = #FF0000FF
  20. LIME = #00FF00FF
  21. GRAY = #808080FF
  22. DARKRED = #8B0000FF
  23. DARKGREEN = #006400FF
  24. GOLD = #FFD700
  25. WHITE = color.white
  26.  
  27. // ——————————————— MORE Colors
  28. // MyGreenRaw = color.new(color.lime,0), MyGreenMedium = color.new(#00b300,0), MyGreenSemiDark = color.new(#009900,0), MyGreenDark = color.new(#006600,0), MyGreenDarkDark = color.new(#003300,0)
  29. // MyRedRaw = color.new(color.red,0), MyRedMedium = color.new(#cc0000,0), MyRedSemiDark = color.new(#990000,0), MyRedDark = color.new(#330000,0), MyRedDarkDark = color.new(#330000,0)
  30. // MyFuchsiaRaw = color.new(color.fuchsia,0), MyFuchsiaMedium = color.new(#c000c0,0), MyFuchsiaDark = color.new(#800080,0), MyFuchsiaDarkDark = color.new(#400040,0)
  31. // MyYellowRaw = color.new(color.yellow,0), MyYellowMedium = color.new(#c0c000,0), MyYellowDark = color.new(#808000,0), MyYellowDarkDark = color.new(#404000,0)
  32. // MyOrangeRaw = color.new(#ffa500,0), MyOrangeMedium = color.new(#cc8400,0), MyOrangeDark = color.new(#996300,0)
  33. // MyBlueRaw = color.new(#4985E7,0), MyBlueMedium = color.new(#4985E7,0)
  34. // MyGreenBackGround = color.new(#00FF00,93), MyRedBackGround = color.new(#FF0000,90)
  35.  
  36. // Plots
  37. GREEN_LIGHT = color.new(color.green, 40)
  38. RED_LIGHT = color.new(color.red, 40)
  39. BLUE_LIGHT = color.new(color.aqua, 40)
  40. PURPLE_LIGHT = color.new(color.purple, 40)
  41.  
  42. // ---------- Candle components and states
  43. NonZeroValue = 0.0000000001
  44.  
  45. ///////////////////////////////////////////////////////////////////////////////
  46. ///////////////////////////////////////////////////////////////////////////////
  47. ///////////////////////////////// UTILITIES ///////////////////////////////////
  48. ///////////////////////////////////////////////////////////////////////////////
  49. ///////////////////////////////////////////////////////////////////////////////
  50.  
  51. bool is_newday = change(time("D")) != 0
  52. int bars_in_day = barssince(is_newday)
  53.  
  54. f_securitys(_ticker)=>
  55. _r = timeframe.period
  56. _g = barmerge.gaps_off
  57. _l = barmerge.lookahead_on
  58.  
  59. _close = security(symbol=_ticker, resolution=_r, expression=close, gaps=_g, lookahead=_l)
  60. _high = security(symbol=_ticker, resolution=_r, expression=high, gaps=_g, lookahead=_l)
  61. _low = security(symbol=_ticker, resolution=_r, expression=low, gaps=_g, lookahead=_l)
  62.  
  63. prev = prevLongTerm ? 1 : 0
  64. weekH = security(_ticker, 'W', _high, lookahead=true)[prev]
  65. weekL = security(_ticker, 'W', _low, lookahead=true)[prev]
  66.  
  67. monthH = security(_ticker, 'M', _high, lookahead=true)[prev]
  68. monthL = security(_ticker, 'M', _low, lookahead=true)[prev]
  69.  
  70. quarterH = security(_ticker, '3M', _high, lookahead=true)[prev]
  71. quarterL = security(_ticker, '3M', _low, lookahead=true)[prev]
  72.  
  73. yearH = security(_ticker, '12M', _high, lookahead=true)[prev]
  74. yearL = security(_ticker, '12M', _low, lookahead=true)[prev]
  75.  
  76. // Conditions
  77. new_weekH = crossover(_close, weekH)
  78. new_weekL = crossunder(_close, weekL)
  79.  
  80. new_monthH = crossover(_close, monthH)
  81. new_monthL = crossunder(_close, monthL)
  82.  
  83. new_quarterH = crossover(_close, quarterH)
  84. new_quarterL = crossunder(_close, quarterL)
  85.  
  86. new_yearH = crossover(_close, yearH)
  87. new_yearL = crossunder(_close, yearL)
  88.  
  89. _color = iff(new_yearH, color.new(color.green, 0),
  90. iff(new_quarterH, color.new(color.green, 20),
  91. iff(new_monthH, color.new(color.green, 40),
  92. iff(new_weekH, color.new(color.green, 60),
  93. iff(new_yearL, color.new(color.red, 0),
  94. iff(new_quarterL, color.new(color.red, 20),
  95. iff(new_monthL, color.new(color.red, 40),
  96. iff(new_weekL, color.new(color.red, 60), color.new(color.orange, 50)))))))))
  97.  
  98. [new_weekH, new_weekL,
  99. new_monthH, new_monthL,
  100. new_quarterH, new_quarterL,
  101. new_yearH, new_yearL, _color]
  102.  
  103.  
  104. lapos_x = timenow + round(change(time)*6)
  105.  
  106. //f_color_label(_stackPos) => _stackPos ? color.new(color.green, 30) : color.new(color.red, 30)
  107.  
  108. f_geom(_pr_a, _id, _color)=>
  109.  
  110.  
  111. var label la = na
  112. var counter = 0
  113. counter := counter + 1
  114. str_counter = ""//tostring(counter, "#") + ": "
  115. label.delete(la)
  116. la := label.new(
  117. x=lapos_x, y=ceil(_pr_a),
  118. text=str_counter + _id, xloc=xloc.bar_time, yloc=yloc.price, color=_color,
  119. style=label.style_labeldown, textcolor=color.black, size=size.small
  120. )
  121.  
  122.  
  123. [s00_weekH, s00_weekL, s00_monthH, s00_monthL, s00_quarterlyH, s00_quarterlyL, s00_yearlyH, s00_yearlyL, s00_color] = f_securitys(sec00)
  124. [s01_weekH, s01_weekL, s01_monthH, s01_monthL, s01_quarterlyH, s01_quarterlyL, s01_yearlyH, s01_yearlyL, s01_color] = f_securitys(sec01)
  125. [s02_weekH, s02_weekL, s02_monthH, s02_monthL, s02_quarterlyH, s02_quarterlyL, s02_yearlyH, s02_yearlyL, s02_color] = f_securitys(sec02)
  126.  
  127.  
  128. plotshape(s00_weekH or s00_weekL ? 0 : na , style=shape.square, location=location.absolute, color=s00_color, size = size.tiny)
  129. plotshape(s00_monthH or s00_monthL ? 0 : na , style=shape.circle, location=location.absolute, color=s00_color, size = size.tiny)
  130. plotshape(s00_quarterlyH or s00_quarterlyL ? 0 : na, style=shape.diamond, location=location.absolute, color=s00_color, size = size.tiny)
  131. plotshape(s00_yearlyH or s00_yearlyL ? 0 : na , style=shape.flag, location=location.absolute, color=s00_color, size = size.tiny)
  132.  
  133. plotchar(not s00_weekH and not s00_weekL and not s00_monthH and not s00_monthL and not s00_quarterlyH and not s00_quarterlyL and not s00_yearlyH and not s00_yearlyL ? 0 : na,
  134. char='-',location=location.absolute, color=s00_color, size = size.normal)
  135.  
  136. plotshape(s01_weekH or s01_weekL ? 1 : na , style=shape.square, location=location.absolute, color=s01_color, size = size.tiny)
  137. plotshape(s01_monthH or s01_monthL ? 1 : na , style=shape.circle, location=location.absolute, color=s01_color, size = size.tiny)
  138. plotshape(s01_quarterlyH or s01_quarterlyL ? 1 : na, style=shape.diamond, location=location.absolute, color=s01_color, size = size.tiny)
  139. plotshape(s01_yearlyH or s01_yearlyL ? 1 : na , style=shape.flag, location=location.absolute, color=s01_color, size = size.tiny)
  140.  
  141. plotchar(not s01_weekH and not s01_weekL and not s01_monthH and not s01_monthL and not s01_quarterlyH and not s01_quarterlyL and not s01_yearlyH and not s01_yearlyL ? 1 : na,
  142. char='-',location=location.absolute, color=s01_color, size = size.normal)
  143.  
  144. plotshape(s02_weekH or s02_weekL ? 2 : na , style=shape.square, location=location.absolute, color=s02_color, size = size.tiny)
  145. plotshape(s02_monthH or s02_monthL ? 2 : na , style=shape.circle, location=location.absolute, color=s02_color, size = size.tiny)
  146. plotshape(s02_quarterlyH or s02_quarterlyL ? 2 : na, style=shape.diamond, location=location.absolute, color=s02_color, size = size.tiny)
  147. plotshape(s02_yearlyH or s02_yearlyL ? 2 : na , style=shape.flag, location=location.absolute, color=s02_color, size = size.tiny)
  148.  
  149. plotchar(not s02_weekH and not s02_weekL and not s02_monthH and not s02_monthL and not s02_quarterlyH and not s02_quarterlyL and not s02_yearlyH and not s02_yearlyL ? 2 : na,
  150. char='-',location=location.absolute, color=s02_color, size = size.normal)
  151.  
  152. // right labels
  153. f_geom(0, sec00, s00_color)
  154. f_geom(1, sec01, s01_color)
  155. f_geom(2, sec02, s02_color)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement