int start(){ oz_up=iCustom(Symbol(), 0, "OZ_M5", 3, 1); oz_dw=iCustom(Symbol(), 0, "OZ_M5", 2, 1); lag=iCustom(Symbol(), 0, "LAG_M5", 0, 1); if (Close[1]>oz_up && lag>0.5 && b==0) { b=2; s=0; if ( oz_up + MAX*Point >= Close[1]) { SendOrder(OP_BUY, Lot, "UP"); OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),slippage,0,Ask+Takeprofit*Point,0,Magic,0,Blue); } else { OrderSend(Symbol(),OP_BUYLIMIT,Lot,NormalizeDouble(oz_up + OTS*Point ,Digits),slippage,0,Ask+Takeprofit*Point,0,Magic,0,Blue); SendOrder(OP_BUY, Lot, "UP"); } } else { if (Close[1]<oz_dw && lag<0.5 && s==0) { s=2; b=0; if ( oz_dw - MAX*Point <= Close[1]) { SendOrder(OP_SELL, Lot, "DW"); OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,0,Bid-Takeprofit*Point,0,Magic,0,Red); } else { OrderSend(Symbol(),OP_SELLLIMIT,Lot,NormalizeDouble(oz_dw - OTS*Point ,Digits),slippage,0,Bid-Takeprofit*Point,0,Magic,0,Blue); SendOrder(OP_SELL, Lot, "DW"); } } } return(0);}//-------------------------------------------------------------------------bool SendOrder(int tip, double lot, string com){ for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS)) { if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if (OrderComment()==com) return(0); } } } int error,nn; while(true) { RefreshRates(); //------------------------------------------------------------------------- if (tip==OP_BUY) { for(int n=0;n<OrdersTotal();n++) { if (!OrderSelect(n, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Yellow); n--; } if(OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Yellow); n--; } } error = 1; } //------------------------------------------------------------------------- if (tip==OP_SELL) { for(int p=0;p<OrdersTotal();p++) { if (!OrderSelect(p, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=Magic) continue; if(OrderType()==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Yellow); p--; } if(OrderType()==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Yellow); p--; } } error = 1; } //------------------------------------------------------------------------- if (error==-1) { Print("OrderSend Error ",GetLastError()," Lot ",lot); Sleep(1000); } else return(1); nn++; if (nn>10) return(0); } return(1);}//-------------------------------------------------------------------