0% found this document useful (0 votes)
19 views5 pages

Entrytime OTL

This document defines an indicator for the MT4 trading platform that draws boxes on a chart to represent trading sessions according to user-defined times and colors. It includes inputs for session settings, individual session settings, and moving average plots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views5 pages

Entrytime OTL

This document defines an indicator for the MT4 trading platform that draws boxes on a chart to represent trading sessions according to user-defined times and colors. It includes inputs for session settings, individual session settings, and moving average plots.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

//@version=5

indicator('Timing OTL ', 'Timing OTL', overlay=true, max_lines_count=200,


max_boxes_count=200, max_labels_count=200, max_bars_back=500,
explicit_plot_zorder=true)

// ------------------------
// Group
// ------------------------
g0 = '//Session Settings//'
g1_01 = '// ♯1 SESSION //'
g1_02 = '// ♯2 SESSION //'
g1_03 = '// ♯3 SESSION //'
g1_04 = '// ♯4 SESSION //'
g1_05 = '// ♯5 SESSION //'
g1_06 = '// ♯6 SESSION //'
g1_07 = '// ♯7 SESSION //'
g1_08 = '// ♯8 SESSION //'
g1_09 = '// ♯9 SESSION //'
g1_10 = '// ♯10 SESSION //'
g4 = '// EMA200 //'

option_border_style1 = '────'
option_border_style2 = '- - - - - -'
option_border_style3 = '•••••••••'

TRANSPARENT = color.new(color.black, 100)

tf1 = timeframe.period=='1'
// ------------------------
// Input
// ------------------------

tz = input.string('GMT+7', title='Timezone', options=['GMT-


11', 'GMT-10', 'GMT-9', 'GMT-8', 'GMT-7', 'GMT-6', 'GMT-5', 'GMT-4', 'GMT-3', 'GMT-
2', 'GMT-1', 'GMT+0', 'GMT+1', 'GMT+2', 'GMT+3', 'GMT+330', 'GMT+4', 'GMT+430',
'GMT+5', 'GMT+530', 'GMT+6', 'GMT+7', 'GMT+8', 'GMT+9', 'GMT+10', 'GMT+11',
'GMT+12'], group=g0)
text_size = input.string('small', 'Text Size', options=['tiny',
'small', 'normal', 'large', 'huge', 'auto'], group=g0)
text_Hali = input.string('center', 'Text Alignment',
options=['center', 'left', 'right'], group=g0)
extZone = input.int(defval=400, minval=10, maxval=1000, step=1,
title="Session Length", group=g0)
text_Color = input.color(color.red, 'Text Color', group=g0)
alertS = input.bool(true, 'Alert the trading session has opened',
group=g0)

ema_0 = input.color(color.orange, 'EMA 21 1m', inline = '0',


group=g4)
show_ema_0 = input.bool(true, " ", inline = "0", group=g4)
ema_1 = input.color(color.blue, 'EMA 200 1m', inline = '1',
group=g4)
show_ema_1 = input.bool(true, " ", inline = "1", group=g4)
ema_2 = input.color(color.red, 'EMA 200 5m', inline = '2',
group=g4)
show_ema_2 = input.bool(true, " ", inline = "2", group=g4)
ema_3 = input.color(color.purple, 'EMA 21 1D ', inline = '3',
group=g4)
show_ema_3 = input.bool(true, " ", inline = "3", group=g4)
// Sessions
i_show_sess1 = input.bool(true, 'Session 1 ', group=g1_01,
inline='session1_1')
i_sess1_label = input.string('08:30', '', group=g1_01,
inline='session1_1')
i_sess1_color = input.color(#66D9EF, 'Box color', group=g1_01,
inline='session1_1')
i_sess1 = input.session('0830-0831', 'Time', group=g1_01)

i_show_sess2 = input.bool(true, 'Session 2 ', group=g1_02,


inline='session2_1')
i_sess2_label = input.string('13:00', '', group=g1_02,
inline='session2_1')
i_sess2_color = input.color(#1081FF, 'Box color', group=g1_02,
inline='session2_1')
i_sess2 = input.session('1300-1301', 'Time', group=g1_02)

i_show_sess3 = input.bool(true, 'Session 3 ', group=g1_03,


inline='session3_1')
i_sess3_label = input.string('14:00', '', group=g1_03,
inline='session3_1')
i_sess3_color = input.color(#1081FF, 'Box color', group=g1_03,
inline='session3_1')
i_sess3 = input.session('1400-1401', 'Time', group=g1_03)

i_show_sess4 = input.bool(true, 'Session 4 ', group=g1_04,


inline='session4_1')
i_sess4_label = input.string('16:30', '', group=g1_04,
inline='session4_1')
i_sess4_color = input.color(#FD971F,'Box color', group=g1_04,
inline='session4_1')
i_sess4 = input.session('1630-1631', 'Time', group=g1_04)

i_show_sess5 = input.bool(true, 'Session 5 ', group=g1_05,


inline='session5_1')
i_sess5_label = input.string('19:00', '', group=g1_05,
inline='session5_1')
i_sess5_color = input.color(#07b354, 'Box color', group=g1_05,
inline='session5_1')
i_sess5 = input.session('1900-1901', 'Time', group=g1_05)

i_show_sess6 = input.bool(true, 'Session 6 ', group=g1_06,


inline='session6_1')
i_sess6_label = input.string('20:30', '', group=g1_06,
inline='session6_1')
i_sess6_color = input.color(#ae81ff,'Box color', group=g1_06,
inline='session6_1')
i_sess6 = input.session('2030-2031', 'Time', group=g1_06)

