PureBytes Links
Trading Reference Links
|
At 09:22 PM 3/4/2005, jbclem1 wrote:
>I'm trying to write an ExitLong rule that will exit after a minimum number
>of bars up (for starters, an up bar defined as the close higher than the
>prev close) and if the current bars low is lower than the prev bars low.
>
>I can write it for a fixed number of bars but I'd like the rule to stay long
>as long as the up bars continue to occur, and to be able to vary the minimum
>number of bars.
Your code doesn't do what your words say so it is not clear what you need.
You might try counting the upbars vs time. You then can save that count when you enter a position and exit after it increases by the number you are looking for - see below.
Bob Fulks
Input: MyCnt(4);
Vars: MP(0), UpBar(FALSE), UpCnt(0);
MP = MarketPosition;
UpBar = Close > Close[1];
if UpBar then UpCnt = UpCnt + 1;
if MP = +1 then begin
if MP[1] < +1 then SaveCnt = UpCnt;
if UpCnt - SaveCnt > MyCnt and Low < Low[1] then ExitLong;
end;
|