HELP PLEASE... MQL5 coding EA error: unexpected end of program

 

Hello,Guys,

I just started coding on MT5 platform few days ago, so I am very new in this. However, I was trying to build Partial close EA, but I constantly getting two errors: '}' - unexpected end of program ; '{' - unbalanced parentheses. I checked the code many times but I can't find where is the mistake if I try to balanced parentheses then I am getting like 32 more errors... I can't find where is a problem. Can someone help me please? :) I will add my code so you can understand better that I am talking about. Thank you :)

//+------------------------------------------------------------------+
//|                                                                  |
//|                        Input Variables                           |
//|                                                                  |
//+------------------------------------------------------------------+
input double TradeVolume=0.2;
input int StopLoss=500;
input int TakeProfit1=500;
input int TakeProfit2=1000;

//+------------------------------------------------------------------+
//|                                                                  |
//|                        Expert tick function                      |
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
//Open buy market order
{
glBuyPlaced=Trade.Buy(_Symbol,TradeVolume);
//Modify SL/TP
if(glBuyPlaced==true)
{
   do Sleep(100); while(PositionSelect(_Symbol)==false);
   double positionOpenPrice=PositionOpenPrice();
   
   double buyStopLoss=BuyStopLoss(_Symbol,StopLoss,positionOpenPrice);
   if(buyStopLoss>0) buyStopLoss=AdjustBelowStopLevel(_Symbol,buyStopLoss);
   
   double buyTakeProfit=BuyTakeProfit(_Symbol,TakeProfit2,positionOpenPrice);
   if(buyTakeProfit>0) buyTakeProfit=AdjustAboveStopLevel(_Symbol,buyTakeProfit);
   
   if(buyStopLoss>0 || buyTakeProfit>0)
      Trade.ModifyPosition(_Symbol,buyStopLoss,buyTakeProfit);
      
   glSellPlaced=false;
 }
 
//Open partial close order
  
   double partialClose=positionOpenPrice+(TakeProfit1*_Point);
   double partialVolume=TradeVolume/2;
    
   Trade.SellLimit(_Symbol,partialVolume,partialClose);
 } 
  
  
  //--- OnTick function end
 
kesa:

Hello,Guys,

I just started coding on MT5 platform few days ago, so I am very new in this. However, I was trying to build Partial close EA, but I constantly getting two errors: '}' - unexpected end of program ; '{' - unbalanced parentheses. I checked the code many times but I can't find where is the mistake if I try to balanced parentheses then I am getting like 32 more errors... I can't find where is a problem. Can someone help me please? :) I will add my code so you can understand better that I am talking about. Thank you :)

remove one open curly bracket after void OnTick()
 
thank you for your quick reply. I tried to delete one after //open buy market order. It looks like that now but I am getting 32 errors now instead of 2... What do you think what else it could be because I am running out of options... :)
void OnTick()
{
//Open buy market order

glBuyPlaced=Trade.Buy(_Symbol,TradeVolume);
//Modify SL/TP
if(glBuyPlaced==true)
{
   do Sleep(100); while(PositionSelect(_Symbol)==false);
   double positionOpenPrice=PositionOpenPrice();
   
   double buyStopLoss=BuyStopLoss(_Symbol,StopLoss,positionOpenPrice);
   if(buyStopLoss>0) buyStopLoss=AdjustBelowStopLevel(_Symbol,buyStopLoss);
   
   double buyTakeProfit=BuyTakeProfit(_Symbol,TakeProfit2,positionOpenPrice);
   if(buyTakeProfit>0) buyTakeProfit=AdjustAboveStopLevel(_Symbol,buyTakeProfit);
   
   if(buyStopLoss>0 || buyTakeProfit>0)
      Trade.ModifyPosition(_Symbol,buyStopLoss,buyTakeProfit);
      
   glSellPlaced=false;
 }
 
//Open partial close order
  
   double partialClose=positionOpenPrice+(TakeProfit1*_Point);
   double partialVolume=TradeVolume/2;
    
   Trade.SellLimit(_Symbol,partialVolume,partialClose);
 } 
  
  
  //--- OnTick function end
  
 
kesa:
thank you for your quick reply. I tried to delete one after //open buy market order. It looks like that now but I am getting 32 errors now instead of 2... What do you think what else it could be because I am running out of options... :)
check the journal log or paste the whole code
Reason: