int start() {
.
.код совы
.
.
.
.
.
int ind_close=-1; // 0 - close buy, 1 - close sell;
if (time_bar!=iTime(Symbol(),time_frame,0)) {
time_bar=iTime(Symbol(),time_frame,0);
double buf_0=iCustom(Symbol(),time_frame,"Dynamic zone TMAcentered _",HalfLength,Price,DzLookBackBars,DzStartBuyProbability1,DzStartBuyProbability2,DzStartSellProbability1,DzStartSellProbability2,ArrowShift,7,0);
double buf_1=iCustom(Symbol(),time_frame,"Dynamic zone TMAcentered _",HalfLength,Price,DzLookBackBars,DzStartBuyProbability1,DzStartBuyProbability2,DzStartSellProbability1,DzStartSellProbability2,ArrowShift,6,0);
if(buf_0<Ask*2) ind_close=0;
if(buf_1<Ask*2) ind_close=1;
}
if(ind_close!=-1) {
for(int ord_i=OrdersTotal()-1;ord_i>=0;ord_i--) if(OrderSelect(ord_i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderType()==ind_close) {
double close_price;
if(OrderType()==0) close_price=Bid; else close_price=Ask;
OrderClose(OrderTicket(),OrderLots(),close_price,3);
}
}
return(0);
}