I keep getting these errors on getting trade data from csv file on web

 
The code

//+------------------------------------------------------------------+
//|                                                      My Expert.mq4|
//|                                      Copyright 2021, John Doe    |
//|                                             https://www.example.com|
//+------------------------------------------------------------------+

#property strict
#property version   "1.00"

// Input variables
input double  LotSize = 0.01;
input ENUM_TP TakeProfitLevel = TP_Level1;

// Global variables
const string URL = "https://example.com/path/to/csv/file.csv"; // Change this to your own CSV file URL
const int    CheckInterval = 1800; // Check the CSV file every 30 minutes
datetime     lastCheckTime = 0;

// Order data structure
struct OrderData
{
    string  symbol;
    int     type;
    double  openPrice;
    double  stopLossPrice;
    double  takeProfit1;
    double  takeProfit2;
    double  takeProfit3;
};

// Global variables
OrderData orders[25]; // An array to store the order data
int       lastOrderIndex = -1; // The index of the last pending order

// Enumerations
enum ENUM_TP
{
    TP_Level1 = 0,
    TP_Level2,
    TP_Level3
};

// Initialization function
int OnInit()
{
    // Set up the timer to check the CSV file every 30 minutes
    EventSetTimer(CheckInterval);
    
    // Fill the orders array with empty data
    for (int i = 0; i < ArraySize(orders); i++)
    {
        orders[i].symbol        = "";
        orders[i].type          = -1;
        orders[i].openPrice     = 0.0;
        orders[i].stopLossPrice = 0.0;
        orders[i].takeProfit1   = 0.0;
        orders[i].takeProfit2   = 0.0;
        orders[i].takeProfit3   = 0.0;
    }
    
    return(INIT_SUCCEEDED);
}

// Deinitialization function
void OnDeinit(const int reason)
{
    // Clean up any pending orders
    for (int i = 0; i < ArraySize(orders); i++)
    {
        if (orders[i].symbol != "")
        {
            OrderDelete(orders[i].symbol);
        }
    }
}

// Timer event function
void OnTimer()
{
    // Check if it's time to check the CSV file
    if (TimeCurrent() < lastCheckTime + CheckInterval)
    {
        return;
    }
    
    // Download the CSV file
    string content = "";
    if (WebRequest(URL, content))
    {
        // Parse the CSV file
        string[] lines = StringSplit(content, "\n");
        for (int i = 1; i < ArraySize(lines); i++)
        {
            string[] fields = StringSplit(lines[i], ",");
            if (ArraySize(fields) != 7)
            {
                continue;
            }
            
            // Extract the order data
            string symbol = fields[0];
            int    type   = fields[1] == "Buy Limit" ? OP_BUYLIMIT : OP_SELLLIMIT;
            double openPrice = StringToDouble(fields[2]);
            double stopLossPrice = StringToDouble(fields[3]);
            double takeProfit1 = StringToDouble(fields[4]);
            double takeProfit2 = StringToDouble(fields[5]);
            double takeProfit3 = StringToDouble(fields[6]);
            
            // Check if there is an open position for this symbol
            bool hasOpenPosition = false;
            for (int j = 0; j <= lastOrderIndex; j++)
            {
                if (orders[j].symbol == symbol && OrderSelect(orders[j].symbol, SELECT_BY_TICKET))
                {
                    if (OrderType() == OP_BUY || OrderType() == OP_SELL)
                    {
                        hasOpenPosition = true;
                        break;
                    }
                }
            }
            
            // Update or create the pending order
            if (!hasOpenPosition)
            {
                int ticket = -1;
                if (lastOrderIndex >= 0 && orders[lastOrderIndex].symbol == symbol)
                {
                    ticket = orders[lastOrderIndex].ticket;
                    OrderModify(ticket, openPrice, stopLossPrice, takeProfit1, 0);
                }
                else
                {
                    ticket = OrderSend(symbol, type, openPrice, 0, 0, stopLossPrice, takeProfit1, "", 0, 0, CLR_NONE);
                }
                
                if (ticket > 0)
                {
                    lastOrderIndex++;
                    orders[lastOrderIndex].symbol        = symbol;
                    orders[lastOrderIndex].type          = type;
                    orders[lastOrderIndex].openPrice     = openPrice;
                    orders[lastOrderIndex].stopLossPrice = stopLossPrice;
                    orders[lastOrderIndex].takeProfit1   = takeProfit1;
                    orders[lastOrderIndex].takeProfit2   = takeProfit2;
                    orders[lastOrderIndex].takeProfit3   = takeProfit3;
                    orders[lastOrderIndex].ticket        = ticket;
                }
            }
        }
    }
    
    // Update the last check time
    lastCheckTime = TimeCurrent();
}

