hi
anbei der code für einen TrailingStop der erst ab einem gewissen TP den stop nachzieht
vl ist das das was du suchtst
falls nicht müsstest du mal dazusagen wie der stop gesetzt werden soll
LG
(der Code ist nicht von mir sonder aus einem anderen EA)
Code:
void TrailingAlls(int start,int stop, double AvgPrice)
{
int profit;
double stoptrade;
double stopcal;
if(stop==0)
return;
int trade;
for(trade=OrdersTotal()-1;trade>=0;trade--)
{
if(!OrderSelect(trade,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)
continue;
if(OrderSymbol()==Symbol()||OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
profit=NormalizeDouble((Bid-AvgPrice)/Point,0);
if(profit<start)
continue;
stoptrade=OrderStopLoss();
stopcal=Bid-(stop*Point);
if(stoptrade==0||(stoptrade!=0&&stopcal>stoptrade))
// OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);
OrderModify(OrderTicket(),AvgPrice,stopcal,OrderTakeProfit(),0,Aqua);
}//Long
if(OrderType()==OP_SELL)
{
profit=NormalizeDouble((AvgPrice-Ask)/Point,0);
if(profit<start)
continue;
stoptrade=OrderStopLoss();
stopcal=Ask+(stop*Point);
if(stoptrade==0||(stoptrade!=0&&stopcal<stoptrade))
// OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);
OrderModify(OrderTicket(),AvgPrice,stopcal,OrderTakeProfit(),0,Red);
}//Shrt
}
Sleep(1000);
}//for
}