OK guys,
Going to open up this thread again. This thread was intriguing, and I tried it implement what I think are NYC's rules in Wealth Lab. This implementation only yields about a 25% return. Anyone care to comment on this code below ? (SORRY BUT I CANNOT GET INDENTING TO WORK PROPERLY, SO READABILITY IS A LITTLE UGLY !)
var Bar: integer;
var DX_Val, ADX_Val, PDI_Val, MDI_Val: float;
var DX_Val_Last, ADX_Val_Last, PDI_Val_Last, MDI_Val_Last: float;
var tmp: string;
for Bar := 15 to BarCount - 1 do
begin
PortfolioSynch(Bar, '');
DX_Val_Last := DX(Bar-1,15);
DX_Val := DX(Bar,15);
ADX_Val_Last := ADX(Bar-1,15);
ADX_Val := ADX(Bar,15);
PDI_Val_Last := DIPlus(Bar-1,15);
PDI_Val := DIPlus(Bar,15);
MDI_Val_Last := DIMinus(Bar-1,15);
MDI_Val := DIMinus(Bar,15);
if not LastPositionActive then
begin
If ((ADX_Val_Last < PDI_Val_Last) and (ADX_Val > PDI_VAL)) or
((ADX_Val_Last < MDI_Val_Last) and (ADX_Val > MDI_Val)) then
begin
If ((ADX_Val > PDI_Val) and (PDI_Val > MDI_Val)) then
begin
tmp := 'BUY- ADX:' + floattostr(ADX_Val) + ' PDI:' + floattostr(PDI_Val) + ' MDI:' + floattostr(MDI_Val);
BuyAtMarket(Bar+1, tmp);
end
else
If ((ADX_Val > MDI_Val) and (MDI_Val > PDI_Val)) then
begin
tmp := 'SHORT- ADX:' + floattostr(ADX_Val) + ' PDI:' + floattostr(PDI_Val) + ' MDI:' + floattostr(MDI_Val);
ShortAtMarket(Bar+1, tmp);
end;
end;
end
else
begin
if PositionLong(LastPosition) then
begin
If MDI_Val > PDI_Val then
begin
tmp := 'SELL- ADX:' + floattostr(ADX_Val) + ' PDI:' + floattostr(PDI_Val) + ' MDI:' + floattostr(MDI_Val);
SellAtMarket(Bar+1, Lastposition, tmp);
end;
end
else
if PositionShort(LastPosition) then
begin
If PDI_Val > MDI_Val then
begin
tmp := 'COVER- ADX:' + floattostr(ADX_Val) + ' PDI:' + floattostr(PDI_Val) + ' MDI:' + floattostr(MDI_Val);
CoverAtMarket(Bar+1, LastPosition, tmp);
end;
end;
end;
end;
Regards,
Doug