Extended features for Dealbook Chartstudio CTL programming


CTLDLL HOME



AF_Period_S
function AF_Period_S;
// returns one of
// tik, xxm, xxh, xxd, wek, mth, unk
// where xx is a two digit number ,
// and unk means unknown (can’t calculate)
result Period(string);
vars t(number), t1(number), t2(number);
begin
t1 := timestamp[back(open)-2];
t2 := timestamp[back(open)-3];
t := t1 - t2;
if t < 60 then { less than 1 minute
Period := "tik"
else if t < 60 * 60 then { less than 1 hour
begin
t := int(t/60);
if t < 10 then
Period := "0" + numbertostring(t) + "m"
else
Period := numbertostring(t) + "m";
end
else if t < 60 * 60 * 24 then { less than 1 day
begin
t := int(t/(60*60));
if t < 10 then
Period := "0" + numbertostring(t) + "h"
else
Period := numbertostring(t) + "h";
end
else if t < 60 * 60 * 24 * 7 then { less than 1 week
begin
t := int(t/(60*60*24));
if t < 10 then
Period := "0" + numbertostring(t) + "d"
else
Period := numbertostring(t) + "d";
end
else if t < 60 * 60 * 24 * 28 then { less than 1 month
begin
Period := "wek";
end
else if t < 60 * 60 * 24 * 7 * 52 then { less than 1 year
begin
Period := "mth";
end
else
Period := "Unk";
end.



Click here for Orders, demos and Enquiries



CTLDLL HOME