Download MetaTrader 5
To add comments, please log in or register
Do you want to deposit to your account? Do this in any convenient way!
Nurudeen Amedu
37838
Nurudeen Amedu 2016.07.08 09:23 

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?

Nianfu Li
1378
Nianfu Li 2016.07.08 10:05  
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);
Nurudeen Amedu
37838
Nurudeen Amedu 2016.07.08 10:12  
ok thanks
Nianfu Li
1378
Nianfu Li 2016.07.08 10:15  
This file will appear in the following folder:
 Application Data\MetaQuotes\Terminal\Common
Nurudeen Amedu
37838
Nurudeen Amedu 2016.07.08 13:54  
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
Nurudeen Amedu
37838
Nurudeen Amedu 2016.07.08 14:03  
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);
      }
    }
  }
Nurudeen Amedu
37838
Nurudeen Amedu 2016.07.09 21:05  
Nianfu Li:
how do i write to the directory?
/
To add comments, please log in or register