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
but the code for my indicator draws the histogram one bar late.
Any help finding the error would be greatly appreciated !!!!!
Your indenting doesn't help me, I hope it helps you . . . try this . . .
thanks SDC, point taken about the commenting, I have been using the extra commenting as a tool to remind myself what each line does as I learn
but agree it is annoying and counterproductive when I ask you guy on the forum for help
Cheers
Thanks RaptorUK, everything seems to work now except,
I still can't work out why the buffers calculate the correct values
(values matching the actual MT4 indicators in the next chart window)
but the code for my indicator draws the histogram one bar late.
Any help finding the error would be greatly appreciated !!!!!
Thanks, yes I will work on the indenting, I promise !!
Code now works exactly as planned.
Working code attached below for anyone interested.
THANKS AGAIN FOR YOUR HELP !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I don't agree . . too many comments ( unless we are talking irrelevant padding and "eye candy" ) are much better than none . . .
RaptorUK I was looking back at some help you gave me with this indicator and trying to work on my nemesis
That is: understanding and getting my loops right and having the code execute the way I want.
In this example you helped me, by suggesting the use of 3 different "while" loops, each calculating a separate buffer value.
I am not sure I understand why this could not be done all inside one loop.
Would you or another person on the forum help me understand this better by explaining this.
When I look in the code base:
As long as the Condition of the operator 'while' is true: The program passes the control to the operator of the cycle body; after all operators in the cycle body have been executed, it passes the control to the header to test the truth of the Condition.
If the Condition of the operator 'while' is false, the control must be passed to the operator that follows the cycle operator 'while'.
I read this as meaning that as long as the 3 buffers can be calculated (until i is not greater than 0) the loop should calculate......but it does not seem to work this way in practice
Any help always appreciated.....
RaptorUK I was looking back at some help you gave me with this indicator and trying to work on my nemesis
That is: understanding and getting my loops right and having the code execute the way I want.
In this example you helped me, by suggesting the use of 3 different "while" loops, each calculating a separate buffer value.
I am not sure I understand why this could not be done all inside one loop.
Many people increment their bar number variable in their for or while loops in Indicators, if you then include an iMAOnArray() call in this loop the data that it needs from the Array has not yet been written to the Array, for example lets take a random bar number . . 175, as the loop progresses through the bars the array is filled, at our chosen example bar the value for the Array (buffer) is filled and then the iMAOnArray() call tries to work with the Array data for bar 175, 176, 177,etc. but the values for bar 176, 177, etc have not yet been calculated.
thank you to you both, exactly the description I was looking for from RaptorUk and the chance to look at working loop code side by side (priceless!!..thanks WHRoeder)
it is these basics and subtleties that I want to fully inderstand before I venture into the world of EAs
that is whyI keep going back to my old postings trying to get it straight in my head
thanks again !!!