거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
3798
평가:
(27)
게시됨:
2013.03.29 11:55
업데이트됨:
2016.11.22 07:32
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

When writing to a file, the data may be actually found there only after some time. To save the data in the file instantly, use the FileFlush() function. If the function is not used, part of the data that has not been stored in the disk yet, will be forcibly written there only when the file is closed using the FileClose() function.

The script in the loop gets the current Bid and Ask prices data and calls the FileWrite() function to write them. At each 128 iteration the FileFlush() function is called for the forced reset of pre-written data to disk.

Code:

//--- show the window of input parameters when launching the script
#property script_show_inputs
//--- file name for writing
input string InpFileName="example.csv"; // file name
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- reset error value
   ResetLastError();
//--- open the file
   int file_handle=FileOpen(InpFileName,FILE_READ|FILE_WRITE|FILE_CSV);
   if(file_handle!=INVALID_HANDLE)
     {
      //--- write data to the file
      for(int i=0;i<1000;i++)
        {
         //--- call write function
         FileWrite(file_handle,TimeCurrent(),SymbolInfoDouble(Symbol(),SYMBOL_BID),SymbolInfoDouble(Symbol(),SYMBOL_ASK));
         //--- save data on the disk at each 128th iteration
         if((i & 127)==127)
           {
            //--- now, data will be located in the file and will not be lost in case of a critical error
            FileFlush(file_handle);
            PrintFormat("i = %d, OK",i);
           }
         //--- 0.01 second pause
         Sleep(10);
        }
      //--- close the file
      FileClose(file_handle);
     }
   else
      PrintFormat("Error, code = %d",GetLastError());
  }

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/1615

Demo_FileMove Demo_FileMove

The script demonstrates the example of using the FileMove() function

The20sv0.20 The20sv0.20

The semaphore trend signal indicator

i-IntradayFibonacci i-IntradayFibonacci

Intraday Fibonacci levels

Demo_FileIsEnding Demo_FileIsEnding

The script demonstrates the example of using the FileIsEnding() function