Download MetaTrader 5

OffLine Debug/ OnTick() emulator

To add comments, please log in or register
Marcelo Coutinho
1201
Marcelo Coutinho  

Hi,

Can someone please tell me if there is any option on MT5 that allows me to Debug a EA when the market is closed ?

I was wondering is there is any way to "send a tick" to the EA based on a market data.

Thank you

MRC 

Rodrigo Malacarne
Moderator
10258
Rodrigo Malacarne  
YouTrade:

Hi,

Can someone please tell me if there is any option on MT5 that allows me to Debug a EA when the market is closed ?

I was wondering is there is any way to "send a tick" to the EA based on a market data.

Thank you

MRC 

You can try to put parts of code inside the event handler OnTimer( ). Of course it won't send any order to the market, however, functions involving copy of data and plots of indicators will work normally inside OnTimer( ). Of course it's not the best solution, however if you use it together with the Strategy Tester, it helps you do decrease significantly the development time of your code.
Marcelo Coutinho
1201
Marcelo Coutinho  
Malacarne:
You can try to put parts of code inside the event handler OnTimer( ). Of course it won't send any order to the market, however, functions involving copy of data and plots of indicators will work normally inside OnTimer( ). Of course it's not the best solution, however if you use it together with the Strategy Tester, it helps you do decrease significantly the development time of your code.
Thank you
Alexander Piechotta
7055
Alexander Piechotta  

With the help of WinApi you can try it.

Here is an example for MetaTrader 4:

/**
* MT4/experts/scripts/ticks.mq4
* send a fake tick every 200 ms to the chart and
* all its indicators and EA until this script is removed.
*/

#property copyright "© Bernd Kreuss"

#import "user32.dll"
   int PostMessageA(int hWnd, int Msg, int wParam, int lParam);
   int RegisterWindowMessageA(string lpString);
#import

int start(){
   int hwnd = WindowHandle(Symbol(), Period());
   int msg = RegisterWindowMessageA("MetaTrader4_Internal_Message");
   while(!IsStopped()){
      PostMessageA(hwnd, msg, 2, 1);
      Sleep(200);
   }
}

//+------------------------------------------------------------------+
Alain Verleyen
Moderator
32821
Alain Verleyen  
FinGeR:

With the help of WinApi you can try it.

Here is an example for MetaTrader 4:

That doesn't work for MT5.
Rogerio Figurelli
Moderator
42444
Rogerio Figurelli  
YouTrade:

Hi,

Can someone please tell me if there is any option on MT5 that allows me to Debug a EA when the market is closed ?

I was wondering is there is any way to "send a tick" to the EA based on a market data.

Thank you

MRC 

Hi Marcelo, what about Strategy Tester to do it using common functions like Print(), Comment(), etc?

Or are you talking about the MT5 debugger specifically? 

Marcelo Coutinho
1201
Marcelo Coutinho  
figurelli:

Hi Marcelo, what about Strategy Tester to do it using common functions like Print(), Comment(), etc?

Or are you talking about the MT5 debugger specifically? 

Debugger specifically :(
To add comments, please log in or register