HTML Code:
void TpModify(double tp)
{

double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
double TakeProfit_B=NormalizeDouble(Ask+minstoplevel + tp*Point,Digits); //BUY
double TakeProfit_S=NormalizeDouble(Bid-minstoplevel - tp*Point,Digits); //SELL

for (int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderSymbol()!=Symbol())continue;
if(OrderMagicNumber()!= MagicNumber)continue;

if (OrderType() == OP_BUY)
{
if (OrderOpenPrice()< TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), 0,0, clrGreen))
Print("Modifying order, delete TakeProfit");
}

if (tp< TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), TakeProfit_B,0, clrGreen))
Print("Modifying order, TakeProfit_B!");
else
Print("Error modifying order!, error#", GetLastError());
}
else if(tp> TakeProfit_B)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 0, clrGreen))
Print("Modifying order!");
else
Print("Error modifying order!, error#", GetLastError());
}

}
if (OrderType()==OP_SELL)
{

if (OrderOpenPrice()> TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), 0,0, clrGreen))
Print("Modifying order, delete TakeProfit");
}
if (tp< TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), TakeProfit_S, 0, clrGreen))
Print("Modifying orderTakeProfit_S!");
else
Print("Error modifying order!, error#", GetLastError());
}
else if (tp> TakeProfit_S)
{
if (OrderModify(OrderTicket(), OrderOpenPrice(),OrderStopLoss(), tp, 0, clrGreen))
Print("Modifying order!");
else
Print("Error modifying order!, error#", GetLastError());
}

}
}
Ragazzi ho fatto questa funzione che mi sposta il tp degli ordini, in input gli passo il valora di una media, ora succede questo a volte nonostante il take venga "preso" l'ordine non si chiude(allego screen), e poi capita anche che il take segue il prezzo poi il prezzo si (ritira) e il take rimane senza chiudere l'ordine (non so come spiegare meglio dovrei farvi un video)
vi è mai successo avete suggerimenti?
Attached Files