run strategy tester from code?

 

hello, I would like to know if is it possible to run the strategy tester from code,

or do some workaround to get the net profit for an expert advisor. I only need the net profit.


Thanks in advance, Cyberglassed.

 
cyberglassed:

hello, I would like to know if is it possible to run the strategy tester from code,

or do some workaround to get the net profit for an expert advisor. I only need the net profit.


Thanks in advance, Cyberglassed.

You can't run the Strategy Tester from code. What you can do is run it from command line, see this topic https://www.mql5.com/en/forum/13468.

Can you explain what you are trying to do ?

 

Hi angevoyageur that would be a good option for me,

now I'm trying to test an EA from command line. With this config file the terminal launches and

also connects to the server showing all available symbols live-changing the sell and buy prices.

But the EA test doesn't launch. My configuration file is as follows. 

Here I hided the login and password, but on the file I use they are set properly.

On the Expert variable I have tryed with and without the extension (.ex5) but no success.

My problem is that the testing doesn't launch.

What could be wrong?

Thanks in advance, Cyberglassed.

[Common]
Server=dc1.demo.mt5.alpari.co.uk:443
Login=????????
Password=???????
ProxyEnable=0
KeepPrivate=1
NewsEnable=0
CertInstall=0

[Tester]
Expert=Cyberglassed\EA001
Symbol=EURUSD
Period=M5
FromDate=2013.10.21
ToDate=2013.10.25
ForwardMode=0
ExecutionMode=0
Model=0
Deposit=200
Leverage=1:100
Optimization=0
Report=angel_results
ReplaceReport=1
ShutdownTerminal=0
 

Hi again, accidentally I have noticed that when I restart the computer and run the command:

"C:\Program Files\MetaTrader 5\terminal64.exe" /config:"D:\MT5\config.ini"

the tester starts automatically, but only in that circumstances. If I close the MT5 and rerun that command

the tester doesn't start automatically. Even If I close and open my user session again the tester doesn't start automatically.

Only when I restart or turn off and on the computer.

It is very strange from my point of view.

What could be wrong?

I use Windows 7.


Thanks in advance, Cyberglassed.

 
cyberglassed:

Hi again, accidentally I have noticed that when I restart the computer and run the command:

the tester starts automatically, but only in that circumstances. If I close the MT5 and rerun that command


Did you check that MT5 had actually terminated before running the command again ?
 

Hi RaptorUK,unfortunatelly I ran the tasklist command before and after the mentioned above command works and exported

the list to a file and the list of opened processes are the same, so I think the problem is not some processes keep opened,

do you have some other idea of what could be happening?


thanks, Cyberglassed

 
cyberglassed:

Hi RaptorUK,unfortunatelly I ran the tasklist command before and after the mentioned above command works and exported

the list to a file and the list of opened processes are the same, so I think the problem is not some processes keep opened,

do you have some other idea of what could be happening?

Try to get it working using the files from the other posts with a standard MT5 included EA,  once you have it working you can start changing settings and using your own EA . . .
 

Hi RaptorUK, I have uninstalled MT5  at all (from Program Files and removed all files from my user folder),

then I retryed with the configuration file on the end of this url:

https://www.metatrader5.com/en/terminal/help/start_advanced/start

(only changing some important values as login, password, server, etc.)

but not success, some other ideas?


Thanks.

 
cyberglassed:

Hi RaptorUK, I have uninstalled MT5  at all (from Program Files and removed all files from my user folder),

then I retryed with the configuration file on the end of this url:

https://www.metatrader5.com/en/terminal/help/start_advanced/start

(only changing some important values as login, password, server, etc.)

but not success, some other ideas?

Post your config file here please ( attached as files ) and I will try them . . .   als please post the command line you are using.
 
RaptorUK:
Post your config file here please ( attached as files ) and I will try them . . .   als please post the command line you are using.

Hi RaptorUK, here you have both files.

On a virtual machine with Windows XP I have installed MT5 and did the same try and I have the same behaviour, it is very curious.

With Windows XP the strategy tester works only if MT5 have not been started before after machine turn on (the same as on my normal Windows 7).

One thing I have noticed is that when the first start up of MT5 (after machine turn on) the symbol you specify for the tester on the config

file is correctly taken by the tester and it is on the select box of the tester (properly behaviour). But next times, when you run that command

that select box on the tester doesn't takes properly the symbol you specify on the tester, it takes the first symbol on the available list, in my case: AUDCAD,

when I have specified: EURUSD. The other parameters are taken correctly the next times you run the command but I think there is a problem with the symbol

and that behaviour occurrs exactly the same with Windows XP. That's what I'm  experiencing.


Thanks,  Cyberglassed.

Files:
 
cyberglassed:

Hi RaptorUK, here you have both files.

On a virtual machine with Windows XP I have installed MT5 and did the same try and I have the same behaviour, it is very curious.

With Windows XP the strategy tester works only if MT5 have not been started before after machine turn on (the same as on my normal Windows 7).

One thing I have noticed is that when the first start up of MT5 (after machine turn on) the symbol you specify for the tester on the config

file is correctly taken by the tester and it is on the select box of the tester (properly behaviour). But next times, when you run that command

that select box on the tester doesn't takes properly the symbol you specify on the tester, it takes the first symbol on the available list, in my case: AUDCAD,

when I have specified: EURUSD. The other parameters are taken correctly the next times you run the command but I think there is a problem with the symbol

and that behaviour occurrs exactly the same with Windows XP. That's what I'm  experiencing.

OK,  I've just done a little testing using the info you sent.

I have no problem with MT5 running each time I execute the following . . .

"C:\MT5Installs\terminal64.exe" /config:"C:\MT5Installs\MQL5\config.ini"

  . . . obviously my paths are a little different to yours,  I am running in Windows 7 Pro 64bit.

I was running EURUSD without any problems but when I changed the config.ini to GBPUSD the Strategy tester was still running with EURUSD,  when I investigated I found that GBPUSD could not be selected manually in the Strategy Tester.  This was easily rectified by going to the Market Watch ( Ctrl + M ) right clicking on any symbol and the clicking Show All   this allowed me to select GBPUSD in the Strategy Tester manually.  When I tried the command line with the config.ini  set to GBPUSD it executed correctly and the Strategy tester was started with GBPUSD.

Let me know if this helps or if I need to keep investigating . . . .

Reason: