To select closed orders on backtest...

 

Hi all,

I want to select my closed order on back test.

I use foolowing code;

if(OrderSelect(tickets,SELECT_BY_POS,MODE_HISTORY==true))
  }
   datetime ctm=OrderCloseTime();
   if(ctm!=0){     
      closed=true;

However, Orderselect says always false.

What should I do?

Best.

Murat Y.

 

This code is all over the place. 

if(OrderSelect(tickets,SELECT_BY_POS,MODE_HISTORY==true)) //passing the result of a boolean expression as the pool param! 
  } // what is this doing here???
   datetime ctm=OrderCloseTime();
   if(ctm!=0){     
      closed=true;


if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderCloseTime() != 0)
{ 
   ///Order is closed
}
 
nicholi shen:

This code is all over the place. 


Sorry, coorect code is as follows;

if(OrderSelect(tickets,SELECT_BY_POS,MODE_HISTORY==true))
 {
   datetime ctm=OrderCloseTime();
   if(ctm!=0){     
      closed=true;

Thank you for the code. However, OrderSelect is always says to me false. I don't understand.

 

I read that if I use Mode_History and select_by_pos, I cannot use tickets. I must use index.

However, what should the index be on back test? I am new one on programmer. 

 
if(OrderSelect(tickets,SELECT_BY_POS,MODE_HISTORY==true))
 {
   datetime ctm=OrderCloseTime();
   if(ctm!=0){     
      closed=true;

Where do you get the value for the variable tickets from?

This type of code you would normally expect to see in a loop.

Your logic makes no sense. Why check if an order from the history pool is closed - All trades in the history pool must be closed or they wouldn't be in the pool.

Reason: