int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t"); if(handle<0) return(0); //write header into file FileWrite(handle, "#", "Opening price", "Opening time", "Symbol", "Lots"); int total=OrdersTotal(); // write only open orders into the file for(int pos=0;pos<total;pos++) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==false) continue; FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots()) } FileClose(handle);
int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t"); if(handle<0) return(0); //write header into file FileWrite(handle, "#", "Opening price", "Opening time", "Symbol", "Lots"); int total=OrdersTotal(); // write only open orders into the file for(int pos=0;pos<total;pos++) { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==false) continue; FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots()) } FileClose(handle);
// This function returns the total amount of orders the expert advisor has open int TotalOpenOrders()
{
Cnt=OrdersTotal();
int TotalOpenOrders = 0;
if(Cnt==0)
{
return(0);
}
else
{
for(;Cnt>=0;Cnt--)
{
RefreshRates();
OrderSelect(Cnt,SELECT_BY_POS);
if(OrderMagicNumber()==Magic)
{
TotalOpenOrders++;
}
}
}
return(TotalOpenOrders);
}
// This function returns the total amount of orders the expert advisor has opened int TotalOpenOrders() { Cnt=OrdersTotal(); int TotalOpenOrders = 0; if(Cnt==0) { return(0); } else { for(;Cnt>=0;Cnt--) { RefreshRates(); OrderSelect(Cnt,SELECT_BY_POS); if(OrderMagicNumber()==Magic) { TotalOpenOrders++; } } } return(TotalOpenOrders); }
And this function should be written before you start the program.
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.
int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");
if(handle<0) return(0);
//write header into file
FileWrite(handle, "#", "Opening price", "Opening time", "Symbol", "Lots");
int total=OrdersTotal();
// write only open orders into the file
for(int pos=0;pos<total;pos++)
{
if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==false) continue;
FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots())
}
FileClose(handle);
Please, tell me how to use it in my EA ?
You've given your own answer - Maybe something needs to be fixed somewhere in the configuration or something...?
Where is the configuration? Please, tell me!
int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");
if(handle<0) return(0);
//write header into file
FileWrite(handle, "#", "Opening price", "Opening time", "Symbol", "Lots");
int total=OrdersTotal();
// write only open orders into the file
for(int pos=0;pos<total;pos++)
{
if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==false) continue;
FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots())
}
FileClose(handle);
Can you tell me how to use it in my EA ?
Copy-paste ?!
You must insert the code in this way:
I understand but how to use it afterwards. Do I have to write a condition?
I understand but how to use it afterwards. Do I have to write a condition?
// This function returns the total amount of orders the expert advisor has opened
int TotalOpenOrders()
{
Cnt=OrdersTotal();
int TotalOpenOrders = 0;
if(Cnt==0)
{
return(0);
}
else
{
for(;Cnt>=0;Cnt--)
{
RefreshRates();
OrderSelect(Cnt,SELECT_BY_POS);
if(OrderMagicNumber()==Magic)
{
TotalOpenOrders++;
}
}
}
return(TotalOpenOrders);
}
And this function should be written before you start the program.
Where is this configuration? Please advise!
Read the articles
https://www.mql5.com/ru/articles/1490
https://www.mql5.com/ru/articles/1417
{ here?