Help open parenthesis expected - page 3

 
i have same error , how to solve it please    

'<' - open parenthesis expected 4CandlesEA.mq5  line 28 14




//+------------------------------------------------------------------+
//| Expert Advisor template                                          |
//|                                                                  |
//| This is a simplified example of an Expert Advisor (EA) for MT5.  |
//| It implements a strategy based on four consecutive candle patterns. |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh> // Include trade functions

input double LotSize = 0.1;   // Lot size for trading

CTrade trade; // Create a trade object

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
    // Initialization code here
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
    // Check if there are enough bars for analysis (at least 5 candles)
    if (Bars < 5)
    {
        Print("Not enough bars for the strategy to work.");
        return;
    }

    // Get the close prices of the last 5 candles
    double close1 = iClose(NULL, 0, 1);
    double close2 = iClose(NULL, 0, 2);
    double close3 = iClose(NULL, 0, 3);
    double close4 = iClose(NULL, 0, 4);
    double close5 = iClose(NULL, 0, 5);

    // Check for 4 consecutive bullish candles
    if (close5 > close4 && close4 > close3 && close3 > close2 && close2 > close1)
    {
        // Check if there is no open position for the symbol
        if (!PositionSelect(Symbol()))
        {
            double sl = iLow(NULL, 0, 4);  // Stop loss at the low of the fourth candle
            trade.Buy(LotSize, Symbol(), SymbolInfoDouble(Symbol(), SYMBOL_ASK), sl, 0, "4 Bullish Candles");
        }
    }

    // Check for 4 consecutive bearish candles
    if (close5 < close4 && close4 < close3 && close3 < close2 && close2 < close1)
    {
        // Check if there is no open position for the symbol
        if (!PositionSelect(Symbol()))
        {
            double sl = iHigh(NULL, 0, 4);  // Stop loss at the high of the fourth candle
            trade.Sell(LotSize, Symbol(), SymbolInfoDouble(Symbol(), SYMBOL_BID), sl, 0, "4 Bearish Candles");
        }
    }

    // Manage open positions for take profit or other management
    for (int i = PositionsTotal() - 1; i >= 0; i--)
    {
        if (PositionGetTicket(i) > 0)
        {
            string symbol = PositionGetString(POSITION_SYMBOL);
            double open_price = PositionGetDouble(POSITION_PRICE_OPEN);
            double current_price = (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) ? SymbolInfoDouble(Symbol(), SYMBOL_BID) : SymbolInfoDouble(Symbol(), SYMBOL_ASK);
            double profit = PositionGetDouble(POSITION_PROFIT);

            // Implement logic for managing open positions (take profit, trailing stop, etc.)
            // Example:
            /*
            if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
            {
                // Check for conditions to close buy positions
                if (current_price >= open_price + TakeProfitPoints * Point)
                {
                    trade.PositionClose(symbol);  // Close the position
                }
            }
            else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
            {
                // Check for conditions to close sell positions
                if (current_price <= open_price - TakeProfitPoints * Point)
                {
                    trade.PositionClose(symbol);  // Close the position
                }
            }
            */
        }
    }
}
 

With - Bars - You may need to call on the Symbol and Period, then move the data into an int....

Bars

(Returns the number of bars count in the history for a specified symbol and period. There are 2 variants of functions calls.)

// Check if there are enough bars for analysis (at least 5 candles)

   

int bars=Bars(_Symbol,_Period);

if(bars>5)