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.
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.
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.
https://www.mql5.com/en/forum/107674

- 2017.03.23
- www.mql5.com
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"); }
I tried to delete the file but I receive these errors:
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 |

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use