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

Re: Problem Exiting at End of Session??



PureBytes Links

Trading Reference Links

Hans,

couple o' questions:

> 
> if time = Sess1EndTime -1 then begin
> 	EXITLONG;
> 	EXITSHORT;
> end;
> 

Will T/S adjust Sess1EndTime to an earlier time for days where
they stop trading earlier than usual, such as half days typical
near major holidays, or days when they close trading due to
significant volatility?

And .... since T/S expresses Time in an HHMM (hours/mins encoded
as decimal digits) format, subtracting 1 might cause probs., for
example, if Sess1EndTime is 1400, because 1399 won't be a valid
time, and the equality test above won't work.  Something like this
might:

Var:  etime(0);

    { convert end time to hours }
    etime = intpart(Sess1EndTime) + mod(Sess1EndTime, 100)/60.0;
    { subtract a minute from etime }
    etime = etime - 1/60;
    { convert back to HHMM format }
    etime = Intpart(etime) * 100 + IntrPart(FractPart(etime) * 60 + 0.001);

Or, this might be a little easier to follow:

    if mod(Sess1EndTime, 100) = 0 then begin
       { MM = 0, so subtract 1 from HH, and make MM = 59 }
       etime = (Intpart(Sess1EndTime/100)-1) * 100 + 59;
    end else begin
       { otherwise just subtract 1 from HHMM }
       etime = Sess1EndTime - 1;
    end;

Then, 

    if time >= etime and time < Sess1EndTime then begin
	    EXITLONG;
	    EXITSHORT;
    end;


-- 
--
| Gary Funck,  Intrepid Technology, gary@xxxxxxxxxxxx, (650) 964-8135