how to solve ',' - open parenthesis expected error in MQL5 ?

 

Hi, I try to create a simple EA with MQL5, when I run my code I get this error:',' - open parenthesis expected. , I don't know what the problem is , would you please help me to solve this error? Here is my code://+------------------------------------------------------------------+

 //|                                                         test.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"
//+------------------------------------------------------------------+
//| Global variables                                                |
//+------------------------------------------------------------------+
input int MA_Period = 50; // Period for the moving average
input double Risk_Percentage = 2.0; // Risk percentage per trade
input double Stop_Loss = 100.0; // Initial stop loss in points
input double Take_Profit = 200.0; // Take profit level in points
double LotSize; // Position size based on risk
//+------------------------------------------------------------------+
#include <Trade\PositionInfo.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   // Calculate position size based on risk percentage and stop loss
   LotSize = AccountInfoDouble(ACCOUNT_FREEMARGIN) * Risk_Percentage / Stop_Loss;
   
   Print("Expert Advisor initialized successfully.");
   
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   Print("Expert Advisor deinitialized successfully.");
}
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   double closePrice[]; // Declare 'closePrice' as an array

   if (!CopyClose(Symbol(), 0, 1, 1, closePrice))
   {
      Print("Error copying Close price: ", GetLastError());
      return;
   }

   double ma = iMA(Symbol(), 0, MA_Period, 0, MODE_SMA, PRICE_CLOSE);
   
   if (closePrice[1] < ma && closePrice[0] > ma)
   {
      MqlTradeRequest request;
      request.action = TRADE_ACTION_DEAL;
      request.magic = 123456;
      request.symbol = Symbol();
      request.volume = LotSize;
      request.price = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
      request.type = ORDER_TYPE_BUY;
      request.type_filling = ORDER_FILLING_FOK;
      request.tp = NormalizeDouble(closePrice[0] + Take_Profit * Point, Digits); // Set take profit level

      MqlTradeResult result;

      if (!OrderSend(request, result))
      {
         Print("Buy OrderSend error: ", GetLastError());
         return;
      }
   }
   else if (closePrice[1] > ma && closePrice[0] < ma)
   {
      MqlTradeRequest request;
      request.action = TRADE_ACTION_DEAL;
      request.magic = 123456;
      request.symbol = Symbol();
      request.volume = LotSize;
      request.price = SymbolInfoDouble(Symbol(), SYMBOL_BID);
      request.type = ORDER_TYPE_SELL;
      request.type_filling = ORDER_FILLING_FOK;
      request.tp = NormalizeDouble(closePrice[0] - Take_Profit * Point, Digits); // Set take profit level

      MqlTradeResult result;

      if (!OrderSend(request, result))
      {
         Print("Sell OrderSend error: ", GetLastError());
         return;
      }
   }

}

I got this error in these lines : 

request.tp = NormalizeDouble(closePrice[0] + Take_Profit * Point, Digits); // Set take profit level
request.tp = NormalizeDouble(closePrice[0] - Take_Profit * Point, Digits); // Set take profit level


 

The error you're encountering, "'(',')' - open parenthesis expected," typically occurs when there's a syntax issue in the code. In MQL5, this error message often suggests that there's a problem with a function call or a parameter list.

Looking at the lines you've mentioned:

request.tp = NormalizeDouble(closePrice[0] + Take_Profit * Point, Digits); // Set take profit level

request.tp = NormalizeDouble(closePrice[0] - Take_Profit * Point, Digits); // Set take profit level

The error could arise from the use of Point . In MQL5, Point is a predefined variable representing the smallest price change for a given symbol. However, it's possible that in your environment, Point might not be recognized correctly, leading to this error.

To fix this issue, you need to ensure that Point is properly defined and recognized by the compiler. Here are a few steps you can take:

  1. Check Compilation Settings: Make sure you have the correct compiler settings in your MetaEditor. Sometimes, incorrect settings might lead to issues with predefined variables like Point .

  2. Include Required Libraries: Ensure that you have included all the necessary libraries that define Point . Typically, it should be included by default in MQL5, but if you're using any custom libraries or environments, you might need to explicitly include them.

  3. Declare Point if Necessary: If for some reason, Point is not recognized, you can declare it manually. For example:

double Point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
This line fetches the value of Point for the current symbol ( _Symbol ).
 
thanks a lot , my errors are solved !