-
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
Messages Editor -
Perhaps you should read the manual.
OnTick is only called on EAs.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11 -
Did you enable the timer? The call can fail — retry in OnCalculate if necessary.
Hello all,
I have tried searching for this answer, but could not find the answer I am looking for.
I would like my OBJ_HLINE to update every tick to be at the current bid price.
To test if OnTick or OnTimer were working I used these:
Both don't seem to work for an indicator. Is there any other way?
Thanks.
Simon
int OnInit() { EventSetTimer(60); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { //--- destroy timer EventKillTimer(); } void OnTimer() { //--- OnSMSKontrol(); } void OnSMSKontrol() { Print(" xx"); }
Hello all,
I have tried searching for this answer, but could not find the answer I am looking for.
I would like my OBJ_HLINE to update every tick to be at the current bid price.
To test if OnTick or OnTimer were working I used these:
Both don't seem to work for an indicator. Is there any other way?
Thanks.
Simon
"I would like my OBJ_HLINE to update every tick to be at the current bid price."
It is unnecessary to use Timer for this.
You do the desired action at each tick. Using a timer is to process without waiting for a tick.
void OnTick() { ObjeCiz(); } void ObjeCiz() { // example ObjectCreate(0,"SMSClose",OBJ_BUTTON,0,0,0); ObjectSetInteger(0,"SMSClose",OBJPROP_XDISTANCE,150); ObjectSetInteger(0,"SMSClose",OBJPROP_YDISTANCE,25); ObjectSetInteger(0,"SMSClose",OBJPROP_XSIZE,100); ObjectSetInteger(0,"SMSClose",OBJPROP_YSIZE,50); }
- www.mql5.com
You do the desired action at each tick. Using a timer is to process without waiting for a tick.
As William has already pointed out, indicators do not use OnTick(), EAs do.
Why don't you just enable "Show bid price line" in chart properties !
Hello all,
I have tried searching for this answer, but could not find the answer I am looking for.
I would like my OBJ_HLINE to update every tick to be at the current bid price.
To test if OnTick or OnTimer were working I used these:
Both don't seem to work for an indicator. Is there any other way?
Thanks.
Simon
I think indicator use onCalculate() instead of onTick(). Then if there is no data from server eg. during weekend, it won't triggered because there is basically no data received. Try onChartEvent() instead. For a timer, you need to activated it first.
Hello all,
Thank you for your comments.
As mentioned before: OnTick() and OnTimer() seem to be inactive. As for OnCalculate(), this one seems to only trigger once.
As to why i dont just use show bid price line. That's because its part of something bigger. I just wanted to know how to trigger methods each tick or second.
Thank you for your comments.
As mentioned before: OnTick() and OnTimer() seem to be inactive. As for OnCalculate(), this one seems to only trigger once.
As to why i dont just use show bid price line. That's because its part of something bigger. I just wanted to know how to trigger methods each tick or second.
All of these have already been addressed
OnTick() is for EAs, not indicators
Have you actually enabled OnTimer()?
OnCalculate() will only be called after the indicator is initialized and when there is a new incoming tick. At the weekend there are no new ticks for most symbols.
- 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 all,
I have tried searching for this answer, but could not find the answer I am looking for.
I would like my OBJ_HLINE to update every tick to be at the current bid price.
To test if OnTick or OnTimer were working I used these:
Both don't seem to work for an indicator. Is there any other way?
Thanks.
Simon