Limiting BIN files to a maxsize of lines per file

MQL4 Esperti Script

Lavoro terminato

Tempo di esecuzione 1 giorno
Feedback del dipendente
Friendly customer
Feedback del cliente
Good job, straight to the point and honest.

Specifiche

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

Con risposta

1
Sviluppatore 1
Valutazioni
(5)
Progetti
7
29%
Arbitraggio
1
0% / 100%
In ritardo
0
Gratuito
2
Sviluppatore 2
Valutazioni
(4)
Progetti
4
0%
Arbitraggio
1
0% / 100%
In ritardo
1
25%
Gratuito
3
Sviluppatore 3
Valutazioni
(6)
Progetti
7
0%
Arbitraggio
0
In ritardo
5
71%
Gratuito
4
Sviluppatore 4
Valutazioni
(1)
Progetti
2
0%
Arbitraggio
0
In ritardo
1
50%
Gratuito
5
Sviluppatore 5
Valutazioni
(82)
Progetti
86
57%
Arbitraggio
25
0% / 84%
In ritardo
19
22%
Gratuito
6
Sviluppatore 6
Valutazioni
(64)
Progetti
144
46%
Arbitraggio
20
40% / 15%
In ritardo
32
22%
In elaborazione
7
Sviluppatore 7
Valutazioni
(7)
Progetti
13
0%
Arbitraggio
5
20% / 60%
In ritardo
0
Gratuito

Informazioni sul progetto

Budget
30 - 50 USD
Scadenze
da 1 a 10 giorno(i)