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

Re: Coding help



PureBytes Links

Trading Reference Links

Remember, stop orders are executed on the bar following the bar where
you issue the order.

> If Time > CalcTime(Sess1StartTime, 60) and BarDir < 0 then begin
>         Sell at BarLo - Pts Points Stop;
>         SetExitonClose; 

If your conditions are true on the last bar of the day, the trade can be
executed on the next bar, which is the opening bar of the next day.

Unverified version with an extra var added to eliminate redundant
calculations.....

{30 min bars only}
        
Inputs: Pts(1);
                
Vars: BarDir(0), BarHi(0), BarLo(0), MP(0);
Vars: DirTime(CalcTime(Sess1StartTime, 60));

If D > D[1] then begin
        BarDir = 0;
        BarHi = 0;
        BarLo = 0;
End;

If Time = DirTime then begin
        BarDir = Close - Open;
        BarHi = High;
        BarLo = Low;    
End;

If Time > DirTime and Time < Sess1EndTime then begin
	If BarDir < 0 then begin
        	Sell at BarLo - Pts Points Stop;
        	SetExitonClose; 
	End;

	If BarDir > 0 then begin
        	Buy at BarHi + Pts Points Stop;
        	SetExitonClose;
	End;
End;

-- 
  Dennis