Combining DMI and Moving Average for a EUR/USD trading system
The article by Rombout Kerstens in this issue, "Combining DMI and Moving Average for a EUR/USD trading system", has demonstrated how the combination of the moving average (MA) and the directional movement index (DMI) can limit the number of trades while delivering better results per trade.
Using Strategy Builder, you can create the strategy for the described method.
Here is the Tradecision code for the strategy:
Long:
Var
ParamMA:=30;
ParamDMI:=14;
DMILong:=false;
DMIShort:=false;
MALong:=false;
MAShort:=false;
vDMIMinus:=0;
vDMIPlus:=0;
MA:=0;
End_var
vDMIMinus := DMIMinus(ParamDMI);
vDMIPlus := DMIPlus(ParamDMI);
MA := SMA(Close,ParamMA);
if HISTORYSIZE > ParamMA then
begin
if CrossAbove(vDMIPlus,vDMIMinus)
then
begin
DMILong := true;
DMIShort := false;
end;
if CrossBelow(vDMIPlus,vDMIMinus)
then
begin
DMILong := false;
DMIShort := true;
end;
if CrossAbove(Close,MA)
then
begin
MALong := true;
MAShort := false;
end;
if CrossBelow(Close,MA)
then
begin
MALong := false;
MAShort := true;
end;
If dmilong = true and malong = true then
return true;
end;
return false;
Short:
Var
ParamMA:=30;
ParamDMI:=14;
DMILong:=false;
DMIShort:=false;
MALong:=false;
MAShort:=false;
vDMIMinus:=0;
vDMIPlus:=0;
MA:=0;
End_var
vDMIMinus := DMIMinus(ParamDMI);
vDMIPlus := DMIPlus(ParamDMI);
MA := SMA(Close,ParamMA);
if HISTORYSIZE > ParamMA then
begin
if CrossAbove(vDMIPlus,vDMIMinus)
then
begin
DMILong := true;
DMIShort := false;
end;
if CrossBelow(vDMIPlus,vDMIMinus)
then
begin
DMILong := false;
DMIShort := true;
end;
if CrossAbove(Close,MA)
then
begin
MALong := true;
MAShort := false;
end;
if CrossBelow(Close,MA)
then
begin
MALong := false;
MAShort := true;
end;
If dmishort = true and mashort = true then
return true;
end;
return false;
|
Download to import into Tradecision. 
How to use this indicator in Tradecision:
- Click Download.
- Save this indicator in a safe location on your hard drive.
- Open Tradecision and in the Tools menu click Indicator Builder.
- In the Indicator Builder dialog, click Import, locate the saved file and then click OK.
The indicator will be added to the Custom Indicators list.
|