Hi, I try to create an EA with MQL5 th.... However, I get this [error:',' - open parenthesis expected.] , I don't know what the problem is , would you please help me to solve this error?

 
//+------------------------------------------------------------------+
//|                        Z3alth MT5 Trading Bot                   |
//|           Uses swing high/low and support/resistance logic        |
//+------------------------------------------------------------------+
#property strict

// Input parameters
input double LotSize = 0.1;
input ENUM_TIMEFRAMES TradeTimeframe = PERIOD_M1;
input int MaxPositions = 3;
input double TrailingStop = 20.0;
input int SwingLookback = 20;
input double SupportResistanceBuffer = 5.0;
input bool UseStopLoss = true; // Enable or disable stop loss

// Declare global ticket variable
int ticket = 0;

// Function to count open positions
int CountOpenPositions() {
    int count = 0;
    for (int i = 0; i < PositionsTotal(); i++) {
        if (PositionSelect(Symbol())) {  // Select position by symbol
            count++;
        }
    }
    return count;
}

// Function to find swing high/low
double FindSwingHighLow(bool isHigh) {
    double level = isHigh ? iLow(Symbol(), TradeTimeframe, 0) : iHigh(Symbol(), TradeTimeframe, 0);
    for (int i = 1; i <= SwingLookback; i++) {
        double temp = isHigh ? iLow(Symbol(), TradeTimeframe, i) : iHigh(Symbol(), TradeTimeframe, i);
        if (isHigh) {
            level = MathMax(level, temp);
        } else {
            level = MathMin(level, temp);
        }
    }
    return level;
}

// Function to place trades
void TradeLogic() {
    if (CountOpenPositions() >= MaxPositions) return;

    double swingHigh = FindSwingHighLow(true) + SupportResistanceBuffer * Point;
    double swingLow = FindSwingHighLow(false) - SupportResistanceBuffer * Point;

    double stopLoss = 0;
    if (UseStopLoss) {
        stopLoss = (SymbolInfoDouble(Symbol(), SYMBOL_ASK) > swingHigh) ? swingLow : swingHigh;
    }

    double AskPrice = SymbolInfoDouble(Symbol(), SYMBOL_ASK);
    double BidPrice = SymbolInfoDouble(Symbol(), SYMBOL_BID);

    // Place buy order if price is above swingHigh
    if (AskPrice > swingHigh) {
        MqlTradeRequest buyRequest = {};
        MqlTradeResult result = {};
        buyRequest.action = TRADE_ACTION_DEAL;
        buyRequest.symbol = Symbol();
        buyRequest.volume = LotSize;
        buyRequest.price = AskPrice;
        buyRequest.sl = stopLoss;
        buyRequest.tp = 0;
        buyRequest.deviation = 3;
        buyRequest.type = ORDER_TYPE_BUY;

        if (OrderSend(buyRequest, result)) {
            ticket = result.order; // Store the ticket globally after a successful buy
            Print("Buy order placed successfully. Ticket: ", ticket);
        } else {
            Print("Error opening buy order: ", GetLastError());
        }
    } 
    // Place sell order if price is below swingLow
    else if (BidPrice < swingLow) {
        MqlTradeRequest sellRequest = {};
        MqlTradeResult result = {};
        sellRequest.action = TRADE_ACTION_DEAL;
        sellRequest.symbol = Symbol();
        sellRequest.volume = LotSize;
        sellRequest.price = BidPrice;
        sellRequest.sl = stopLoss;
        sellRequest.tp = 0;
        sellRequest.deviation = 3;
        sellRequest.type = ORDER_TYPE_SELL;

        if (OrderSend(sellRequest, result)) {
            ticket = result.order; // Store the ticket globally after a successful sell
            Print("Sell order placed successfully. Ticket: ", ticket);
        } else {
            Print("Error opening sell order: ", GetLastError());
        }
    }
}

// Function to manage trailing stop on all open positions
void ManageTrailingStop() {
    for (int i = PositionsTotal() - 1; i >= 0; i--) {
        if (PositionSelect(Symbol())) {
            ticket = PositionGetInteger(POSITION_TICKET); // Use global ticket
            int ticketInt = (int)ticket; // Cast to int to avoid data loss warning
            double currentPrice = (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ?
                                  SymbolInfoDouble(Symbol(), SYMBOL_BID) :
                                  SymbolInfoDouble(Symbol(), SYMBOL_ASK);
            double newStop;
            double TrailStopPoint;

            // For Buy positions
            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) {
                TrailStopPoint = TrailingStop * Point; 
                newStop = currentPrice - TrailStopPoint ;
                if (newStop > PositionGetDouble(POSITION_SL) || PositionGetDouble(POSITION_SL) == 0) {
                    MqlTradeRequest modifyRequest = {};
                    MqlTradeResult result = {};
                    modifyRequest.action = TRADE_ACTION_SLTP;
                    modifyRequest.symbol = Symbol();
                    modifyRequest.order = ticketInt; // Use casted int here
                    modifyRequest.sl = newStop;
                    modifyRequest.tp = PositionGetDouble(POSITION_TP);

                    if (OrderSend(modifyRequest, result)) {
                        Print("Buy order trailing stop modified successfully");
                    } else {
                        Print("Error modifying buy order: ", GetLastError());
                    }
                }
            }
            // For Sell positions
            else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) {
                TrailStopPoint = TrailingStop * Point;
                newStop = currentPrice + TrailStopPoint;
                if (newStop < PositionGetDouble(POSITION_SL) || PositionGetDouble(POSITION_SL) == 0) {
                    MqlTradeRequest modifyRequest = {};
                    MqlTradeResult result = {};
                    modifyRequest.action = TRADE_ACTION_SLTP;
                    modifyRequest.symbol = Symbol();
                    modifyRequest.order = ticketInt; // Use casted int here
                    modifyRequest.sl = newStop;
                    modifyRequest.tp = PositionGetDouble(POSITION_TP);

                    if (OrderSend(modifyRequest, result)) {
                        Print("Sell order trailing stop modified successfully");
                    } else {
                        Print("Error modifying sell order: ", GetLastError());
                    }
                }
            }
        }
    }
}

// Main event loop
void OnTick() {
    TradeLogic();
    ManageTrailingStop();
}
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Execution of trade operations results in the opening of a position, changing of its volume and/or direction, or its disappearance. Trade operations...
 
Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Matthew-Earl Whitmore:

Point should be _Point