iMA egality problem - page 2

To add comments, please log in or register
Bond
66
Bond  

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 ?

William Roeder
18335
William Roeder  
  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?
Bond
66
Bond  

i+2 for be sure

ok but will it takes order ?

Bond
66
Bond  

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 ...) ?

Take order

Simon Gniadkowski
17666
Simon Gniadkowski  
Bad_Bond:

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 ?
Bond
66
Bond  

yes, you're right

but what does "ma_shift" mean ?

Simon Gniadkowski
17666
Simon Gniadkowski  
Bad_Bond:

yes, you're right

but what does "ma_shift" mean ?

Red the documentation,  use the Forum search . . .  

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

Bond
66
Bond  

yeah i know

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

Simon Gniadkowski
17666
Simon Gniadkowski  
Bad_Bond:

yeah i know

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

Do you see it now ?

 

12
To add comments, please log in or register