Pending order report to CSV

 

Hi,,


I found below code , it does what I want, the problem it dumps all orders types , I just need the pending orders:

I believe my problem in this line:

--->       ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE) OrderType();

I need to put only below Identifiers :


ORDER_TYPE_BUY
ORDER_TYPE_SELL
ORDER_TYPE_BUY_LIMIT
ORDER_TYPE_SELL_LIMIT
ORDER_TYPE_BUY_STOP
ORDER_TYPE_SELL_STOP
ORDER_TYPE_BUY_STOP_LIMIT
ORDER_TYPE_SELL_STOP_LIMIT
ORDER_TYPE_CLOSE_BY



================================

#property copyright "test"

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//---

    int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");

  if(handle<0) return;

  // write header

  FileWrite(handle,"#","open price","open time","symbol","lots");

  int total=OrdersTotal();

  // write open orders

  for(int pos=0;pos<total;pos++)

     {

      if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

      ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE) OrderType();

      FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots(),EnumToString(type));

     }


   FileClose(handle);

   if(OrderSelect(2, SELECT_BY_TICKET)==true)

    OrderPrint();

  else

    Print("OrderSelect failed error code is",GetLastError());

  }

//+------------------------------------------------------------------+

Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. How to make mql5 always running even if...
 

I managed to do it as I want I have something in code , it repeats the order type , listing them all as Buy Limit:

#property copyright "test"

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//---

    int handle=FileOpen("107.csv",FILE_WRITE|FILE_CSV,"\t");

  if(handle<0) return;

  // write header

//  FileWrite(handle,"#","open price","symbol","lots");

   FileWrite(handle, " , " ,"open price", " , " ,"symbol", " , " ,"lots", " , " ,"Type");

  int total=OrdersTotal();

  // write open orders

  for(int pos=0;pos<total;pos++)

     {

      if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

      ENUM_ORDER_TYPE type=ORDER_TYPE_BUY_LIMIT;  ORDER_TYPE_SELL_LIMIT; ORDER_TYPE_BUY_STOP; ORDER_TYPE_SELL_STOP; OrderType();

      FileWrite(handle," , ", OrderOpenPrice()," , " , OrderSymbol()," , " , OrderLots()," , ", EnumToString(type));

     }


   FileClose(handle);

   if(OrderSelect(2, SELECT_BY_TICKET)==true)

    OrderPrint();

  else

    Print("OrderSelect failed error code is",GetLastError());

  }

//+------------------------------------------------------------------+


  open price     symbol     lots     Type
  85.018     CADJPY     0.05     ORDER_TYPE_BUY_LIMIT
  83.90000000000001     CADJPY     0.05     ORDER_TYPE_BUY_LIMIT
  86     CADJPY     0.05     ORDER_TYPE_BUY_LIMIT
  87     CADJPY     0.05     ORDER_TYPE_BUY_LIMIT
  82     CADJPY     0.05     ORDER_TYPE_BUY_LIMIT
  111.835     CHFJPY     0.05     ORDER_TYPE_BUY_LIMIT
  1.7252     EURNZD     0.05     ORDER_TYPE_BUY_LIMIT
  0.7101     AUDCHF     0.05     ORDER_TYPE_BUY_LIMIT
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. Check for current profit?? Hello...
 

Also it is not the solution but I can browse them all , I will filter for now by excel , but I still need to select only the specified order types:


#property copyright "test"

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//---

    int handle=FileOpen("200.csv",FILE_WRITE|FILE_CSV,"\t");

  if(handle<0) return;

  // write header

  FileWrite(handle, " , " ,"open price", " , " ,"symbol", " , " ,"lots", " , " ,"Type");

  int total=OrdersTotal();

  // write open orders

  for(int pos=0;pos<total;pos++)

     {

      if(OrderSelect(pos,SELECT_BY_POS)==false) continue;

      ENUM_ORDER_TYPE type=OrderType();

      FileWrite(handle," , ", OrderOpenPrice()," , " , OrderSymbol()," , " , OrderLots()," , ", EnumToString(type));

     }


   FileClose(handle);

   if(OrderSelect(2, SELECT_BY_TICKET)==true)

    OrderPrint();

  else

    Print("OrderSelect failed error code is",GetLastError());

  }

//+------------------------------------------------------------------+


Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • www.mql5.com
Ask questions on technical analysis, discuss trading systems and improve your MQL5 programming skills to develop your own trading strategies. Communicate and share your experience with traders from anywhere in the world, answer questions and help beginners — MQL5.community is developing along with you. Error for seller Hello guys.. please...
Reason: