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
//I Set xs as 1 in order to skip the current Candle in order if the trend is bearish it wont count it
for(xs=1; xs<Bars(_Symbol,PERIOD_D1); xs++)
if(zigzagDown[xs]!=EMPTY_VALUE && zigzagDown[xs] < SymbolInfoDouble(_Symbol,SYMBOL_LAST))
//This piece of code prints me 0.0
Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
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
Do you have a question about MQL5 or MQL4?
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?
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.
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.
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?"
Mistake number two: OnInit prepares data. And you need to receive data in OnTick.
Correct your mistake.
Correct your mistake
Still it doesn't run when the market is closed. There is no Price Ticking
Please enable the necessary setting in your browser, otherwise you will not be able to log in.