![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
What do you intend to achieve with that line?
Do you know how a for loop works?
Thanks for the response.
Sorry for this long post it's sort of lengthy to describe.
YES I created "histoupcount" to hold the bar number MACD signal line that crossed up. "histodowncount" for the bar that crosses down below MACD signal line.
So in this case A_low or A_high will use histoupcount=i or histodowncount=i bar index number. I will use this to find the fractals on either side of those bars. "histoupcount / histodowncount".
A_low is a fractal before histo_() crosses up. And A_high is the fractal before histo_() crosses down. Since histo_() is a bool I used global histo_1 instead for this part.
Anyhow here is the unfinished code but mostly functional.
As you will see. I use 5min on EURUSD chart but any time is good. Crossing up or down you will see the print in the expert tab printing the values for A and B also the bar locations.
I get Print, I get Object colors changing as needed.
However, I had assumed return was actually TRUE since the colors were all correct.
However, it's actually false all the time, but giving me Object color as true.
I assumed my syntax was wrong but that does not seem to be the case. Now I have ran out of what to look for.
I keep thinking the for loop is starting as false and returning false for some reason. Yet I don't see why it would be false while Object shows true.
My inexperience is likely not letting me see the problem but I will keep reading it.
Question: What if for loop starts as false ? Will this make the function false by default ? I assume so ? But then why Object color change as true ?
Thanks everyone this is an interesting problem.
Question: What if for loop starts as false ? Will this make the function false by default ? I assume so ? But then why Object color change as true ?
Thanks everyone this is an interesting problem.
I don't use MT4 and can't run this code, but still it can be so much improved even without trying to understand what it's supposed to do.
As for the question. yes, the condition in the second expression (FI val1==0 in A_high) is evaluated before each time the for is going to be executed, and the first time is already false - so no entry.
You can see it easily if you use the builtin debugger (the green triangle) when you stop at the for loop (double click on that line before running).
One solution is to set the val1 to 0 before the for loop. But even that is not necessary, because you return from the function when it's 0.
An example of a better written A_high
No need to ask if (cond == true), instead if(cond). Same for if(cond == false), instead if(!cond).
You initialize the object back ground color to the same color you set in case it's false.
You have non relevant additional brackets in A_high,A_low etc.. see example.
You have non relevant additional variables, not need to complicate (A,B,C,D).
Start with that.
I don't use MT4 and can't run this code, but still it can be so much improved even without trying to understand what it's supposed to do.
As for the question. yes, the condition in the second expression (FI val1==0 in A_high) is evaluated before each time the for is going to be executed, and the first time is already false - so no entry.
You can see it easily if you use the builtin debugger (the green triangle) when you stop at the for loop (double click on that line before running).
One solution is to set the val1 to 0 before the for loop. But even that is not necessary, because you return from the function when it's 0.
An example of a better written A_high
No need to ask if (cond == true), instead if(cond). Same for if(cond == false), instead if(!cond).
You initialize the object back ground color to the same color you set in case it's false.
You have non relevant additional brackets in A_high,A_low etc.. see example.
You have non relevant additional variables, not need to complicate (A,B,C,D).
Start with that.
Thanks, I see it now. Helps a lot.
I knew I was getting close to something but just could not see it.
Learning to debug better would likely lead me in the right direction earlier.
Thanks again. Back to the drawing board.
P.S
It is suppose to look like this and then eventually sent me phone notification to check in on the charts.