void Сorrect(string OrdType)
{
int trade;
double TP_all;
double AveragePrice;
AveragePrice = AveragePrice(OrdType);
for(trade=OrdersTotal()-1;trade>=0;trade--)
{
OrderSelect(trade, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
//-----
if (OrdType=="buy")
{
if(OrderType()==OP_BUY)
{
TP_all = AveragePrice+TP*Point;
if (OrderTakeProfit() != TP_all)
{
Print("Модифицируем покупку. Безубыток =
"+DoubleToStr(AveragePrice,4)+", ТР = "+DoubleToStr(TP,4)+" Новый
уровень = "+DoubleToStr(TP_all,4));
OrderModify(OrderTicket(), AveragePrice,
OrderStopLoss(), TP_all, 0, Yellow);
}
}
}
//----
if (OrdType=="sell")
{
if(OrderType()==OP_SELL)
{
TP_all = AveragePrice-TP*Point;
if (OrderTakeProfit() != TP_all)
{
Print("Модифицируем продажу. Безубыток =
"+DoubleToStr(AveragePrice,4)+", ТР = "+DoubleToStr(TP,4)+" Новый
уровень = "+DoubleToStr(TP_all,4));
OrderModify(OrderTicket(), AveragePrice,
OrderStopLoss(), TP_all, 0, Yellow);
}
}
}
//----
}
}
}