-
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
You get handles in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
I am trying to get the first lower point of the ZigZag indicator which it shouldn't be the current candle may somebody help me please and tell me what is wrong with my code I think I'm doing it right and I didn't get the point
Thank's in advance
Do you have a question about MQL5 or MQL4?
-
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
- Terminal starts.
- Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
- OnInit is called.
- For indicators OnCalculate is called with any existing history.
- Human may have to enter password, connection to server begins.
- New history is received, OnCalculate called again.
- New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
-
You get handles in OnInit. In OnTick (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 2020.03.08
How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 2020.07.05
How to call indicators in MQL5 - MQL5 Articles 12 March 2010
actually this is an assisting expert which I run it only once daily while the market is closed. it's job is to loop through all the securities in a stock market and searchs if a certain condition met.
is there any possibke way for?
Thanks
Do you have a question about MQL5 or MQL4?
I'll be thankful if you kindly help me with my issue.
Do you have a question about MQL5 or MQL4?
I'll be thankful if you kindly help me with my issue.
I think that Vladimir is asking whether your question concerns MQL5 or MQL4.
I think that Vladimir is asking whether your question concerns MQL5 or MQL4.
yep it's an mql5 question I thought it's clear with the handle part.
yep it's an mql5 question I thought it's clear with the handle part.
I often see a lot of wild code. So you always have to ask.
And you immediately have a GREAT MISTAKE: you are creating a NEW handle AT EVERY TICK !!! Remember, in MQL5, the indicator handle MUST BE CREATED ONCE and you need to do it in OnInit !!!
Please fix this bug and post the changed code again.
I often see a lot of wild code. So you always have to ask.
And you immediately have a GREAT MISTAKE: you are creating a NEW handle AT EVERY TICK !!! Remember, in MQL5, the indicator handle MUST BE CREATED ONCE and you need to do it in OnInit !!!
Please fix this bug and post the changed code again.
My Entire code is in OnInit, I want all the functions run only once when the market is closed, So there's no OnTick function.
"actually this is an assisting expert which I run it only once daily while the market is closed. it's job is to loop through all the securities in a stock market and searchs if a certain condition met.
is there any possibke way for?"
Thanks
My Entire code is in OnInit, I want all the functions run only once when the market is closed, So there's no OnTick function.
"actually this is an assisting expert which I run it only once daily while the market is closed. it's job is to loop through all the securities in a stock market and searchs if a certain condition met.
is there any possibke way for?"
Thanks
Mistake number two: OnInit prepares data. And you need to receive data in OnTick.
Correct your mistake.
Mistake number two: OnInit prepares data. And you need to receive data in OnTick.
Correct your mistake
Still it doesn't run when the market is closed. There is no Price Ticking
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am trying to get the first lower point of the ZigZag indicator which it shouldn't be the current candle may somebody help me please and tell me what is wrong with my code I think I'm doing it right and I didn't get the point
Thank's in advance