Discussion of article "Developing a cross-platform grider EA (part III): Correction-based grid with martingale"

 

New article Developing a cross-platform grider EA (part III): Correction-based grid with martingale has been published:

In this article, we will make an attempt to develop the best possible grid-based EA. As usual, this will be a cross-platform EA capable of working both with MetaTrader 4 and MetaTrader 5. The first EA was good enough, except that it could not make a profit over a long period of time. The second EA could work at intervals of more than several years. Unfortunately, it was unable to yield more than 50% of profit per year with a maximum drawdown of less than 50%.

The "Recovery factor" column is of most interest for us. The column value shows the ratio of a profit obtained by the EA to the maximum drawdown, i.e. recovery factor = profit/maximum drawdown. Thus, the greater the value, the more profitable the EA becomes on a tested instrument. The test period should also be considered for the correct comparison.

The test period for Forex comprises 9 years, while for a stock market it is 6 years. Thus, for example, the recovery factor of 9 for Forex is equal to 100% of profit per year, while for stock market instruments, it is equal to 150% of profit per year.

The balance graphs are provided below.

USDCAD:

Entry by the previous bar, USDCAD

NZDUSD:

Entry by the previous bar, NZDUSD

Author: Roman Klymenko

 

Thank you for the excellent work!  It is very much appreciated.

--Dave

 
i have tested your EA and saw that is a too risky martingale.
 

Every time I try to test this on historical data I get:

2019.08.17 20:38:02.707 2018.11.18 22:23:30   failed market sell 0.01 XXX [Unsupported filling mode]

It happens for any symbol I choose (FX or Stocks). No trading is performed. What could be the problem?


 
Ben Shapiro:

Every time I try to test this on historical data I get:

2019.08.17 20:38:02.707 2018.11.18 22:23:30   failed market sell 0.01 XXX [Unsupported filling mode]

It happens for any symbol I choose (FX or Stocks). No trading is performed. What could be the problem?


You may have a try to modify the "Order filling mode" input parameter. Let it meet the spec of the symbol of your broker.

How to check the filling mode of the symbol:

Go to "Market Watch" -> Select symbol and right click it ->Click the "Specification..." menu item -> Check the "Filling" description.

 
Ben Shapiro:

Every time I try to test this on historical data I get:

2019.08.17 20:38:02.707 2018.11.18 22:23:30   failed market sell 0.01 XXX [Unsupported filling mode]

It happens for any symbol I choose (FX or Stocks). No trading is performed. What could be the problem?


Read the source Luke!

switch(useORDER_FILLING_RETURN){
   case FOK:
      mrequest.type_filling = ORDER_FILLING_FOK;
      break;
   case RETURN:
      mrequest.type_filling = ORDER_FILLING_RETURN;
      break;
   case IOC:
      mrequest.type_filling = ORDER_FILLING_IOC;
      break;
}

The code is very nice. Choose your filling mode. Broker friendly :)

 
Arthur Albano:

Read the source Luke!

The code is very nice. Choose your filling mode. Broker friendly :)

The code is really neat for a cross-platform, with time-series and all, BUT, I am trying to dig which Ask/Bid price my MT4 tester (build 1260) gets for this code to open trades. Each attempt of OrderSend ends with error 138 (New Prices), as if the MqlTick structure produces a wrong Ask/Bid for the tick?? or is it pulling the data from alt. timeframes? - I ran it at all the same timeframes as the operational tf, and it's still the same.

Does anybody here who tried the EA, experience similar problem and what may be the reason for error 138 in the tester?

Also, as the problem above, filling an order at market price (as could be the only option for a broker/instrument) doesn't seem an option in this EA, at least for MQL4 compillation:

#ifdef __MQL5__ 
   #include <Trade\Trade.mqh>
   CTrade Trade;

   enum TypeOfFilling // Filling Mode
     {
      FOK,//ORDER_FILLING_FOK
      RETURN,// ORDER_FILLING_RETURN
      IOC,//ORDER_FILLING_IOC
     }; 
   input TypeOfFilling  useORDER_FILLING_RETURN=FOK; // Order filling mode
#endif 

(but I shouldn't show my arrogance by asking if such a choise is required for MT5 platform... ;-)


Also, not being a programmer myself, I came across a sample of code where it is postulated that ..'Running on every incoming tick is mandatory for strategy tester, but real-time processing is best onTimer event - standard 200 ms.'   How does this may affect the EA performance, particularly a multi-timeframe like this one?

Thank you forany comment on the above.

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
rmshau:

The code is really neat for a cross-platform, with time-series and all, BUT, I am trying to dig which Ask/Bid price my MT4 tester (build 1260) gets for this code to open trades. Each attempt of OrderSend ends with error 138 (New Prices), as if the MqlTick structure produces a wrong Ask/Bid for the tick?? or is it pulling the data from alt. timeframes? - I ran it at all the same timeframes as the operational tf, and it's still the same.

Does anybody here who tried the EA, experience similar problem and what may be the reason for error 138 in the tester?

Also, as the problem above, filling an order at market price (as could be the only option for a broker/instrument) doesn't seem an option in this EA, at least for MQL4 compillation:

(but I shouldn't show my arrogance by asking if such a choise is required for MT5 platform... ;-)


Also, not being a programmer myself, I came across a sample of code where it is postulated that ..'Running on every incoming tick is mandatory for strategy tester, but real-time processing is best onTimer event - standard 200 ms.'   How does this may affect the EA performance, particularly a multi-timeframe like this one?

Thank you forany comment on the above.

This topic is about MQL5, you don't seem to know what platform you are using.

Anything concerning MT4 should be posted in the MT4 section.

Reason: