MQ5 expert advisor auto trade with 2 EMA

 

Can please someone help me o make this work?


void OnTick()

{

   // create an Array for several prices

   double myMovingAverageArray1[],myMovingAverageArray2[];


   // define the properties of the Moving Average1

   int movingAverageDefinition1 = iMA (_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE);

   

   // define the properties of the Moving Average2

     int movingAverageDefinition2 = iMA (_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE);

   

   // sort the price array1 from the current candle downwards

   ArraySetAsSeries (myMovingAverageArray1, true );

   

   // sort the price array1 from the current candle downwards

   ArraySetAsSeries (myMovingAverageArray2, true );

   

   // Defined MA1, one line, current candle, 3 candles, store result

   CopyBuffer (movingAverageDefinition1,0,0,3, myMovingAverageArray1);

   

   // Defined MA2, one line, current candle, 3 candles, store result

   CopyBuffer (movingAverageDefinition2,0,0,3, myMovingAverageArray2);

   

   if ( // Check if the 20 candle EA is above the 50 candle EA

         ( myMovingAverageArray1[0]>myMovingAverageArray2[0])

         && ( myMovingAverageArray2[1]>myMovingAverageArray1[1])

         )

         

          trade. "Buy(0.10, NULL,Ask,Ask -300* _Point,Ask+150*_Point, NULL ;"

         

         

     

         

   

 

Use command alt+s when posting your code!

code attach

Reason: