extern double Lot = 0.1; // ðàçìåð ëîòà extern int StartBar = 0; // íà÷àëüíûé áàð, ñ êîòîðîãî èäåò îòñ÷åò äâóõ îäèíàêîâûõ ïàëîê extern int TakeProfit = 20; extern int StopLoss = 10; extern int Trailing = 10; // Âåëè÷èíà òðåéëèíãà extern int MaxOrders = 1; // ìàêñèìàëüíîå êîëè÷åñòâî îäíîâðåìåíî îòêðûòûõ îðäåðîâ datetime last; int start() { double ao1,ao2,ao3; if(OrdersTotal()>0) TrailingControl(); if((Time[0]-last)>=Period()*60) { ao1=iAO(Symbol(),0,StartBar); ao2=iAO(Symbol(),0,StartBar+1); ao3=iAO(Symbol(),0,StartBar+2); if(ao1<ao2 && ao2<ao3) OrderOp(OP_SELL); if(ao2>ao3 && ao1>ao2) OrderOp(OP_BUY); last=Time[0]; } return(0); } int OrderOp(int ord) { double TP,SL,ticket; if(OrdersTotal()<MaxOrders) { if(ord==OP_BUY) { TP=Bid+TakeProfit*Point; if(TakeProfit==0) TP=0; SL=Ask-StopLoss*Point; if(StopLoss==0) SL=0; ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,SL,TP,"Ïîêóïàåì",16384,0,White); } if(ord==OP_SELL) { TP=Ask-TakeProfit*Point; if(TakeProfit==0) TP=0; SL=Bid+StopLoss*Point; if(StopLoss==0) SL=0; ticket=OrderSend(Symbol(),OP_SELL,Lot,Bid,3,SL,TP,"Ïðîäàåì",16384,0,Yellow); } } } int OrderCl(int ord) { int cnt; for(cnt=OrdersTotal();cnt>0;cnt--) { OrderSelect(cnt-1, SELECT_BY_POS, MODE_TRADES); if(OrderType()==OP_BUY && ord==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,White); if(OrderType()==OP_SELL && ord==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Yellow); } } int TrailingControl() { int total=OrdersTotal(),cnt; for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if(Trailing>0) { if(Bid-OrderOpenPrice()>Point*Trailing) { if(OrderStopLoss()<Bid-Point*Trailing) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*Trailing,OrderTakeProfit(),0); return(0); } } } } else { if(Trailing>0) { if((OrderOpenPrice()-Ask)>(Point*Trailing)) { if(OrderStopLoss()>(Ask+Point*Trailing)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*Trailing,OrderTakeProfit(),0); return(0); } } } } } } }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Indicators Used:
Bill Williams Awesome oscillator
Custom Indicators Used:
Order Management characteristics:
Checks for the total of open orders
It automatically opens orders when conditions are reached
It Closes Orders by itself
It can change open orders parameters, due to possible stepping strategy
Other Features: