To select closed orders on backtest...

To add comments, please log in or register
Murat Yazici
1521
Murat Yazici  

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.

nicholi shen
2392
nicholi shen  

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
}
Murat Yazici
1521
Murat Yazici  
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.

Murat Yazici
1521
Murat Yazici  

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. 

Keith Watford
Moderator
20336
Keith Watford  
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.

To add comments, please log in or register