Make Buttons Work on MQL5 backtest

 

Hello friends

Please I'm trying to make my gui buttons work on MT5 backtest

Below is the code I used

Please help. Thanks

long   lparam = 0;
double dparam = 0.0;
string sparam = "";
	
sparam = "btnLines";
if( bool( ObjectGetInteger( 0, sparam, OBJPROP_STATE ) ) )
    OnChartEvent( CHARTEVENT_OBJECT_CLICK, lparam, dparam, sparam );

sparam = "btnActivate"
if( bool( ObjectGetInteger( 0, sparam, OBJPROP_STATE ) ) 
    OnChartEvent( CHARTEVENT_OBJECT_CLICK, lparam, dparam, sparam );
Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC", "Every tick" and "Every tick based on real ticks" using actual historical data.
 
Osazee Asikhemhen:

Hello friends

Please I'm trying to make my gui buttons work on MT5 backtest

Below is the code I used

Please help. Thanks

chart events are not supported in the strategy tester

 
Paul Anscombe #:

chart events are not supported in the strategy tester

That means I can't use buttons on strategy tester?

 
Osazee Asikhemhen #That means I can't use buttons on strategy tester?

Correct, but there is a partial work-around you can use. The code below is for MQL4 but you can adjust it for MQL5 ...

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;
}
 
And please don't add so much white-space in your posts. I have edited them and removed the extra blank lines.