
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
i try to change my mode from the netting mode to the Hedge mode, so i want to selct the histroy order with MagicNumber and Symbol,
i use follofing code
{
double deal_price;
double deal_volume;
double deal_profit;
// --- time interval of the trade history needed
datetime end=TimeCurrent(); // current server time
datetime start=end-PeriodSeconds(PERIOD_D1)*Days_Order_loockback;// decrease 1 day
//--- request of trade history needed into the cache of MQL5 program
HistorySelect(start,end);
//--- get total number of deals in the history
int deals=HistoryDealsTotal();
//--- get ticket of the deal with the last index in the list
ulong deal_ticket=HistoryDealGetTicket(deals-1);
if(deal_ticket>0) // deal has been selected, let's proceed ot
{
//--- ticket of the order, opened the deal
ulong order=HistoryDealGetInteger(deal_ticket,DEAL_ORDER);
string deal_symbol=PositionGetString(POSITION_SYMBOL);
long order_magic=HistoryDealGetInteger(deal_ticket,DEAL_MAGIC);
long pos_ID=HistoryDealGetInteger(deal_ticket,DEAL_POSITION_ID);
deal_price=HistoryDealGetDouble(deal_ticket,DEAL_PRICE);
deal_volume=HistoryDealGetDouble(deal_ticket,DEAL_VOLUME);
deal_profit=HistoryDealGetDouble(deal_ticket,DEAL_PROFIT);
// PrintFormat("Deal: #%d opened by order: #%d with ORDER_MAGIC: %d was in position: #%d price: #%f volume: #%f",
// deals-1,order,order_magic,pos_ID,deal_price,deal_volume);
}
else // error in selecting of the deal
{
PrintFormat("Total number of deals %d, error in selection of the deal"+
" with index %d. Error %d",deals,deals-1,GetLastError());
}
return(deal_volume);
}
does anyone have an idea, that i get only the volume for the last trade in with my MagicNumer in the Symbol back?
amando