![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Technically that is correct according to the documentation, but unfortunately it has happened to me twice. And on a third occasion it even grew larger than the previous value.
I have no ideia why it happened, but to be better safe than sorry, I decided to make all my indicator keep incremental track of states or counts.
To save space, I often use "union" to store multiple variables in a single buffer. Since buffers are "double", I can easily map the 8 bytes into multiple variables, like "bool", "uchar", "shortint" in a single buffer.
Technically that is correct according to the documentation, but unfortunately it has happened to me twice. And on a third occasion it even grew larger than the previous value.
I have no ideia why it happened, but to be better safe than sorry, I decided to make all my indicator keep incremental track of states or counts.
To save space, I often use "union" to store multiple variables in a single buffer. Since buffers are "double", I can easily map the 8 bytes into multiple variables, like "bool", "uchar", "shortint" in a single buffer.
Thanks for the clarification. I really appreciate your work on this forum. Your replies are very helpful and there is no arrogance in them like some other users' replies. However, if something like this can happen (prev_calculated can scroll backwards or forwards), it will be a problem for the buffer as well (same as for a static variable). In that case, the only option is really to watch the increments in our own way.
Yes, that is correct. I keep track of prev_calculated and rates_total values by using a two static variables of previous values.
When I detect discrepancies, I adjust accordingly and sometimes even do a complete refresh if the values are incoherent.
You are welcome and I thank you for the complement! I truely appreciate it!
Please, first attempt to code what has been explained already — namely, add the extra buffer for tracking the current trend.
Then provide complete code that compiles, that includes the indicator properties and declarations of global variables, including the buffers.
Thank you for your help. I am doing it. Seems the hardest thing for me is coding, I'm just an amateur. I will update the results later.