You need to select the position first (Positions Totals would not be needed if you only have 1 position)
//Runner Breakeven if(PositionSelect(Symbol())) // if(PositionGetTicket(0)>0) { ulong positionticket=PositionGetInteger(POSITION_TICKET); double Openprice=PositionGetDouble(POSITION_PRICE_OPEN); double PositionTP=PositionGetDouble(POSITION_TP); trade.PositionModify(positionticket,Openprice,PositionTP); }
PositionSelect gets the first trade of that symbol (if I remember correctly) and PositionGetTicket gets the ticket of the position at that index. For more complex things it's better to use the standard library (CTrade, CPositionInfo...)
You need to select the position first (Positions Totals would not be needed if you only have 1 position)
PositionSelect gets the first trade of that symbol (if I remember correctly) and PositionGetTicket gets the ticket of the position at that index. For more complex things it's better to use the standard library (CTrade, CPositionInfo...)
//Runners Breakeven if(TimeCheck()==true && PositionsTotal()==1) { ulong positionticket=PositionGetTicket(0); double Openprice=PositionGetDouble(POSITION_PRICE_OPEN); double PositionTP=PositionGetDouble(POSITION_TP); trade.PositionModify(positionticket,Openprice,PositionTP); }
Thanks man, that fixed it

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Experts,
The open position stop loss is not modified for some reason. Am I doing it wrong? Here is my current breakeven code.
Thanks,
M Amir