Limiting BIN files to a maxsize of lines per file

仕事が完了した

実行時間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 日