Searching for script creating more detailed report with more statistics after testing EA

 

Hi everyone,

I'm looking for some script to generate more detailed report.

I need more statistics in report, sharpe ratio, average time of trade, intra trade drawdown etc

Has anybody found something like that? any script, library etc???

 
There could be a few by our very own Rosh. Here's one for example on MAE/MFE. And here's his article on the others Here. Those should give you motivation to write your own scripts for Ms-Excel. I'm trying to figure out how to create them myself at this time.
 

hihi ubzen

I will take a look at that. I need report with statistics of every single trade or cumulative of all the trades i mean average time of trade (I know I can calculate it from history) but also maximal intra dd of the trade, maximal potential profit of a trade etc..

I know more less how to write it will take me a loooot of time because its a statisticas of all price movements between open a trade and closing the trade.

ubzen:
There could be a few by our very own Rosh. Here's one for example on MAE/MFE. And here's his article on the others Here. Those should give you motivation to write your own scripts for Ms-Excel. I'm trying to figure out how to create them myself at this time.
 
Personally, I dump trade info to CSV and use excel to create the statisctics I want. I check for closed orders and update the csv when an order closes. I also store info like original stop loss and trade type etc in the comment field and seperate each item with ; so I can parse it in excel. Far easier to use excel than MQ4 for this kind of data analysis imho.

This is a code snippet out of my EA so it might not compile as is, but you get the idea

hth

V

EDIT: Noticed a bug on the MAE/MFE calc.

//------------------------------------------------------------------
   //Check for closed trades and export details    
   string file_name=DoubleToStr(magic,0);
   static int LastHistoryCount;
   
   if (LastHistoryCount!=OrdersHistoryTotal())
      {
      for(int n = LastHistoryCount ; n < OrdersHistoryTotal(); n++)
         {
         OrderSelect(n, SELECT_BY_POS, MODE_HISTORY);
         if (OrderSymbol()==Symbol() && OrderType()<=1 && OrderMagicNumber()==magic)
            {
            double open=OrderOpenPrice();
            double close=OrderClosePrice();
            datetime tm=OrderOpenTime();
            int   tmshft=iBarShift(NULL,0,tm);
            double   mae=iLow(NULL,0,iLowest(NULL,0,MODE_LOW,tmshft,0));
            double   mfe=iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,tmshft,0));
            string date=TimeToStr(OrderOpenTime(),TIME_DATE|TIME_MINUTES);
            int    type=OrderType();
            string notes=OrderComment();
            double profit=OrderProfit();
            int    id=OrderTicket();
            double stop=OrderStopLoss();
            double target=OrderTakeProfit();
            int handle=FileOpen(file_name+"tradhist.csv",FILE_CSV|FILE_READ|FILE_WRITE,';');
            if (handle>0)
               {
               FileSeek(handle, 0, SEEK_END);
               FileWrite(handle, id,date, type, open,close,profit,target,mae,mfe,notes);
               FileClose(handle);
               handle=0;
               }
            }  
         }
      }
   LastHistoryCount=OrdersHistoryTotal();
 

Thank You Viffer, I think I will use it but I'm thinking if my mae and mfe will be calculated correctly because i use 1H bars and very often I open a trade and close inside one bar...


Viffer:
Personally, I dump trade info to CSV and use excel to create the statisctics I want. I check for closed orders and update the csv when an order closes. I also store info like original stop loss and trade type etc in the comment field and seperate each item with ; so I can parse it in excel. Far easier to use excel than MQ4 for this kind of data analysis imho.

This is a code snippet out of my EA so it might not compile as is, but you get the idea

hth

V

 
In that case ladygaga maybe back-testing with 1_Hour_Tick_Mode (which means 1-minute) data would be best for this kind of test. Mt4 back_tester is slow, I can only imagine that these types of file_write would slow it down even more. I would run it before bed_time and deal with it the next day.
 

yeah ubzen but I'm thinking if I can calculate correctly mae and mfe from Your formula because: When I have 1H bar and lets say i enter the trade at 00:26 and close it at 00:53 my mae and mfe could be equal to high and low of that bar but only in some cases...

because functions like iLow and iLowest gives me only low value of one bar or few but I need a lowest value between lest say 26 and 53 minute....

Maybe I can test in on 1H mode and use iLowest with timeframe 1M?????


other way could be to write a function:

if (trade is open)

if( Ask> double intra_high)

intra_high=Ask etc...

When trade is over we have intra high intra low and other things...




ubzen:
In that case ladygaga maybe back-testing with 1_Hour_Tick_Mode (which means 1-minute) data would be best for this kind of test. Mt4 back_tester is slow, I can only imagine that these types of file_write would slow it down even more. I would run it before bed_time and deal with it the next day.
 

Well anything is possible :)

Unlike my good friend V over there, I haven't had the time to program any statistical information into a Custom Report yet. I still have my hands full trying to learn how to work with Html files. It would be nice if someone could just post a script or ea within this thread which dumps out Sharpe ratio, Average hold time, Holding period returns, Intra trade draw_down, Standard deviation, Variance, Maximal/Relative DD, Z-Score, Linear Regression/Correlation, Risk_of_Ruin, Return_on_Investment, Optimum-f, N-Zero, MAE/MFE...etc. I've searched through the Code-Base on this site. If no such tool have pop-up yet, I doubt the miracle is gonna happen here. 

 

Yes, what you suggest sounds like a good idea. However, the only enemy here is time. Who's gonna spend the time to program that and how fast is it gonna run in the back_tester? I'm gonna program my_own, to serve my_own purpose when I have the time. If it's gonna take a year then so be it. Other solutions could be downloading mt5, I hear the report is pretty extended but I do-not-know to what extend because it'll not install on my computer.

 

Haven't tried but I guess the 1 minute route would work...

int      tmshft=iBarShift(NULL,1,tm);
double   mae=iLow(NULL,1,iLowest(NULL,1,MODE_LOW,tmshft,0));
double   mfe=iHigh(NULL,1,iHighest(NULL,1,MODE_HIGH,tmshft,0));
I think, so long as you get the raw data out, most of those metrics are far easier in excel. That's the route I'm taking anyway. Whilst I'm sure it's possible, there would be too much faffing around with arrays to do this effectively in MQ4 imho. And tbh I've not seen a significant difference in test times with file write.
 

....And tbh I've not seen a significant difference in test times with file write.

Thats nice to know V. I'm in no way shape or form suggesting doing this with Mql. I'm going the same route as you, export as CSV, put in Excel and manipulate it there. Seem from the hints we get around here. Thats how it's done.

 
yeah guys it could be great to have detailed report with all statisctics and additionaly to have opportunity to optimize it by for example lowest stddev etc...
ubzen:

....And tbh I've not seen a significant difference in test times with file write.

Thats nice to know V. I'm in no way shape or form suggesting doing this with Mql. I'm going the same route as you, export as CSV, put in Excel and manipulate it there. Seem from the hints we get around here. Thats how it's done.

Reason: