Undeclared Parameters in Code

 

Please I wrote out this code but whenever I try to compile it gives me this errors

//+------------------------------------------------------------------+
//|                                                      ARTaker.mq5 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
// Declare input parameters
// Declare input parameters
input double LotSize = 0.05;         // Lot size of the orders
input int StopLoss = 20;             // Stop loss in pips
input int TakeProfit = 40;           // Take profit in pips
input string OrderTime = "08:00:00"; // Time at which orders are placed

// Declare variables
datetime currentTime;
datetime orderTime;
double high;
double low;

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



void OnTick()
{
    // Check if it's the specified order time
    currentTime = TimeGMT();
    orderTime = TimeParse(Date() + " " + OrderTime);

    if (currentTime != orderTime)
        return;

    // Calculate the high and low of the day
    high = HighDay();
    low = LowDay();

    // Place buy limit order at low price
    if (OrderSend(Symbol(), OP_BUYLIMIT, LotSize, low, 3, low - StopLoss * _Point, low + TakeProfit * _Point, "Buy Limit", 0, 0, Green))
        Print("Buy limit order placed at ", low);
    else
        Print("Failed to place buy limit order");

    // Place sell limit order at high price
    if (OrderSend(Symbol(), OP_SELLLIMIT, LotSize, high, 3, high + StopLoss * _Point, high - TakeProfit * _Point, "Sell Limit", 0, 0, Red))
        Print("Sell limit order placed at ", high);
    else
        Print("Failed to place sell limit order");
}

// Calculate the high of the day
double HighDay()
{
    double high = 0;
    int count = Bars(_Symbol, PERIOD_D1);

    for (int i = 0; i < count; i++)
    {
        if (Time[i] >= TimeParse(Date() + " 00:00:00") && Time[i] <= TimeParse(Date() + " 23:59:59"))
        {
            if (high < High[i])
                high = High[i];
        }
    }

    return high;
}

// Calculate the low of the day
double LowDay()
{
    double low = 9999999;
    int count = Bars(_Symbol, PERIOD_D1);

    for (int i = 0; i < count; i++)
    {
        if (Time[i] >= TimeParse(Date() + " 00:00:00") && Time[i] <= TimeParse(Date() + " 23:59:59"))
        {
            if (low > Low[i])
                low = Low[i];
        }
    }

    return low;
}


//+------------------------------------------------------------------+

These are the errors I keep getting 

Files:
 
Kachebri Hackwi: Please I wrote out this code but whenever I try to compile it gives me this errors. These are the errors I keep getting 

This is MQL4 code. It will not function in MQL5.

Are you sure this is your code or was it generated by ChatGPT?

Please don't use ChatGPT! It generates horrible code that cannot be easily fixed.

 
Fernando Carreiro #:

This is MQL4 code. It will not function in MQL5.

Are you sure this is your code or was it generated by ChatGPT?

Please don't use ChatGPT! It generates horrible code that cannot be easily fixed.

Very true!

ChatGPT jumbles up MQL4 and MQL5 codes together. Sometimes it can't differentiate between both.

As a result , it generates codes filled with lots of errors.

Kachebri Hackwi, your code may run on MQL4 with fewer errors.