Inherit or set new trade-comment on partially closed trade using PositionClosePartial or alternative (Hedging Account)
Not sure but got the thinking you use comment for managing the trade. It can work most of the time, but not all of the time because brokers can modify comments. I only know 1 broker which allows the option to explicitly leave comment section alone.
If you use it to manage, i suggest to figure out another method without need for comment for sake of compatibility and risk.
As to your question. There is no way to manage the comment section in the sense that it can be updated at your will. Imagine trade servers being spammed with non relevant data to deal with.
Thanks, the comment is not necessary for the EA to work, but it should help to keep the overview of the trades, if that makes sense.
Adding the following line fixed the problem :
bool CTrade::PositionClosePartial(const string symbol,const double volume,const ulong deviation) { uint retcode=TRADE_RETCODE_REJECT; //--- check stopped if(IsStopped(__FUNCTION__)) return(false); //--- for hedging mode only if(!IsHedging()) return(false); //--- clean ClearStructures(); //--- check filling if(!FillingCheck(symbol)) return(false); //--- check if(SelectPosition(symbol)) { 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); } } else { //--- position not found m_result.retcode=retcode; return(false); } //--- check volume double position_volume=PositionGetDouble(POSITION_VOLUME); if(position_volume>volume) position_volume=volume; //--- setting request m_request.comment =PositionGetString(POSITION_COMMENT); m_request.action =TRADE_ACTION_DEAL; m_request.symbol =symbol; m_request.volume =position_volume; m_request.magic =m_magic; m_request.deviation=(deviation==ULONG_MAX) ? m_deviation : deviation; m_request.position =PositionGetInteger(POSITION_TICKET); //--- hedging? just send order return(OrderSend(m_request,m_result)); }
It's so funny to understand every day how many bug does MetaQuotes library contain, and what they do to fix them: nothing.

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 am working on Partial Closing Positions (MQL5).
On A Netting account, I simply open an opposite order with the right volume,and can (of course) set the trade comment (Name of the EA) like with any other trade.
On a hedging account I use PostionTradePartial to partially close a position:
This works fine, StopLoss and TakeProfit are inherited, however not the comment. The Comment section is empty. I have no clue how to manage to get the remaining position to have a trade-comment (either inherited or created new).
bool PositionClosePartial(
const ulong ticket, // Ticket der Position
const double volume, // Volumen
ulong deviation=ULONG_MAX // Abweichung
)
Does anyone no a solution to my problem?
Thx