This is unreadable.
You need to clarify the scope of each if statement with { }.
For example.
bool Scenario2_B() { if(High[1]-Close[1]<30*Point) { if(Ema20_1 -20*Point>Ema100_1) { if(Ema20_1>Ema20_40 || Ema20_1>Ema20_60) { if(Ema100_1>Ema100_20 || Ema100_1>Ema100_40) { if(TimeCurrent() -1800>TStamp2_B) { if(Buyticket2_4==0) { if((PivotAlign_1(Ema100_0,10*Point) == true) || (PivotAlign_2(Ema100_0,10*Point) == true) || (PivotAlign_3(Ema100_0,10*Point) == true)) { if(Low[1]-15*Point<Ema100_1) { if(MarketInfo(Symbol(),MODE_BID)>Ema100_0) { return(true); } } } else if((PivotAlign_1(Ema125_0,10*Point)==true) || (PivotAlign_2(Ema125_0,10*Point) == true) || (PivotAlign_3(Ema125_0,10*Point) == true)) { if(Low[1]-15*Point<Ema125_1) { if(MarketInfo(Symbol(),MODE_BID)>Ema125_0) { return(true); } } } } } } } } } return(false); }
Hi, I am having trouble with my code and am wondering if the fault is always with the programmer or sometimes it could be the stability of mql4? The problems usually occur after a long list of "if statements". I've included a typical example of the complexity of the code below. There would be about 7 or 8 "if statements" in a row and should only return(true) if all are correct. But sometimes a statement is wrong but it still returns (true). I even have checked with the data window and one of the statements would be definitely wrong. Anyway, what I am basically asking is do I assume there is always a mistake in my code or can the computer sometimes go haywire from reading the code. I should add that this is on a demo account but I don't see how that should change anything. Thanks
{} correctly put
bool Scenario2_B() { if(High[1] - Close[1] < 30*Point) if(Ema20_1 -20*Point > Ema100_1) if(Ema20_1 > Ema20_40 || Ema20_1 > Ema20_60) if(Ema100_1 > Ema100_20 || Ema100_1 > Ema100_40) if(TimeCurrent() -1800 > TStamp2_B) if(Buyticket2_4 == 0) { if((PivotAlign_1(Ema100_0,10*Point)) || (PivotAlign_2(Ema100_0,10*Point)) || (PivotAlign_3(Ema100_0,10*Point))) { if (Low[1] -15*Point < Ema100_1) if (MarketInfo(Symbol(), MODE_BID) > Ema100_0) return(true); } else if((PivotAlign_1(Ema125_0,10*Point)) || (PivotAlign_2(Ema125_0,10*Point)) || (PivotAlign_3(Ema125_0,10*Point))) { if (Low[1] -15*Point < Ema125_1) if (MarketInfo(Symbol(), MODE_BID) > Ema125_0) return(true); } } return(false); }
I see nothing wrong in this code, the problem is probably in Ema* and PivotAlign* functions. Which statement was wrong?
In my cases it also has been the programmer. Every single time.

if(Buyticket2_4 == 0) { if((PivotAlign_1(Ema100_0,10*Point) == true) || (PivotAlign_2(Ema100_0,10*Point) == true) || (PivotAlign_3(Ema100_0,10*Point) == true)) if (Low[1] -15*Point < Ema100_1) if (MarketInfo(Symbol(), MODE_BID) > Ema100_0) { return(true); } else if((PivotAlign_1(Ema125_0,10*Point) == true) || (PivotAlign_2(Ema125_0,10*Point) == true) || (PivotAlign_3(Ema125_0,10*Point) == true)) if (Low[1] -15*Point < Ema125_1) if (MarketInfo(Symbol(), MODE_BID) > Ema125_0) { return(true); } }and
if(Buyticket2_4 == 0) { if((PivotAlign_1(Ema100_0,10*Point)) || (PivotAlign_2(Ema100_0,10*Point)) || (PivotAlign_3(Ema100_0,10*Point))) { if (Low[1] -15*Point < Ema100_1) if (MarketInfo(Symbol(), MODE_BID) > Ema100_0) return(true); } else if((PivotAlign_1(Ema125_0,10*Point)) || (PivotAlign_2(Ema125_0,10*Point)) || (PivotAlign_3(Ema125_0,10*Point))) { if (Low[1] -15*Point < Ema125_1) if (MarketInfo(Symbol(), MODE_BID) > Ema125_0) return(true); } }
Thanks guys for all your comments! Gives me a lot to go through but it is good to know the problem is with my code and not the system, so eventually I can figure it out.
Thanks!
The 'else' is about the second 'if' vs. the fourth and short writing for checking boolean functions?
I assumed he wants the 'else' on the last 'if', but it really makes more sense ema100 or ema125, not half of both.
P.S.
https://www.youtube.com/watch?v=poz6W0znOfk
Loved the video! I switched most of the if's to &&'s. There must be a video for and

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I am having trouble with my code and am wondering if the fault is always with the programmer or sometimes it could be the stability of mql4? The problems usually occur after a long list of "if statements". I've included a typical example of the complexity of the code below. There would be about 7 or 8 "if statements" in a row and should only return(true) if all are correct. But sometimes a statement is wrong but it still returns (true). I even have checked with the data window and one of the statements would be definitely wrong. Anyway, what I am basically asking is do I assume there is always a mistake in my code or can the computer sometimes go haywire from reading the code. I should add that this is on a demo account but I don't see how that should change anything. Thanks