i_show_sess7 = input.bool(true, 'Session 7 ', group=g1_07,


inline='session7_1')
i_sess7_label = input.string('22:30', '', group=g1_07,
inline='session7_1')
i_sess7_color = input.color(#1081FF, 'Box color', group=g1_07,
inline='session7_1')
i_sess7 = input.session('2230-2231', 'Time', group=g1_07)
i_show_sess8 = input.bool(true, 'Session 8 ', group=g1_08,
inline='session8_1')
i_sess8_label = input.string('00:30', '', group=g1_08,
inline='session8_1')
i_sess8_color = input.color(#1081FF, 'Box color', group=g1_08,
inline='session8_1')
i_sess8 = input.session('0030-0031', 'Time', group=g1_08)

// ------------------------
// Type and method
// ------------------------

type Session
string sess
string tz
string name
color colour
box[] boxes
int session

method create (Session this) =>


this.boxes := array.new<box>()
this

method session (Session this) =>


time("1", this.sess, this.tz)

// ------------------------
// Session
// ------------------------

draw (_show, Session data) =>


session = data.session()
col = data.colour
name = data.name
var box my_box = na
is_started = na(session[1]) and not na(session)
if _show and is_started
if data.boxes.size() > 0
ele = data.boxes.get(0)
box.delete(ele)
data.boxes.shift()

my_box := box.new(bar_index, low, bar_index + extZone, high, col, 1,


line.style_dashed, bgcolor=color.new(col, 85), text = name,text_size = text_size,
text_halign = text_Hali, text_color = text_Color)
array.push(data.boxes, my_box)

var sess1_data = Session.new(i_sess1, tz, i_sess1_label, i_sess1_color).create()


var sess2_data = Session.new(i_sess2, tz, i_sess2_label, i_sess2_color).create()
var sess3_data = Session.new(i_sess3, tz, i_sess3_label, i_sess3_color).create()
var sess4_data = Session.new(i_sess4, tz, i_sess4_label, i_sess4_color).create()
var sess5_data = Session.new(i_sess5, tz, i_sess5_label, i_sess5_color).create()
var sess6_data = Session.new(i_sess6, tz, i_sess6_label, i_sess6_color).create()
var sess7_data = Session.new(i_sess7, tz, i_sess7_label, i_sess7_color).create()
var sess8_data = Session.new(i_sess8, tz, i_sess8_label, i_sess8_color).create()
if tf1
draw(i_show_sess1, sess1_data)
draw(i_show_sess2, sess2_data)
draw(i_show_sess3, sess3_data)
draw(i_show_sess4, sess4_data)
draw(i_show_sess5, sess5_data)
draw(i_show_sess6, sess6_data)
draw(i_show_sess7, sess7_data)
draw(i_show_sess8, sess8_data)

// ------------------------
// Ema
// ------------------------

drawLiveEma(bool condition, float y, color co, string txt) =>


x = time
if barstate.islast and condition and tf1
lbl = label.new(x, y, txt, xloc.bar_time, color = TRANSPARENT, textcolor =
co, style = label.style_label_left, size = size.small)
label.delete(lbl[1])

ema21_1m = ta.ema(close, 21)


ema200_1m = ta.ema(close, 200)
ema200_5m = request.security(syminfo.tickerid, '5', ta.ema(close, 200), lookahead =
barmerge.lookahead_on)
ema21_1D = request.security(syminfo.tickerid, 'D', ta.ema(close, 21), lookahead =
barmerge.lookahead_on)
smooth_ema200_5m = ta.sma(ema200_5m, 5)
smooth_ema21_1D = ta.sma(ema21_1D, 1440)

plot(show_ema_0 and tf1 ? ema21_1m : na, color=ema_0, linewidth=1, title='EMA21


1m')
plot(show_ema_1 and tf1 ? ema200_1m : na, color=ema_1, linewidth=1, title='EMA200
1m')
plot(show_ema_2 and tf1 ? smooth_ema200_5m : na, color=ema_2, linewidth=1,
title='EMA200 5m')
plot(show_ema_3 and tf1 ? smooth_ema21_1D : na, color=ema_3, linewidth=1,
title='EMA21 1D')
drawLiveEma(show_ema_0, ema21_1m, ema_0, 'EMA 21 1m')
drawLiveEma(show_ema_1, ema200_1m, ema_1, 'EMA 200 1m')
drawLiveEma(show_ema_2, smooth_ema200_5m, ema_2, 'EMA 200 5m')
drawLiveEma(show_ema_3, smooth_ema21_1D, ema_3, 'EMA 21 1D')

getStyleArrow(bool style) => style ? label.style_arrowdown : label.style_arrowup


getYloc(bool style) => style ? yloc.abovebar : yloc.belowbar

// ------------------------
// Alert
// ------------------------
alertSession(sess, string lbl, bool show) =>
if not na(time(timeframe.period, sess, tz)) and show and alertS
alert('The ' + lbl + ' trading session has opened')

alertSession(i_sess1, i_sess1_label, i_show_sess1)


alertSession(i_sess2, i_sess2_label, i_show_sess2)
alertSession(i_sess3, i_sess3_label, i_show_sess3)
alertSession(i_sess4, i_sess4_label, i_show_sess4)
alertSession(i_sess5, i_sess5_label, i_show_sess5)
alertSession(i_sess6, i_sess6_label, i_show_sess6)
alertSession(i_sess7, i_sess7_label, i_show_sess7)
alertSession(i_sess8, i_sess8_label, i_show_sess8) Bạn có thể chuyển đổi ngôn
ngữ này qua bên ngôn ngữ phù hợp mới indicator MT4

You might also like