Download MetaTrader 5

Ubzen OOP Project with MAE

To add comments, please log in or register
Ubzen
5394
Ubzen 2013.11.14 23:53 
Ok, I cannot get self-motivated enough to complete this project on_my_own and thats why I'm starting this thread.

The Objective: Create an MAE( Maximum Adverse Excursion ) generator which reads mt4 && mt5 report. The mql_code will utilize || test the new OOP features being incorporated into the mql4 language. *** Just fyi... I do intend to sell (perhaps expanded version) upon the mql4|mql5 market. The (basic version) codes would also be provided within this thread, why? because you guys are sooo cool, and no-one read this forum ;)

The Technical: The goal is reading those reports but I also want it reading those .csv reports generated by the signals. Therefore its more accurate to say it's being designed to read .csv files in the format of the signals report. I'll need to convert the html>.csv. And then the .csv > orders*. Because this must work with mt4 and mt5, I've decided to use the strategy_tester to generate the mae_per_deal. I do-not want to use dll's.

Any comments and || suggestion welcomed.
Ubzen
5394
Ubzen 2013.11.15 00:18  
Because the similar syntax of the OOP code between mql4 && mql5. And the fact that the mql_OOP is within early stages of development, I've decided to proceed with the mql5 version first. Then incorporate / modify the codes to work with mql4_OOP. I'm an OOP newbie and doubt that my codes would be adopted by any professional programmer. I intend to include allot of software development concepts which serves as a learning platform for myself. Should someone more experienced see something which could be improved please post :).
Uwe Goetzke
1484
Uwe Goetzke 2013.11.15 06:00  

I might be interested ;)

So you want to determine from trading history the better stop levels for the trading "expert"?

A list with the currency and settings used?   

I have plenty of OO experience...

Uwe 

Ubzen
5394
Ubzen 2013.11.15 07:38  

@ugo58: Yeah definitely could help with better stop levels. The applications for MAE is quite endless for trading analysis.

We've seen so many systems in Signals etc, which leaves trades open for extended draw-down hoping it comes back into profit. These strategies do-not show the amount of risk || draw-down associated with the strategy. This'll help put an end to that.

We talk allot about the Coin-Toss analysis on the forums: Examples:

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

https://www.mql5.com/en/forum/11121#comment_449360.

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

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

https://www.mql5.com/en/forum/119244/page5#857663.

The problem is Avg_Loss doesn't provide a good measure of risk. The Avg_DrawDown per Deal (in mql5_words) is what I'm trying to capture.

A list of "currency and settings used" is one I haven't really taught of. Could you expand upon what you have in mind?

Ubzen
5394
Ubzen 2013.11.15 08:02  

I have some questions:

-1) It seems mql5 doesn't like the it when you place files directly into the Tester Folder. Something like C:\MetaTrader 5\Tester\Agent\MQL5\Files. So therefore I had to place the files in the C:\MetaTrader 5\MQL5\Files and then tell the Expert_Advisor the filename is "Report.htm". Is this really how it Needs to be done?

2) If number one is the case, how is it possible to save files during testing into the C:\MetaTrader 5\MQL5\Files folder?

3) Will the tester generally delete any files within the Tester\Files folder when upon Start_Up?

4) If all the above is True, I do-not really like what I'm seeing. Any Ideas about the easiest ways to get non-programmers to place a Report_File into the File* folders? With UAC enable, I think the paths gets confusing, am I wrong here?

5) metaQuotes provides another option with NamePipes, of-course thats the next thing I'm gonna research. Anyone have a better experience with that? Any Limitations vs the File()?

6) metaQuotes provides a healthy number of fileOpen classes however allot of the examples I've seen do-not utilize the Standard Classes ... any ideas why?

Ubzen
5394
Ubzen 2013.11.15 10:29  

Already.... Little baby step here.

For someone following this thread and learning OOP like me, Attached is my Little "Hello_World" like program in mql5 OOP. There isn't much there but I think I got to print the Handles Both as Object and Data. Objects sure are funny, they stack_up these Methods which wasn't quite obvious they had, yet I still cannot just Print them directly. I feel less powerful but still excited :)

Is there anything which I'm doing really wrong?

At this time, I'll like to Switch Gears and research "Self Documenting Codes", "Version Tracking", "Unit_Testing". Man, I still don't have any Idea how I want to deal with "Error Handling" Sigh. There are some Articles I have in mind. If you guys can recommend other things please do.

Files:
Folder_A.zip 1 kb
Uwe Goetzke
1484
Uwe Goetzke 2013.11.15 12:05  
As I travelling around today, I will keep it short. I think the MAE may depend on the strategy of entering and leaving the market. The simple case is entering and waiting for the exit condition. Both depend on a signal generation whoose parameters I would like to record withe currency involved. If you have different parameters you have a different strategy. As MAE and MFE are depending on the strategy I would like Record Information about the used strategy if possible. If you use your own that could be achieved otherwise you could take comment from the entering position. More later if I am on computer with a real keyboard again... Uwe
Ubzen
5394
Ubzen 2013.11.15 22:15  
ugo58:
As I travelling around today, I will keep it short. I think the MAE may depend on the strategy of entering and leaving the market. The simple case is entering and waiting for the exit condition. Both depend on a signal generation whoose parameters I would like to record withe currency involved. If you have different parameters you have a different strategy. As MAE and MFE are depending on the strategy I would like Record Information about the used strategy if possible. If you use your own that could be achieved otherwise you could take comment from the entering position. More later if I am on computer with a real keyboard again... Uwe
Sounds Interesting. Hope to hear more about it when you're at a keyboard. How do you plan on analyzing the parameter data?
Uwe Goetzke
1484
Uwe Goetzke 2013.11.16 10:08  

Well, I did not ment to analyse the parameters but to keep  a way to differ the trading logic used. But this may some steps to far ahead.

To keep it easy one could take care that only one trading strategey takes place at a certain time and filter according to start and end time.

(I am developing an multicurrency EA with adaptive strategies therefore I see the world more complicated ;)

Did you read this article?

Ubzen
5394
Ubzen 2013.11.16 11:01  

Woah... That article sure looks great . Thanks Man. I'm sure your complexity will pay off in the end. 

Uwe Goetzke
1484
Uwe Goetzke 2013.11.16 12:29  

As I would like to continously adapt the MAE, MFE on a running expert I think the code to calculate the values should be based on a common structure.

Check this article, too.

So the code could be indepent wherever the deals are read from.

For this kind of calculation it might sufficent to record only the exits. If you have an in/out than split the record into an "in" and "out" record.

So you could use the struct of this article as a basis model for the deals (fill the same structure from the html-parser and write to csv):

//--- take over Deal properties from the history and offer a method to read from and dump to a CSV file
struct HistoryDealProperty
  {
   string            symbol;     // Symbol
   string            comment;    // Comment
   ENUM_DEAL_TYPE    type;       // Deal type, SELL or BUY
   double            price;      // entry price
   double            profit;     // Profit/Loss
   double            volume;     // Volume
   double            swap;       // Swap
   double            commission; // Commission
   datetime          entrytime;  // entry time of the deal
   datetime          exittime;   // exit time of the deal, on exit fill both values below
   double            mae_price;  // Maximum Adverse Excursion price, filled on out
   double            mfe_price;  // Maximum Favorable Excursion price
  };
Mathematics in Trading: How to Estimate Trade Results - MQL4 Articles
  • www.mql5.com
Mathematics in Trading: How to Estimate Trade Results - MQL4 Articles: automated forex trading
12
To add comments, please log in or register