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
You can now see that this code . . .
//-- Define the Lower Fractals buffer as
. . . is outside of your
And this . . .
. . . was the last line meant to be executed with the for loop ? because it isn't.
Similar for this . . .
what about these { } braces, what are they for ?
One other thing, these arrays, yes they are arrays not buffers, you have 2 buffers, they are ExtUpFractalsBuffer and ExtDownFractalsBuffer . . .
double HVal[],LVal[],HValTime[],LValTime[];
they all have a size of zero elements . . . you don't give them a size or resize them so they are all size 0, so any values you assign to them will be forgotten and you will always read zero from them. So if you draw a line it will be back in 1970 . . .
Do you find it easy to read your own code without using any kind of indenting to mark blocks of code controlled by { } braces ? I don't, i find it a pain in the neck and it takes me at least twice as long to follow, maybe more . . .
To read your code easily I have to do this . . .
. . . that took me 7 minutes. Now I can read it . . .
Simon give a try to mql5 editor, copy & paste the code in an empty new file in metaeditor5 and then CTRL+,
It may be a good idea, I hope the OP will take note of it.
Thank you, thank you, thank you Raptor for this help.
It is probably the result of not having any programming background that I both struggle with my loops and practice bad indenting habits.
With respect to the indenting, I did not know it was a bad habit :-( but do now! Have tried to improve the indenting in the code below.
To answer one of your questions, I was using the {}braces incorrectly in attempt to control what was in my loops. Had it in my head that I had to separate Time[i] for upper and lower fractals..
I have the code almost working properly now.
It plots the fractal lines as I expected, but when a new fractal is formed, the fractal line is drawn in the new correct position, but then disappears on the open of the next bar.
I have not been able to work out why and would appreciate some advice with this if possible.
When I look at the objects using CtrlB after the line disappears, it shows that I have a zero length trend line of the same start and end point, not sure why?
I assume I am referencing the array values incorrectly.
Also, I noticed the indicator was plotting fractal lines corresponding to the last 2 values in my arrays rather than the first two.
But this was fixed when I changed " for(int i=0; i<limit;i++)" to "for(int i = limit; i>0; i--)"
I am confused about this solution, but it works?
Aslo have not used metaeditor 5.....should I be worried about such things at this early part of my coding schooling?
I have not been able to work out why and would appreciate some advice with this if possible.
When I look at the objects using CtrlB after the line disappears, it shows that I have a zero length trend line of the same start and end point, not sure why?
I assume I am referencing the array values incorrectly.
When the Indicator first runs it checks all bars and plots all Fractals, after that for each tick it only plots the fractals for new bars . . . and this will only be bar number 1, so you will only use array index 1 . . .
You have 2 trend lines, they each need 4 values, 2 time and 2 price values so in total you need 8 variables, why do you have 4 arrays each with space for 10,000 values ? that is space for 40,000 variables when you only need 8 ?
For the lines to be re-draw buf must be non-zero, have you checked if this is the case for all bars ? I suspect it is, you need to investigate this and find out why it is non-zero and fix it.
MetaEditor 5 is for mql5, it was suggested because it will automatically indent your code for you, once indented you could then copy and paste it back into Meta Editor 4. mql5 and mql4 are chalk and cheese . . .
One additional thing, dates and times are not doubles, they should be datetime variable types . . .
I would do something like this, I have left most of the code I have changed in but // commented out so you can see the changes . . .