// Input variable functions
string LotSizeToString(double value)
{
    return DoubleToString(value, 2);
}

double LotSizeFromString(string value)
{
    return StringToDouble(value);
}

string TakeProfitLevelToString(ENUM_TP value)
{
    switch (value)
    {
        case TP_Level1: return "Take Profit 1";
        case TP_Level2: return "Take Profit 2";
        case TP_Level3: return "Take Profit 3";
        default:        return "Take Profit 1";
    }
}

ENUM_TP TakeProfitLevelFromString(string value)
{
    if (value == "Take Profit 1")
    {
        return TP_Level1;
    }
    else if (value == "Take Profit 2")
    {
        return TP_Level2;
    }
    else if (value == "Take Profit 3")
    {
        return TP_Level3;
    }
    else
    {
        return TP_Level1;
    }
}

// Custom functions
void CloseAllOrders()
{
    for (int i = 0; i <= lastOrderIndex; i++)
    {
        if (orders[i].symbol != "")
        {
            OrderDelete(orders[i].ticket);
            orders[i].symbol = "";
        }
    }
}

void ModifyAllOrders()
{
    for (int i = 0; i <= lastOrderIndex; i++)
    {
        if (orders[i].symbol != "")
        {
            OrderModify(orders[i].ticket, orders[i].openPrice, orders[i].stopLossPrice, orders[i].takeProfit1, 0);
        }
    }
}

//+------------------------------------------------------------------+
//| Custom functions for the dropdown menus                          |
//+------------------------------------------------------------------+
string[] LotSizeDropdown = {"0.01", "0.02", "0.03", "0.04", "0.05"};
int LotSizeDropdownIndex(double value)
{
    for (int i = 0; i < ArraySize(LotSizeDropdown); i++)
    {
        if (StringToDouble(LotSizeDropdown[i]) == value)
        {
            return i;
        }
    }
    return 0;
}
double LotSizeDropdownValue(int index)
{
    return StringToDouble(LotSizeDropdown[index]);
}

string[] TakeProfitLevelDropdown = {"Take Profit 1", "Take Profit 2", "Take Profit 3"};
int TakeProfitLevelDropdownIndex(ENUM_TP value)
{
    return int(value);
}
ENUM_TP TakeProfitLevelDropdownValue(int index)
{
    return ENUM_TP(index);
}
//+------------------------------------------------------------------+
//| Custom functions for the dropdown menus                          |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom functions for the dropdown menus                          |
//+------------------------------------------------------------------+
string[] LotSizeDropdown = {"0.01", "0.02", "0.03", "0.04", "0.05"};
int LotSizeDropdownIndex(double value)
{
    for (int i = 0; i < ArraySize(LotSizeDropdown); i++)
    {
        if (StringToDouble(LotSizeDropdown[i]) == value)
        {
            return i;
        }
    }
    return 0;
}
double LotSizeDropdownValue(int index)
{
    return StringToDouble(LotSizeDropdown[index]);
}

string[] TakeProfitLevelDropdown = {"Take Profit 1", "Take Profit 2", "Take Profit 3"};
int TakeProfitLevelDropdownIndex(ENUM_TP value)
{
    return int(value);
}
ENUM_TP TakeProfitLevelDropdownValue(int index)
{
    return ENUM_TP(index);
}
//+------------------------------------------------------------------+


Here is the errors

