datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;
Print(B);
At the above program at time difference part,
when printing "B" the result is very very big.
like billions numbers .
Why?
At the above program at time difference part,
when printing "B" the result is very very big.
like billions numbers .
Why?
Your loop is wrong . . .
for(int i=OrdersTotal();i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); } // loop has ended here . . . Lots=OrderLots(); ticket=OrderTicket(); int type=OrderType(); double orderprice=OrderOpenPrice(); datetime ordertime=OrderOpenTime(); datetime orderclosetime=OrderCloseTime(); double B=orderclosetime-ordertime; double emirsuresi; Print(B);
it should start at OrdersTotal() - 1
Is your Order closed ? if not it has a OrderCloseTime() of 0
Try this . . .
for(int i = OrdersTotal() - 1; i >= 0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ) continue; Lots = OrderLots(); ticket = OrderTicket(); int type = OrderType(); double orderprice = OrderOpenPrice(); datetime ordertime = OrderOpenTime(); datetime orderclosetime = OrderCloseTime(); ulong B = orderclosetime - ordertime; double emirsuresi; if (orderclosetime > 0) Print("Ticket: ", ticket, "difference from OpenTime to CloseTime: ", B); }
Try this . . .
for(int i = OrdersTotal() - 1; i >= 0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES) ) : if (orderclosetime > 0
If you are reading the trades pool, ALL the orders will ALWAYS be open (or pending.)
datetime ordertime=OrderOpenTime();
datetime orderclosetime=OrderCloseTime();
double B=orderclosetime-ordertime;
double emirsuresi;
Print(B);
At the above program at time difference part,
when printing "B" the result is very very big.
like billions numbers .
Why?
The OrderOpenTime() and OrderCloseTime() are functions that return data of the datetime type.
What this means is that the time it is returning is the number of seconds since the first second of 1970.
Which is over 1 billion 394 million.... however the difference between the open and close time should only display
the number of seconds the order was open.
However as WHRoeder pointed out....if you are selecting an order close of zero because you are selecting
an open trade from trade pool that has not closed yet. Then you are right .. it will be the open time minus zero..
a reallly big number.. If you'll use the loop that RaptorUK provided with the MODE-HISTORY change that WHRoeder
noticed instead of MODE-TRADES you should get some kind of a better result.
pascalboy: Mode history :)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use