
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
This could interest you, in next MT5 update :
Terminal: In the hedging mode, the ticket of a closed position is now displayed for the orders and deals in the trading history. This makes it easier to find related opening and closing operations.
This could interest you, in next MT5 update :
Thanks Alain, is this update already out, what version is it? Please post the link, thanks.
Hi Nguyen and sorry for late reply. This is exactly what I need, I've tested and it works ok. However I will extend the CTrade class and reimplement the PositionClose methods, rather then changing the class definition directly. Thank you once again for your help. I owe you a beer ;)
How can overwrite this code?
bool CTrade::PositionClose(const ulong ticket,const ulong deviation)
?
p.s.
This solution is OK but I get compiler error:
'PositionClose' - function already defined and has body bolbands_joze_115h35.mq5 2866 14
Hi
i get code below from CTrade, i add code about comment. you can comment anything when EA close position.
but can not if postion hit TP/SL.
{
//--- check stopped
if(IsStopped(__FUNCTION__))
return(false);
//--- check position existence
if(!PositionSelectByTicket(ticket))
return(false);
string symbol=PositionGetString(POSITION_SYMBOL);
//--- clean
ClearStructures();
//--- check
if((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
{
//--- prepare request for close BUY position
m_request.type =ORDER_TYPE_SELL;
m_request.price=SymbolInfoDouble(symbol,SYMBOL_BID);
}
else
{
//--- prepare request for close SELL position
m_request.type =ORDER_TYPE_BUY;
m_request.price=SymbolInfoDouble(symbol,SYMBOL_ASK);
}
//--- setting request
m_request.action =TRADE_ACTION_DEAL;
m_request.position =ticket;
m_request.symbol =symbol;
m_request.volume =PositionGetDouble(POSITION_VOLUME);
m_request.magic =m_magic;
m_request.deviation=(deviation==ULONG_MAX) ? m_deviation : deviation;
m_request.comment = PositionGetString(POSITION_COMMENT); // "Comment anything";
//--- close position
PrintFormat("PositionClose #%I64d %s %.2f",ticket,EnumToString((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)),m_request.volume);
return(OrderSend(m_request,m_result));
}