Changing Objects properties in MT5 Tester

 
Hi developers, can we change EDIT_OBJ in MT5 tester?
What about detecting mouse movement?
 
Fatemeh Ameri: Hi developers, can we change EDIT_OBJ in MT5 tester? What about detecting mouse movement?

In the Strategy Tester, only custom events can be handled by the OnChartEvent() handler in an EA.

Event Handling in the Tester

...

When testing in an EA, we can handle custom events using the OnChartEvent() function, but in the indicators, this function can not be called in the tester. Even if the indicator has the OnChartEvent() event handler and this indicator is used in the tested EA, the indicator itself will not receive any custom events.

During testing, an Indicator can generate custom events using the EventChartCustom() function, and the EA can process this event in the OnChartEvent().

 
Fernando Carreiro #:

In the Strategy Tester, only custom events can be handled by the OnChartEvent() handler in an EA.

Hi Fernando.
Thank for your replay.
But I am not sure if my answer is yes or no.

Can we change Edit box in MT5 Tester? (using custom events)
Can we detect mouse movement (lapram,dparam) in MT5 Tester?(using custom events)
Documentation on MQL5: Working with Events / EventChartCustom
Documentation on MQL5: Working with Events / EventChartCustom
  • www.mql5.com
EventChartCustom - Working with Events - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fatemeh Ameri #: Hi Fernando. Thank for your replay. But I am not sure if my answer is yes or no. Can we change Edit box in MT5 Tester? (using custom events). Can we detect mouse movement (lapram,dparam) in MT5 Tester?(using custom events)

Please read the documentation. Custom events are those with the custom_event_id "CHARTEVENT_CUSTOM+N".

All other event types are not supported in the tester. That means you will NOT be able to use keystroke events, mouse events, object events, or any other chart events, except for custom events.

So obviously, editing an EDIT_OBJ may require reacting to keystroke, mouse, and object events which are not supported by the tester at this time. Is that clear now?

EDIT: There are however some workarounds available for simple actions like mouse clicks on buttons. Anything else requires more complex workarounds that may or may not be possible.

Forum on trading, automated trading systems and testing trading strategies

OnChartEvent() not called in Expert Advisor (EA)

Fernando Carreiro, 2016.05.21 22:13

As GumRai has stated, when testing EA's, the "OnChartEvent()" does not work (it only works in "real-time", not in the "Strategy Tester").

However, depending on what kind of Chart Event you are trying to implement, some of them can be "simulated" with some extra code. In the following post, I used some code to simulate and check when a button is clicked: https://www.mql5.com/en/forum/149901

Forum on trading, automated trading systems and testing trading strategies

Chart Event For MT4 Backtester

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;
}
 
Fernando Carreiro #:

Please read the documentation. Custom events are those with the custom_event_id "CHARTEVENT_CUSTOM+N".

All other event types are not supported in the tester. That means you will NOT be able to use keystroke events, mouse events, object events, or any other chart events, except for custom events.

So obviously, editing an EDIT_OBJ may require reacting to keystroke, mouse, and object events which are not supported by the tester at this time. Is that clear now?

EDIT: There are however some workarounds available for simple actions like mouse clicks on buttons. Anything else requires more complex workarounds that may or may not be possible.

Yes, This is now sound and clear, Thank you man, You are always helping.