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
(62)
Progetti
140
46%
Arbitraggio
19
42% / 16%
In ritardo
32
23%
Gratuito
7
Sviluppatore 7
Valutazioni
(7)
Progetti
13
0%
Arbitraggio
5
20% / 60%
In ritardo
0
Gratuito
Ordini simili
I need an expert to decrypt my itf file using on prorealtime. I forgot my password, so I need to generate the source code. I need someone that can help me to derive source code from the itf file I have
I’m looking for someone experienced with Think or Swim to create a backtesting script for an in-the-money Iron Condor strategy using options on the SPX. The strategy involves setting up 10 contracts of an Iron Condor with a 10-point spread width and a net credit requirement of $11 per contract. The goal is to backtest the performance over the last three years, focusing on trades where the SPX closes outside a
I currently have a license code that connects to my web server, and I add the account number, client name, and expiration date. I’d like something more automated. Currently I allow clients 10 licenses, but adding for them on my side can get exhausting. I’d like a better solution for myself and clients

Informazioni sul progetto

Budget
30 - 50 USD
IVA (18%): 5.4 - 9 USD
Totale: 35.4 - 59 USD
Per lo sviluppatore
27 - 45 USD
Scadenze
da 1 a 10 giorno(i)