# Problems with my moving average crossover EA.

22

Hi, I am preparing my first "simple" strategy, but for me it wasn´t that simple... I created this code:

//Global Variables

extern int slow =  9, fast = 3; // for subsequent optimization process **

extern int z= 150, w = 150;

int start()

{

//--------------------------------------------------------Variables declaration.

int pricet = (High[1]+Close[1]+Low[1])/3;

int ma1 =iMA(NULL, 0, slow, 0,MODE_SMA, PRICE_TYPICAL,0);

int ma2 =iMA(NULL, 0, fast, 0, MODE_SMA, PRICE_TYPICAL,0);

int ma3 =iMA(NULL, 0, slow, 0,MODE_SMA, pricet,0);// I created this variable for simultaneously condition.

int ma4=iMA(NULL, 0, fast, 0, MODE_SMA, pricet,0);

//---------------------------------------------------

if(ma4<ma3 && ma2 == ma1)//simultaneously condition

{

}

//----------------------------------------------------

if(ma4>ma3 && ma2== ma1)// simultaneously condition

{

}

//----------------------------------------------------

return(ticket);

}

When I run it with the strategy tester, it just doesnt execute the OrderSend(). Anyone can help me please :)????

7007

theforce:

Hi, I am preparing my first "simple" strategy, but for me it wasn´t that simple... I created this code:

//Global Variables

extern int slow =  9, fast = 3; // for subsequent optimization process **

extern int z= 150, w = 150;

int start()

{

//--------------------------------------------------------Variables declaration.

int pricet = (High[1]+Close[1]+Low[1])/3;

int ma1 =iMA(NULL, 0, slow, 0,MODE_SMA, PRICE_TYPICAL,0);

int ma2 =iMA(NULL, 0, fast, 0, MODE_SMA, PRICE_TYPICAL,0);

int ma3 =iMA(NULL, 0, slow, 0,MODE_SMA, pricet,0);// I created this variable for simultaneously condition.

int ma4=iMA(NULL, 0, fast, 0, MODE_SMA, pricet,0);

//---------------------------------------------------

if(ma4<ma3 && ma2 == ma1)//simultaneously condition

{

}

//----------------------------------------------------

if(ma4>ma3 && ma2== ma1)// simultaneously condition

{

}

//----------------------------------------------------

return(ticket);

}

When I run it with the strategy tester, it just doesnt execute the OrderSend(). Anyone can help me please :)????

loop in void OnTick()
Moderator
10619

Do you have your SL and TP reversed?

Please use the SRC button when posting code, I have done it for you this time.
62820

theforce:

Hi, I am preparing my first "simple" strategy, but for me it wasn´t that simple... I created this code:

When I run it with the strategy tester, it just doesnt execute the OrderSend(). Anyone can help me please :)????

Your ma1 and m12 will almost never be equal. It is a bad idea to us a comparison like this
if(ma4<ma3 && ma2 == ma1)
or this :
if(ma4>ma3 && ma2 == ma1)
in the conditions - it will, as you have already noticed, almost never happen. Use some other conditions
16058