This is the function i use:
int orderTickets[]; int start() { getOrderTickets(orderTickets, 123456); return(0); } void getOrderTickets(int& orderTickets[], int magicNumber = 0){ int c; //initialize array to 0 ArrayResize(orderTickets, 0); for(c = 0; c < OrdersTotal(); c++){ OrderSelect(c, SELECT_BY_POS); if(OrderSymbol() == Symbol() && OrderMagicNumber() == magicNumber){ ArrayResize(orderTickets, ArraySize(orderTickets) + 1); orderTickets[ArraySize(orderTickets) - 1] = OrderTicket(); } } }
jmca:
This is the function i use:
Thank you for the idea jmca. It really helped :)
Regards,
Umer
Master.Aurora:
Please don't reply to 3.5 year old posts . . .
jmca's last post was in June 2009, it is unlikely he will see your post.
Thank you for the idea jmca. It really helped :)
Regards,
Umer
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I need your help.
How can i retrieve the new ticket number after a partial close within the same loop or do i need to make a new loop.
Thanks
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{
if(Bid >= TPBuy1 && OrderStopLoss() < OrderOpenPrice() && OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==(MAGICMABO)
&& OrderLots() == lotsbuy)
{
OrderClose(OrderTicket(), NormalizeDouble(OrderLots()/2.0,digits), Ask, 5, CLR_NONE);
OrderModifyExtended(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+PipsInProfitAtTP1*Point,OrderTakeProfit(),0,White);
}
}
else if(Ask <= TPSell1 && OrderStopLoss() > OrderOpenPrice() && OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==(MAGICMABO+2)
&& OrderLots() == lotssell)
{
OrderClose(OrderTicket(), NormalizeDouble(OrderLots()/2.0,digits), Bid, 5, CLR_NONE);
OrderModifyExtended(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-PipsInProfitAtTP1*Point,OrderTakeProfit(),0,White);
}
}