Professional Documents
Culture Documents
if bar_index == 3
timeDiff1 = (time - time[1]) / 60000
timeDiff2 = (time[2] - time[3]) / 60000
// Inputs {
i_showHighLow = input(false, "Show Highs/Lows")
i_hideSessiontf = input.int(59, "Hide Session on TF above (Minutes)", 1)
i_showMidLine = input.bool(true, "Show Session Mid Lines")
grpMMM = "MMM"
i_MMMlength = input.int(200, "MMM Lenght", 0, group=grpMMM)
i_hideMMMtf = input.int(59, "Hide MMM on TF above (Minutes)", 1, group=grpMMM)
// Functions {
//Bars
isNewBar(sess) =>
t = time("D", sess)
na(t[1]) and not na(t) or t[1] < t
isSession(sess) =>
not na(time("D", sess))
newLow := if session
if newbar
low
else
math.min(newLow[1],low)
else
newLow[1]
newHigh := if session
if newbar
high
else
math.max(newHigh[1],high)
else
newHigh[1]
newStart := if session
if newbar
time
else
math.min(newStart[1],time)
else
na
newEnd := if session
if newbar
time_close
else
math.max(newEnd[1],time_close)
else
na
f_tfShow(hideValue) =>
hide = bar_time <= hideValue
hide
// Calcutations {
pricehigh_daily = request.security(syminfo.tickerid, 'D', high[1])
pricelow_daily = request.security(syminfo.tickerid, 'D', low[1])
// Asia
asiaLow = float(na)
asiaHigh = float(na)
asiaStart = int(na)
asiaEnd = int(na)
asiaNewbar = isNewBar(i_asiaSession)
asiaSession = isSession(i_asiaSession)
asiaLow := asiaLow_
asiaHigh := asiaHigh_
asiaStart := asiaStart_
asiaEnd := asiaEnd_
if not asiaNewbar
f_changeBox(asiaBox[1], asiaLow, asiaHigh, asiaEnd)
if i_showMidLine
yValue = math.avg(asiaHigh, asiaLow)
f_changeMidLine(asiaMidLine[1], yValue, asiaEnd)
// Frankfut
frankfurtLow = float(na)
frankfurtHigh = float(na)
frankfurtStart = int(na)
frankfurtEnd = int(na)
frankfurtNewbar = isNewBar(i_frankfurtSession)
frankfurtSession = isSession(i_frankfurtSession)
frankfurtLow := frankfurtLow_
frankfurtHigh := frankfurtHigh_
frankfurtStart := frankfurtStart_
frankfurtEnd := frankfurtEnd_
if not frankfurtNewbar
f_changeBox(frankfurtBox[1], frankfurtLow, frankfurtHigh, frankfurtEnd)
if i_showMidLine
yValue = math.avg(frankfurtHigh, frankfurtLow)
f_changeMidLine(frankfurtMidLine[1], yValue, frankfurtEnd)
// London
londonLow = float(na)
londonHigh = float(na)
londonStart = int(na)
londonEnd = int(na)
londonNewbar = isNewBar(i_londonSession)
londonSession = isSession(i_londonSession)
londonLow := londonLow_
londonHigh := londonHigh_
londonStart := londonStart_
londonEnd := londonEnd_
if not londonNewbar
f_changeBox(londonBox[1], londonLow, londonHigh, londonEnd)
if i_showMidLine
yValue = math.avg(londonHigh, londonLow)
f_changeMidLine(londonMidLine[1], yValue, londonEnd)
// New York
newYorkLow = float(na)
newYorkHigh = float(na)
newYorkStart = int(na)
newYorkEnd = int(na)
newYorkNewbar = isNewBar(i_newYorkSession)
newYorkSession = isSession(i_newYorkSession)
newYorkLow := newYorkLow_
newYorkHigh := newYorkHigh_
newYorkStart := newYorkStart_
newYorkEnd := newYorkEnd_
if not newYorkNewbar
f_changeBox(newYorkBox[1], newYorkLow, newYorkHigh, newYorkEnd)
if i_showMidLine
yValue = math.avg(newYorkHigh, newYorkLow)
f_changeMidLine(newYorkMidLine[1], yValue, newYorkEnd)
// MMMs
if i_showMMM1 and hour == i_MMM1hour and minute == i_MMM1minute and
f_tfShow(i_hideMMMtf)
f_drawVertical(i_MMM1color, i_MMM1width)
//Daily Plots
plot(i_showHighLow and pricehigh_daily ? pricehigh_daily : na, "Previous Daily
High", style=plot.style_linebr, color=color.white)
plot(i_showHighLow and pricelow_daily ? pricelow_daily : na, "Previous Daily Low",
style=plot.style_linebr, color=color.white)
// Alerts {
// }