Limiting BIN files to a maxsize of lines per file

MQL4 Uzmanlar Komut dosyaları

İş tamamlandı

Tamamlanma süresi: 1 gün
Geliştirici tarafından geri bildirim
Friendly customer
Müşteri tarafından geri bildirim
Good job, straight to the point and honest.

Şartname

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

Yanıtlandı

1
Geliştirici 1
Derecelendirme
(5)
Projeler
7
29%
Arabuluculuk
1
0% / 100%
Süresi dolmuş
0
Serbest
2
Geliştirici 2
Derecelendirme
(4)
Projeler
4
0%
Arabuluculuk
1
0% / 100%
Süresi dolmuş
1
25%
Serbest
3
Geliştirici 3
Derecelendirme
(6)
Projeler
7
0%
Arabuluculuk
0
Süresi dolmuş
5
71%
Serbest
4
Geliştirici 4
Derecelendirme
(1)
Projeler
2
0%
Arabuluculuk
0
Süresi dolmuş
1
50%
Serbest
5
Geliştirici 5
Derecelendirme
(82)
Projeler
86
57%
Arabuluculuk
25
0% / 84%
Süresi dolmuş
19
22%
Serbest
6
Geliştirici 6
Derecelendirme
(64)
Projeler
144
46%
Arabuluculuk
20
40% / 20%
Süresi dolmuş
32
22%
Serbest
7
Geliştirici 7
Derecelendirme
(7)
Projeler
13
0%
Arabuluculuk
5
20% / 60%
Süresi dolmuş
0
Serbest

Proje bilgisi

Bütçe
30 - 50 USD
Son teslim tarihi
from 1 to 10 gün