I am not able to fix these errors:

 

I am not able to fix these errors:


//+------------------------------------------------------------------+
//|                             YourExpertAdvisor                   |
//|                      Copyright 2023, YourName                    |
//|                       https://www.yourwebsite.com               |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, YourName"
#property link      "https://www.yourwebsite.com"
#property version   "1.00"
#property strict

// Trading constants
enum TradeOperation
{
    OP_BUY = 0,
    OP_SELL = 1
};

// EA parameters
input double LotSize = 0.1;      // Lot size for the position
input int StopLossPips = 50;     // Stop-loss in pips
input int TakeProfitPips = 150;  // Take-profit in pips
input int ContinuationBars = 1;  // Minimum number of continuation bars

// Global variables
bool positionOpened = false;
int consecutiveBars = 0;
double highOfLastBar = 0;
double lowOfLastBar = 0;
double Point; // Point variable declared in the global scope

//+------------------------------------------------------------------+
//| Expert Advisor initialization function                           |
//+------------------------------------------------------------------+
void OnInit()
{
    // No operations here, as the Point variable will be declared in the OnTick() function.
}

//+------------------------------------------------------------------+
//| Tick function (called on each new tick)                          |
//+------------------------------------------------------------------+
void OnTick()
{
    double Ask = SymbolInfoDouble(Symbol(), SYMBOL_ASK); // Declared Ask variable and obtained its value
    Point = SymbolInfoDouble(Symbol(), SYMBOL_POINT);    // Declared Point variable and obtained its value

    // Check if a new high bar has formed
    if (IsNewHighBar())
    {
        if (!positionOpened && IsContinuation() && IsTrendBroken())
        {
            // Open a buy position
            double entryPrice = Ask;
            double stopLossPrice = lowOfLastBar - StopLossPips * Point;
            double takeProfitPrice = Ask + TakeProfitPips * Point;

            // Function to open a buy position (using the TradeOperation::OP_BUY constant)
            MqlTradeRequest request;
            MqlTradeResult result;
            ZeroMemory(request);
            ZeroMemory(result);
            request.action = TRADE_ACTION_DEAL;
            request.symbol = Symbol();
            request.volume = LotSize;
            request.type = TradeOperation::OP_BUY; // Correction here
            request.price = entryPrice;
            request.sl = stopLossPrice;
            request.tp = takeProfitPrice;
            request.type_filling = ORDER_FILLING_FOK;
            request.deviation = 5;
            if (OrderSend(request, result))
            {
                positionOpened = true;
                Print("BUY position opened at ", entryPrice);
            }
            else
            {
                Print("Error opening BUY position. Error code: ", GetLastError());
            }
        }
    }
}

//+------------------------------------------------------------------+
//| Function to check if it's a new high bar                         |
//+------------------------------------------------------------------+
bool IsNewHighBar()
{
    double highOfPreviousBar = iHigh(Symbol(), PERIOD_M5, 1);
    double highOfCurrentBar = iHigh(Symbol(), PERIOD_M5, 0);

    return (highOfCurrentBar > highOfPreviousBar);
}

//+------------------------------------------------------------------+
//| Function to check if there is a continuation of the trend        |
//+------------------------------------------------------------------+
bool IsContinuation()
{
    int i = 1;
    while (i <= ContinuationBars)
    {
        double highOfNextBar = iHigh(Symbol(), PERIOD_M5, i);
        double lowOfNextBar = iLow(Symbol(), PERIOD_M5, i);

        if (highOfNextBar > highOfLastBar || lowOfNextBar < lowOfLastBar)
        {
            return false;
        }

        highOfLastBar = highOfNextBar;
        lowOfLastBar = lowOfNextBar;
        i++;
    }

    consecutiveBars = i - 1;
    return (consecutiveBars >= ContinuationBars);
}

//+------------------------------------------------------------------+
//| Function to check if a new bar breaks the trend                  |
//+------------------------------------------------------------------+
bool IsTrendBroken()
{
    double highOfNextBar = iHigh(Symbol(), PERIOD_M5, ContinuationBars + 1);

    return (highOfNextBar > highOfLastBar);
}
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
When you post code please use the Code button (Alt+S) !

...

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

...

MQL5.community - User Memo
MQL5.community - User Memo
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
 
Junior Vidal:

I am not able to fix these errors:


'ask' - undeclared identifier         line:48

'ask' - undeclared identifier         line:50

'OP_BUY' undeclared identifier        line:53

'Ordersed'- wrong parameters count    line:53

built-in: bool OrderSend(const MqlTradeRequest&,Mqltraderresult&)   line:53

This code is using mql4 syntax and you are trying to compile it with MT5 (mql5).