As a consequence, an indicator I wrote to display vertical TL to indicate session breaks does not work as expected any more, the TL is not only drawn at the 1515 session end as expected, but also at 1507 (see attached picture).
I wrote the indicator since I don't like to get caught with an open position during session breaks...
I would also suggest that we get an option to show session breaks in advance as an implemented feature of MC, so additional indicators as the one below wouldn't be required any more.
The code is as follows:
Code: Select all
inputs:
session_end_time(1515),
session_end_time_friday(1515);
var:
tl(-1),
tl_warn(-1),
EoS(0),
EoS_friday(0),
count_a(1),
count_b(1),
tl_color(RGB(47,79,79)),
tl_friday_color(lightgray),
warn_color(cyan),
show_countdown(true),
countdown(0),
countdown_time_axis_offset(0),
HHmm_to_EoS(0),
jHHmm_to_EoS(0),
pre_tl_HHmm(30),
pre_tl_warn_HHmm(10),
pre_countdown_HHmm(10),
jbarinterval(0);
If bartype_ex >= 2 and bartype_ex <= 7 then begin
EoS = session_end_time;
jbarinterval = eltimetodatetime(barinterval);
if session_end_time_friday <> session_end_time then begin
if dayofweek(date)=5 then EoS = session_end_time_friday
else EoS = session_end_time;
end;
jHHmm_to_EoS = (eltimetodatetime(EoS) - eltimetodatetime(time)-jbarinterval);
if jHHmm_to_EoS > 0 then HHmm_to_EoS = datetime2eltime(jHHmm_to_EoS)
else HHmm_to_EoS = 0;
if HHmm_to_EoS < pre_tl_HHmm and jHHmm_to_EoS >0 and count_a = 1 then begin
count_a = count_a + 1;
tl = tl_new(date,EoS, h, date,EoS, h+100);
if dayofweek(date)<>5 then tl_setcolor(tl, tl_color);
if dayofweek(date)=5 then tl_setcolor(tl, tl_friday_color);
tl_setstyle(tl, 5);
tl_setextleft(tl, true);
tl_setextright(tl, true);
tl_lock(tl, true);
end;
If HHmm_to_EoS < pre_tl_warn_HHmm and jHHmm_to_EoS > 0 and count_b = 1 then begin
count_b = count_b + 1;
tl_warn = tl_new(date,EoS, h, date, EoS, h+100);
tl_setcolor(tl_warn, warn_color);
tl_setstyle(tl_warn, 5);
tl_setextleft(tl_warn, true);
tl_setextright(tl_warn, true);
tl_lock(tl_warn, false);
if show_countdown then begin
countdown = text_new(date, EoS+countdown_time_axis_offset,
(GetAppInfo(aihighestdispvalue) + getappinfo(ailowestdispvalue))*0.5," ");
text_setcolor(countdown,white);
text_setsize(countdown,13);
end;
end;
if show_countdown and barinterval <= 10 then begin
countdown=text_getfirst(1);
if HHmm_to_EoS <= pre_countdown_HHmm then begin
if dayofweek(date) <> 5 then
text_setstring(countdown,text(NumToStr((HHmm_to_EoS),0)," ","min"))
else
text_setstring(countdown,text(Spaces(7),"Attention!" +Newline+
"Friday Session ends" +Newline+ Spaces(8)+ "in"," ", NumToStr((HHmm_to_EoS),0) ," ","min"));
end;
end;
if time >= session_end_time or date<>date[1] then begin
count_a = 1;
count_b = 1;
if tl_getcolor(tl_warn) = warn_color then tl_delete(tl_warn);
text_delete(countdown);
end;
end;