Limiting BIN files to a maxsize of lines per file

MQL4 Experten Skripte

Auftrag beendet

Ausführungszeit 1 Tag
Bewertung des Entwicklers
Friendly customer
Bewertung des Kunden
Good job, straight to the point and honest.

Spezifikation

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

Bewerbungen

1
Entwickler 1
Bewertung
(5)
Projekte
7
29%
Schlichtung
1
0% / 100%
Frist nicht eingehalten
0
Frei
2
Entwickler 2
Bewertung
(4)
Projekte
4
0%
Schlichtung
1
0% / 100%
Frist nicht eingehalten
1
25%
Frei
3
Entwickler 3
Bewertung
(6)
Projekte
7
0%
Schlichtung
0
Frist nicht eingehalten
5
71%
Frei
4
Entwickler 4
Bewertung
(1)
Projekte
2
0%
Schlichtung
0
Frist nicht eingehalten
1
50%
Frei
5
Entwickler 5
Bewertung
(82)
Projekte
86
57%
Schlichtung
25
0% / 84%
Frist nicht eingehalten
19
22%
Frei
6
Entwickler 6
Bewertung
(64)
Projekte
144
46%
Schlichtung
19
42% / 16%
Frist nicht eingehalten
32
22%
Arbeitet
7
Entwickler 7
Bewertung
(7)
Projekte
13
0%
Schlichtung
5
20% / 60%
Frist nicht eingehalten
0
Frei

Projektdetails

Budget
30 - 50 USD
Ausführungsfristen
von 1 bis 10 Tag(e)