Download MetaTrader 5

market and pending orders Report

To add comments, please log in or register
Do you know that MQL5 has structures?
bah12ram
76
bah12ram 2016.03.27 17:48 
I tried to write a Script that save my market and pending orders,

I've noticed a (cannot open file 'C:\Program Files\MetaTrader 4\MQL4\Scripts\test.ex4' ) in the Expert tab in MT4
This is the Code.

void OnStart()
  {
//---
    int handle=FileOpen("OrdersReport.csv",FILE_WRITE|FILE_CSV,"\t");
  if(handle<0) return(0);
  // 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;
     FileWrite(handle,OrderTicket(),OrderOpenPrice(),OrderOpenTime(),OrderSymbol(),OrderLots());
    }
  FileClose(handle);

  }

What is wrong in this Code?
To add comments, please log in or register