OPEN-SOURCE SCRIPT
Mekayl's Session Zones

//version=5
indicator("Mekayl's Session zones", overlay=true, max_boxes_count=200)
// --- Colors
asiaFill = color.new(#3b3333, 80)
preLdnFill = color.new(#292323, 80)
ldnFill = color.new(#242222, 80)
preNyFill = color.new(#443322, 80)
nyFill = color.new(#664422, 80)
asiaBorder = color.new(#4d718f, 0)
preLdnBorder = color.new(#00897B, 0)
ldnBorder = color.new(#B2EBF2, 0)
preNyBorder = color.new(#FFA500, 0)
nyBorder = color.new(#FF8C00, 0)
// --- Sessions
asia_sess = "0100-0600"
preldn_sess = "0600-0800"
ldn_sess = "0800-1200"
preNY_sess = "1200-1300"
ny_sess = "1300-1700"
tz = "Europe/London"
// --- Variables for boxes & labels
var box asia_box = na
var label asia_label = na
var box pre_box = na
var label pre_label = na
var box ldn_box = na
var label ldn_label = na
var box preNY_box = na
var label preNY_label = na
var box ny_box = na
var label ny_label = na
// --- Function to get horizontal center above box
f_label_xy(b) =>
x = (box.get_left(b) + box.get_right(b)) / 2
y = box.get_top(b) + 3 * syminfo.mintick
[x, y]
// --- Asia box
asia_in = not na(time(timeframe.period, asia_sess, tz))
if asia_in
if na(asia_box)
asia_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=asiaFill, border_color=asiaBorder, border_width=2)
[x, y] = f_label_xy(asia_box)
asia_label := label.new(x, y, "asia", style=label.style_none, textcolor=color.new(asiaBorder,0), size=size.normal)
else
box.set_right(asia_box, bar_index)
box.set_top(asia_box, math.max(box.get_top(asia_box), high))
box.set_bottom(asia_box, math.min(box.get_bottom(asia_box), low))
[x, y] = f_label_xy(asia_box)
label.set_xy(asia_label, x, y)
else
if not na(asia_box)
box.set_right(asia_box, bar_index)
asia_box := na
asia_label := na
// --- Pre-London box
pre_in = not na(time(timeframe.period, preldn_sess, tz))
if pre_in
if na(pre_box)
pre_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=preLdnFill, border_color=preLdnBorder, border_width=2)
[x, y] = f_label_xy(pre_box)
pre_label := label.new(x, y, "pre_ldn", style=label.style_none, textcolor=color.new(preLdnBorder,0), size=size.normal)
else
box.set_right(pre_box, bar_index)
box.set_top(pre_box, math.max(box.get_top(pre_box), high))
box.set_bottom(pre_box, math.min(box.get_bottom(pre_box), low))
[x, y] = f_label_xy(pre_box)
label.set_xy(pre_label, x, y)
else
if not na(pre_box)
box.set_right(pre_box, bar_index)
pre_box := na
pre_label := na
// --- London box
ldn_in = not na(time(timeframe.period, ldn_sess, tz))
if ldn_in
if na(ldn_box)
ldn_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=ldnFill, border_color=ldnBorder, border_width=2)
[x, y] = f_label_xy(ldn_box)
ldn_label := label.new(x, y, "ldn", style=label.style_none, textcolor=color.new(ldnBorder,0), size=size.normal)
else
box.set_right(ldn_box, bar_index)
box.set_top(ldn_box, math.max(box.get_top(ldn_box), high))
box.set_bottom(ldn_box, math.min(box.get_bottom(ldn_box), low))
[x, y] = f_label_xy(ldn_box)
label.set_xy(ldn_label, x, y)
else
if not na(ldn_box)
box.set_right(ldn_box, bar_index)
ldn_box := na
ldn_label := na
// --- Pre-New York box
preNY_in = not na(time(timeframe.period, preNY_sess, tz))
if preNY_in
if na(preNY_box)
preNY_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=preNyFill, border_color=preNyBorder, border_width=2)
[x, y] = f_label_xy(preNY_box)
preNY_label := label.new(x, y, "pre-ny", style=label.style_none, textcolor=color.new(preNyBorder,0), size=size.normal)
else
box.set_right(preNY_box, bar_index)
box.set_top(preNY_box, math.max(box.get_top(preNY_box), high))
box.set_bottom(preNY_box, math.min(box.get_bottom(preNY_box), low))
[x, y] = f_label_xy(preNY_box)
label.set_xy(preNY_label, x, y)
else
if not na(preNY_box)
box.set_right(preNY_box, bar_index)
preNY_box := na
preNY_label := na
// --- New York box
ny_in = not na(time(timeframe.period, ny_sess, tz))
if ny_in
if na(ny_box)
ny_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=nyFill, border_color=nyBorder, border_width=2)
[x, y] = f_label_xy(ny_box)
ny_label := label.new(x, y, "ny", style=label.style_none, textcolor=color.new(nyBorder,0), size=size.normal)
else
box.set_right(ny_box, bar_index)
box.set_top(ny_box, math.max(box.get_top(ny_box), high))
box.set_bottom(ny_box, math.min(box.get_bottom(ny_box), low))
[x, y] = f_label_xy(ny_box)
label.set_xy(ny_label, x, y)
else
if not na(ny_box)
box.set_right(ny_box, bar_index)
ny_box := na
ny_label := na
indicator("Mekayl's Session zones", overlay=true, max_boxes_count=200)
// --- Colors
asiaFill = color.new(#3b3333, 80)
preLdnFill = color.new(#292323, 80)
ldnFill = color.new(#242222, 80)
preNyFill = color.new(#443322, 80)
nyFill = color.new(#664422, 80)
asiaBorder = color.new(#4d718f, 0)
preLdnBorder = color.new(#00897B, 0)
ldnBorder = color.new(#B2EBF2, 0)
preNyBorder = color.new(#FFA500, 0)
nyBorder = color.new(#FF8C00, 0)
// --- Sessions
asia_sess = "0100-0600"
preldn_sess = "0600-0800"
ldn_sess = "0800-1200"
preNY_sess = "1200-1300"
ny_sess = "1300-1700"
tz = "Europe/London"
// --- Variables for boxes & labels
var box asia_box = na
var label asia_label = na
var box pre_box = na
var label pre_label = na
var box ldn_box = na
var label ldn_label = na
var box preNY_box = na
var label preNY_label = na
var box ny_box = na
var label ny_label = na
// --- Function to get horizontal center above box
f_label_xy(b) =>
x = (box.get_left(b) + box.get_right(b)) / 2
y = box.get_top(b) + 3 * syminfo.mintick
[x, y]
// --- Asia box
asia_in = not na(time(timeframe.period, asia_sess, tz))
if asia_in
if na(asia_box)
asia_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=asiaFill, border_color=asiaBorder, border_width=2)
[x, y] = f_label_xy(asia_box)
asia_label := label.new(x, y, "asia", style=label.style_none, textcolor=color.new(asiaBorder,0), size=size.normal)
else
box.set_right(asia_box, bar_index)
box.set_top(asia_box, math.max(box.get_top(asia_box), high))
box.set_bottom(asia_box, math.min(box.get_bottom(asia_box), low))
[x, y] = f_label_xy(asia_box)
label.set_xy(asia_label, x, y)
else
if not na(asia_box)
box.set_right(asia_box, bar_index)
asia_box := na
asia_label := na
// --- Pre-London box
pre_in = not na(time(timeframe.period, preldn_sess, tz))
if pre_in
if na(pre_box)
pre_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=preLdnFill, border_color=preLdnBorder, border_width=2)
[x, y] = f_label_xy(pre_box)
pre_label := label.new(x, y, "pre_ldn", style=label.style_none, textcolor=color.new(preLdnBorder,0), size=size.normal)
else
box.set_right(pre_box, bar_index)
box.set_top(pre_box, math.max(box.get_top(pre_box), high))
box.set_bottom(pre_box, math.min(box.get_bottom(pre_box), low))
[x, y] = f_label_xy(pre_box)
label.set_xy(pre_label, x, y)
else
if not na(pre_box)
box.set_right(pre_box, bar_index)
pre_box := na
pre_label := na
// --- London box
ldn_in = not na(time(timeframe.period, ldn_sess, tz))
if ldn_in
if na(ldn_box)
ldn_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=ldnFill, border_color=ldnBorder, border_width=2)
[x, y] = f_label_xy(ldn_box)
ldn_label := label.new(x, y, "ldn", style=label.style_none, textcolor=color.new(ldnBorder,0), size=size.normal)
else
box.set_right(ldn_box, bar_index)
box.set_top(ldn_box, math.max(box.get_top(ldn_box), high))
box.set_bottom(ldn_box, math.min(box.get_bottom(ldn_box), low))
[x, y] = f_label_xy(ldn_box)
label.set_xy(ldn_label, x, y)
else
if not na(ldn_box)
box.set_right(ldn_box, bar_index)
ldn_box := na
ldn_label := na
// --- Pre-New York box
preNY_in = not na(time(timeframe.period, preNY_sess, tz))
if preNY_in
if na(preNY_box)
preNY_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=preNyFill, border_color=preNyBorder, border_width=2)
[x, y] = f_label_xy(preNY_box)
preNY_label := label.new(x, y, "pre-ny", style=label.style_none, textcolor=color.new(preNyBorder,0), size=size.normal)
else
box.set_right(preNY_box, bar_index)
box.set_top(preNY_box, math.max(box.get_top(preNY_box), high))
box.set_bottom(preNY_box, math.min(box.get_bottom(preNY_box), low))
[x, y] = f_label_xy(preNY_box)
label.set_xy(preNY_label, x, y)
else
if not na(preNY_box)
box.set_right(preNY_box, bar_index)
preNY_box := na
preNY_label := na
// --- New York box
ny_in = not na(time(timeframe.period, ny_sess, tz))
if ny_in
if na(ny_box)
ny_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, bgcolor=nyFill, border_color=nyBorder, border_width=2)
[x, y] = f_label_xy(ny_box)
ny_label := label.new(x, y, "ny", style=label.style_none, textcolor=color.new(nyBorder,0), size=size.normal)
else
box.set_right(ny_box, bar_index)
box.set_top(ny_box, math.max(box.get_top(ny_box), high))
box.set_bottom(ny_box, math.min(box.get_bottom(ny_box), low))
[x, y] = f_label_xy(ny_box)
label.set_xy(ny_label, x, y)
else
if not na(ny_box)
box.set_right(ny_box, bar_index)
ny_box := na
ny_label := na
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.