PureBytes Links
Trading Reference Links
|
At 2:01 PM -0400 5/3/99, TWA7663@xxxxxxx wrote:
>{
>Vars: LowLow(0);
>
>If L[2] > L[1] and
> L[1] < L then
>begin
> LowLow = L[1];
>end;
>
>If MarketPosition =1 then ExitLong at LowLow stop;
>}
>Can someone tell me why this occasionally exits incorrectly?
This code will reset the value of "LowLow" only when the specified
condition is met.
But your ExitLong ststement will exit any long position on any bar where
the price drops through whatever LowLow value exists at that time, even a
value from long ago.
If you want to exit on the bar after you detect the swing low do this:
If L[2] > L[1] and
L[1] < L then
begin
LowLow = L[1];
end;
If MarketPosition = 1 then ExitLong at market;
If you want to use the swing low as a set-up to get out on a stop, you will
need to set a flag to remember this condition for several bars until the
stop is hit. You might want to use a counter to only keep the Exit signal
active for a few bars (assume 6 in the example below):
Count = Count + 1;
If MarketPosition = 1 and
L[2] > L[1] and
L[1] < L then
begin
LowLow = L[1];
ExitOK = TRUE;
Count = 0;
end;
If Count <= 6 then begin
If ExitOK then ExitLong at LowLow stop;
end else
ExitOk = FALSE;
If MarketPosition = 0 then ExitOk = FALSE;
Bob Fulks
|