Read the Book or the Documentation (Links at the top, Language Basics!) or the reference (part of your editor) of how to work with functions!
I've already done that and don't see what I'm doing wrong. If I did, I wouldn't ask. If you don't want to help, then don't bother replying at all.
Hello,
I'm trying to build a relatively simple EA that should log:
a) All trades that have been closed (either manually or by TP/SL);
b) Time, open, high, low and close data for bars between trade entry and trade exit.
I have attempted to use the CopyTime, High etc. functions, and assign the data into arrays which are to then be written into a .csv/tsv. The purpose of doing so is so that I can use D3.js (a front-end JS library) to render charts on a website. However, because I'm not familiar with MQL4/C++ being a web dev, I'm having serious trouble with the EA.
I am including my code with SRC as follows:
Calling the functions gives me a "function can be declared only in the global scope" error during compilation - I cannot seem to find the reason behind this. Also, if you would be so kind as to check for any other errors in my script, I would be very grateful. Dealing with C-style arrays is really doing my head in.
What this code is supposed to do ? You can't include such declaration there.
int CopyOpen (const string EURUSD, ENUM_TIMEFRAMES PERIOD_CURRENT, datetime TimeOpen, datetime TimeClose, double PBO); int CopyHigh (const string EURUSD, ENUM_TIMEFRAMES PERIOD_CURRENT, datetime TimeOpen, datetime TimeClose, double PBH); int CopyClose (const string EURUSD, ENUM_TIMEFRAMES PERIOD_CURRENT, datetime TimeOpen, datetime TimeClose, double PBC); int CopyLow (const string EURUSD, ENUM_TIMEFRAMES PERIOD_CURRENT, datetime TimeOpen, datetime TimeClose, double PBL);
What you are doing wrong is :
- Posting two function definitions (init and start.) Irrelevant. Nowhere have you posted any function call, and a function call is not a function declaration.
- Not posting the code above the error.
- Indicating what line indicates the error. There are no mind readers here.
Pretty sure I stated very clearly:
I have attempted to use the CopyTime, High etc. functions, and assign the data into arrays which are to then be written into a .csv/tsv. The purpose of doing so is so that I can use D3.js (a front-end JS library) to render charts on a website. However, because I'm not familiar with MQL4/C++ being a web dev, I'm having serious trouble with the EA.
Calling the functions gives me a "function can be declared only in the global scope" error during compilation - I cannot seem to find the reason behind this. Also, if you would be so kind as to check for any other errors in my script, I would be very grateful. Dealing with C-style arrays is really doing my head in.
For the sake of clarity, the calls are below. I am NOT familiar with strictly-typed languages and so am not sure about syntax for making function calls in MQL4. Now I have removed the type declarations as someone here suggested, and am getting 'CopyXXXX' - no one of the overloads can be applied to the function call. The problem is, I am not overloading the function (as far as I can tell); I am passing in the parameters in accordance with what is written in documentation about the THIRD version of making calls to CopyOpen/High etc.
I have also declared the parameters with the correct types as far as I can tell (datetime and double).
datetime ClosedOrdersOpenTime[]; datetime ClosedOrdersCloseTime[]; datetime TradeTimeOpen = 0; datetime TradeTimeClose = 0; double PositionBarOpen[]; double PositionBarHigh[]; double PositionBarClose[]; double PositionBarLow[];
Thank for the help...Function calls below:
for(int l = 0; l < ClosedOrdersTotal; l++) { TradeTimeOpen = ClosedOrdersOpenTime[l]; TradeTimeClose = ClosedOrdersCloseTime[l]; double PBO = PositionBarOpen[l]; double PBH = PositionBarHigh[l]; double PBC = PositionBarClose[l]; double PBL = PositionBarLow[l]; CopyOpen (Symbol(), PERIOD_CURRENT, TradeTimeOpen, TradeTimeClose, PBO); CopyHigh (Symbol(), PERIOD_CURRENT, TradeTimeOpen, TradeTimeClose, PBH); CopyClose (Symbol(), PERIOD_CURRENT, TradeTimeOpen, TradeTimeClose, PBC); CopyLow (Symbol(), PERIOD_CURRENT, TradeTimeOpen, TradeTimeClose, PBL); ArrayResize(PositionBarOpen, MathMax(ClosedOrdersTotal, l)); ArrayResize(PositionBarHigh, MathMax(ClosedOrdersTotal, l)); ArrayResize(PositionBarClose, MathMax(ClosedOrdersTotal, l)); ArrayResize(PositionBarLow, MathMax(ClosedOrdersTotal, l)); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I'm trying to build a relatively simple EA that should log:
a) All trades that have been closed (either manually or by TP/SL);
b) Time, open, high, low and close data for bars between trade entry and trade exit.
I have attempted to use the CopyTime, High etc. functions, and assign the data into arrays which are to then be written into a .csv/tsv. The purpose of doing so is so that I can use D3.js (a front-end JS library) to render charts on a website. However, because I'm not familiar with MQL4/C++ being a web dev, I'm having serious trouble with the EA.
I am including my code with SRC as follows:
Calling the functions gives me a "function can be declared only in the global scope" error during compilation - I cannot seem to find the reason behind this. Also, if you would be so kind as to check for any other errors in my script, I would be very grateful. Dealing with C-style arrays is really doing my head in.