How do i read a csv from another MT4 on the same computer

 

I want to copy trades between 2 platforms, one writes to a csv file in its files folder and i want the other one to read the csv

 I tried this but its not working

void load_positions() {

  int handle=FileOpen(filename+".csv",FILE_CSV|FILE_READ,";");
  if(handle>0) {

    string line=FileReadString(handle);
    if (TotalCounter == StrToInteger(line)) {
      FileClose(handle);
      return;
    }

In the filename parameter, i entered D:\Users\Forbes\AppData\Roaming\MetaQuotes\Terminal\B86ACF179AE0C55FA87E9532FBCA2802\MQL4\Files\TradeCopy

the name of the file is TradeCopy.csv but i either get Error 5004 or Error 5002 

please how do i code this?

 
Nurudeen Amedu:

I want to copy trades between 2 platforms, one writes to a csv file in its files folder and i want the other one to read the csv

 I tried this but its not working

In the filename parameter, i entered D:\Users\Forbes\AppData\Roaming\MetaQuotes\Terminal\B86ACF179AE0C55FA87E9532FBCA2802\MQL4\Files\TradeCopy

the name of the file is TradeCopy.csv but i either get Error 5004 or Error 5002 

please how do i code this?

handle=FileOpen("\\filename.csv",FILE_COMMON|FILE_SHARE_READ|FILE_BIN|FILE_READ);
 
ok thanks
 
This file will appear in the following folder:
 Application Data\MetaQuotes\Terminal\Common
 
Nianfu Li:
This file will appear in the following folder:
 Application Data\MetaQuotes\Terminal\Common
so i have to read and write with that directory
 
Nianfu Li:
This file will appear in the following folder:
 Application Data\MetaQuotes\Terminal\Common

i was able to write script to delete pending orders if they have been deleted on master account

but i need help with closing open trades closed by master account using magic number

  for (j=0;j<RealSize;j++) {
//    cmt=cmt+nl+"checking "+j+" <> "+x[j];
    if (x[j]!=1) { //no master order, close the ticket
//      Price=MarketPrice(RealOrdSym[j],"close");
//      OrderClose(RealOrdId[j],RealOrdLot[j],Price,5,CLR_NONE);
      if (RealOrdTyp[j]<2) {
        Price=MarketPrice(j,"close");
        result=OrderClose(RealOrdId[j],RealOrdLot[j],Price,5,CLR_NONE);
        if (result<1) Print ("Close ",RealOrdId[j]," / ",RealOrdLot[j]," / ",Price," failed: ",GetLastError());
        if (Balance<AccountBalance()) Balance=AccountBalance();
      }else{
        OrderDelete(RealOrdId[j],CLR_NONE);
      }
    }
  }
 
Nianfu Li:
how do i write to the directory?