Thanks for the quick reply!
so looping like this is safer?
for (int i=OrdersTotal()-1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
do you mean bracket? {} to interrupt?
break interupts the loop. without this command both cases check all the orders except that it is safer to countdown with i-- from OrdersTotal()-1
I go to the search box in the top right hand corner of these web pages and I type in the word break and bingo there appears lots of information about the break command or operator (russian - english translation reasoning perhaps)
The documentation on break is https://docs.mql4.com/basis/operators/break
I go to the search box in the top right hand corner of these web pages and I type in the word break and bingo there appears lots of information about the break command or operator (russian - english translation reasoning perhaps)
The documentation on break is https://docs.mql4.com/basis/operators/break
Oh yeah i thought you were talking about the brackets...i dont need to break the loop i just want to know if OrderSelect() will loop and exit at the first condition met or actually it will loop through all the orders.. if you see in the code i ve posted, the second case to be true needs to have 2 orders of different types and from different magic numbers to return 1, i just want to know if this is the correct way to code it
break interupts the loop. without this command both cases check all the orders except that it is safer to countdown with i-- from OrdersTotal()-1
your second example wont do what you want it to. You only select ONE order at a time and you only check that ONE order if either of the conditions you are checking are true then tradecases will equal 1 but you wont know if both orders your are checking for are in your orders list or not. You will only know that it has either none of the conditions you are checking for or that you found at least ONE order that satisfied your condition, you won't know if both were satisfied.
your second example wont do what you want it to. You only select ONE order at a time and you only check that ONE order if either of the conditions you are checking are true then tradecases will equal 1 but you wont know if both orders your are checking for are in your orders list or not. You will only know that it has either none of the conditions you are checking for or that you found at least ONE order that satisfied your condition, you won't know if both were satisfied.
yeah thats what i thought......do you know how i can accomplish that?
yeah thats what i thought......do you know how i can accomplish that?
How about just checking each order individually and using a scoring system like this from Derk Wehler's synergy indi.
Just check for order type & magic numbers and assign a value to each,
Then check if (value total >= somenumber) tradecases = ?;
int MA_TrendSum = 0; // We are looking for the general trend here, so check // whether lines are headed up or down, comparing this // candle with the prev and the prev prev if (MA_Hi_0 > MA_Hi_1) MA_TrendSum += 3; if (MA_Lo_0 > MA_Lo_1) MA_TrendSum += 3; if (MA_Hi_0 > MA_Hi_2) MA_TrendSum += 2; if (MA_Lo_0 > MA_Lo_2) MA_TrendSum += 2; if (MA_Hi_1 > MA_Hi_2) MA_TrendSum += 1; if (MA_Lo_1 > MA_Lo_2) MA_TrendSum += 1; if (MA_Hi_0 < MA_Hi_1) MA_TrendSum -= 3; if (MA_Lo_0 < MA_Lo_1) MA_TrendSum -= 3; if (MA_Hi_0 < MA_Hi_2) MA_TrendSum -= 2; if (MA_Lo_0 < MA_Lo_2) MA_TrendSum -= 2; if (MA_Hi_1 < MA_Hi_2) MA_TrendSum -= 1; if (MA_Lo_1 < MA_Lo_2) MA_TrendSum -= 1; // If we have 6 out of 12, consider it to have a direction if (MA_TrendSum >= 6) return(OP_BUY); else if (MA_TrendSum <= -6) return(OP_SELL); else return(-1);
A computer program is like a recipee you follow each instruction step by step you learn more if you try following the instructions as if you were the computer. So try it out on paper see a variable name write its name down and next to the name the number thats in it. See a comparason check your current values and decide if the comparason is true or false, if its true you work on the line of code or the code block started with { and finishing the actions of the code block at } the word else means that if you did worked the true part then you skip the nexe line or code block. if the comparason was false you skip the next like or code block and move on to the next line.
It is doubtful that you ever did VB programming as you said in another post - of if you did, it would have been in the same way you are programming now.
There are only four basic elemets to programming
Input output assignment and the IF something THEN something ELSE something different. the ELSE part is optional.
all other statements are just variations on using these four ideas in combination.
- 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 Guys i have a question:
lets say i want to loop through my orders inside a function and return a value if this condition is valid...
please have a look at this code
is the second case possible? i mean when i do the loop it stop at the first order or actually it continue through all the orders?
Thanks