urgent fix need for EA in MQL5 code for me

 

Hi, i am trying to fix this code buy and sell at same time but getting error '}' - unexpected end of program and '{' - unbalanced parentheses can any one fix and complete the code for me.


#include <Trade/Trade.mqh>

input int       InpMaxTrades = 10;  // max number of trades
input double    inpTradeGap   = 0.005; // minimum gap between trades
input ENUM_ORDER_TYPE BType  = ORDER_TYPE_BUY;  //order type
input ENUM_ORDER_TYPE SType  = ORDER_TYPE_BUY;  //order type
input double   InpMinProfit  = 1.00;  // Profit in base currency
input int   InpMagicNumber  = 1111; // Magic Number
input string  InpTradeComment = __FILE__;  // Trade Comment
input double  InpVolume  = 0.01; // Volume Per order

struct STradeSum {
 int count;
 double profit;
 double trailPrice;
 };
 
 CTrade Trade;
 
 int OnInit()  {
 
   Trade.SetExpertMagicNumber(InpMagicNumber);
 
   return(INIT_SUCCEEDED);
 }
 

 
 }
 
 void OnTick() {
 
   STradeSum sum;
   GetSum(sum);
   
   if (sum.profit>InpMinProfit) { // target reached
     CloseAll();   
   } else
   if (sum.count==0)  { // no trades
    OpenTrade();
    }
     
     
void OpenTrade()  {

   double ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   ask = NormalizeDouble(ask,_Digits);
   double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   bid = NormalizeDouble(bid,_Digits);
   
     for(int i = PositionsTotal()-1; i >= 0; i--)
     {
      ulong posTicket = PositionGetTicket(i);
      CPositionInfo pos;
      if(pos.SelectByTicket(posTicket))
        {
         if(pos.PositionType() == POSITION_TYPE_BUY)
             {
               Trade.PositionOpen(Symbol(), BType, InpVolume, price, 0, 0, InpTradeComment));
           }
         else
            if(pos.PositionType() == POSITION_TYPE_SELL)
              {
                  Trade.PositionOpen(Symbol(), SType, InpVolume, price, 0, 0, InpTradeComment));
                 }
              }
     }
     
 
If it is "urgent", then hire someone in the Freelance section to fix it for you.
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.06.01
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Hello,

1) This seems to be a ChatGPT generated code, we will not help you if you have not put any effort.
2) This is a very easy problem to fix, you don’t even need a coder to do so.
3) If you do not manage to fix it. Pay a Freelancer to do it for you. 

Sorry if it seems harsh, but I hate seeing poorly coded ChatGPT code (to not say a bad word).  
 
Fernando Carreiro #:
If it is "urgent", then hire someone in the Freelance section to fix it for you.

Thanks. But i am learning the code i want to know what mistake i made in this code..

 
Zaky Hamdoun #:
Hello,

1) This seems to be a ChatGPT generated code, we will not help you if you have not put any effort.
2) This is a very easy problem to fix, you don’t even need a coder to do so.
3) If you do not manage to fix it. Pay a Freelancer to do it for you. 

Sorry if it seems harsh, but I hate seeing poorly coded ChatGPT code (to not say a bad word).  

Hello,

This is not a ChatGPT code i made it when i run with single mode order type it is working when i try with both order mode is getting error. looking for a good person to point it. Thanks for you comment.

 
Suresh D #: Thanks. But i am learning the code i want to know what mistake i made in this code..

Then if you are learning, then it is NOT urgent! Don't say it is "urgent"!

 
Fernando Carreiro #:

Then if you are learning, then it is NOT urgent! Don't say it is "urgent"!

Hello, I dont hold my time for studying for long time also i dont waste my time. get solution fast learn fast. .hope understand. Thanks for advice. 
 
Suresh D #: Thanks. But i am learning the code i want to know what mistake i made in this code..

Make sure your brackets are in pairs. Use of the styler will help.

void OpenTrade()  {                                      <<<< 1
   ⋮   
     for(int i = PositionsTotal()-1; i >= 0; i--)
     {                                                   <<<< 2
      ⋮
      if(pos.SelectByTicket(posTicket))
        {                                                <<<< 3
         if(pos.PositionType() == POSITION_TYPE_BUY)
             {                                           <<<< 4
               ⋮
           }                                             <<<< 3 end Buy
         else
            if(pos.PositionType() == POSITION_TYPE_SELL)
              {                                          <<<< 4
                  ⋮
                 }                                       <<<< 3 end Sell
              }                                          <<<< 2 end SelectByTicket
     }                                                   <<<< 1 end loop
       <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ??????????
void CloseAll() {
 
William Roeder #:

Make sure your brackets are in pairs. Use of the styler will help.

Hello William, let me check. Thanks of your kind help..:)
 
William Roeder #:Make sure your brackets are in pairs. Use of the styler will help.
Hello William, Thank you very much as you suggested. i fixed all my error and it working as i was thinking once again thank you very much..:)
Reason: