- Selecting the 2nd oldest opened order
- audio file attaching
- Script : close oldest 5 buy orders
Is this the right way to get the oldest order's profits from too many opened orders thanks for help
By "profits from too many opened orders " you mean the sum of all opened trades profits then :
resul = resul + OrderProfit()+OrderSwap()+OrderCommission();
if(OrderOpenTime() > ...
it's called pseudo code and it's allowed to contain typo's.
It's used to just give the idea, in this case the use of the function OrderOpenTime().
A hint if you wish.
I am very busy and i can not post complete working concepts but i try to help with a quick response to point him in the right direction.Is this the right way to get the oldest order's profits from too many opened orders thanks for help
double OLDESTPROFIT() { double resul= 0; datetime timeOpenOrder = TimeCurrent(); for ( int i=0; i<OrdersTotal(); i++) { if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES )) continue; if ( OrderMagicNumber() != MagicNumber) continue; if ( OrderType()!= OP_SELL && OrderType()!= OP_BUY )continue; if ( OrderOpenTime() > timeOpenOrder) continue; timeOpenOrder = OrderOpenTime(); resul= OrderProfit()+OrderSwap()+OrderCommission(); } return(resul); }
Or
double OLDESTPROFIT() { double resul= 0; int ticket = 0; for ( int i=0; i<OrdersTotal(); i++) { if (! OrderSelect(i, SELECT_BY_POS, MODE_TRADES )) continue; if ( OrderMagicNumber() != MagicNumber) continue; if ( OrderType()!= OP_SELL && OrderType()!= OP_BUY )continue; if ( OrderTicket() > ticket && ticket > 0 ) continue; ticket = OrderTicket(); resul= OrderProfit()+OrderSwap()+OrderCommission(); } return(resul); }
Or
thanks konstantin but i guess this code
if ( OrderType()!= OP_SELL && OrderType()!= OP_BUY )continue;
must be written in this way
if ( OrderType()!= OP_SELL || OrderType()!= OP_BUY )continue;
thanks for your help
it's called pseudo code and it's allowed to contain typo's.
It's used to just give the idea, in this case the use of the function OrderOpenTime().
A hint if you wish.
I am very busy and i can not post complete working concepts but i try to help with a quick response to point him in the right direction.thanks for the hint sir it is very useful
Olderst order can use
thanks allot
By "profits from too many opened orders " you mean the sum of all opened trades profits then :
no i mean only the oldest opened order profits
exam
if i open 20 sell order one after one then i close the first then the second then the third and there is the rest 17 orders her the oldest open one is the order number 4 ,,so i need to get the profits of this order only
//+------------------------------------------------------------------+ double OLDESTPROFIT() { double result=0; datetime timeOpenOrder=TimeCurrent(); for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(OrderMagicNumber()==MagicNumber) { if(OrderType()==OP_SELL || OrderType()==OP_BUY) { if(OrderOpenTime()<timeOpenOrder) { timeOpenOrder=OrderOpenTime(); result=OrderProfit()+OrderSwap()+OrderCommission(); } } } } } return(result); } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use