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
Ok - last post from me. If you are going to program you really should understand the data your program is working with.
a) you are assuming the data does have low and a top
b) you are not taking into account two numbers of the same value next to each other does not necessarily make a low or a top
If link I gave you has code you can download and look at which gives you an idea of how someone else solved the
problem of finding a high point and a low point.
The way the code is written makes it difficult to read and there is no explanation of the method you are
using to find a top or low, the difficult layout is not explanation enough.
Finding why a program does not work can sometimes only be done by you pretending to be the computer.
Use the print statment and look at what your program actually does rather than looking at the code and
assuming the the logic works the way you think it should.
Your condition, which may have been what you intended,
if (max==High[y]) break:
is very odd as each low or high value is unlikely to equal or be anywhere near any other low high.
Each Low[i] is the y co-ordinate of a (x,y) co-ordinate or pencil points on a graph with x-axis as
descrete points in time. However since it is your logic, for all I know this might be intentional
on your part and be part of your method.
adapting the fractal code a bit while not conclusive in finding a high you could have used
------
bFound=false;
for(i=1,i<bars-1,i++)
{
max=High[i]; // Assume my bar[i] is the highest then the two bars either side of me must be lower
if( ( max>High[i+1] ) && max>High[i-1] )
{
bFound=true; // nearest high found.
break:
}
}
------
I have not bothered to check if the breakout logic is correct.
Nobody has to answer your question. People who answer don't know how much or how little you know
nor will they necessarily understand what your intentions are.
OK here is my code with the description of what it's meant to do and the logic behind it. If I missed sth please let me know!
Hello Farhang
God gave the names of every thing and taught human to know them.
So please try the same to give the beautiful names to your program elements.
This sample may be useful: https://www.mql5.com/en/forum/124521/page4
Best regards
code for determining if the Highest bar of x number of bars is in the center : (1 statement)
bool IsMiddleBar = iHighest(NULL, 0, MODE_CLOSE, iEnd,iBegin ) == (iEnd+iBegin)/2;
Easy once you think it out before diving into the code
At the time I wrote this I was not aware of the iHighest function!