PositionGetDouble(POSITION_SL) is not working New comment Cristo 2015.03.10 00:00 Hi, thanks for reading.I have this trailing stop, my problem is "PositionGetDouble(POSITION_SL)" is not working or only it work when "PositionModify" works?Here i am debugging and "pos_sl" is 0.0, why? if(PositionSelect(_Symbol)){ if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY){ pr=(SymbolInfoDouble(_Symbol,SYMBOL_BID)-PositionGetDouble(POSITION_PRICE_OPEN))/_Point; new_tp=NormalizeDouble(PositionGetDouble(POSITION_PRICE_OPEN)+(TP*_Point),_Digits); new_sl=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID)-Trailing*_Point,_Digits); pos_sl=NormalizeDouble(PositionGetDouble(POSITION_SL),_Digits); if(SymbolInfoDouble(_Symbol,SYMBOL_BID)>PositionGetDouble(POSITION_PRICE_OPEN)+Trailing*_Point){ if(new_sl>pos_sl){ if(trade.PositionModify(_Symbol,new_sl,new_tp)){ Print("Todo bien: ",trade.ResultRetcode()," , ",trade.ResultRetcodeDescription()); Print("Current prize: ",PositionGetDouble(POSITION_PRICE_CURRENT)); }else Print("Todo mal: ",trade.ResultRetcode()," , ",trade.ResultRetcodeDescription()); } } if(pr>=TP){ trade.PositionClose(_Symbol); comprado=false; } if(pr<=-StopLoss){ trade.PositionClose(_Symbol); comprado=false; } } if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL){ pr=(PositionGetDouble(POSITION_PRICE_OPEN)-SymbolInfoDouble(_Symbol,SYMBOL_ASK))/_Point; new_tp=NormalizeDouble(PositionGetDouble(POSITION_PRICE_OPEN)-(TP*_Point),_Digits); new_sl=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK)+Trailing*_Point,_Digits); pos_sl=NormalizeDouble(PositionGetDouble(POSITION_SL),_Digits); if(SymbolInfoDouble(_Symbol,SYMBOL_ASK)<PositionGetDouble(POSITION_PRICE_OPEN)-Trailing*_Point){ if(new_sl<pos_sl){ if(trade.PositionModify(_Symbol,new_sl,new_tp)){ Print("Todo bien: ",trade.ResultRetcode()," , ",trade.ResultRetcodeDescription()); Print("Current prize: ",PositionGetDouble(POSITION_PRICE_CURRENT)); }else Print("Todo mal: ",trade.ResultRetcode()," , ",trade.ResultRetcodeDescription()); } } if(pr>=TP){ trade.PositionClose(_Symbol); comprado=false; } if(pr<=-StopLoss){ // if(PositionGetDouble(POSITION_PRICE_CURRENT)>preciosHigh[1]) trade.PositionClose(_Symbol); comprado=false; } } }// why MQL5 can't get the order's ST / TP ? Newbie needs help with PositionModify please Trailing stop function New comment
Hi, thanks for reading.
I have this trailing stop, my problem is "PositionGetDouble(POSITION_SL)" is not working or only it work when "PositionModify" works?
Here i am debugging and "pos_sl" is 0.0, why?