Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © nautilusalpha
- //@version=5
- indicator(title='alpha', shorttitle='Killzones', overlay=true)
- //ASIA
- asiashow = input(true, title='Display Asia Range', group="Asia Session")
- asiacolor = input(color.new(color.aqua, 70), 'Asia Range Color', group="Asia Session")
- asia = input.session(title='Asia Session', defval='1900-0000', group="Asia Session")
- // FUNCTIONS
- in_session(sess) =>
- not na(time(timeframe.period, sess))
- start_time(sess) =>
- int startTime = na
- startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
- startTime
- is_new_session(res, sess) =>
- t = time(res, sess)
- na(t[1]) and not na(t) or t[1] < t
- BarInSession(sess) =>
- time(timeframe.period, sess) != 0
- _hline(StartTime, EndTime, Price, Color, Style, Width) =>
- return_1 = line.new(StartTime, Price, EndTime, Price, xloc=xloc.bar_time, extend=extend.none, color=Color, style=Style, width=Width)
- //PARAMS
- indexHighTF = barstate.isrealtime ? 0 : 0
- indexCurrTF = barstate.isrealtime ? 0 : 0
- dailyhigh = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)[indexHighTF]
- dailylow = request.security(syminfo.tickerid, 'D', low[indexCurrTF], lookahead=barmerge.lookahead_on)[indexCurrTF]
- //ASIA BOX
- asia_session = is_new_session('1440', asia)
- float _asialow = na
- float _asiahigh = na
- _asiabox = box(na)
- _asiastart = start_time(asia)
- _asialow := asia_session ? low : in_session(asia) ? math.min(low, _asialow[1]) : na
- _asiahigh := asia_session ? high : in_session(asia) ? math.max(high, _asiahigh[1]) : na
- diff = _asiahigh[1] - _asialow[1]
- if in_session(asia)
- if in_session(asia)[1]
- box.delete(_asiabox[1])
- if low < _asialow
- _asialow := low
- _asialow
- if high > _asiahigh
- _asiahigh := high
- _asiahigh
- if asiashow
- _asiabox := box.new(_asiastart, _asiahigh, time, _asialow, xloc=xloc.bar_time, bgcolor=asiacolor, border_color=asiacolor, border_style=line.style_solid)
- _asiabox
- //LONDON
- londonshow = input(true, title='Display London session', group="London Session")
- londoncolor = input(color.new(#28db46, 70), 'London Session Color', group="London Session")
- london = input.session(title='London Session', defval='0200-0500', group="London Session")
- //LONDON BOX
- london_session = is_new_session('1440', london)
- float _londonlow = na
- float _londonhigh = na
- _londonbox = box(na)
- _londonstart = start_time(london)
- _londonlow := london_session ? low : in_session(london) ? math.min(low, _londonlow[1]) : na
- _londonhigh := london_session ? high : in_session(london) ? math.max(high, _londonhigh[1]) : na
- if in_session(london)
- if in_session(london)[1]
- box.delete(_londonbox[1])
- if low < _londonlow
- _londonlow := low
- _londonlow
- if high > _londonhigh
- _londonhigh := high
- _londonhigh
- if londonshow
- _londonbox := box.new(_londonstart, _londonhigh, time, _londonlow, xloc=xloc.bar_time, bgcolor=londoncolor, border_color=londoncolor, border_style=line.style_solid)
- _londonbox
- //NEW YORK
- newyorkshow = input(true, title='Display London session', group="London Session")
- newyorkcolor = input(color.new(#e02c2c, 70), 'New York Session Color', group="New York Session")
- newyork = input.session(title='New York Session', defval='0700-1000', group="New York Session")
- //NEW YORK BOX
- newyork_session = is_new_session('1440', newyork)
- float _newyorklow = na
- float _newyorkhigh = na
- _newyorkbox = box(na)
- _newyorkstart = start_time(newyork)
- _newyorklow := newyork_session ? low : in_session(newyork) ? math.min(low, _newyorklow[1]) : na
- _newyorkhigh := newyork_session ? high : in_session(newyork) ? math.max(high, _newyorkhigh[1]) : na
- if in_session(newyork)
- if in_session(newyork)[1]
- box.delete(_newyorkbox[1])
- if low < _newyorklow
- _newyorklow := low
- _newyorklow
- if high > _newyorkhigh
- _newyorkhigh := high
- _newyorkhigh
- if newyorkshow
- _newyorkbox := box.new(_newyorkstart, _newyorkhigh, time, _newyorklow, xloc=xloc.bar_time, bgcolor=newyorkcolor, border_color=newyorkcolor, border_style=line.style_solid)
- _newyorkbox
Advertisement
Add Comment
Please, Sign In to add comment