
src=«http://zakaz.opentraders.ru/uploads/images/4/4/3/7/33217/f66b0d36f5.jpg»/>









<code>int start() { int Buy, Sell, BuyStop, SellStop, BuyStep, SellStep, summ; double - все остальные; for(int i=0; i<OrdersTotal(); i++) { chk=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); //... прямой пересчёт ордеров. if(OrderSymbol()==Symbol() && OrderType()==0) Buy++; BuyKoefProfit=Ask+(Koef*Trend-MODE_SPREAD); BuyStep=Ask+(Step+Tral); if(OrderSymbol()==Symbol() && OrderType()==1) Sell++; SellKoefProfit=Bid-(Koef*Trend-MODE_SPREAD); SellStep=Bid-(Step+Tral); if(OrderSymbol()==Symbol() && OrderType()==4) BuyStop++; BuyStopPrice1=Ask+Trend; BuyStopPrice2=Ask+Tral; if(OrderSymbol()==Symbol() && OrderType()==5) SellStop++; SellStopPrice1=Bid-Trend; SellStopPrice2=Bid-Tral; }</code>
if (BuyStop==0) OrderSend(symbol,4,MODE_MINLOT,BuyStopPrice1,0,0,0,0,0);
<code>if (BuyStop==1 && Buy==0 && OrderOpenPrice() - Ask > BuyStopPrice) OrderModify(OrderTicket(),BuyStopPrice1,0,0,0,0);</code>
<code>if (Buy<=Koef && OrderTakeProfit()!=BuyKoefProfit) OrderModify(OrderTicket(),OrderOpenPrice(),0,BuyKoefProfit,0,0);</code>
<code>if (BuyStop==1 && Buy!=0 && OrderOpenPrice()-Ask>=BuyStep) OrderSend(symbol,4,Lot=KefLot*Lot,BuyStopPrice2,0,0,0,0,0);</code>
<code>if (BuyStop==2 && OrderOpenPrice()-Ask>Tral) OrderModify(OrderTicket(),BuyStopPrice2,0,0,0,0);</code>
<code>if (Buy>Koef && OrderTakeProfit()==0) Lots=Lots+OrderLots(); Summ=Summ+OrderLots()*OrderOpenPrice(); BU=Summ/Lots; BuyProfit=BU+TP; OrderModify(OrderTicket(),OrderOpenPrice(),0,BuyProfit,0,0);</code>
<code>if (summ<Buy) summ=Buy; if (summ>Buy && (OrderStopLoss()==0) || (Ask-OrderStopLoss()>Tral)) StopLoss=Ask-Tral; summ=Buy; OrderModify(OrderTicket(),OrderOpenPrice(),StopLoss,0,0,0); </code>//… для всех оставшихся ордеров Buy.
<code>if (Bid>=OrderTakeProfit() ) OrderClose(Buy); if (Bid<=OrderStopLoss()) CloseSeries(Buy);</code>
<code>return(0); } string Error(int error_code)</code>
bablusut