Cycle Operator 'for' questions - page 16

 
RaptorUK:

Nope,  this is wrong . . get rid of it.  The positions and indexes are the same thing and they are 0 to 9  . . .   there is nothing that is 1 to 10 . . .  expunge it from your brain.

This needs to be rectified, pronto.

If indexes and position numbers are identical then this is true...

Ten tickets total in active trades order pool:

ticket position numbers are as follows: 0,1,2,3,4,5,6,7,8,9

ticket position numbers indexed are as follows: |0|1|2|3|4|5|6|7|8|9|

If this is indeed the case, a ticket position number can be zero (0).

Please confirm above statements or please state otherwise.


Thank you.

 
WhooDoo22:

This needs to be rectified, pronto.

If indexes and position numbers are identical then this is true...

Ten tickets total in active trades order pool:

ticket position numbers are as follows: 0,1,2,3,4,5,6,7,8,9

ticket position numbers indexed are as follows: |0|1|2|3|4|5|6|7|8|9|

If this is indeed the case, a ticket position number can be zero (0).

We have been through this before . . . .  an Order has a ticket number . . .   an Order also has a position in the Trading pool for Open/Pending Orders or the History pool for closed Orders..

If we have 10 open orders the Order positions are 0 to 9  or  0,1,2,3,4,5,6,7,8,9  or  |0|1|2|3|4|5|6|7|8|9|  end, Fin, done

 
RaptorUK:

We have been through this before . . . .  an Order has a ticket number . . .   an Order also has a position in the Trading pool for Open/Pending Orders or the History pool for closed Orders..

If we have 10 open orders the Order positions are 0 to 9  or  0,1,2,3,4,5,6,7,8,9  or  |0|1|2|3|4|5|6|7|8|9|  end, Fin, done


Thank you.
 

Hello MQL4 community Forum,

Presently, I attempt to save price values for order closes. I tried including the OrderProfit() function but don't like it. No-no :O .Will use it if all other avenues fail. I'd like to save the order close price :) instead using OrderClosePrice() function. Once all order close prices are saved I could group the results in pairs. Once grouped in pairs, add each group then divide each group by two to retrieve their average. Once all pairs are averaged regroup the results and repeat process. Once all pairs are averaged and only one total remains I would subtract the spread from this total and if the result is greater-than or equal (>=) to order open price a Boolean would remain false. If the result is less than the order open price a Boolean would be initialized true.

Has anyone been down this road before? If so can you provide some warnings to keep in mind?

Thank you

 
WhooDoo22:

Has anyone been down this road before? If so can you provide some warnings to keep in mind?

Don't do it . . .   read what you need from the History pool it's all in there.  Keep things simple . . . . if you save the data in an array you have too save it to file so in the event of MT4 or PC crash you can get it back . . .  etc, etc, etc

HEADACHE
 

Ah yeah, history pool. "No-brainer!". You're straight pro Simon! Hahaha! ;) Why didn't I think of this first, right?

You'll make an "MQL4 coding rock-star" out of me yet! Hahahaha!

Thank you

 

Simon,

I've been reviewing documentation for 'Break' and 'Continue' operators. As far as I can see, a 'Break' operator terminates an operator 'while' or 'for' cycle passing program control to the next line of code below the 'while' or 'for' cycle. A 'Continue' operator stops reading the operator 'while' or 'for' cycle's body and passes program control to either the expression in an operator 'while' cycle OR 'Expression 2' if a 'for' cycle possesses no 'Expression 3' or 'Expression 3' if the 'for' cycle does posses 'Expression 3'.

What are your thoughts regarding this?

Thank you

 
WhooDoo22:

Simon,

I've been reviewing documentation for 'Break' and 'Continue' operators. As far as I can see, a 'Break' operator terminates an operator 'while' or 'for' cycle passing program control to the next line of code below the 'while' or 'for' cycle. A 'Continue' operator stops reading the operator 'while' or 'for' cycle's body and passes program control to either the expression in an operator 'while' cycle OR 'Expression 2' if a 'for' cycle possesses no 'Expression 3' or 'Expression 3' if the 'for' cycle does posses 'Expression 3'.

What are your thoughts regarding this?

Thank you

All in all: use continue inside a loop to jump back to the entry point. use break to exit the loop immediatly.

One more thing, break and continue are code optimizing operations, you never really need them. Additionally use them with care as they can lead to hard to track bugs.

As nearly always with programming, a simple example says more then 1000 words:

for(int i=0;i<10;i++){
 Print("1");
 continue;
 Print(2);
}

//Prints: 1111111111

for(int i=0;i<10;i++){
 Print("1");
 break;
 Print(2);
}

//Prints: 1

 

Michael, thank you for your explanation in words and in code. Both are explanatory.

Thank you

Reason: