#property copyright "Евгений Л. Leus79@yandex.ru" extern int tp=1450; extern int sl=650; extern double Lot=0.1; extern int perma1=5; extern int perma2=8; int Us1=70; int Us2=30; int Ur1=70; int Ur2=30; extern int perst=5; extern int slowst=3; extern int perrsi=5; extern bool Tral=true; double SARstep=0.02; double SARmax=0.2; extern int TrailingStep=950; int Ust=70; //--------------------------------------------------------------------- //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } bool New_Bar; int tick,tick2; //------------------------------------------------------------------------------------------------------ int start() { New_Bar=false ; Fun_New_Bar(); if ( New_Bar==true){ tick=0; tick2=0;} HideTestIndicators(true); double slb,sls,tpb,tps; double m1=iMA(NULL,0,perma1,0,1,0,0); double m2=iMA(NULL,0,perma2,0,1,0,0); //--------------------------------- double m11=iMA(NULL,0,perma1,0,1,0,1); double m22=iMA(NULL,0,perma2,0,1,0,1); //--------------------------------- double r=iRSI(NULL,0,perrsi,0,0); double s=iStochastic(NULL,0,perst,3,slowst,0,0,0,0); double s1=iStochastic(NULL,0,perst,3,slowst,0,0,0,1); if (OrderSelect(tick,SELECT_BY_TICKET)==false ){ if (m1>=m2 && m11s1 && s50 && rm22 && 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);} } } }