Need Help Finding Error In Code Or Console

 

I am trying to follow the code this person is providing in his example (Code pasted below)



   #include<Trade\Trade.mqh>
   
   Ctrade trade;

input int SmallMovingAverage=20;
input int BigMovingAverage=50;
   
void OnTick()
  {
   // Calculate Ask price
   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   
   // Calculate Bid price
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
   
      // create string for the signal
      string signal="";
      
      // create Array for several prices
      double SmallMovingAverageArray[],BigMovingAverageArray[];
      
      // define properties of the Small Moving Average
      int SmallMovingAverageDefinition = iMA (_Symbol,_Period,SmallMovingAverage,0,MODE_SMA,PRICE_CLOSE);
      
      // define properties of the Big Moving Average
      int BigMovingAverageDefinition = iMA (_Symbol,_Period,BigMovingAverage,0,MODE_SMA,PRICE_CLOSE);
      
      // ?
      CopyBuffer(SmallMovingAverageDefinition,0,0,3,SmallMovingAverageArray);
      
      // ?
      CopyBuffer(BigMovingAverageDefinition,0,0,3,BigMovingAverageArray);
      
      if (BigMovingAverageArray[1] > SmallMovingAverageArray[1])
      
      
      if  (BigMovingAverageArray[2] < SmallMovingAverageArray[2])
      {
         signal="buy";
      }
      
      ////  ////
      
      if (BigMovingAverageArray[1] < SmallMovingAverageArray[1])
      
      
      if  (BigMovingAverageArray[2] > SmallMovingAverageArray[2])
      {
         signal="sell";
      }
      
      // Sell 10 Microlot
      if (signal =="sell" && PositionsTotal()<1)
         trade.Sell(0,10,NULL,Bid,0,(Bid-150 * _Point),NULL);
         
      // Buy 10 Microlot
      if (signal =="buy" && PositionsTotal()<1)
         trade.Buy(0,10,NULL,Ask,0,(Ask+150 * _Point),NULL);
      
      // Chart output
      Comment ("The signal is now: ",signal);
      
      
      
  }
//+------------------------------------------------------------------+

I am not sure why certain parts of this code are indented, but I've copied the essential parts of his example (non-commented lines) word for word, yet I seem to be getting strange errors, please refer to pic:


https://imgur.com/tczlAgP


These errors just don't make sense. For example the second error says a semicolon is expected on   line 3:  

Ctrade trade;

A semicolon is present, I am confused.




This video is definitely not the best place to start learning MQL5. Nevertheless I wanted to ask what I was doing wrong to get these strange errors.

 

it's CTrade trade; , not Ctrade.

you also get a wrong parameters count for buy and sell orders. check the official documentation to solve those errors.

btw, the videos are great if you are new in mql5. The rest is just using the official documentation to transform your ideas into code.

 
Gabriel Selegean:

it's CTrade trade; , not Ctrade.

you also get a wrong parameters count for buy and sell orders. check the official documentation to solve those errors.

btw, the videos are great if you are new in mql5. The rest is just using the official documentation to transform your ideas into code.


aha, good catch. It compiles without errors now,  thank you!



Well, here is a snapshot of it running so far:   ***

My question is: why does it only trade the first crossover since the start of the program? None of the other crossovers are being acted upon.


blue line: Jan 1 (start date)

blue circle: first executed trade

RED INDICATOR: 20 MA

YELLOW INDICATOR: 50 MA

 
hello. can some please help. i am using *** to code my experts/indicators. i have build an indicator and its working/showing on my charts. now i have completed the experts advisor and i am trying to run it on tester but it give me the code 1 error and it autometical removes it from the chart.
 
Pazna # :
hello. can some please help. i am using *** to code my experts/indicators. i have build an indicator and its working/showing on my charts. now i have completed the experts advisor and i am trying to run it on tester but it give me the code 1 error and it autometical removes it from the chart.

The forum does not allow discussion of third-party products. You need to contact the author of the product and ask him questions.