Problem! I can't modify position.
1. Please insert the code correctly: when editing a message, press the button
and paste your code into the pop-up window. (The first time I corrected your message)
2. To access the properties of a position, this position must first be selected (for example, using PositionGetTicket )
- www.mql5.com
i added an input for the index of the position you want to modify
void ModifyPorfit(int index) { if(!PositionSelectByTicket(PositionGetTicket(index))) return; double p = PositionGetDouble(POSITION_PROFIT); if(p < 0) return; double volume = PositionGetDouble(POSITION_VOLUME); double points = p / volume ; if(points > 100) { double sl = PositionGetDouble(POSITION_PRICE_OPEN); double tp = PositionGetDouble(POSITION_TP); if(!ExtTrade.PositionModify(PositionGetTicket(0), sl, tp)) { int code = ExtTrade.ResultRetcode(); printf("Modify failed:" + code); } } }
Example code
#include <Trade\PositionInfo.mqh>
CPositionInfo eaposition;
if(eaposition.SelectByIndex(i))
{
// Get Value here
}
I tried to modify the loss. But I got error code 10016.
How to call PositionModify correctly?
Thanks.