since I want to automatically calculate and display the lock limits defined for some futures contracts (e.g. commodity futures at CME), I use "tl_new" to calculate and display those lock limits (generic example):
Code: Select all
input:
lock_limit_up(10),
lock_limit_down(-10),
settlement_time(1430);
var:
settlement_price(0),
id.tl.c_up_1(-1),
id.tl.c_up_2(-1),
id.tl.c_dn_1(-1),
id.tl.c_dn_2(-1);
if time=settlement_time then begin
settlement_price=close;
end;
if time > sessionstarttime(0,1) then begin
id.tl.c_up_1 = tl_new(date, sessionstarttime(0,1), settlement_price+lock_limit_up, date,
2355, settlement_price+lock_limit_up);
id.tl.c_dn_1 = tl_new(date, sessionstarttime(0,1), settlement_price+lock_limit_down, date,
2355, settlement_price+lock_limit_down);
tl_setcolor(id.tl.c_up_1,blue);
tl_setcolor(id.tl.c_dn_1,yellow);
tl_setstyle(id.tl.c_up_1,5);
tl_setstyle(id.tl.c_dn_1,5);
end;
if time < settlement_time then begin
id.tl.c_up_2 = tl_new(date, 0005, settlement_price+lock_limit_up, date,
sessionendtime(0,1), settlement_price+lock_limit_up);
id.tl.c_dn_2 = tl_new(date, 0005, settlement_price+lock_limit_down, date,
sessionendtime(0,1), settlement_price+lock_limit_down);
tl_setcolor(id.tl.c_up_2,blue);
tl_setcolor(id.tl.c_dn_2,yellow);
tl_setstyle(id.tl.c_up_2,5);
tl_setstyle(id.tl.c_dn_2,5);
end;
Unfortunately, executing this codes results in a noticeable slow down of my system - and this just to plot some horizontal lines! Computing power shouldn't be the issue (System spec: Quadcore @ 4,5 Ghz, 16 GB RAM, Windows 7 64bit).
Obviously, the trendline calculation consumes a lot of computing power, even if it is utilized to calculate just a horizontal "trend" line.
Wouldn't it be worth thinking about the introduction of a dedicated reserved word for just drawing lines (horizontal, vertical, ....)?
Or is the example provided just badly coded? If so, any suggestions on how to improve it are appreciated.