Trabalho concluído
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Termos de Referência
I have created a trailing pending order component of an EA but keep given this error message;
The code is an follows;
============================================================================================================================================================================
double findHigh(){
double highestHigh = 0;
for(int i = 0; i < barsray; i++){
double high = iHigh(Stonk,Timeframe,i);
if(i > BarsN && iHighest(Stonk,Timeframe,MODE_HIGH,BarsN*2+1,i-5) == i){if(high > highestHigh){return high;}}
highestHigh = MathMax(high,highestHigh);}return -1;}
double findLow(){
double lowestLow = DBL_MAX;
for(int i = 0; i < barsray; i++){
double low = iLow(Stonk,Timeframe,i);
if(i > BarsN && iLowest(Stonk,Timeframe,MODE_LOW,BarsN*2+1,i-5) == i){if(low < lowestLow){return low;}}
lowestLow = MathMin(low,lowestLow);} return -1;}
void order_mody()
{for(int i = OrdersTotal()-1; i >=0; i--){ ulong orderTkt = OrderGetTicket(i);
if(OrderSelect(orderTkt) && OrderGetString(ORDER_SYMBOL) == Stonk){ENUM_ORDER_TYPE orderType = (ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE);
double orderPricy = OrderGetDouble(ORDER_PRICE_OPEN); int digts = (int)SymbolInfoInteger(Stonk,SYMBOL_DIGITS); double pnts = SymbolInfoDouble(Stonk,SYMBOL_POINT);
if(orderType == ORDER_TYPE_BUY_STOP){ double pricy = findHigh(); pricy =NormalizeDouble(pricy,digts);
double ordtp = (findHigh() + (findHigh()*TpPoints)); ordtp = NormalizeDouble(ordtp,digts);
double ordsl = (findHigh() - (findHigh()*SlPoints)); ordsl = NormalizeDouble(ordsl,digts);
datetime expiration = iTime(Stonk,Timeframe,0) + ExpirationHours * PeriodSeconds(PERIOD_H1);
if(pricy>orderPricy) {if(trade.OrderModify(orderTkt,pricy,ordsl,ordtp,ORDER_TIME_SPECIFIED,expiration,0))
{Print(__FUNCTION__, ">Order #", orderTkt,"modified by trailing");}}}
else if(orderType == ORDER_TYPE_SELL_STOP){double pricy = findLow(); pricy =NormalizeDouble(pricy,digts);
double ordtp =(findLow()-(findLow() *TpPoints)); ordtp = NormalizeDouble(ordtp,digts);
double ordsl =(findLow()+(findLow()*SlPoints)); ordsl = NormalizeDouble(ordsl,digts);
datetime expiration = iTime(Stonk,Timeframe,0) + ExpirationHours * PeriodSeconds(PERIOD_H1);
if(pricy<orderPricy) {if(trade.OrderModify(orderTkt,pricy,ordsl,ordtp,ORDER_TIME_SPECIFIED,expiration,0))
{Print(__FUNCTION__, ">Order #", orderTkt,"modified by trailing");}}}
}}}
============================================================================================================================================================================
I need a code that will enable a pending order to trail a the highest of high/lowest of low within a dynamic set of candles of array of candles.