int total=OrdersTotal();
for(int i=0;i<total;i++)
{
Print("i=",i);
if(!OrderSelect(i,SELECT_BY_POS))
{
Print("order not selected. Error=",GetLastError());
continue;
}
if(OrderMagicNumber()!=magic_number)
{
Print("magic number not correct.");
continue;
}
if(OrderSymbol()!=Symbol())
{
Print("symbol not correct.");
continue;
}
if(OrderType()!=OP_SELL)
{
Print("order type not correct.");
continue;
}
if(OrderCloseTime()>0)
{
Print("order close time not correct.");
continue;
}
if(!OrderClose(ticket,lots,price,slippage,clrClose))
{
Print("order Sell with ticket=",ticket,", was not closed. Error=",GetLastError());
}
else
{
Print("order Sell with ticket=",ticket,", was closed.");
}
}
Why am I getting a 4051 error in OrderSelect()? First open order is closed correctly, on second order not selected. Error=4051. Valid value 2 in total.
Why am I getting a 4051 error in OrderSelect()? First open order is closed correctly, on second order not selected. Error=4051. Valid value 2 in total.
When deleting and closing, the loop should be reversed:
Good afternoon, please help with these questions (2):
1. Is there such an EA, save the results of testing by history in an excel file. For example, I have tested an EA and want to get the parameters of the EA, there profit, type of trade, result, DAYS OF THE WEEK and so on.
I would also like to know how to do detailed analysis or share my experience on how you test an EA and see if it is worthwhile or total crap.
2. How do I pass an array or structure to a function? I.e. I have a lot of variables, I add these variables to a structure and pass it to a function.
Then I open this structure in this function and get the variables I need. This is done to avoid "dragging" all values of variables into a function (for convenience).
Good afternoon, please help with these questions (2):
1. Is there such an EA, save the results of testing by history in an excel file. For example, I have tested an EA and want to get the parameters of the EA, there profit, type of trade, result, DAYS OF THE WEEK and so on.
I would also like to know how to do detailed analysis or share my experience on how you test an EA and see if it is worthwhile or total crap.
2. How do I pass an array or structure to a function? I.e. I have a lot of variables, I add these variables to a structure and pass it to a function.
Then I open this structure in this function and get the variables I need. This is done to avoid "dragging" all values of variables into a function (for convenience).
//+------------------------------------------------------------------+//| передача параметров по ссылке |//+------------------------------------------------------------------+double SecondMethod(int &i,int &j)
{
double res;
//---
i*=2;
j/=2;
res=i+j;
//---return(res);
}
//+------------------------------------------------------------------+//| Script program start function |//+------------------------------------------------------------------+voidOnStart()
{
//---int a=14,b=8;
Print("a и b перед вызовом:",a," ",b);
double d=SecondMethod(a,b);
Print("a и b после вызова:",a," ",b);
}
//+------------------------------------------------------------------+//--- результат выполнения скрипта// a и b перед вызовом: 14 8// a и b после вызова: 28 4
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Why am I getting a 4051 error in OrderSelect()? First open order is closed correctly, on second order not selected. Error=4051. Valid value 2 in total.
Why am I getting a 4051 error in OrderSelect()? First open order is closed correctly, on second order not selected. Error=4051. Valid value 2 in total.
When deleting and closing, the loop should be reversed:
Some wondrous bug or other.
Adding in the inputs:
input datetime test =0;
input variable cannot be changed in the EA
extern variable - yes
The input variable cannot be changed in the EA
the extern variable - you can
Not in the EA code. In the input parameters window, when you attach the EA to the chart.
The cycle should be reversed when deleting and closing:
thank you
Good afternoon, please help with these questions (2):
1. Is there such an EA, save the results of testing by history in an excel file. For example, I have tested an EA and want to get the parameters of the EA, there profit, type of trade, result, DAYS OF THE WEEK and so on.
I would also like to know how to do detailed analysis or share my experience on how you test an EA and see if it is worthwhile or total crap.
2. How do I pass an array or structure to a function? I.e. I have a lot of variables, I add these variables to a structure and pass it to a function.
Then I open this structure in this function and get the variables I need. This is done to avoid "dragging" all values of variables into a function (for convenience).
Thank you.
Good afternoon, please help with these questions (2):
1. Is there such an EA, save the results of testing by history in an excel file. For example, I have tested an EA and want to get the parameters of the EA, there profit, type of trade, result, DAYS OF THE WEEK and so on.
I would also like to know how to do detailed analysis or share my experience on how you test an EA and see if it is worthwhile or total crap.
2. How do I pass an array or structure to a function? I.e. I have a lot of variables, I add these variables to a structure and pass it to a function.
Then I open this structure in this function and get the variables I need. This is done to avoid "dragging" all values of variables into a function (for convenience).
Thank you.
The answer is here.
Dear Sirs!
Please help me to understand the problem.
I used a switch(int err) operator
got a message
int ErrorDescription()
{
Alert("beg ErrorDescription")
switch(err)
{
case 0: err="No error"; break;
case 1: err="No error, but result unknown"; break;
case 2: err="General error"; break;
case 3: err="Wrong parameters";
what's the matter, can't figure out where semicolon should be? It's not clear...
Dear Sirs!
Please help me to understand the problem.
I used a switch(int err) operator
got a message
int ErrorDescription()
{
Alert("beg ErrorDescription")
switch(err)
{
case 0: err="No error"; break;
case 1: err="No error, but result unknown"; break;
case 2: err="General error"; break;
case 3: err="Wrong parameters";
what's the matter, can't figure out where semicolon should be? It's not clear...
Have you looked after Alert()? Where is ";" ?
And why do you give the function a fragment?Have you looked after Alert()? Where is the ";" ?
And why are you giving me a fragment of the function?It didn't seem to be after Alert... And now it's there, or I put it there somewhere in the process and didn't notice it myself.
Thanks anyway.
The problem is solved. Thanks again, Artyom.