There is no reason why that print statement shouldn't generate something.
If you add the indicator to a new chart, does it print (without having to change the timeframe)?
If so, it could be an issue of already having the indicator on a chart and then recompiling expecting to see the change.
Thanks for prompt comment, appreciate that.
Yeah! It prints below message either Load Template or Add Indicator.
20... ... EURUSD,M1: This Year1900
But as you know that code could give me " 2017 ".
//--- 2nd time edited
When I recompiling it shows correct result.
But I can't open MetaEditor that I recompiling when I try to add indicator and load template... I hope you understand what I mean.
Possibly the reason it is giving you the "wrong" year is OnInit() is running before you've connected to your broker.
Year() is based on server time... if there isn't a connection, it doesn't know the year.
Compare it with:
I know for sure OnInit() and OnCalculate(...) needs different code style...I will try rewrite my indicators again.( it's possible I will give up )
Thanks for your comment.
I think I could write a code for first delete all indicator objects then rewrite them.I tried like below code. But I have doubt that method.
Q: Is that method enough to delete all objects of indicator, please?
Any advice would be better thanks.
ObjectsDeleteAll( 0, prefix );
// then all my indicator code here...
Cool! Thanks for your reply.Now, I just need to see how will work my indicator next day.
( p.s I do not like to test my indicator with Tester )
( Once I told )
I use below method code for my few indicators, that indicators have not any problems, but only have a problem when I start MT4 platform which is that indicators needs to restart platform that updates just for correct values. I face with that issue ONLY once each day.
Q: So, is below part of code can cause a problem that can't updates correct values, please?
Thanks in advance.
datetime a = iTime( Symbol(), 0, 0 );
int b = iBarShift( Symbol(), 0, a );
datetime c = iOpen( Symbol(), 0, b );
Code in OnInit() only runs once.
When you restart your terminal, OnInit() can finish before you have connected to your broker.
Without a connection to your broker, the time is going to be wrong.
I'd suggest moving your code out of OnInit(), or at least check IsConnected()
Never use this IsConnected(), I will research about that.
Thanks a lot.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.