Author: Imanol SAGA
Miscellaneous
Uses files from the file systemIt writes information to file
0 Views
0 Downloads
0 Favorites
GetSwaps
//+------------------------------------------------------------------+
//|                                                     GetSwaps.mq5 |
//|                                                      Imanol SAGA |
//|                                           https://www.hipogen.tk |
//+------------------------------------------------------------------+
#property copyright "Imanol SAGA"
#property link      "https://www.hipogen.tk"
#property version   "1.00"


//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
      string file_name= "SwapsFile.csv";
      
      if(FileIsExist(file_name)){ FileDelete(file_name); }
      
      int file_handle= FileOpen(file_name,FILE_COMMON|FILE_ANSI|FILE_WRITE|FILE_CSV);
         
      if(file_handle!=INVALID_HANDLE)
      { 
         FileWrite(file_handle, "SYMBOL","SW_SHORT","SW_LONG");
         
         for(int i=0; i<SymbolsTotal(false); i++)
         {
            string syna= SymbolName(i,false);
            
            string done= i!=0? ((string)((i/SymbolsTotal(false)) * 100))+" % " : "0 % ";
            Comment("Process = "+done+syna);
            
            //for(int w=0; w<90000 && !SymbolIsSynchronized(syna); w++) Sleep(100);
            
            FileWrite(file_handle, syna, SymbolInfoDouble(syna,SYMBOL_SWAP_SHORT), SymbolInfoDouble(syna,SYMBOL_SWAP_LONG));
         }
         
         FileClose(file_handle);
         
         Comment("");
      }
  }
//+------------------------------------------------------------------+

Comments