'ENUM_TP' - declaration without type 12 7

'[' - name expected 226 7

'0.02' - name expected 226 37

'0.03' - name expected 226 45

'0.04' - name expected 226 53

'0.05' - name expected 226 61

'}' - semicolon expected 226 67

'}' - expressions are not allowed on a global scope 226 67

'[' - name expected 243 7

'Take Profit 2' - name expected 243 54

'Take Profit 3' - name expected 243 71

'}' - semicolon expected 243 86

'}' - expressions are not allowed on a global scope 243 86

'[' - name expected 259 7

'0.02' - name expected 259 37

'0.03' - name expected 259 45

'0.04' - name expected 259 53

'0.05' - name expected 259 61

'}' - semicolon expected 259 67

'}' - expressions are not allowed on a global scope 259 67

'LotSizeDropdownIndex' - function already defined and has body 260 5

   see previous declaration of function 'LotSizeDropdownIndex' 227 5

'LotSizeDropdownValue' - function already defined and has body 271 8

   see previous declaration of function 'LotSizeDropdownValue' 238 8

'[' - name expected 276 7

'Take Profit 2' - name expected 276 54

'Take Profit 3' - name expected 276 71

'}' - semicolon expected 276 86

'}' - expressions are not allowed on a global scope 276 86

'TakeProfitLevelDropdownIndex' - function already defined and has body 277 5

   see previous declaration of function 'TakeProfitLevelDropdownIndex' 244 5

'TakeProfitLevelDropdownValue' - function already defined and has body 281 9

   see previous declaration of function 'TakeProfitLevelDropdownValue' 248 9

'WebRequest' - no one of the overloads can be applied to the function call 88 9

could be one of 2 function(s) 88 9

   built-in: int WebRequest(const string,const string,const string,const string,int,const char&[],int,char&[],string&) 88 9

   built-in: int WebRequest(const string,const string,const string,int,const char&[],char&[],string&) 88 9

'[' - name expected 91 15

'

' - name expected 91 47

'lines' - undeclared identifier 92 39

'lines' - parameter conversion not allowed 92 39

'lines' - array required 92 39

'[' - name expected 94 19

',' - name expected 94 53

'fields' - undeclared identifier 95 27

'fields' - parameter conversion not allowed 95 27

'fields' - array required 95 27

implicit conversion from 'number' to 'string' 101 29

implicit conversion from 'number' to 'string' 102 29

implicit conversion from 'number' to 'string' 103 47

implicit conversion from 'number' to 'string' 104 51

implicit conversion from 'number' to 'string' 105 49

implicit conversion from 'number' to 'string' 106 49

implicit conversion from 'number' to 'string' 107 49

implicit conversion from 'string' to 'number' 113 73

'ticket' - struct member undefined 129 53

return value of 'OrderModify' should be checked 130 21

'ticket' - struct member undefined 147 44

implicit conversion from 'string' to 'number' 72 35

return value of 'OrderDelete' should be checked 72 13

'ticket' - struct member undefined 206 35

return value of 'OrderDelete' should be checked 206 13

'ticket' - struct member undefined 218 35

return value of 'OrderModify' should be checked 218 13

'LotSizeDropdown' - undeclared identifier 262 35

'LotSizeDropdown' - parameter conversion not allowed 262 35

'LotSizeDropdown' - array required 262 35

implicit conversion from 'number' to 'string' 264 28

'LotSizeDropdown' - undeclared identifier 273 27

implicit conversion from 'number' to 'string' 273 27




 

Please don't post randomly in any section. Your question is not related to the section you posted.

MT4/mql4 has it's own section on the forum.

I have moved your topic to the correct section.

 
  1. //|                                                      My Expert.mq4|

    Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. string[] lines = StringSplit(content, "\n");

    Perhaps you should read the manual. What does StringSplit return and how many arguments does it require?
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  3. ghergherak:

    'ENUM_TP' - declaration without type 12 7

    input ENUM_TP TakeProfitLevel = TP_Level1;
    Start fixing the errors one by one. You didn't define an ENUM_TP prior to line 12.