Learning how to code. Help please.

 

Hi, just trying to do  a simple MA crossover EA, but im new and cant understand where the problem is. If anyone could help me i would apreciate it. Thanks!


#include<Trade\Trade.mqh>

CTrade trade;


void OnTick()

  {
         string entry ="";
         
         double ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK,_Digits);
         
         double bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID,_Digits);
        
         double myMovingAverageArray1{},myMovingAverageArray2{};
         
         int movingAverageDefinition1 = iMA (_Symbol,_Period,50,0,MODE_EMA,PRICE_CLOSE);
         
         int movingAverageDefinition2 = iMA (_Symbol,_Period,100,0,MODE_EMA,PRICE_CLOSE);
   
   
         ArraySetAsSeries (myMovingAverageArray1,true);
         
         ArraySetAsSeries (myMovingAverageArray2,true);
   
         CopyBuffer(movingAverageDefinition1,0,0,3,myMovingAverageArray1);
         
         CopyBuffer(movingAverageDefinition2,0,0,3,myMovingAverageArray2);
   
      if  (
               (myMovingAverageArray1[0]>myMovingAverageArray2[0]) 
           &&  (myMovingAverageArray1[1]<myMovingAverageArray2[1])
          )
                  {
                  entry="BUY";
                  }
   
      if (
   
               (myMovingAverageArray1[0]<myMovingAverageArray2[0])
           &&  (myMovingAverageArray1[1]>myMovingAverageArray2[1])
         )
   
                   {
                   entry="SELL";
                   }
                   
                   
      if (entry =="BUY" && PositionsTotal () <1
      trade.Buy (0.2,NULL,Ask,0,0,NULL);
      
      if (entry =="SELL" && PositionsTotal () <1
      trade.Sell (0.2,NULL,Bid,0,0,NULL);
   
  
}

ERRORS:

'SymbolInfoDouble' - no one of the overloads can be applied to the function call TEST3.mq5 11 37


';' - unexpected token TEST3.mq5  11    81   ';' - unexpected token TEST3.mq5 11 81

'{' - semicolon expected TEST3.mq5 15 38     '}' - semicolon expected   TEST3.mq5 15 39




 
ffsss:

Hi, just trying to do  a simple MA crossover EA, but im new and cant understand where the problem is. If anyone could help me i would apreciate it. Thanks!


ERRORS:

'SymbolInfoDouble' - no one of the overloads can be applied to the function call TEST3.mq5 11 37


';' - unexpected token TEST3.mq5  11    81   ';' - unexpected token TEST3.mq5 11 81

'{' - semicolon expected TEST3.mq5 15 38     '}' - semicolon expected   TEST3.mq5 15 39




Forum on trading, automated trading systems and testing trading strategies

Requests & Ideas (MQL5 only!)

Vladimir Karputov, 2020.03.17 13:23

This is not MQL5 code. Please read the topic title: this is a topic about MQL5.

In MQL5, the handle of the indicator NEEDS to be received ONCE (as a rule, this is done in OnInit ()). MQL5 language basics (with examples) are discussed in the topic

How to start with MQL5


Reason: