PureBytes Links
Trading Reference Links
|
Hello all,
I am trying to write an exit statement for a TSytem (data1=30'; data2=60')
based on the high & low of the first hour of trading session, but seem to be
having some difficutly.
Basically, I am trying to construct an exit where if today's open is <>
Low/High of yesterday's first hour, the system exitshort at "L first
hour[1]" or exitlong at "H first hour[1]".
Thkx a lot for any help & happy new year.
Davide
{Sistem First Hour; barinterval of data1=30 min, data2=60 min}
VARS:
Sess1firstbardate(0,data2),Sess1firstbarhigh(0,data2),Sess1firstbarlow(0,dat
a2);
If time of data2=sess1firstbartime of data2 or date[0] of data2>date[1] of
data2 then begin
Sess1firstbardate=date[0] of data2;
Sess1firstbarhigh=high[0] of data2;
Sess1firstbarlow=low[0] of data2;
end;
If Sess1firstbardate=date and time <Sess1endtime then begin
IF C[1]<Sess1firstbarhigh THEN BUY AT Sess1firstbarhigh STOP;
IF MARKETPOSITION=1 AND C[1]>Sess1firstbarhigh THEN EXITLONG AT
Sess1firstbarhigh STOP;
IF C[1]>Sess1firstbarlow THEN SELL AT Sess1firstbarlow STOP;
IF MARKETPOSITION=-1 AND C[1]<Sess1firstbarlow THEN EXITLONG AT
Sess1firstbarlow STOP;
end;
{--------->>>>>>> Please, Help Me!!
if marketposition=1 and open of today is > Sess1firstbarhigh of yesterday I
want exit at the Sess1firstbarhigh[1];
if marketposition=-1 and open of today is < Sess1firstbarlow of yesterday I
want exit at the Sess1firstbarlow[1]}
VARS:pHigh(0),pLow(99999),firstdate(0),R1(0),S1(0),dd(0);
If CurrentBar=1 then firstdate=date;
If time=Sess1FirstBarTime then begin
pHigh=HIGH;
pLow=LOW;
END;
IF H>pHigh THEN pHigh=H;
IF L<pLow THEN pLow=L;
IF TIME=Sess1EndTime THEN BEGIN
if phigh>h then R1=pHigh else R1=h;
if plow<l then S1=pLow else S1=l;
dd=date;
end;
IF date>dd THEN BEGIN
if Open >R1[1] then exitlong("1") at R1[1] stop;
if Open <S1[1] then exitshort("2") at S1[1] stop;
end;
|