# iMA egality problem - page 2

66

and if I make

```int i=0;
int magicalNumber,ticket;
Moyenne1=iMA(NULL,PERIOD_M30,20,8,MODE_SMA,PRICE_CLOSE,i);
Moyenne1bis=iMA(NULL,PERIOD_M30,20,8,MODE_SMA,PRICE_CLOSE,i+2);
Moyenne2=iMA(NULL,PERIOD_M30,50,8,MODE_SMA,PRICE_CLOSE,i);
Moyenne2bis=iMA(NULL,PERIOD_M30,50,8,MODE_SMA,PRICE_CLOSE,i+2);

magicalNumber = 98765;

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

will it work ?

18335

1. Using i=0 means it will probably cross multiple times as the bar forms
2. why i+2? that is 2 bars ago, don't you want i+1?
66

i+2 for be sure

ok but will it takes order ?

66

re

so heres my new code :

```int i=1;
int magicalNumber,ticket;
Moyenne1=iMA(NULL,PERIOD_M30,20,8,MODE_SMA,PRICE_CLOSE,i);
Moyenne1bis=iMA(NULL,PERIOD_M30,20,8,MODE_SMA,PRICE_CLOSE,i+2);
Moyenne2=iMA(NULL,PERIOD_M30,50,8,MODE_SMA,PRICE_CLOSE,i);
Moyenne2bis=iMA(NULL,PERIOD_M30,50,8,MODE_SMA,PRICE_CLOSE,i+2);

magicalNumber = 98765;

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

but why did it take so long to make order (it should take order at 18:00, not later ...) ?

17666

re

so heres my new code :

but why did it take so long to make order (it should take order at 18:00, not later ...) ?

Perhaps it's something to do with your setting for ma_shift of 8 ?  did you set a shift of 8 for the MAs you have on your chart ?
66

yes, you're right

but what does "ma_shift" mean ?

17666

yes, you're right

but what does "ma_shift" mean ?

Red the documentation,  use the Forum search . . .

https://www.mql5.com/en/forum/140831

66

yeah i know

but i don't see the difference between MA_SHIFT and SHIFT

17666