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
I'm still learning the intricacies of indicators and have questions. I reset indicator buffer in OnInit(), but for some reason buffers are not reset during indicator compilation. For logic, there should be one full cell for each buffer after compilation, but in the picture you can see that there are many of them (I think that these are the previous buffer cells). Where do I make a mistake?
if(rates_total-8==i)// || rates_total-5==i || rates_total-2==i) { ColorHistogram_2Buffer1[i]=high[i]; ColorHistogram_2Buffer2[i]=low[i]; ColorHistogram_2Colors[i]=0; }
I'm still learning the intricacies of indicators and have questions. I reset indicator buffer in OnInit(), but for some reason buffers are not reset during indicator compilation. For logic, after compilation there should be one full cell for each buffer . Where do I make a mistake?
In OnInit the indicator buffers have zero length.
That's why they can do whatever you want with them - it all looks like a dead man's work to them.
And when code execution switches to OnCalculate, the size immediately becomes equal to rates_total.
and there is "rubbish" in all cells of the array. There may be leftover from old indicator calculation as well.
In OnInit, indicator buffers have zero length.
That's why you can do whatever you want with them, they are a dead giveaway.
And when code execution passes to OnCalculate, the size immediately becomes equal to rates_total.
and all the cells in the array have "rubbish" in them. There may be some left over from the old indicator calculation.
Thank you very much, I got it all and it worked! Did it like this:
Thank you very much, it all worked out! I did it like this:
Why assign a value to a variable twice?
And a question: What's the point of doing all this? After all, passing through all bars in the loop, all cells of the array must be filled with something anyway. Unless the indicator should only show the current position, but then the array must be initialized on each bar, not only at the beginning...
Why assign a value to a variable twice?
And the question is: Why do we need all this? After all, passing through all the bars in the loop, all cells of the array must be filled with something, anyway. Unless the indicator should only show the current position, but then the array should be initialized on each bar, not only at the beginning...
In this example, I just wanted to understand how to reset the buffer. But in future (in the indicator that I'm working on now), I will need to both leave the previous cells and add new ones. And just on this I began to work.So to speak - the first tests.
I was not sure that all actions with the chart are imitated by OnInit(), e.g. change of taimfreims. Changing taimfreim reset (checked it now), but maybe there's something else, so I put the second one in OnInit() to be sure. But if not, then I won't put it there.
Ahh. Well yes, the global level variables are not initialised when the chart period changes. ???I think... can't remember exactly.
And in general you can do without that extra bool variable.
And in general, you can do without this extra bool variable.
Yes, exactly, even better, thank you.
Can you tell me why, if the period is more than 30 minutes, it returns such a strange number?
KP 0 14:33:22.423 Test_DRAW_COLOR_HISTOGRAM2 (EURUSD,M30) PERIOD: 30
GG 0 14:33:24.402 Test_DRAW_COLOR_HISTOGRAM2 (EURUSD,H1) PERIOD: 16385
RJ 0 14:33:25.675 Test_DRAW_COLOR_HISTOGRAM2 (EURUSD,H4) PERIOD: 16388Can you tell me why if the period is more than 30 minutes, it returns such a strange number?
In MT5, period values are not equal to the number of minutes, as in MT4