//+------------------------------------------------------------------+ //| MT4Orders_QuickReport.mqh | //+------------------------------------------------------------------+ // Out to report all deals without filters & other options as on Report.mqh // Sample call from MT4Orders expert: QuickReport("report", true);// will save report to report.htm file and open it on browser (DLL required) // Sample call from Virtual library: // for (int v = 0 ; v <= VIRTUAL::Total(); v++){if (VIRTUAL::SelectByIndex(v)){QuickReport("report_"+(string)v, true, v);}} // will print report for each virtual tester. // Or call just to 2nd tester VIRTUAL::SelectByIndex(2)){QuickReport("report_2", true, 2);} // #define REPORT_BROWSER // Open report in browswer automatically. Require DLL. // By default MT4Orders_QuickReport use free google.charts, but you can use highcharts if you have rights. // #define USE_highcharts // You can download and try out all Highcharts products for free. Once your project/product is ready for launch, purchase a commercial license. https://shop.highcharts.com/ // for MT4 #ifndef __MQL5__ #property strict long OrderOpenTimeMsc( void ) { return(OrderOpenTime() * 1000); } long OrderCloseTimeMsc( void ) { return(OrderCloseTime() * 1000); } double OrderOpenPriceRequest( void ) {return(OrderOpenPrice()); } double OrderClosePriceRequest( void ) {return(OrderClosePrice()); } enum ENUM_ACCOUNT_MARGIN_MODE{ ACCOUNT_MARGIN_MODE_RETAIL_NETTING, ACCOUNT_MARGIN_MODE_EXCHANGE, ACCOUNT_MARGIN_MODE_RETAIL_HEDGING}; #define SYMBOL_CUSTOM (-1) #define ACCOUNT_MARGIN_MODE (-1) #define ACCOUNT_CURRENCY_DIGITS (-2) long AccountInfoInteger2( const int Property ){ switch (Property){ case ACCOUNT_MARGIN_MODE: return(ACCOUNT_MARGIN_MODE_RETAIL_HEDGING); case ACCOUNT_CURRENCY_DIGITS: return(2); } return(AccountInfoInteger(Property)); } #define AccountInfoInteger AccountInfoInteger2 #endif // #ifndef __MQL5__ // end for MT4 #include #ifdef REPORT_BROWSER #import "shell32.dll" int ShellExecuteW( int, string, string, string, string, int ); #import #import "Kernel32.dll" void GetLocalTime(ushort& time[]); #import #endif string GetLocalTimeS(){ #ifdef REPORT_BROWSER if((bool)::MQLInfoInteger(MQL_DLLS_ALLOWED)){ushort time[8];GetLocalTime(time); return StringFormat ("%d.%d.%d %d:%d:%d.",time[0], time[1], time[3], time[4], time[5], time[6])+IntegerToString((long)time[7], 3, '0'); }else #endif return (string)TimeLocal(); } static ulong TimeStartTest = ::GetMicrosecondCount(); static string TimeLocalStartTest = GetLocalTimeS(); static string TimeLocalEndTest; static datetime TestSartTime = ::TimeLocal(); ulong FirstRepStartTime=0; void QuickReport(string file_name, bool is_open_file_in_browser=true, int virtual_number=0, bool hide_account_and_name=false){// ulong RepStartTime = ::GetMicrosecondCount(); if(FirstRepStartTime==0){FirstRepStartTime=RepStartTime;TimeLocalEndTest=GetLocalTimeS();}//if more then one virtual testers out data, then save time first call string FileName="QuickReport\\"+file_name+".htm"; ResetLastError(); int f=FileOpen(FileName,FILE_READ|FILE_WRITE|FILE_CSV|FILE_ANSI,","); if(f!=INVALID_HANDLE){ FileWrite(f,QuickReport_HTMLTemplate()); FileWrite(f,""); FileClose(f); string BASEPATH_ = (::TerminalInfoString(TERMINAL_DATA_PATH) + "\\MQL5\\Files\\"); #ifndef __MQL5__ BASEPATH_ = (::TerminalInfoString(TERMINAL_DATA_PATH) + "\\MQL4\\Files\\"); #endif // #ifndef __MQL5__ Print("Quick Report saved to: "+BASEPATH_ + FileName); #ifdef REPORT_BROWSER if(is_open_file_in_browser){ if ((bool)::MQLInfoInteger(MQL_DLLS_ALLOWED)){ if (::MQLInfoInteger(MQL_TESTER)){if (!::MQLInfoInteger(MQL_OPTIMIZATION)){ shell32::ShellExecuteW(0, "Open", BASEPATH_ + FileName, NULL, NULL, 3);}} else{shell32::ShellExecuteW(0, "Open", BASEPATH_ + FileName, NULL, NULL, 3);} } } #endif }else{PrintFormat("Failed to open file %s, Error code = %d",FileName,GetLastError());} } string toStr(double v, int d){if(v==0.0){return "";} return DoubleToString(v,d);} int inArr(string v, string &a[], int len){for (int i = 0; i < len; i++){ if(a[i] == v){return i;}}return -1;} string QuickReport_HTMLTemplate(){ return "paginator sample\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" +"\n" #ifndef USE_highcharts +"\n" +"\n" #else //USE_highcharts +"\n" +"\n" +"\n" +"\n" #endif //USE_highcharts +"
\n" +"Orders Report
    
\n" +"
\n" +"

\n" +"

\n" +"

\n" +"Options
\n" +"Set Forward Test Date:
\n" +"
\n" +"
\n"; }