//+------------------------------------------------------------------+ //| MacdPatternTrader.mq4 | //| FORTRADER.RU | //| http://FORTRADER.RU | //+------------------------------------------------------------------+ /* Обрабатываем паттерн голова и плечи Original description strategies: http://www.unfx.ru/strategies_to_trade/strategies_134.php Подробное описание параметров советника доступно в номере журнала от 23 Июня, предложения и отзывы мы будем рады видеть в нашей электропочте: letters@fortrader.ru http://www.fortrader.ru/arhiv.php A detailed description of the parameters adviser available issue of the journal dated Iune 23, suggestions and feedback we will be glad to see in our e-mail: letters@fortrader.ru http://www.fortrader.ru/arhiv.php Looking for an interpreter for the English version of the magazine on partnership. */ #property copyright "FORTRADER.RU" #property link "http://FORTRADER.RU" extern int stoplossbars = 6; extern int takeprofitbars = 20; extern int otstup = 10; extern int lowema=5; extern int fastema=13; extern int sum_bars_bup=10; extern double maxur=0.0045; extern double maxur1=0.0030; extern double minur=-0.0045; extern double minur1=-0.0030; extern string x="Настройки MA:"; extern int perema1=7; extern int perema2=21; extern int persma3=98; extern int perema4=365; extern double Lots=1; int buy,sell;int nummodb,nummods;int flaglot,bars_bup; int start() { AOPattern(lowema,fastema,maxur,minur); ActivePosManager(perema1,perema2,persma3,perema4); return(0); } int aop_maxur,aop_minur,aop_oksell,aop_okbuy,S,S1,H,H2,bS,bS1,bH,bH2,stops,stops1,sstops,sstops1; double max1,max2,max3,min1,min2,min3; int AOPattern(double FastEMA,double SlowEMA,double maxur,double minur) { //загружаем индикаторы double macdcurr =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,1); double macdlast =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,2); double macdlast3 =iMACD(NULL,0,FastEMA,SlowEMA,1,PRICE_CLOSE,MODE_MAIN,3); if(macdcurr>maxur1){S=1;bars_bup=bars_bup+1;} if(S==1 && macdcurrmacdlast3 && macdlast>max1 && stops==0){max1=macdlast;Print("m1"+max1);} if(max1>0 &&macdcurrmaxur&& macdcurrmacdlast3 && macdlast>max1 && macdlast>max2 && stops1==0){max2=macdlast;Print("m2"+max2);} if(max2>0 &&macdcurrmacdlast3 && macdlastmacdlast && macdlastminur){sstops=1;bS=0;} if(macdcurr>minur1 ){sstops=0;min1=0;bS=0;} /*******************************************************************************************/ if(sstops==1 && macdcurrmacdlast && macdlastminur){sstops1=1;sstops=0;} if(macdcurr>minur1 ){sstops1=0;min2=0;} /*******************************************************************************************************************/ if(sstops1==1 && macdcurr>minur&& macdlast>minur&& macdlast3>minur&& macdcurr>macdlast && macdlastmin2 && aop_okbuy==0){min3=macdlast;Print("mi3"+min3);aop_okbuy=1;sstops1=0;} if(macdcurr>maxur1 ){aop_okbuy=0;} if(aop_okbuy==1 ) { OrderSend(Symbol(),OP_BUY,Lots,Ask,3,StopLoss(1),TakeProfit(1),"FORTRADER.RU",16385,0,Red); aop_okbuy=0; aop_minur=0; nummodb=0; flaglot=0; sstops1=0; min1=0; min2=0; min3=0; } } double StopLoss(int type) {double stoploss; if(type==0) { stoploss=High[iHighest(NULL,0,MODE_HIGH,stoplossbars,1)]+otstup*Point; return(stoploss); } if(type==1) { stoploss=Low[iLowest(NULL,0,MODE_LOW,stoplossbars,1)]-otstup*Point; return(stoploss); } } double TakeProfit(int type) { int x=0,stop=0;double takeprofit; if(type==0) { while(stop==0) { takeprofit =Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x)]; if(takeprofit>Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x+takeprofitbars)]) { takeprofit =Low[iLowest(NULL,0,MODE_LOW,takeprofitbars,x+takeprofitbars)]; x=x+takeprofitbars; } else { stop=1;return(takeprofit); } } } if(type==1) { while(stop==0) { takeprofit =High[iHighest(NULL,0,MODE_HIGH,takeprofitbars,x)]; if(takeprofit5 && Close[1]>ema2 && nummodb==0) { OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/3,2),Bid,3,Violet); nummodb++; } if(OrderType()==OP_BUY && OrderProfit()>5 && High[1]>(sma1+ema3)/2 && nummodb==1) { OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),Bid,3,Violet); nummodb++; } if(OrderType()==OP_SELL && OrderProfit()>5 && Close[1]5 && Low[1]<(sma1+ema3)/2 && nummods==1) { OrderClose(OrderTicket(),NormalizeDouble(OrderLots()/2,2),Ask,3,Violet); nummods++; } } }