xmd79

alpha

Dec 16th, 2022
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 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. // © nautilusalpha
  3.  
  4. //@version=5
  5. indicator(title='alpha', shorttitle='Killzones', overlay=true)
  6.  
  7. //ASIA
  8. asiashow = input(true, title='Display Asia Range', group="Asia Session")
  9. asiacolor = input(color.new(color.aqua, 70), 'Asia Range Color', group="Asia Session")
  10. asia = input.session(title='Asia Session', defval='1900-0000', group="Asia Session")
  11.  
  12.  
  13. // FUNCTIONS
  14. in_session(sess) =>
  15. not na(time(timeframe.period, sess))
  16.  
  17. start_time(sess) =>
  18. int startTime = na
  19. startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
  20. startTime
  21.  
  22. is_new_session(res, sess) =>
  23. t = time(res, sess)
  24. na(t[1]) and not na(t) or t[1] < t
  25.  
  26. BarInSession(sess) =>
  27. time(timeframe.period, sess) != 0
  28.  
  29. _hline(StartTime, EndTime, Price, Color, Style, Width) =>
  30. return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=extend.none, color=Color, style=Style, width=Width)
  31.  
  32. //PARAMS
  33. indexHighTF = barstate.isrealtime ? 0 : 0
  34. indexCurrTF = barstate.isrealtime ? 0 : 0
  35. dailyhigh = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)[indexHighTF]
  36. dailylow = request.security(syminfo.tickerid, 'D', low[indexCurrTF], lookahead=barmerge.lookahead_on)[indexCurrTF]
  37.  
  38.  
  39. //ASIA BOX
  40. asia_session = is_new_session('1440', asia)
  41.  
  42. float _asialow = na
  43. float _asiahigh = na
  44. _asiabox = box(na)
  45.  
  46. _asiastart = start_time(asia)
  47. _asialow := asia_session ? low : in_session(asia) ? math.min(low, _asialow[1]) : na
  48. _asiahigh := asia_session ? high : in_session(asia) ? math.max(high, _asiahigh[1]) : na
  49. diff = _asiahigh[1] - _asialow[1]
  50.  
  51. if in_session(asia)
  52. if in_session(asia)[1]
  53. box.delete(_asiabox[1])
  54.  
  55. if low < _asialow
  56. _asialow := low
  57. _asialow
  58. if high > _asiahigh
  59. _asiahigh := high
  60. _asiahigh
  61.  
  62. if asiashow
  63. _asiabox := box.new(_asiastart, _asiahigh, time, _asialow, xloc=xloc.bar_time, bgcolor=asiacolor, border_color=asiacolor, border_style=line.style_solid)
  64. _asiabox
  65. //LONDON
  66. londonshow = input(true, title='Display London session', group="London Session")
  67. londoncolor = input(color.new(#28db46, 70), 'London Session Color', group="London Session")
  68. london = input.session(title='London Session', defval='0200-0500', group="London Session")
  69.  
  70.  
  71.  
  72. //LONDON BOX
  73. london_session = is_new_session('1440', london)
  74.  
  75. float _londonlow = na
  76. float _londonhigh = na
  77. _londonbox = box(na)
  78.  
  79. _londonstart = start_time(london)
  80. _londonlow := london_session ? low : in_session(london) ? math.min(low, _londonlow[1]) : na
  81. _londonhigh := london_session ? high : in_session(london) ? math.max(high, _londonhigh[1]) : na
  82.  
  83. if in_session(london)
  84. if in_session(london)[1]
  85. box.delete(_londonbox[1])
  86.  
  87. if low < _londonlow
  88. _londonlow := low
  89. _londonlow
  90. if high > _londonhigh
  91. _londonhigh := high
  92. _londonhigh
  93.  
  94. if londonshow
  95. _londonbox := box.new(_londonstart, _londonhigh, time, _londonlow, xloc=xloc.bar_time, bgcolor=londoncolor, border_color=londoncolor, border_style=line.style_solid)
  96. _londonbox
  97. //NEW YORK
  98. newyorkshow = input(true, title='Display London session', group="London Session")
  99. newyorkcolor = input(color.new(#e02c2c, 70), 'New York Session Color', group="New York Session")
  100. newyork = input.session(title='New York Session', defval='0700-1000', group="New York Session")
  101.  
  102.  
  103.  
  104. //NEW YORK BOX
  105. newyork_session = is_new_session('1440', newyork)
  106.  
  107. float _newyorklow = na
  108. float _newyorkhigh = na
  109. _newyorkbox = box(na)
  110.  
  111. _newyorkstart = start_time(newyork)
  112. _newyorklow := newyork_session ? low : in_session(newyork) ? math.min(low, _newyorklow[1]) : na
  113. _newyorkhigh := newyork_session ? high : in_session(newyork) ? math.max(high, _newyorkhigh[1]) : na
  114.  
  115. if in_session(newyork)
  116. if in_session(newyork)[1]
  117. box.delete(_newyorkbox[1])
  118.  
  119. if low < _newyorklow
  120. _newyorklow := low
  121. _newyorklow
  122. if high > _newyorkhigh
  123. _newyorkhigh := high
  124. _newyorkhigh
  125.  
  126. if newyorkshow
  127. _newyorkbox := box.new(_newyorkstart, _newyorkhigh, time, _newyorklow, xloc=xloc.bar_time, bgcolor=newyorkcolor, border_color=newyorkcolor, border_style=line.style_solid)
  128. _newyorkbox
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
Advertisement
Add Comment
Please, Sign In to add comment