DMI Cross strategy

Strategies are published here.

Moderator: admin

DMI Cross strategy

Postby Alexander.Gettinger » Tue Nov 02, 2010 1:57 am

DMI_Cross_Strategy.png

Signals appear when DMI+ and DMI- crossing.
The signal can be direct or reverse.
MT4/MQ4 version.
viewtopic.php?f=38&t=69485
DMI_Cross_Signal.lua
(11.2 KiB) Downloaded 1742 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: DMI Cross strategy

Postby sabrumea » Thu Dec 09, 2010 6:18 pm

could anyone check if sound is playing in this strategy?... because i only get alerts on the screen and no sound :( even though i specified the file and everything..
User avatar
sabrumea
 
Posts: 34
Joined: Thu Aug 26, 2010 6:15 pm

Re: DMI Cross strategy

Postby PipGrabber » Thu Feb 24, 2011 1:35 am

Greetings! What line of code can be added to modify the buy/sell logic. I want to have another filter to it. Like only buy/sell only if the cross occurs on a certain DMI Level, say 25 or could be any constant value. I know it can be added as another "AND" condition greater than our constant. But how to know the value of DMI when the cross occurs is my problem. :roll: Thanks!

like AND CROSS value > 25

Code: Select all
local MustB=false;
    local MustS=false;
    if (dip[period]<dim[period] and dip[period-1]>dim[period-1] and instance.parameters.TypeSignal=="direct") or (dip[period]>dim[period] and dip[period-1]<dim[period-1] and instance.parameters.TypeSignal=="reverse") then
     MustS=true;
    end
    if (dip[period]>dim[period] and dip[period-1]<dim[period-1] and instance.parameters.TypeSignal=="direct") or (dip[period]<dim[period] and dip[period-1]>dim[period-1] and instance.parameters.TypeSignal=="reverse") then
     MustB=true;
    end
User avatar
PipGrabber
 
Posts: 46
Joined: Fri Jan 21, 2011 9:22 am

Re: DMI Cross strategy

Postby sunshine » Mon Feb 28, 2011 9:16 am

Hi PipGrabber,
I've added the Cross parameter with default value 25.
Unfortunately there is no function to easily define the crossing value, so I calculate it as follows:
Code: Select all
-- calculation of the crossing value 

    local iXStart, iXEnd;
    iXStart = DMI.DIP:date(period - 1);
    iXEnd = DMI.DIP:date(period);

    local iXDelta;
    iXDelta = iXEnd - iXStart;

    local iYLine1Start, iYLine1End;    -- rates for dip stream (DI+)
    iYLine1Start = DMI.DIP:tick(period - 1);
    iYLine1End = DMI.DIP:tick(period);

    local iYLine2Start, iYLine2End;    -- rates for dim stream (DI-)
    iYLine2Start = DMI.DIM:tick(period - 1);
    iYLine2End = DMI.DIM:tick(period);

    local iXIntersection, CROSS;

    local iYDelta1, iYDelta2;
    iYDelta1 = iYLine1Start - iYLine1End;
    iYDelta2 = iYLine2Start - iYLine2End;

    local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
    local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
    local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;

    CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;

-- end of calculation


And then I've added "AND CROSS > CrossValue" to the Buy/Sell conditions (where CrossValue is the value defined in the properties, CROSS is the value of DI+ and DI- crossing).
Attachments
DMI_Cross_Signal2.lua
(12.4 KiB) Downloaded 1217 times
sunshine
 

Re: DMI Cross strategy

Postby PipGrabber » Tue Mar 01, 2011 10:25 am

Thanks sunshine! I really appreciate the effort you put into making a work around on the crossed value. Hope lua has a built in function that makes things easier..hehe. :roll:
User avatar
PipGrabber
 
Posts: 46
Joined: Fri Jan 21, 2011 9:22 am

Re: DMI Cross strategy

Postby sagymmm » Thu Sep 27, 2012 11:04 pm

I would appreciate if we can add an option of having a limit and SL specified by pips
sagymmm
 
Posts: 21
Joined: Mon May 14, 2012 4:28 am

Re: DMI Cross strategy

Postby Apprentice » Sat Sep 29, 2012 1:36 am

What's wrong with current Stop/Limit settings.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36476
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: DMI Cross strategy

Postby sagymmm » Sat Sep 29, 2012 7:20 pm

They are ok but sometimes when the crossover happens in the opposite direction the trade turns to loss though it has been profitable
That was clear when I made a backtest for the strategy as it ends with few pips as a profit though sometimes it may reach more than 100 pips before it gets closed for 10-20 pips
So I think that having SL with certain amount of pips and trailing stop would endup in more profits
sagymmm
 
Posts: 21
Joined: Mon May 14, 2012 4:28 am

Re: DMI Cross strategy

Postby Avignon » Mon Dec 01, 2014 1:18 am

sunshine wrote:Hi PipGrabber,
I've added the Cross parameter with default value 25.
Unfortunately there is no function to easily define the crossing value, so I calculate it as follows:
Code: Select all
-- calculation of the crossing value 

    local iXStart, iXEnd;
    iXStart = DMI.DIP:date(period - 1);
    iXEnd = DMI.DIP:date(period);

    local iXDelta;
    iXDelta = iXEnd - iXStart;

    local iYLine1Start, iYLine1End;    -- rates for dip stream (DI+)
    iYLine1Start = DMI.DIP:tick(period - 1);
    iYLine1End = DMI.DIP:tick(period);

    local iYLine2Start, iYLine2End;    -- rates for dim stream (DI-)
    iYLine2Start = DMI.DIM:tick(period - 1);
    iYLine2End = DMI.DIM:tick(period);

    local iXIntersection, CROSS;

    local iYDelta1, iYDelta2;
    iYDelta1 = iYLine1Start - iYLine1End;
    iYDelta2 = iYLine2Start - iYLine2End;

    local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
    local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
    local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;

    CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;

-- end of calculation


And then I've added "AND CROSS > CrossValue" to the Buy/Sell conditions (where CrossValue is the value defined in the properties, CROSS is the value of DI+ and DI- crossing).



Hello,

After importing I have the message that is present yet it does not appear in the indicators.
Avignon
FXCodeBase: Graduate
 
Posts: 287
Joined: Mon Nov 17, 2014 3:54 am

Re: DMI Cross strategy

Postby Avignon » Mon Dec 01, 2014 3:50 pm

Avignon wrote:
sunshine wrote:Hi PipGrabber,
I've added the Cross parameter with default value 25.
Unfortunately there is no function to easily define the crossing value, so I calculate it as follows:
Code: Select all
-- calculation of the crossing value 

    local iXStart, iXEnd;
    iXStart = DMI.DIP:date(period - 1);
    iXEnd = DMI.DIP:date(period);

    local iXDelta;
    iXDelta = iXEnd - iXStart;

    local iYLine1Start, iYLine1End;    -- rates for dip stream (DI+)
    iYLine1Start = DMI.DIP:tick(period - 1);
    iYLine1End = DMI.DIP:tick(period);

    local iYLine2Start, iYLine2End;    -- rates for dim stream (DI-)
    iYLine2Start = DMI.DIM:tick(period - 1);
    iYLine2End = DMI.DIM:tick(period);

    local iXIntersection, CROSS;

    local iYDelta1, iYDelta2;
    iYDelta1 = iYLine1Start - iYLine1End;
    iYDelta2 = iYLine2Start - iYLine2End;

    local dA = iXStart * iYLine1End - iYLine1Start * iXEnd;
    local dB = iXStart * iYLine2End - iYLine2Start * iXEnd;
    local dC = iXDelta * iYDelta2 - iYDelta1 * iXDelta;

    CROSS = (dB * iYDelta1 - dA * iYDelta2) / dC;

-- end of calculation


And then I've added "AND CROSS > CrossValue" to the Buy/Sell conditions (where CrossValue is the value defined in the properties, CROSS is the value of DI+ and DI- crossing).



Hello,

After importing I have the message that is present yet it does not appear in the indicators.


I was wrong: the topic strategy here. :oops:
Avignon
FXCodeBase: Graduate
 
Posts: 287
Joined: Mon Nov 17, 2014 3:54 am

Next

Return to Custom Strategies

Who is online

Users browsing this forum: No registered users and 67 guests