Already discussed. You answered your question yourself.
I don't think anyone can add anything useful currently in that matter. Except MetaQuotes of course.
I'm seeing that events from OnChartEvent seem to work in the Indicator strategy tester, but it doesn't seem to be the case in the EA strategy tester.
The events from an EA code script are working correctly on a chart, but not inside the strategy tester in visual mode.
The goal is to simulate manual trading at a higher speed in the visual tester... but it appears it's not feasible.
Hopefully in the future a buy and sell simulator will be possible inside the strategy tester for testing strategies. It is already possible in tradingview.
The only work-around I know (that might still work), is to read a button's state directly and not rely on chart events.
It worked in MQL4, and probably also works in MQL5, but I have never tested it. Adapt the code below to MQL5 and try it and see if it still works.
If the OnTick() event handler is not sufficient, you can try the OnTimer() event handler too, but I have never tested that type of event in the tester environment and don't know how it is handled.
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; }
The only work-around I know (that might still work), is to read a button's state directly and not rely on chart events.
It worked in MQL4, and probably also works in MQL5, but I have never tested it. Adapt the code below to MQL5 and try it and see if it still works.
If the OnTick() event handler is not sufficient, you can try the OnTimer() event handler too, but I have never tested that type of event in the tester environment and don't know how it is handled.
Great! I was just about to give up, but since your approach looked like it should/could work, I had to make a test
Here's the small test, it seems to work perfectly
string idResetButtonObject = "ResetButton"; // button object //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { if(!ObjectCreate(0, idResetButtonObject, OBJ_BUTTON, 0, 0, 0)) { Print("Error creating button: ", GetLastError()); return(INIT_FAILED); } // Set button properties ObjectSetInteger(0, idResetButtonObject, OBJPROP_XDISTANCE, 10); ObjectSetInteger(0, idResetButtonObject, OBJPROP_YDISTANCE, 10); ObjectSetInteger(0, idResetButtonObject, OBJPROP_XSIZE, 100); ObjectSetInteger(0, idResetButtonObject, OBJPROP_YSIZE, 30); ObjectSetString(0, idResetButtonObject, OBJPROP_TEXT, "Reset"); ObjectSetInteger(0, idResetButtonObject, OBJPROP_COLOR, clrWhite); ObjectSetInteger(0, idResetButtonObject, OBJPROP_BGCOLOR, clrBlue); ObjectSetInteger(0, idResetButtonObject, OBJPROP_BORDER_COLOR, clrBlack); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Check reset button state | //+------------------------------------------------------------------+ void CheckResetButton() { // Verify the button exists if(ObjectFind(0, idResetButtonObject) < 0) { Print("Button '", idResetButtonObject, "' not found!"); return; } // Check if button is pressed if(ObjectGetInteger(0, idResetButtonObject, OBJPROP_STATE)) { Print("Button pressed!"); if(!ObjectSetInteger(0, idResetButtonObject, OBJPROP_STATE, false)) { Print("Error resetting button state: ", GetLastError()); } } } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { if(MQLInfoInteger(MQL_VISUAL_MODE)) { CheckResetButton(); } } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { ObjectDelete(0, idResetButtonObject); }
There are a couple of Market products that do just that, one of them is free last time a checked. Run a search and see if any fit your needs.
From the CodeBase:
SimSim (Simple Simulator v1.0)
Boris, 2020.08.21 15:54
Simple Simulator is designed to practice manual trading on historical data.While I haven't stated why, there's a reason why I wanted to use the EA visual tester and not the indicator tester.
I'm building a virtual simulator (essentially an EA code) which can load several indicators at once and create virtual buy and sell buttons to simulate live trading, and because ChartIndicatorAdd doesn't work in the indicator strategy tester, it's not convenient for my goal. I understand that some people are happy to simulate trading with just candles and no indicators, but I'm an indicator guy, and I want to see how effective some might be in combination
While I haven't stated why, there's a reason why I wanted to use the EA visual tester and not the indicator tester.
I'm building a virtual simulator (essentially an EA code) which can load several indicators at once and create virtual buy and sell buttons to simulate live trading, and because ChartIndicatorAdd doesn't work in the indicator strategy tester, it's not convenient for my goal. I understand that some people are happy to simulate trading with just candles and no indicators, but I'm an indicator guy, and I want to see how effective some might be in combination
While I haven't stated why, there's a reason why I wanted to use the EA visual tester and not the indicator tester.
Fair enough. You stated EA and Tester in the title of this thread, so my bad for posting a link to an indicator. Thank you for clarifying.
I'm building a virtual simulator (essentially an EA code) which can load several indicators at once and create virtual buy and sell buttons to simulate live trading, and because ChartIndicatorAdd doesn't work in the indicator strategy tester, it's not convenient for my goal. I understand that some people are happy to simulate trading with just candles and no indicators, but I'm an indicator guy, and I want to see how effective some might be in combination
If you're willing to be bothered by manually adding indicators, the SimSim indicator is merely a chart replay utility. I just loaded it and popped a moving average onto the chart, and both the bars and the moving average populated in synchronized simulated time.
Of course, "Simple" is built into the name of the indicator so I see what you mean.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I'm seeing that events from OnChartEvent seem to work in the Indicator strategy tester, but it doesn't seem to be the case in the EA strategy tester.
The events from an EA code script are working correctly on a chart, but not inside the strategy tester in visual mode.
The goal is to simulate manual trading at a higher speed in the visual tester... but it appears it's not feasible.
Hopefully in the future a buy and sell simulator will be possible inside the strategy tester for testing strategies. It is already possible in tradingview.