Problem with coding an EA

 

Hi,

Hereunder is the code of an EA that don't want to run correctly :(

it should work like this :

MALx => long EMA (200); x => period

MAMx => medium EMA (80)

MACx => short EMA (30)

Order 1 => buying order and Order 2 => selling order

I would like to do a buying order when :

Long Ema is going up, then wait for medium EMA is going up (going down first and going up after), then wait for short EMA is going up (going down first and when change for going up do a buying order)

I don't understand why the code below don't work !

if (MAL0>MAL1) Long0=1;
if (MAL0<MAL1) Long0=2;
if (MAL1>MAL2) Long1=1;
if (MAL1<MAL2) Long1=2;

if (MAM0>MAM1) Medium0=1;
if (MAM0<MAM1) Medium0=2;
if (MAM1>MAM2) Medium1=1;
if (MAM1<MAM2) Medium1=2;

if (MAC1>MAC2) Short0=1;
if (MAC1<MAC2) Short0=2;
if (MAC2>MAC3) Short1=1;
if (MAC2<MAC3) Short1=2;

if (Medium0==1 && Medium1==2) tempM=1;
if (Medium0==2 && Medium1==1) tempM=2;
if (Short0==1 && Short1==2) tempC=1;
if (Short0==2 && Short1==1) tempC=2;


if (Long0==1)
   {if (tempM==1) fix=1;
    if (tempM==2) fix=0;}
if (fix==1 && tempC==1) order=1;

if (Long0==2)
   {if (tempM==2) fix=2;
    if (tempM==1) fix=0;}
if (fix==2 && tempC==2) order=2;

Thank in advance for your help.

Regards,

TAAD

 

Hi TAAD,

Your code seems do not have programming error.

To me, the only reason it doesn't work might due to

the conditions you set never met since you set so much conditions to trigger sell/buy

 

it seem your logical with EMA is not perfectly configured. try to send complete code here, may be i can help.


---------------- ads ------------

AUTO TRADING with RoboTrader

June 3rd, 2010 Update: 2,681.70% NET Profit since 01/01/2009 (518 days)

<a target="_blank_top" href="https://www.mql4.com/go?http://b895a3lesflyeq392-vjmbbu4l.hop.clickbank.net" ="Click Here!">Click Here! to find more about how we can achieve that.

Reason: