Questions from Beginners MQL5 MT5 MetaTrader 5 - page 517
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
MT4, please help the community.
1. In the Expert Advisor, working (by ticks or on a timer 0.5 sec) on the M1 chart, you need to make calculations at the moment of a new candle on the H1 chart.
We can catch the start of the M1 candle, following the last M1 candle of each hour (NN:00 minutes), but it is not very nice ... Besides, the H1 candlestick may not appear at that moment.
Maybe somebody did it more elegantly ?
2. How much longer it takes to get the indicator values through iCustom(), compared to the indicator code in the Expert Advisor text?
3. if the code of the indicator in the text of the Expert Advisor is much faster to be calculated, how in the Expert Advisor attached to the M1 chart, to calculate the indicator value on the H1 chart ?
MT4, I am asking for help from the community.
1. In the Expert Advisor, working (by ticks or by timer 0.5 sec) on the M1 chart, you need to make calculations at the moment when a new candle appears on the H1 chart.
We can catch the start of the M1 candle, following the last M1 candle of each hour (NN:00 minutes), but it is not very nice ... Besides, the H1 candlestick may not appear at that moment.
Maybe somebody did it more elegantly ?
2. How much longer to get the indicator values through iCustom(), compared to the indicator code in the Expert Advisor text?
3. if the code of the indicator in the text of the Expert Advisor is much faster to be calculated, how in the Expert Advisor attached to the M1 chart, to calculate the indicator value on the H1 chart ?
The answer to the first question, the function defines a new bar.
example of use
The answer to the first question, the function defines a new bar.
Thanks a lot Sergey, I've looked through the documentation, but somehow I missed iTime() ... :
And whycall NevBar() inOnInit() ?
The first function call, otherwise it will be triggered immediately. To make surethat OnInit() is not called
The first function call, otherwise it will be triggered immediately. To make surethat OnInit() is not called
Thank you Sergei ! On the forum, I was scared stiff: "Don't use static variables ! " :)
Thank you Sergei ! On the forum, I was scared stiff: "Don't use static variables ! " :)
This is the first time I've heard about them, I wonder what's so scary about them, I rarely use them too, but they are better suited for certain tasks.
The point is that static variable can only be used if NevDay() is called for the same symbol and timeframe. If there are 2 or more symbols, NevDay() will return incorrect values. My Expert Advisor is multi-currency ... :(
If you need it for multicurrency mode, here is an example, it works in MT4 and MT5
The point is that the static variable can only be used if NevDay() is called for the same symbol and timeframe. If there are 2 or more symbols, NevDay() will return incorrect values. My Expert Advisor is multi-currency ... :(
Here is another option using the class
Test result