store data to CSV file with flushfile failed

 

This is success as it do as a scrip to dump all data. 

But I can't call script in EA.(case 1)

so I try to call a function in EA, I try to write csv file to log data as OnDeinit() event.(case 2) 
To log all deal in csv file to check more detail, In debug there is data, but it didn't store in file. 

 test file link  (PS test case without could)


If I don't do something before OnDeint(), I will get failed deals history..

Even if I try this On timer maybe get failed can,t flush all data out.


I got so confuse, who to flush all data, if there is some interrupt will break normal process, so I will lost data?


=====File data lost ====

case 1 setting a: no action onTime

result :empty result for deal history. 

case 2 setting b: action onTime (do same call as onDeinit )

result:some deals get but not all

 

Note

Deinit event is generated for EAs and indicators 


So it's not for Scripts.

See here

Documentation on MQL5: Event Handling / OnDeinit
Documentation on MQL5: Event Handling / OnDeinit
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 |
 
Marco vd Heijden:

Note

Deinit event is generated for EAs and indicators 


So it's not for Scripts.

See here


Thanks  Marco vd Heijden, I got Deinit for EA and indicators.

I change script as mqh function already. This function do " open write flush close file"

But file data get lost ....  

 
SungSungE: But file data get lost ....  
Do you really expect an answer with the information you've provided? There are no mind readers here and our crystal balls are cracked. We can't see your broken code.
 
William Roeder:
Do you really expect an answer with the information you've provided? There are no mind readers here and our crystal balls are cracked. We can't see your broken code.

Thanks your response. I try do do more description , maybe put result csv file in cloud can say more.  (upload already as case 1 case 2 csv files)

The files can execution on my platform. If can't run on your. Could you provide more detail error message? 

 
SungSungE:

Thanks your response. I try do do more description , maybe put result csv file in cloud can say more.  (upload already as case 1 case 2 csv files)

The files can execution on my platform. If can't run on your. Could you provide more detail error message? 

Ya,It's okay. ^,^ 

I solve it.

Reason: