what about asking service desk
i did think the forum is the place where such thinks must be ask.
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.
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; }
@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
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:
I am new to MQL4 programming. Is your code work on MQL4 as well?
I copied and pasted your code to my EA and it returned error "idResetButtonObject undeclared identifier". I changed "idResetButtonObject" to my button objects,
but still unable to use the buttons in back testing mode. I am not sure what I missed. Please assist. thank you.
I am new to MQL4 programming. Is your code work on MQL4 as well?
I copied and pasted your code to my EA and it returned error "idResetButtonObject undeclared identifier". I changed "idResetButtonObject" to my button objects,
but still unable to use the buttons in back testing mode. I am not sure what I missed. Please assist. thank you.
Yes it works on MQL4 but it is only a code sample/snippet. That is why I stated in my post: "something like this"! You have to adapt it according to your own needs!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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.