[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 13

 


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 ?

 
Roger:

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!
 
sergey_r:


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:


 
// 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);
}
 

I understand but how to use it afterwards. Do I have to write a condition?

 
sergey_r:

I understand but how to use it afterwards. Do I have to write a condition?

//-------------------------------------------------------------------+
extern int    TotalOrders    = 1;
//-------------------------------------------------------------------+
    // only perform analysis and open new order if we have not reached our TotalOpenOrders max
    if(TotalOpenOrders() < TotalOrders)
    {
 

// 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.

 
Which programme?
 
borilunad:

Where is this configuration? Please advise!


Read the articles

https://www.mql5.com/ru/articles/1490

https://www.mql5.com/ru/articles/1417

 
int start()
{ here?
Reason: