iMA egality problem

 

yo,

here's my code :

int magicalNumber,ticket;
double Moyenne1=iMA(NULL,PERIOD_M30,20,8,MODE_SMA,PRICE_CLOSE,i);
double Moyenne2=iMA(NULL,PERIOD_M30,50,8,MODE_SMA,PRICE_CLOSE,i);

magicalNumber = 98765;

            if( Moyenne1 == Moyenne2 )
            {
               ticket = OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"SELL",magicalNumber,0,Red);
               
            }


The problem is, it never takes order !

why ?


thanks in advance

 
Bad_Bond:

yo,

here's my code :


The problem is, it never takes order !

why ?


thanks in advance


Maybe because Moyenne1 is never equals to Moyenne2 ;-)
 
angevoyageur:

Maybe because Moyenne1 is never equals to Moyenne2 ;-)

And even if it is equal it may not be  ;-)  Can price != price ?

Does it try and take orders and fail ?   What are Function return values ? How do I use them ?

 
RaptorUK:

And even if it is equal it may not be  ;-)  Can price != price ?

Does it try and take orders and fail ?   What are Function return values ? How do I use them ?

I knew you were going to link without my having to get it :-D
 
angevoyageur:
I knew you were going to link without my having to get it :-D
You are most welcome :-)
 

how could it never been equal ?

look at this :

iMA

 
Bad_Bond:

how could it never been equal ?

Read this and you will find out:  Can price != price ?

Also if the cross is just before or just after a Bar the values at the Bar will not be equal.

 
moving avering is a bar too ?
 
Bad_Bond:
moving avering is a bar too ?

The MAs are only calculated for each bar,  not between bars . . .

 

Bar #3210
MA11.51.61.71.9
MA21.71.71.61.4

 

These 2 MAs have crossed between Bars 1 & 2 but the values are not equal at any of the Bars. 

 
and he returns number every 30 minutes so
Reason: