Opens *.htm or *.html pages within the default browser.
Performs a preliminary safety examine:
- If the file extension shouldn’t be .htm or .html, it stops working.
- Opens pages solely from the file sandbox: from the /MQL5/Recordsdata/ or /Widespread/Recordsdata/ folder.
Utilization:
- Create an HTML file along with your Professional Advisor or script and reserve it to /Recordsdata/ folder.
- Then name this indicator with the trail from the /Recordsdata/ folder to the specified file and the Widespread or MQL5 folder sort indicator.
Instance code for opening an HTML web page:
int HTMLOpen=-1; void Open(string file,bool isCommon=true){ Â Â if(HTMLOpen!=INVALID_HANDLE){IndicatorRelease(HTMLOpen);} Â Â HTMLOpen=iCustom(NULL,0,"HTML_Open.ex5",file,isCommon); } Open("check.htm", true); Open("test1.htm", true);
After that, the web page will open within the browser.
The “HTML_Open” indicator code is small, and anybody can examine its safety:
#property indicator_chart_window #property indicator_plots 0 sinput string file; sinput bool isCommon; int OnInit() { OpenHTML(); return(INIT_FAILED); } int OnCalculate(const int32_t rates_total, const int32_t prev_calculated,const int32_t start,const double &value[]){return(rates_total);} #import "shell32.dll" Â Â int ShellExecuteW( int, string, string, string, string, int ); #import void OpenHTML() { Â Â int len= StringLen(file); string web page; Â Â if(StringSubstr(file, len-4) !=".htm" && StringSubstr(file, len-5) !=".html"){ Â Â Â Â Â Â Alert("Solely .htm or .html pages allowed! Rename the web page."); Â Â } Â Â if ((bool)::MQLInfoInteger(MQL_DLLS_ALLOWED)){ Â Â Â Â Â Â if(isCommon){ Â Â Â Â Â Â Â Â web page = ::TerminalInfoString(TERMINAL_COMMONDATA_PATH) + "Recordsdata"+file; Â Â Â Â Â Â }else{ Â Â Â Â Â Â Â Â web page = ::TerminalInfoString(TERMINAL_DATA_PATH) + "MQL5Recordsdata"+file; Â Â Â Â Â Â } Â Â Â Â Â Â shell32::ShellExecuteW(0, "Open", web page, NULL, NULL, 3); Â Â }else{ Â Â Â Â Â Â Alert("DLL not allowed! Cannot to open HTML web page in browser. Enable the DLL within the settings."); Â Â } }
So as to add an indicator to the terminal:
- Obtain the hooked up file
- Or create a brand new indicator, title it “HTML_Open” and paste the code from this web page into it.
- Compile it.
I ask different programmers to touch upon the indicator’s safety. In my view, all vulnerabilities have been closed.
A suggestion for MetaQuotes builders: please add a operate for opening HTML pages within the terminal with related checks.
