Limiting BIN files to a maxsize of lines per file

MQL4 전문가 스크립트

작업 종료됨

실행 시간 1 일
피고용인의 피드백
Friendly customer
고객의 피드백
Good job, straight to the point and honest.

명시

Hi all, the simple script im currently using has the below functions Ontick:

- Takes the Bid or Ask price of the current chart pair.
- Opens/Creates a new bin file.
- Stores that Bid or Ask price at the BOTTOM of the bin file
- Reopens the bin file to read it
- Stores it into an array in order to be manipulated

I would like to be able to limit this file, because obviously right now the file just keeps getting bigger, to a certain number of lines (circular buffer?)
So that at the current tick, and lets say maxsize = 5, the file looks like this:
-E, D, C, B, A (A being the oldest bid/ask price stored at the end of the line)

on next tick
-F, E, D, C, B  (A deleted and F inserted as the most recent tick price)

The code is the below:

void OnTick()



  {

   double PriceDiff = MarketInfo("AUDCAD",(MODE_ASK));

        

   int fileHandle2 = FileOpen("Myfile.bin",FILE_BIN|FILE_READ | FILE_WRITE);

       

   FileSeek(fileHandle2, 0, SEEK_END); // Write at the end of the file.

   double data2 = PriceDiff;

   FileWriteDouble(fileHandle2,data2);

   FileClose(fileHandle2);    

   double arr[];

   string path= "";

   ResetLastError();

   int file_handle=FileOpen("Myfile.bin",FILE_READ|FILE_BIN);

   if(file_handle!=INVALID_HANDLE)

     {

      FileReadArray(file_handle,arr);

      //--- receive the array size

      int size=ArraySize(arr);

      //--- print data from the array

      for(int i=0;i<size;i++);

      Comment("Total data = ",size);

      //--- close the file

      FileClose(file_handle);


I hope the explanation is clear enough, if not we can discuss further. 

Thanks in advance
Chris

응답함

1
개발자 1
등급
(5)
프로젝트
7
29%
중재
1
0% / 100%
기한 초과
0
무료
2
개발자 2
등급
(4)
프로젝트
4
0%
중재
1
0% / 100%
기한 초과
1
25%
무료
3
개발자 3
등급
(6)
프로젝트
7
0%
중재
0
기한 초과
5
71%
무료
4
개발자 4
등급
(1)
프로젝트
2
0%
중재
0
기한 초과
1
50%
무료
5
개발자 5
등급
(82)
프로젝트
86
57%
중재
25
0% / 84%
기한 초과
19
22%
무료
6
개발자 6
등급
(64)
프로젝트
144
46%
중재
19
42% / 16%
기한 초과
32
22%
작업중
7
개발자 7
등급
(7)
프로젝트
13
0%
중재
5
20% / 60%
기한 초과
0
무료

프로젝트 정보

예산
30 - 50 USD
기한
에서 1  10 일