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

Re: LRW strategy works........but its doing bizare stuff



PureBytes Links

Trading Reference Links

Cameron,

This is an old message of yours but I don't recall seeing any replies.

>Thought id post a strategy , feel free to use it. It would be nice too if
>you repost it back to the list if you can improve it.
>One thought though , something that has been bugging me about this code is
>that i keep getting errros like [strategy tried to reference more than
>allowed bars , increase max barsback setting]

This is due to statements that reference BarsSinceEntry.

>	if marketposition = 1 then sell next bar at low[barssinceentry+1] stop;

>	if marketposition = -1 then buy next bar at high[barssinceentry+1] stop;

It will give a MaxBarsBack error when barssinceentry+1 exceeds
maxbarsback.

To avoid this error, you simply maintain variables that keep track
of the high and the low of the bar prior to entry.  Just stick this
at the beginning of your code:

vars: HE(0), LE(0), mp(0); {high entry, low entry, marketposition}
mp = MarketPosition;
if mp > 0 then begin
   if mp <> mp[1] then HE = H[1];
end;
if mp < 0 then begin
   if mp <> mp[1] then LLE = L[1];
end;

If you want to keep track of the highest high or lowest low since entry,
just insert the line "if H > HE then HE = H;" before the end of the
first "if" block above, and insert "if L < LE then LE = L;" before the
end of the second "if" block.

Then all you have to do is use HE in place of high[barssinceentry+1] and
LE in place of low[barssinceentry+1].

What market did you apply this strategy to?

-Alex