Here is the WL code from the previous test results I published. It goes long when the price exceeds the previous bars H and short when it exceeds it's low. Very simple S/R. The problem is it only works well on the index (INX), not the emini's. Maybe somebody can fine tune and make it profitable with the tradeable contracts.
There's a little surplus in the code that I didn't edit out.
see
http://www.elitetrader.com/vb/showthread.php?s=&threadid=6439&perpage=6&pagenumber=4 for performance stats.
var Bar: integer;
var StopPrice, Tick: float;
var ps: float;
var Barsavailable: integer;
procedure CalcCommission( BasisPrice: float);
var nShares: integer;
{Tick :=.10;}
begin
nShares:=Round(1000/BasisPrice);
if nShares <=1000 then
SetCommission((nShares/1)*45)
else
SetCommission(((nshares/1)*30)+40)
end;
BarsAvailable := Barcount;
SetPositionSize (100000);
InstallStopLoss(20);
for Bar:= Barcount()-499 to BarCount -1 do
begin
{ApplyAutoStops(Bar);}
if NOT LastPositionActive then
{ Entry Rules }
begin
if (PriceLow(Bar)<PriceLow(Bar-1)) and (PriceOpen(Bar) < PriceLow(Bar)) then
ShortAtStop(Bar,PriceLow(Bar-1),'');
If (PriceHigh(Bar)>PriceHigh(Bar-1)) and (PriceHigh(Bar)>PriceOpen(Bar)) then
BuyAtStop(Bar,PriceHigh(Bar-1),'');
CalcCommission(PriceClose(Bar));
end;
{ Exit Rules }
if LastPositionActive then
begin
If PositionShort(LastPosition)then
begin
If PriceHigh(Bar)> PriceHigh(Bar-1) then
Begin
CoverAtStop(Bar, PriceHigh(Bar-1),Lastposition,'');
BuyAtStop(Bar,PriceHigh(Bar-1),'');
CalcCommission(PriceHigh(Bar));
end;
end;
If PositionLong(Lastposition) then
begin
If (PriceLow(Bar)<PriceLow(Bar-1)) and (PriceHigh(Bar) <= PriceHigh(Bar-1))then
begin
SellAtStop(Bar, PriceLow(Bar-1),Lastposition,'');
ShortAtStop(Bar,PriceLow(Bar-1),'');
CalcCommission(PriceLow(Bar));
end;
end;
end;
end;
{$I 'Profit Pane (Bottom)'}