please i ned to fix this error it says " Unbalanced parenthesis " at OnTick Void

 
 //+------------------------------------------------------------------+
//|                                                    stopsbaea.mq5 |
//|                                  Copyright 2024, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
//--- input parameters
input double Lots = 0.1;                     // Lot size
input int StartHour = 12;                    // Start hour of the time window
input int StartMinute = 0;                   // Start minute of the time window
input int EndHour = 14;                      // End hour of the time window
input int EndMinute = 0;                     // End minute of the time window
input double TakeProfit1 = 1.0;              // TP1 as Risk:Reward ratio
input double TakeProfit2 = 2.0;              // TP2 as Risk:Reward ratio
input double TakeProfit3 = 3.0;              // TP3 as Risk:Reward ratio

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
  {

    static bool tradeOpened = false;
    datetime currentTime = TimeCurrent();

    // Get the high and low of the specified time window
    double windowHigh = 0.0;
    double windowLow = DBL_MAX;

    for(int i = 0; i < Bars(_Symbol, PERIOD_M1); i++)
    {
        datetime time = iTime(_Symbol, PERIOD_M1, i);
        int hour = TimeCurrent()
        if(TimeCurrent(time) >= StartHour && TimeMinute(time) >= StartMinute &&
           TimeCurrent(time) <= EndHour && TimeMinute(time) <= EndMinute);
        
            double high = iHigh(_Symbol, PERIOD_M1, i);
            double low = iLow(_Symbol, PERIOD_M1, i);
            if(high > windowHigh) windowHigh = high;
            if(low < windowLow) windowLow = low;
        

    // After the time window, place BuyStop and SellStop orders if not already placed
    if(TimeHour(currentTime) == EndHour && TimeMinute(currentTime) == EndMinute && !tradeOpened)
    {
        double stopLoss = windowLow;
        double buyStop = windowHigh;
        double sellStop = windowLow;

        double tp1 = stopLoss + (buyStop - stopLoss) * TakeProfit1;
        double tp2 = stopLoss + (buyStop - stopLoss) * TakeProfit2;
        double tp3 = stopLoss + (buyStop - stopLoss) * TakeProfit3;

        // Place BuyStop order
        tradeOpened = PlacePendingOrder(ORDER_BUYSTOP, _Symbol, Lots, buyStop, stopLoss, tp1, tp2, tp3);

        tp1 = sellStop - (sellStop - stopLoss) * TakeProfit1;
        tp2 = sellStop - (sellStop - stopLoss) * TakeProfit2;
        tp3 = sellStop - (sellStop - stopLoss) * TakeProfit3;

        // Place SellStop order
        tradeOpened = PlacePendingOrder(ORDER_SELLSTOP, _Symbol, Lots, sellStop, stopLoss, tp1, tp2, tp3);
    
}

bool PlacePendingOrder(int orderType, string symbol, double lotSize, double price, double stopLoss, double tp1, double tp2, double tp3)
{
    double sl = stopLoss;
    double tp = tp1;
    int magicNumber = 123456;

    MqlTradeRequest request;
    MqlTradeResult result;
    ZeroMemory(request);
    ZeroMemory(result);

    request.action = TRADE_ACTION_PENDING;
    request.symbol = symbol;
    request.volume = lotSize;
    request.price = price;
    request.sl = sl;
    request.tp = tp;
    request.type = orderType;
    request.type_filling = ORDER_FILLING_FOK;
    request.type_time = ORDER_TIME_GTC;
    request.magic = magicNumber;

    if(!OrderSend(request, result))
    {
        Print("Error placing pending order: ", ErrorDescription(result.retcode));
        return false;
    }
    return true;
}

void ManageTakeProfits()
{
    for(int i = OrdersTotal() - 1; i >= 0; i--)
    {
        if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
            if(OrderType() == ORDER_BUYSTOP || OrderType() == ORDER_SELLSTOP)
            {
                double price = OrderOpenPrice();
                double stopLoss = OrderStopLoss();
                double takeProfit = OrderTakeProfit();
                double newTakeProfit = 0.0;

                if(OrderType() == ORDER_BUYSTOP)
                {
                    newTakeProfit = price + (price - stopLoss) * TakeProfit2;
                }
                else if(OrderType() == ORDER_SELLSTOP)
                {
                    newTakeProfit = price - (stopLoss - price) * TakeProfit2;
                }

                if(OrderModify(OrderTicket(), OrderOpenPrice(), stopLoss, newTakeProfit, OrderExpiration()))
                {
                    Print("Modified order with new Take Profit 2: ", newTakeProfit);
                }
            }
        }
    }
}



  };
//+------------------------------------------------------------------+

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2024.06.09
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 

Ontick

{

{  remove this duplicate line

 
  1. Always use the CODE button (or Alt+S)! (For large amounts of code, attach it.)  I fixed it for you this time.
          General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
              Messages Editor
          Forum rules and recommendations - General - MQL5 programming forum (2023)

  2.  void OnTick()
    {
      { 
    Why is there an extra bracket?
  3.  for(int i = 0; i < Bars(_Symbol, PERIOD_M1); i++)
        {
            datetime time = iTime(_Symbol, PERIOD_M1, i);
            int hour = TimeCurrent()
            if(TimeCurrent(time) >= StartHour && TimeMinute(time) >= StartMinute &&
               TimeCurrent(time) <= EndHour && TimeMinute(time) <= EndMinute);
            
                double high = iHigh(_Symbol, PERIOD_M1, i);
                double low = iLow(_Symbol, PERIOD_M1, i);
                if(high > windowHigh) windowHigh = high;
                if(low < windowLow) windowLow = low;
            
    
        // After the time window, place BuyStop and SellStop orders if not already placed 
     if(TimeHour(currentTime) == EndHour && TimeMinute(currentTime) == EndMinute && !tradeOpened) 
    
    
    Where is the closing bracket for the for?
  4. Where is the closing bracket for the if?
  5. TimeCurrent does not return an hour.
  6. TimeCurrent does not take an argument.
 
William Roeder #:
TimeCurrent does not take an argument.

It may take argument. But, nevertheless, this fact does not give that code any meaning.

datetime  TimeCurrent(
   MqlDateTime&  dt_struct      // structure type variable
   );
 
In Meta Editor Settings activate "highlight matching brackets" checkbox.
 
oyebanji110394:

This is probably gpt code that's why there's so many very clear errors

In addition to what William said, your for loop is mess

1. There's a missing curled bracket "}" at the end of your loop
2. Your hour variable is missing a ";"
3. Your OnTick function has an extra opening bracket in the beginning and missing one closing bracket at the end 

Lastly there is another closing bracket at the end of the code, which.. no. Remove that "};"

And your