Cycle Operator 'for' questions - page 5

 

Simon,


Questions:

OrderSelect() function's first parameter value of zero (0) represents a ticket number position in the order pool correct?

If this is true, how would replacing value zero with a value of one benefit? Is it a common position just like 1,2,3,etc.?

If this is not true, what ticket number pool position does zero represent?


Can you possibly provide a link for study which may assist me with a brief explanation?


Responses:

Also, I must wait for the market to become active before running EA tests. I intend to occupy my time with a meal and continue writing market filtration (MF) code blocks for Volume II during this time.


Thank you.

 
WhooDoo22:

Simon,


Questions:

OrderSelect() function's first parameter value of zero (0) represents a ticket number position in the order pool correct?

If this is true, how would replacing value zero with a value of one benefit? Is it a common position just like 1,2,3,etc.?

If this is not true, what ticket number pool position does zero represent?

Can you possibly provide a link for study which may assist me with a brief explanation?


Responses:

Also, I must wait for the market to become active before running EA tests. I intend to occupy my time with a meal and continue writing market filtration (MF) code blocks for Volume II during this time.

The first parameter you pass to OrderSelect()  is "Order index or order ticket depending on the second parameter."  you don't need to ask this,  it is in the documentation,  did you read and understand the documentation ?

It is either the Ticket Number or the position of the order in the order pool.

"If this is true, how would replacing value zero with a value of one benefit?"  this is what your while loop does on the 2nd loop . . . isn't it ?  
 
WhooDoo22:


Secondly, 'while' loop is executed.

'while' loop logic:

OrderSelect() function uses variable 'i' as a substitute for a number 1,2,3,etc.. (just keep this in mind please)

So, if the variable i within the OrderSelect() function and OrderSymbol() function is NOT USDJPY, increase variable i by 1. ( i++; )

The 'while' loop increases 'i' variable until OrderSelect() function selects the proper order ticket AND the OrderSymbol() function selects a USDJPY order. When both objectives have been accomplished, the while loop becomes false and control is passed below i++; (the while loop body).

You can use a while loop,  it's function is just the same as a for loop,  but you will always have problems trying to do what you have done here . . . .  you need to think what you are trying to do,  write it down in words - no code . . . what is the purpose of the loop ?  it's not a trick question to catch you out,  you need to be able to think clearly about this stuff BEFORE you start writing any code . . .
 

Simon,

I believe I understand the OrderSelect() function with the exception of understanding the value 0's representation.

What does value 0 represent?

For now, lets agree that we are dealing strictly with an order in an order pool and not a order's ticket number please.

If this is agreed upon what would a value of zero (0) represent in the OrderSelect() functions first parameter in the case of selecting an order's ticket position?


Is it not a marvel what can be accomplished if mind is truly set to purpose? :)

Thank you.

 
WhooDoo22:

Simon,

I believe I understand the OrderSelect() function with the exception of understanding the value 0's representation.

What does value 0 represent?

The fist position in the pool . . .  just like an array,  the first element is at position 0,  the second is at 1, the third at 2, etc.  

What I find strange is that you try and use this function yet not know how to use it . . .  haven't you looked at other code and seen a loop counting down from OrdersTotal() - 1 ?  why do you think the -1 is there ?
 

Simon,

you need to be able to think clearly about this stuff BEFORE you start writing any code . . .

Agreed. Your statement follows the order in which I perform any coding task, regardless of the file-type written.

The trouble does not lie within understanding what needs to be accomplished, the trouble is my lack of understanding (and experience) with the use of a 'for' cycle, which I plan to rectify in haste.

The most troublesome impediment is a lack of time to complete tasks.

Thank you.

 
WhooDoo22:

Simon,

you need to be able to think clearly about this stuff BEFORE you start writing any code . . .

Agreed. Your statement follows the order in which I perform any coding task, regardless of the file-type written.

The trouble does not lie within understanding what needs to be accomplished, the trouble is my lack of understanding (and experience) with the use of a 'for' cycle, which I plan to rectify in haste.

For loops are common to most programming languages,  I learned about the for loop at school 33 years ago . . .  I just assume people trying to code in mql4 know the fundamental basics . . .  I guess that assumption is wrong.  

You do need to know the basics first,  variables, arrays, loops, etc . . .  they aren't particular to mql4 you will find them in most,  if not all, programming languages.
 

Simon,

The fist position in the pool . . .  just like an array,

This statement is of use to me. In an array...

// array example;

int array[]={0,0,0,0};

// In an array containing four zeros the values are represented as such: 0,1,2,3;

What I find strange is that you try and use this function yet not know how to use it . . .

I do believe I understand an OrderSelect() function's purpose and use with maybe a slight question regarding a value of zero when searching for an order ticket's position.

haven't you looked at other code and seen a loop counting down from OrdersTotal() - 1 ?  why do you think the -1 is there ?

I have experience using the OrdersTotal() function as a condition to send orders for previous EAs. However, I do not know why -1 is there. Why is -1 there?

Thank you.

 
WhooDoo22:

The most troublesome impediment is a lack of time to complete tasks.

In that case it is even more critical that you have a clear idea of how you are going to tackle any task so that you can make efficient use of your time.  If you need to write it down then write it down,  if it doesn't work in words on paper then not even a coding genius will make it work in code.
 
WhooDoo22:

Simon,

The fist position in the pool . . .  just like an array,

This statement is of use to me. In an array...

What I find strange is that you try and use this function yet not know how to use it . . .

I believe I do understand an OrderSelect() function's purpose and use with maybe a slight question regarding a value of zero when searching for an order ticket's position.

haven't you looked at other code and seen a loop counting down from OrdersTotal() - 1 ?  why do you think the -1 is there ?

I have experience using the OrdersTotal() function as a condition to send orders for previous EAs. However, I do not know why -1 is there. Why is -1 there?

Thank you.

Why is the  -1 there . . . .  well you can figure that out just by reading the information on this page,  if you can't then you should serious consider if you have the ability to code at all.  I'm not trying to be unkind just blunt and truthful.   The reason for the -1 is a fundamental thing in any programming . . .  if you don't know what and can't figure it out in 30 seconds then you need to take a huge step back and start learning the basics,  the very basics,  like binary, hex, what variables are,  arrays, etc, etc.

Reason: