//+------------------------------------------------------------------+ //| Helen_Iv_Line_Experts_RSI_2.mq4 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Helen_Iv" #property link "http://helenclubfinance.com" //---- input parameters extern double Lots=0.1; extern int p=23; extern int TakeProfit = 980; int BuyTicket,SellTicket; int StLevel2; double slts,tpts; datetime prevtimecalc=0; int OpenBuy=0, OpenSell=0, CloseBuy=0, CloseSell=0; int Spread; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { double DeltaTakeStopMin, DeltaFreezeLevel; Spread = MarketInfo (Symbol(), MODE_SPREAD); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { CalcCloseOpen(); int total=OrdersTotal(); int NP=0; for(int x=total; x>=0; x--) { if (!OrderSelect(x, SELECT_BY_POS, MODE_TRADES))continue; // Закрытие открытых позиций if (OrderType()==OP_BUY && CloseBuy==1){Close_Order(); continue;} if (OrderType()==OP_SELL && CloseSell==1) {Close_Order(); continue;} // исключаем открытие нескольких ордеров на сигнале одном бара if (OrderType()==OP_BUY && OrderOpenPrice()>=Time[0]) NP++; if (OrderType()==OP_SELL && OrderOpenPrice()>=Time[0]) NP++; } if (NP == 0) Open_Buy_Sell (); return(0); } //+------------------------------------------------------------------+ // вычислим условия на закрытие и открытие позиций //+------------------------------------------------------------------+ void CalcCloseOpen() { //Comment("000Buy - ", OpenBuy, " 000Sell - ", OpenSell); if (prevtimecalc==Time[0])return; else prevtimecalc=Time[0]; OpenBuy=0; OpenSell=0; CloseBuy=0; CloseSell=0; double t2=iRSI(NULL,0,p,PRICE_CLOSE,1); double t22=iRSI(NULL,0,p,PRICE_CLOSE,2); if (t2>30.0&&t22<30.0&&t2>t22&&t2>30.0) {OpenBuy=1; CloseSell=1;} if (t2<70.0&&t22>70.0&&t2