Cycle Operator 'for' questions - page 12

 
WhooDoo22:

Simon,

Here it comes... BAM!

Even better! Hahaha ;)

Thank you.

Think before you code . . .  how many orders do you have in the History pool ?  how do you know  i   is the correct one ?
 
WhooDoo22:


Why does the order close time represent in such a form (1357306061) ?

Is the reason why the Print() function works because the OrderSelect() function (within the braces) must select the closed order and NOT an open order? This must be done within the braces right? ;) Tricky, tricky.

How can you ask such a question ?  what does OrderCloseTime() return ?  from the Documentation . . .  "datetime OrderCloseTime( )"  what is a dateetime ?  from the Documentation . . .   "The value represents the amount of seconds elapse from 00:00 Jan 1, 1970."

 

It's time for you to start reading the Documentation . . . 

 
WhooDoo22:

Simon,

Fixed, so it works as intended.

Lines 2 and 3.

Your fix is an improvement . . .

 

If "Lines 2 & 3" is your answer to my question then you need to look again because it is wrong . . .  if you think it is correct please explain why it is correct. 

 

Simon,


Think before you code . . .  how many orders do you have in the History pool ?  how do you know  i   is the correct one ?


I could ask you the same question Simon ;)

How do you know the 'ClosedTicketNumber' variable (OrderTicket();) will select the correct ticket (I expect your response to be similar to my own) ?


I know-

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)

will select the correct ticket AND ;) the-

Print(OrderCloseTime());

will print the correct order ticket because the 'while' cycle found the correct ticket to begin with before the program arrived at this section within braces.


Thank you.

 

Simon,

Your fix is an improvement . . .

Savoring this very rare moment when "Simon says" - "There might possibly be a very slim, glimmering ray of hope for your coding future." Hahaha ;)


If "Lines 2 & 3" is your answer to my question then you need to look again because it is wrong . . .  if you think it is correct please explain why it is correct. 

Aah, yeah, yeah. Workin' on it. ;)


Thank you.

 
WhooDoo22:


I could ask you the same question Simon ;)

How do you know the 'ClosedTicketNumber' variable (OrderTicket();) will select the correct ticket (I expect your response to be similar to my own) ?


I know-

will select the correct ticket AND ;) the-

will print the correct order ticket because the 'while' cycle found the correct ticket to begin with before the program arrived at this section within braces.

Your variable  i  is an index in the Order Pool . . . NOT the History pool . . .  if you have 100 closed orders in the History pool and your value of  i  is 5  then you are looking at a closed trade 95 trades back in time . . .
 
My code works because  . . .   well you should know why it works because you should have read it and figured out what it does and why it works . . .  but you haven't so you have to ask  "why" and this is why you are not learning anything.

My code works because before the Order is closed . . . it's Ticket number  (Ticket numbers are unique regardless of the pool  ! ! )  is stored in a variable,  ClosedTicketNum   . . .  the Order is then closed and moved to the History pool,  then the ClosedTicketNum  variable is used to select the correct Order and finally OrderCloseTime() is now looking at the correct Order . . . not some unknown Order in the History pool based on an index number from the Order pool . . . 
 
WhooDoo22:


I know-

will select the correct ticket AND ;) the-

will print the correct order ticket because the 'while' cycle found the correct ticket to begin with before the program arrived at this section within braces.

Your   while  loop did not find any ticket  . . . .  it possibly found the index of the USDJPY order in the Order pool . . .   a pool index != a ticket number  haven't we been through this before ?  so you have an index for the order pool . . .   why do you expect the closed USDJPY Order to end up in the same position in a completely different pool,  the History pool ?  
 

Simon,

"Your variable  i  is an index in the Order Pool . . . NOT the History pool . . ."

OrderSelect() Documentation does not state its limit number of orders which can be held in the history pool (you wrote something along the lines of a hundred orders). OrderSelect() Documentation does not state this as far as I have read.

I could possibly have assigned zeros to all history pool orders once one hundred orders had been filled by values other than default. However, I believe in this case your way of saving the order ticket number to a variable seems just fine. I assumed values automatically reset once orders history reached its limit of an apparent limit of one hundred.


Thank you.

 
WhooDoo22:

Simon,

"Your variable  i  is an index in the Order Pool . . . NOT the History pool . . ."

OrderSelect() Documentation does not state its limit number of orders which can be held in history (you wrote something along the lines of a hundred orders). OrderSelect() Documentation does not state this as far as I can see.

I could possibly have assigned zeros to all history pool orders once one hundred orders had been filled by values other than default. However, I believe in this case your way of saving the order ticket number to a variable seems just fine. I assumed values automatically reset once orders history reached its limit of an apparent limit of one hundred.

Read again . . .  you misunderstand what I wrote . . . you could have 10 Closed orders in the History pool or 20 or 15 . . .  whatever number you have . . . 10,000 , 1,000 , 121 . . .   if you have any number except for one particular number you code will not work.  What is that particular number ?  it would have to be the value of   i   
 
WhooDoo22:


I could possibly have assigned zeros to all history pool orders once one hundred orders had been filled by values other than default. 

How ?
Reason: