Hi,
I have done quite a bit of searching for information about this, have found lots about init() and when it is and isn't called etc. but not specifically relating to the strategy tester.
I have an EA that works fine on live account and demo but will not work in the tester. All I got was a "zero divide" error with no clue as to what part of the code it was coming from (line count here is in the thousands). After some time attempting to debug it, I worked out that init() is not called by the tester. It is called if I put the EA on a real time chart.
Is this normal behaviour for the strategy tester?
you might find you can avoid your divide by zero error by multiplying instead.
init() is called by the Strategy Tester. If you have a divide by zero error check all your divisions in your code, of course this is made easier if you have your / symbols with a space either side, then you can search for space /space and avoid the comments . . .
Thanks for the reply.
I already found the source of the divide by zero error and traced it back to the initialization of a global variable within init(). Then I edited the code to explicitly set a numeric value for the offending variable instead of the intended calculation. Still it threw the error. Setting a default value at declaration time in the global scope got rid of the divide by zero error, which is what led me to suspect that init()was not being called. I then added debug lines to init() to output variable values - none were executed. I then came to the (as it turns out incorrect) conclusion that init() was not being called.
After your reply I kept digging and then saw this:
if (!IsDllsAllowed()){
MessageBox("DLL imports must be allowed!");
return(-1);
}
It appears in init() before all the code that I was tearing my hair out trying to figure out why was not being executed. Can't believe I missed it. Must get more sleep :)
So now I have a new problem - how to allow DLL imports in the tester?
So now I have a new problem - how to allow DLL imports in the tester?
Don't worry. I found it. You have to set the global option to allow DLLs. The tester doesn't give the option at load time like you get when putting the EA on a live chart.
Don't worry. I found it. You have to set the global option to allow DLLs. The tester doesn't give the option at load time like you get when putting the EA on a live chart.
Yep . . . well done for persistence and listening.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have done quite a bit of searching for information about this, have found lots about init() and when it is and isn't called etc. but not specifically relating to the strategy tester.
I have an EA that works fine on live account and demo but will not work in the tester. All I got was a "zero divide" error with no clue as to what part of the code it was coming from (line count here is in the thousands). After some time attempting to debug it, I worked out that init() is not called by the tester. It is called if I put the EA on a real time chart.
Is this normal behaviour for the strategy tester?
Thanks.