#property copyright "Евгений Л. Leus79@yandex.ru" extern int tp=1400; extern int sl=900; extern double Lots =0.08; extern double Lotmax =0.3; extern double DecreaseFactor=3; int Ust=70; int pma1=5; int pma2=8; int sst=3; int mma1=1; int mma2=1; int Us1=70; int Us2=30; int Ur1=75; int Ur2=25; int pst=5; int prsi=5; extern double SARstep=0.02; extern double SARmax=0.2; extern bool Tral=true; extern int TrailingStep=900; //--------------------------------------------------------------------- //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } bool New_Bar; int tick,tick2; double LoOp() { double lot=Lots; int orders= OrdersHistoryTotal() ; // history orders total int losses=0; // number of losses orders without a break //---- calcuulate number of losses orders without a break if(DecreaseFactor>0) { for(int l=orders-1;l>=0;l--) { if(OrderSelect(l,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; } if(OrderSymbol()==Symbol() && OrderMagicNumber()==5903442){ //---- if(OrderProfit()>0) break; if(OrderProfit()<0) losses++; } } if(losses>=DecreaseFactor) lot=Lots*losses; } //---- return lot size return(lot); } //------------------------------------------------------------------------------------------------------ int start() { if ( Period()!=240){ Print("ошибка-период не H4!"); Comment("ошибка-период не H4!"); return;} if (Symbol()!="EURUSD"){ Print("ошибка-не EURUSD!"); Comment("ошибка-не EURUSD!"); return;} if(AccountBalance()/50001=m2 && m11s1 && s50 && rLotmax){Lot=Lotmax;} if (m1>=m2 && m11s1 && s50 && rm22 && sUs2 && r<50 && r>Ur2 && Low[1]>Close[0] && Low[2]>Close[0]) { double lotbuy=0; for (int е=0; еLotmax){Lot=Lotmax;} if (m1<=m2 && m11>m22 && sUs2 && r<50 && r>Ur2 && Low[1]>Close[0] && Low[2]>Close[0]) { sls=Bid+sl*Point; tps=Bid-tp*Point; while(tick2<=0){ tick2=OrderSend ( Symbol(),OP_SELL,Lot, Bid, 5,sls,tps,"sel",5903442); } } } } SarTrailingStop(); close(); //----------------------------------------------------------------------------------------------- return(0); } void Fun_New_Bar() { static datetime New_Time=0; New_Bar=false; if(New_Time!=Time[0]) { New_Time=Time[0]; New_Bar=true; } } //Трейдинг стоп================================================================================ int SarTrailingStop() { double sar=iSAR(NULL,0,SARstep,SARmax,1); for(int i=0; iOrderStopLoss()) { if((sar-OrderStopLoss())>=TrailingStep*Point && (Bid-sar)>MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),sar,OrderTakeProfit(),0); } } } } if(OrderSelect(i-1,SELECT_BY_POS)==true) { if(Tral==true && OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==5903442) { if(OrderStopLoss()>sar) { if((OrderStopLoss()-sar)>TrailingStep*Point && (sar-Ask)>MarketInfo(Symbol(),MODE_STOPLEVEL)*Point) { OrderModify(OrderTicket(),OrderOpenPrice(),sar,OrderTakeProfit(),0); } } } } } return(0); } //закрытие=========================================================================== int close() { double M1=iMA(NULL,0,5,0,1,0,0); double M2=iMA(NULL,0,5,0,1,1,0); double M11=iMA(NULL,0,5,0,1,0,1); double M21=iMA(NULL,0,5,0,1,1,1); for(int y=0; yM2 && Bid0){ OrderClose(OrderTicket(),OrderLots(),Bid,5);} if (OrderType()==OP_SELL && M1>M2+(Ust*Point) && M11High[1] && OrderProfit()>0){ OrderClose(OrderTicket(),OrderLots(),Ask,5);} } } }