Download MetaTrader 5

Chart Event For MT4 Backtester

To add comments, please log in or register
Make profit on MQL5 services. It's easy!
Tradeing Trader
556
Tradeing Trader 2014.02.22 18:20 

Hello,

i had find out with the help of a Moderator that in the Strategy Tester the function OnChartEvent() does not work, i wanted to ask if somebody knows a trick or solution how i can get the chart event also in a Strategy backtest.

qjol
3243
qjol 2014.02.22 18:46  
Tradeing Trader
556
Tradeing Trader 2014.02.22 19:00  
qjol:
what about asking service desk

i did think the forum is the place where such thinks must be ask.
whroeder1
14519
whroeder1 2014.02.22 22:48  
How do you expect us USERS to help you when "OnChartEvent() does not work"? We can't fix OnChartEvent, only MQ can.
Alain Verleyen
Moderator
30743
Alain Verleyen 2014.02.23 09:52  
PlanandTrade:

Hello,

i had find out with the help of a Moderator that in the Strategy Tester the function OnChartEvent() does not work, i wanted to ask if somebody knows a trick or solution how i can get the chart event also in a Strategy backtest.


OnChartEvent() is not yet implemented in the Strategy Tester. What are you trying to do with it ?
Tradeing Trader
556
Tradeing Trader 2014.02.23 13:15  
angevoyageur:
OnChartEvent() is not yet implemented in the Strategy Tester. What are you trying to do with it ?

I have try to use buttons for trading during a backtest, but without the OnChartEvent() i cannot let the EA open a trade when i click a button, or is there another way to do that?
Taskin Osman
816
Taskin Osman 2014.03.12 18:42  
same problem here, implementing OnChartEvent in Tester is really important. Without backtesting its very hard to develop
Fernando Carreiro
2348
Fernando Carreiro 2016.04.03 15:40  

I know this is a an old thread, but I recently needed to debug some of my code that implements "buttons" to control certain aspects of an EA I was coding and had need for it to work in the Strategy Tester.

The solution I came up with was to check the button states on every incoming tick when the EA was in Visual Mode.

In other words, something like this:

void CheckResetButton()
{
   if( bool( ObjectGetInteger( 0, idResetButtonObject, OBJPROP_STATE ) ) )
   {
      Print( "Reset Button Clicked" );
      ObjectSetInteger( 0, idResetButtonObject, OBJPROP_STATE, false );
   }
}

void OnTick()
{
   // Only needed in Visual Testing Mode
   if( IsVisualMode() )
   {
      // Check Chart Buttons in Visual Mode
      CheckResetButton();
   }

   return;
}
Nikolay
170
Nikolay 2016.05.21 23:00  

@FMIC, nice simple solution.

@PlanandTrade, depending on your use case the following solution may or may NOT be possible (for one use case of mine it worked):

  • implement the reaction to the events in mqh file
  • for the Strategy Tester you implement an additional indicator that listens to the events and calls the reactions in the mqh file
  • for Real Time, you adjust your EA source code to use the mqh file event reactions or use the EA with the indicator
To add comments, please log in or register