Hello evryone,
Writing an EA for the highest close of the last 14 days, any symbol, time frame of the current chart, counting back from the current bar.
Script is written in this manner:
-------------------------------------------------------------------------------------------------
int start ()
High[iHighest(NULL,0,MODE_CLOSE, 14,1)];
{
//---highest close of the last 14 days, any symbol, time frame of the current chart,
//-----counting back from current bar.
return (0);
}
--------------------------------------------------------------------------------------------------
When compiled, 1 Error, Error shows 'High' - semicolon expected,
Any help out there???
Thanks in advance
Huckleberry
Assign this value to a variable:
double high = High[iHighest(NULL,0,MODE_CLOSE, 14,1)];
consider also that is good idea to put the opening brace { on line.2
int start ()
{
var = High...
Assign this value to a variable:
double high = High[iHighest(NULL,0,MODE_CLOSE, 14,1)];
Hello robofx.org, and all others,
The advise does help. Though now I am in the MQL4 cloud again.
Once the SCRIPT is typed out and compiled, it shows: 0 ERRORS, 0 WARNINGS. Thank you.
Now when it is typed into an EA it shows: 4 ERRORS, have a take a look,
#property link "https://www.metaquotes.net/"
extern double highest = 0.0;
extern double atr =0.0;
extern double order=0.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
double high=High[iHighest(NULL,0,MODE_CLOSE,14,1)]; <--------------------'double' -semicolon expected, 'High' -initialization expected,
'[' -comma or semicolon expected, ']' -unexpected square bracket
(Line 35, COL 1,13,17,and 50)
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
4 ERRORS, 0 WARNINGS
Inserting a SCRIPT into an EA is what I had done. The SCRIPT has no errors, BUT when it is inserted into the EA, it shows 4 ERRORS.
I was under the impression that an EA was basically a complete program that was made
up of many scripts. That building a script, compiling it (without ERRORS or WARNINGS), and using it as a building block until the EA is complete,
was proper construction?
Help with understanding the difference in building an EA using scripts is appreciated, as well as what are the ERRORS that are
within the EA that is above.
Regards
Huckleberry
Hello robofx.org, and all others,
The advise does help. Though now I am in the MQL4 cloud again.
Once the SCRIPT is typed out and compiled, it shows: 0 ERRORS, 0 WARNINGS. Thank you.
Now when it is typed into an EA it shows: 4 ERRORS, have a take a look,
#property link "https://www.metaquotes.net/"
extern double highest = 0.0;
extern double atr =0.0;
extern double order=0.0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
double high=High[iHighest(NULL,0,MODE_CLOSE,14,1)]; <--------------------'double' -semicolon expected, 'High' -initialization expected,
'[' -comma or semicolon expected, ']' -unexpected square bracket
(Line 35, COL 1,13,17,and 50)
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
4 ERRORS, 0 WARNINGS
Inserting a SCRIPT into an EA is what I had done. The SCRIPT has no errors, BUT when it is inserted into the EA, it shows 4 ERRORS.
I was under the impression that an EA was basically a complete program that was made
up of many scripts. That building a script, compiling it (without ERRORS or WARNINGS), and using it as a building block until the EA is complete,
was proper construction?
Help with understanding the difference in building an EA using scripts is appreciated, as well as what are the ERRORS that are
within the EA that is above.
Regards
Huckleberry
Insert the code after the {
So it looks like this:
int start()
{
double high=High[iHighest(NULL,0,MODE_CLOSE,14,1)];
return(0);
}
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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 evryone,
Writing an EA for the highest close of the last 14 days, any symbol, time frame of the current chart, counting back from the current bar.
Script is written in this manner:
-------------------------------------------------------------------------------------------------
int start ()
High[iHighest(NULL,0,MODE_CLOSE, 14,1)];
{
//---highest close of the last 14 days, any symbol, time frame of the current chart,
//-----counting back from current bar.
return (0);
}
--------------------------------------------------------------------------------------------------
When compiled, 1 Error, Error shows 'High' - semicolon expected,
Any help out there???
Thanks in advance
Huckleberry