filewrite questions

To add comments, please log in or register
faustf
137
faustf  

hi guys  i have a little script for open trade 2 or more with one button , i want  write a  numbertrade in temporary file i write this  code 

  for(ctrlshort=1;ctrlshort<=QttOpenTrade;ctrlshort++)
        {
         SellShort=OrderSend(Symbol(),OP_SELL,LotSizeTrade,Bid,3,0,0,"Open CloseHide",e_MagicID);//short
         fileHandle=FileOpen(InpDirectoryName+"//"+InpFileName,FILE_READ|FILE_WRITE|FILE_TXT);
         if(fileHandle!=INVALID_HANDLE)
           {
            //  Print(fileHandle);
            FileWrite(fileHandle,SellShort);
           }
         else
            PrintFormat("Failed to open %s file, Error code = %d",InpFileName,GetLastError());
        }
      FileClose(fileHandle);

but  write me only last number of trade , exist  a function filewriteline ???  or how  is possible  write  all number of trade??  thankz

Naguisa Unada
524
Naguisa Unada  
faustf:

hi guys  i have a little script for open trade 2 or more with one button , i want  write a  numbertrade in temporary file i write this  code 

but  write me only last number of trade , exist  a function filewriteline ???  or how  is possible  write  all number of trade??  thankz

How about putting "FileOpen" before the start of the loop?

William Roeder
20210
William Roeder  
faustf: how  is possible  write  all number of trade??
  1. You have begin loop, open, (position is at beginning,) write, close, end loop, so you overwrite each time and only get the last item written.
  2. If you want your file to have all from your loop move the open and close outside the loop.
  3. If you want your file to have all now and previously, move the open and close outside the loop and seek to the end after opening, so you append to the file, not overwrite it.
To add comments, please log in or register