what is SELECT_BY_POS ?

 

what is SELECT_BY_POS ?

it depens on tickets or open time ?

Neither !

i code a script :

//+------------------------------------------------------------------+
//|                                               test_typeorder.mq4 |
//|                       Copyright ?2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
int total= OrdersTotal();
int ticket;
OrderSelect(0,SELECT_BY_POS,MODE_TRADES); ticket =OrderTicket();
Alert("ticket0=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));

  OrderSelect(1,SELECT_BY_POS,MODE_TRADES);ticket =OrderTicket();
Alert("ticket1=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));

  OrderSelect(2,SELECT_BY_POS,MODE_TRADES); ticket =OrderTicket();
Alert("ticket2=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));

  OrderSelect(3,SELECT_BY_POS,MODE_TRADES);ticket =OrderTicket();
Alert("ticket3=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));

OrderSelect(4,SELECT_BY_POS,MODE_TRADES);ticket =OrderTicket();
Alert("ticket4=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));

OrderSelect(5,SELECT_BY_POS,MODE_TRADES);ticket =OrderTicket();
Alert("ticket5=",ticket,",Symbol=",OrderSymbol(),",Opentime=",TimeToStr(OrderOpenTime()));



//----
   return(0);
  }
//+------------------------------------------------------------------+

the output as below:

 

MQL4 book explains SELECT_BY_POS - index in the order pool

==============================================

So, how to determine the index ? definitely,it begins with zero and ends with OrdersTotal() -1

but the picture above shows this index neither same as ticket nor open time.

 

I have a guess here... alphabetical order of symbols may matter.

in your example, it's eurusd, eurusd, gbpjpy, gbpusd, usdchf, usdjpy.

 
Drave wrote >>

I have a guess here... alphabetical order of symbols may matter.

in your example, it's eurusd, eurusd, gbpjpy, gbpusd, usdchf, usdjpy.


alphabetical order of symbols

:)

your are observer.

if some orders close,the index of order will change.

only ticket number is unique.

 
Drave wrote >>

I have a guess here... alphabetical order of symbols may matter.

in your example, it's eurusd, eurusd, gbpjpy, gbpusd, usdchf, usdjpy.


It's the most stupid explanation I've ever heard. I hope it was a joke :-)

If you have opened one or some orders in your terminal they are scored in a list OrdersTotal(), the oldest is 0, the newest has number - OrdersTotal()-1. So, if you have three opened orders, in the list they are - 0,1 and 2.

You can use the loop:

for(int cnt=0;cnt<OrdersTotal();cnt++) {

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

....

}

and see each order in your list by position.

 
Roger:


It's the most stupid explanation I've ever heard. I hope it was a joke :-)

If you have opened one or some orders in your terminal they are scored in a list OrdersTotal(), the oldest is 0, the newest has number - OrdersTotal()-1. So, if you have three opened orders, in the list they are - 0,1 and 2.

You can use the loop:

for(int cnt=0;cnt<OrdersTotal();cnt++) {

OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);

....

}

and see each order in your list by position.

no, it was not a joke, it was an honest attempt to explain what we were seeing.

did you take a look at the picture OP supplied? he also wrote twice (both in posts #1 and #2) that "oldest to newest" numbering was not the case.


on a second thought however, ticket order might well be broker-specific.

 

OK, question to topicstarter - Did you open these orders as Buy and Sell, or as BuyLimit or BuyStop and SellStop and SellLimit?

Reason: