EA testing problems and questions

 
Hi,
I am starting to develop an EA based on price action strategy and I have some doubts that I would like to ask for your help. At the moment, on the EA I want to search for pinbars with 3 EMAs (5,45,200) on the correct order on TF=Daily. When:
- Appears a long pinbar and EMA5>EMA45>EMA200 => BUY position with max of 2% capital;
- Appears a Short pinbar and EMA5<EMA45<EMA200 => SELL position with max of 2% capital;

At first tests, when I test the EA on TF = DL the EA closed the positions with very long losses or profits. Then I saw that the SL or TP was only activated when new bar opened and the results were not correct. I have tried to change the model to “Tick mode” but it take 20min to analyse each bar!

My questions:

- Can I use “Control Points” to monitor SL or TP more close? What does it mean “The results must not be considered”? What is control points?
- On the log file I see that when I print a double it sometimes appears with a lot of decimal symbols and I use normalizedouble? It’s a bug?
- Do I have to initialize all global variables on “OnInit” function? “DeOnInit” is used? On the book this is now explicit these 2 events…

- It is correct to set the SL and TP only after the OrderSend being sended and accepted?

I have tried to search on the forum and on the book for these bugs can I can't understand somethings. I know that most of you can makethe same EA with less code! :)

Thanks for your help.

 

Here is an article about optimisation :

Control Points (the nearest less timeframe)

Method of modeling control points is intended for crude estimate of Expert Advisors trading within a bar. To use this method, historical data of the nearest less timeframe must be available. In the some cases, the data available from a smaller timeframe do not completely cover the time span of the timeframe under test. If there are no data of a smaller timeframe, the bar evolution is generated on basis of predefined wave templates, as it was the case in the preceding third version of MetaTrader 3 Client Terminal.

As soon as historical data of the less timeframe appear, these are these data that are interpolated. However, the really existing OHLC prices of the less timeframe appear as control points. In the most cases, the results of tests of Expert Advisors by method of control points can be considered as estimated results only, not as final ones. Such results are of intermediate, estimated nature. The chart below shows how the on-hour bar of 2007.09.05 10:00 developed by method of control points.

https://www.mql5.com/en/articles/1511


this article also : https://www.mql5.com/en/articles/1385

 

In conclusion, let's consider some of the most frequently asked questions that new users usually have when testing EAs.

1. What causes difference in results of the same tests at different Dealing Centers?

The difference in test results at different Dealing Centers is caused by quote differences. Each broker has its own sources of quote feeds. This gives rise to differences in price, which is then reflected in test results.

2. Why do the same tests run at the same Dealing Center produce different results?

Different results obtained at the same Dealing Center may be caused by several reasons, the most common one being:

Floating spread - it has a quite strong impact on the results, especially when testing on lower time frames and using the EVERY TICK mode. The MetaTrader 4 Strategy Tester stores the last spread value. The spread might change in the next run and the test result will consequently be different.

https://www.mql5.com/en/articles/1385

 
ffoorr:

In conclusion, let's consider some of the most frequently asked questions that new users usually have when testing EAs.

1. What causes difference in results of the same tests at different Dealing Centers?

The difference in test results at different Dealing Centers is causedby quote differences. Each broker has its own sources of quote feeds.This gives rise to differences in price, which is then reflected in testresults.

2. Why do the same tests run at the same Dealing Center produce different results?

Different results obtained at the same Dealing Center may be caused by several reasons, the most common one being:

Floating spread - it has a quite strong impact on the results,especially when testing on lower time frames and using the EVERY TICKmode. The MetaTrader 4 Strategy Tester stores the last spread value. Thespread might change in the next run and the test result willconsequently be different.

https://www.mql5.com/en/articles/1385


Hi ffoorr,

 

Thanks  for your explanation and your links.

Normally I don´t use the www.mql5.com because I was thinking that it was only for MQL5... although there's lots of FAQs and articles for MQL4!

 Can you help on this questions?

- On the log file I see that when I print a double it sometimes appears with a lot of decimal numbers and I use normalizedouble? It’s a bug?

- It is correct to set the SL and TP only after the OrderSend being sended and accepted? Its a good practice?

Thanks for your help. Best regards.

 

Read the book and the documentation :

https://docs.mql4.com/convert

DoubleToString

Converting a numeric value to a text line with a specified accuracy

 
ffoorr:

Read the book and the documentation :

https://docs.mql4.com/convert

DoubleToString

Converting a numeric value to a text line with a specified accuracy

ffoorr,

 I didn't notice on one note that says when using the Print(), the output to Journal may contain a greater number of decimal places than expected! And in my case only happened sometimes and in the log file...

Thanks. Best regards 

Reason: