I'm new to coding, however i turned your code into an EA. And the results of the print (in back-test) because the market is closed and i have no ticks coming in is as follows:
If that's not the result you're expecting, maybe you can send a print screen of the print result you're getting. Someone with more experience might need more info to determine whats going on.
static's are not reinitialized at the deinit/init sequence. So the variable started at 10, and every test case times every tick incremented it.
Don't depend on non-read-only static's being initialized properly, set them in init.
When I choose the model of the tester as "Open price only", I can get the expected result, i.e. 20,30,..... But when I change the model to "Every tick", then the results become 348800,348810,..... like i mentioned before. I don't know what wrong is goning on.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
int tempFun()
{
//----
static int temp=10;
temp=temp+10;
//----
return(temp);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int temp=tempFun();
Print("the temp =",temp);
return(temp);
}
===========
It seems that the satic variable 'temp' is not initialized. the printed temp is something like 348800,348810 ......
Any help is very appreciated.