unexpected token error

 

Hi guys I'm new at mql5 programming language and I'm trying to learn it from youtube. I find the video (below) and try to copy the coding into metaeditor. When I compile the code there's a error message unexpected token on Ctrade line. Anyone can help me why I got the error message while the video is fine?

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

void OnTick()
  {
   //Get the Ask price
   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
  
   //We create an array for the prices
   MqlRates PriceInfo[];
   
   //We sort the price array from the current candle downwards
   ArraySetAsSeries(PriceInfo,true);
   
   //We fill the array with the price data
   int PriceData=CopyRates(_Symbol,_Period,0,3,PriceInfo);
   
   //Buy when candle id bullish
   if (PriceInfo[1].close>PriceInfo[1].open)
   
   //if we have no open positions
   if (PositionsTotal()==0)
   {
   //buy 0.01 lot at ask price, adding stoploss 20 pips from ask price and adding take profit from ask point
   trade.buy{
               
               0.01,                       //volume 0.01 lot
               NULL,                       //current symbol on chart
               Ask,                        //buy price
               Ask-20*_Point,              //adding stop loss 20 pips
               Ask+40*_Point,              //adding take profit 40 pips
               NULL                        //Comment
               
            }

   }
  }


MQL5 TUTORIAL BASICS - 12 HOW TO OPEN A SIMPLE BUY ORDER
MQL5 TUTORIAL BASICS - 12 HOW TO OPEN A SIMPLE BUY ORDER
  • www.youtube.com
https://mql5tutorial.com/?s=order With Metatrader5 and MQL5 we can open a buy position when a special condition is true. In our case we are going to open an ...
 
Luandre Ezra:

Hi guys I'm new at mql5 programming language and I'm trying to learn it from youtube. I find the video (below) and try to copy the coding into metaeditor. When I compile the code there's a error message unexpected token on Ctrade line. Anyone can help me why I got the error message while the video is fine?

Should be:

   trade.bBuy{(
               
               0.01,                       //volume 0.01 lot
               NULL,                       //current symbol on chart
               Ask,                        //buy price
               Ask-20*_Point,              //adding stop loss 20 pips
               Ask+40*_Point,              //adding take profit 40 pips
               NULL                        //Comment
               
            });
And it's not pips... looks more like points...
 
Seng Joo Thio:

Should be:

And it's not pips... looks more like points...
Thank I already fix it. I think I should be more careful with every code. Thanks!
and do you have any reference that I can use to learn mql5?
 
Luandre Ezra:
Thank I already fix it. I think I should be more careful with every code. Thanks!
and do you have any reference that I can use to learn mql5?
Menu --> documentation
All you need is there.
 
               Ask,                        //buy price
               Ask-20*_Point,              //adding stop loss 20 pips
               Ask+40*_Point,              //adding take profit 40 pips
You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (Control-O) → charts → Show ask line.)