PureBytes Links
Trading Reference Links
|
Dennis said:
> -------------
> var: hi(99999), lo(0);
>
> if date > date[1] then begin
> hi = high;
> lo = low;
> end;
>
> buy hi stop;
> sell lo stop;
>
> {Set the system properties to "close all trades at the end of the day
> session".}
> ----------------
> ps - I just saw Ron's answer...
>
> > Buy FirstBarHigh stop;
> > Sell FirstBarLow stop;
> >
> > FirstBarHigh = 99999;
> > FirstBarLow = -99999;
>
> This may or may not be what Jeff wants. If you reset to 99999 or
> whatever, the system will only trade on the second bar of the day and
> won't trade at all if it's an inside bar.
Good point Dennis, and one that many people miss. Stop and limit
orders apply only to the NEXT bar, and you must keep applying them as
long as you want the order to stay open.
But your solution might not be what Jeff wants either, since it
*continues* to buy/sell at the hi/lo all day long. When I set stops
in my systems, I also check the current bar H/L to see if it's hit my
stop, and if so I clear the stop variable. E.g. you might add this
to your example, just before the buy/sell instructions:
if (High > hi) then hi = 99999; { Stop was hit in this bar }
if (Low < lo) then lo = -99999;
Or, if you want to cancel the sell stop when the buy stop is hit and
vice versa, you might say:
if (High > hi) OR (Low < lo) then begin
hi = 99999;
lo = -99999;
end;
Gary
|