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
Hope you don't mind, I have taken the opportunity to learn a little about mql5 using your code . . . I have learned that a lot of things are different compared to mql4 and that not having a Book, as there is for mql4, is a pain in the behind.
This is where I got to, it seems to be OK in terms of changing timeframes and it will update the bar to the right of the currently forming bar when a new bar is formed. It does not update the currently forming bar, not sure if you wanted it to or not.
Not at all RaptorUK :) I am learning from your code too :) Very nice code and it is working perfectly. It is still a little bit weird that we must clear the values as it is not stated anywhere in the references, at least I have not come a cross anything like that...
Br, Candles
EDIT: I will take my word back see bold part of code below taken from references. The buffers are indeed initialized with 0.0 prior to filling them with values:
... And thus the below code also works flawlessly.... I think:
EDIT: Code not working after new bar is completed.
But being the obsessive person I am I would still like to know why indicator buffer arrays can initially have so weird values like in the below pic although it is probably irrelevant:
... And thus the below code also works flawlessly.... I think:
But being the obsessive person I am I would still like to know why indicator buffer arrays can initially have so weird values like in the below pic although it is probably irrelevant:
An array is just a bunch of memory locations that hold the values in the array. When the memory is allocated for the array is it cleared/zeroed ? I don't know if it is or isn't, maybe it isn't, so that could explain the strange values.
... And thus the below code also works flawlessly.... I think:
You may still get issues with the currently forming bar, I think. The four arrays you are using are dynamic arrays, they are not defined with a pre-set size and are not resized using ArrayResize(), they grow as needed and new memory is allocated when needed. Using ArrayInitialise() will, I assume, initialise the array elements that exist at the time . . . what about new elements that get added as new bars are added to the chart ?
This code also sets the Array values to 0.0
but what it doesn't do, because of the limit of the for loop, is clear the array values for the currently forming bar. That position is rates_total-1 the for loop exits when i == rates_total-1 this was why I added
immediately after the loop.
You may still get issues with the currently forming bar, I think. The four arrays you are using are dynamic arrays, they are not defined with a pre-set size and are not resized using ArrayResize(), they grow as needed and new memory is allocated when needed. Using ArrayInitialise() will, I assume, initialise the array elements that exist at the time . . . what about new elements that get added as new bars are added to the chart ?
This code also sets the Array values to 0.0
but what it doesn't do, because of the limit of the for loop, is clear the array values for the currently forming bar. That position is rates_total-1 the for loop exits when i == rates_total-1 this was why I added
immediately after the loop.