Delete file. hst

 
You can delete hst files in folder history? 
 
fly7680:
You can delete hst files in folder history? 

You may, though there is no effect if the chart is already fetched into the terminal.

The hst file of the active offline chart cannot get deleted either.

 
I have to clean the history folder, can I use fileDelete () or another function?
 
fly7680: I have to clean the history folder, can I use fileDelete () or another function?

Why? If it is just a onetime clean-up, then just close MetaTrader, navigate to the appropriate directory and delete the files.

Other than that, what is the reason for deleting those files programmatically?

 

Like @Fernando Carreiro, I cannot think of a reason why you would want to delete the history programmatically. However, it can be done.


fly7680:
can I use fileDelete ()

No. As per the documentation:

"For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file "sandbox.

fly7680:
or another function?

https://www.mql5.com/en/forum/107674

 
in this topic https://www.mql5.com/en/forum/188001 I found a solution to download the historians updated every 4 hours but the problem is that if I turn off the MT4 and turn it back on the next day I think the files hst are not overwritten with the most recent ones and so I thought to delete them so at the new start of the MT4 I was sure that the files were again downloaded correctly.
Download history in MQL4 EA
Download history in MQL4 EA
  • 2017.03.23
  • www.mql5.com
I need 15M 1H 4H 1D 1W for all 28 pairs for 30 periods back in my EA...
 

I tried to delete the file but I receive these errors:


#import "kernel32.dll"
int DeleteFileA(string file);
#import

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason){
      
      DeleteFileA("C:\Users\MIO\AppData\Roaming\MetaQuotes\Terminal\61007F75C6EC7CED9A269B292061D7A1\history\XMUK-Demo 2\AUDCAD1.hst");
}
 
fly7680:

I tried to delete the file but I receive these errors:


Double backslash strings in Windows.
 
OK no errors but does not delete the file!!!
 
fly7680:
OK no errors but does not delete the file!!!

String are unicode in MT4, you need to use DeleteFileW.

 

I get the 4202 error:

4202

ERR_OBJECT_DOES_NOT_EXIST

Object does not exist

Reason: