Lot sum after EA test / Avoid "CLOSE AT STOP"

 

Hello,

1. HOW TO GET INFORMATION FROM TRADES GENERATED BY EA TEST ?

Let's test an EA and then "OPEN CHART". On this chart we can see all orders made by the EA.

To get custom information for this test, I would write a script to get the sum of all lots' order? EXAMPLE: 2 trades at 1.0 lot, 2 trades at 5.0 lots -> sum=12 lots. I think we cannot use OrderLots( ) function because trades (generated by EA durring a test) are not stored in the history pool.

So, how to get information on trades displayed in this chart? Could you help me to write the script?

May be, it is easier to get this information (time, price) from Trendline graphical objects, because each Trendline represents a trade. In this case, how to get the lot value of the trade?

2. HOW TO AVOID "STOP AT CLOSE" RESULTS DURING EA TEST ?

My historical data (EURUSD) go from 1st JULY 2004 to 30th NOVEMBER 2006, and I select "Use date" 1st JULY 2004 to 30th JUNE 2006 (24 months) in my Tester settings.

How to avoid the "Close at Stop" we can see at the end of the Results tab in the Tester (for some EA). Why those trades give big loss?

Thanks.

 

Hi. Regarding your first point, there is no way for a script to extract trade info from the chart opened after a backtest. Even if a script could locate the buy and sell graphics, there would be no way to equate price data to these. But why go to all this trouble - it would be much easier to just add a function to the EA that would keep tabs on the executed trades.

As for your second point, as far as I'm aware, the large drawdown that follows the 'Close At Stop' is a result of poorly written EAs that open multiple orders and are 'forgotten' about until they are closed en-masse by MT at the end of the testdata. As most will probably be in the red, you get a large drawdown.

 
 

write an ea that doesent have huge drawdowns and this problem is avoided.

 

I think it would be possible to write code in the deinit() function, to write to file information the closed orders history; as I remember it, the deinit() function is called during testing before the final stop-out happens.

EDIT: deinit() seems to be called after stop-out, so this method won't work. As a variation, if the start() function keeps track of its last invocation time, then the deinit() function can still dump the closed history to file, and discard trades closed after the time of the last start() function invocation.

Reason: