[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting Military Time to Normal time, heres how!



PureBytes Links

Trading Reference Links

Thought I might help some one, hey you never know !!!

Are you fed up of reading miltary time when looking at text on charts or 
text in the message log,
that have been created from your EL programs.

To convert miltary time to exchange time shown by the chart scale.(If your 
charts are setup as local time, you
may have to fiddle with the calculations to suit).

Open a new function in Power editor,
Name it as : ChartTime   {name of your function is important for code  line 
marked  "XX" }
Select output as : "text"

Input this code :
********************************************************
Inputs: NormTime(NumericSimple);

Vars : AdjTime("0");

If NormTime < 1000 then
	AdjTime = Leftstr(numtostr(NormTime,0),1)+":"+ 
rightstr(numtostr(NormTime,0),2);

If NormTime > 959 and NormTime < 1300 then
	AdjTime = Leftstr(numtostr(NormTime,0),2)+":"+ rightstr(numtostr(NormTime 
,0),2);

If NormTime > 1259 then
	AdjTime = Leftstr(numtostr(NormTime - 1200,0),1)+":"+ 
rightstr(numtostr(NormTime - 1200,0),2);

ChartTime = AdjTime; {XX}

****************************************************************

Thus reading time as 1421 will be 2:21, or 0845 will be 8:45

In Your indicator code when creating the text time to output.

Instead of  :

Numtostr(time,0) {when time is 1421}

Result : 1421 {in text format}

Do : Charttime(time)

Result : 2.21 {in text format}

Thats it , hope it helps someone.

Ian