Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Keith Watford:
Noted. I'm sorry, i'll do better next time!
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
bool conditionMet=true; int x=0; for(; x<=9; x++) { double emaTrend = iMA (NULL,0,200,0,MODE_EMA,PRICE_CLOSE,x); if (emaTrend > High[x]) continue; else { conditionMet=false; break; } } if(conditionMet) Print("Sell Signal"); else Print("No Sell Signal");
This may give you a few ideas how to shorten your code.
Incidentally, it can be shortened further.
Often in my codes I will actually look for when a condition is NOT met
for(; x<=9; x++) { double emaTrend = iMA (NULL,0,200,0,MODE_EMA,PRICE_CLOSE,x); if (emaTrend <= High[x]) { conditionMet=false; break; } }
Keith Watford:
What would be the purpose of break, the loop would only run when all of the conditions met isn't it?
Incidentally, it can be shortened further.
Often in my codes I will actually look for when a condition is NOT met
Renz Carillo:
What would be the purpose of break, the loop would only run when all of the conditions met isn't it?
I tried creating a function out of your concept but it returns not all control path returns a value What would be the purpose of break, the loop would only run when all of the conditions met isn't it?
bool trend() { bool status; int i; for (i=0; i<10; i++) { double emaTrend = iMA (NULL,0,200,0,MODE_EMA,PRICE_CLOSE,i); if (emaTrend > High[i]) { status = true; } else if (emaTrend <Low[i]) { status = false; } return status; }
Renz Carillo:
What would be the purpose of break, the loop would only run when all of the conditions met isn't it?
What would be the purpose of break, the loop would only run when all of the conditions met isn't it?
The execution of the loop has nothing to do with any conditions.
When it is found that one EA is smaller than the high, there is no point in continuing with the loop. Hence the break.
else if (emaTrend <Low[i])
Why do you have this?
The Low doesn't figure in your outline at all!
Keith Watford:
It is originally in my condition for a buy/sell signal, i only incorporated sell signal in my code above so it would be alot easier to help me
Why do you have this?
The Low doesn't figure in your outline at all!

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
I've been trying out things but i really can't seem to figure it out, i tried doing loops but i'm probably doing something wrong.
What i wanted to happen is to only do a sell signal when all 10 candles is below the moving average.
Here is the photo to visualize more : https://ibb.co/LtHDPhp