//+------------------------------------------------------------------+ //| Stalker1_2.mq4 | //| Ìàõðàêîâ Àðòåìèé | //| Mahrusha@narod.ru | //| ðàáîòàåò òîëüêî íà 1ìèí. | //| äëÿ EURUSD per = 56, kor = 0.11 | //| äëÿ GBPUSD per = 53, kor = 0.07 | //| íà äðóãèõ ïàðàõ ìîæåòå ïîäîáðàòü ñàìè | //| äàâîëüíî ñòàáèëüíî ðàáîòàåò íà ôóíòå. | //+------------------------------------------------------------------+ #property copyright "Ìàõðàêîâ Àðòåìèé" #property link "Mahrusha@narod.ru" #define MAGIC 577571 extern double Lots = 0.10; extern double TakeProfit = 30; extern double TrailingStop = 15; extern double kor = 0.09; extern int per = 56; // extern double StopLoss = 10; double Points; int init() { Points = MarketInfo (Symbol(), MODE_POINT); //---- return(0); } int start() { int cnt=0, total; if(Bars<100) { Print("bars less than 100"); return(0); } double diMACD0=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD1=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD2=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_SIGNAL,0); double diEnvelopes3=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_LOWER,0); double diOpen4=iOpen(NULL,0,0); double diStochastic5=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0); double diStochastic6=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_SIGNAL,0); double diEnvelopes7=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_LOWER,0); double diClose8=iClose(NULL,0,0); double diMACD9=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD10=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_SIGNAL,0); double diMACD11=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diEnvelopes12=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_UPPER,0); double diClose13=iClose(NULL,0,0); double diEnvelopes14=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_UPPER,0); double diOpen15=iOpen(NULL,0,0); double diStochastic16=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0); double diStochastic17=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_SIGNAL,0); double diMACD18=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD19=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD20=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_SIGNAL,0); double diClose21=iClose(NULL,0,0); double diEnvelopes22=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_UPPER,0); double diEnvelopes23=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_UPPER,5); double diOpen24=iOpen(NULL,0,0); double diStochastic25=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_SIGNAL,0); double diStochastic26=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0); double diClose27=iClose(NULL,0,0); double diEnvelopes28=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_LOWER,0); double diOpen29=iOpen(NULL,0,0); double diEnvelopes30=iEnvelopes(NULL,0,per,MODE_EMA,0,PRICE_CLOSE,kor,MODE_LOWER,0); double diStochastic31=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_MAIN,0); double diStochastic32=iStochastic(NULL,0,8,3,3,MODE_EMA,PRICE_CLOSE,MODE_SIGNAL,0); double diMACD33=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); double diMACD34=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_SIGNAL,0); double diMACD35=iMACD(NULL,0,5,34,5,PRICE_CLOSE,MODE_MAIN,0); if(OrdersTotal()<1) { if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money"); return(0); } if ((diMACD0<0 && diMACD1>diMACD2 && diEnvelopes3>diOpen4 && diStochastic5<20 && diStochastic6<20 && diEnvelopes7>diClose8)) { OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Points,"macd signal",16384,0,Red); // èñïîëíÿåì if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice()); return(0); } if ((diMACD9>0 && diMACD10>diMACD11 && diEnvelopes12<diClose13 && diEnvelopes14<diOpen15 && diStochastic16>80 && diStochastic17>80)) { OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Points,"macd sample",16384,0,Red); // èñïîëíÿåì if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice()); return(0); } } total=OrdersTotal(); for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_SELL && OrderSymbol()==Symbol()) { if(OrderType()==OP_BUY) { if ((diMACD18>0 && diMACD19<diMACD20 && diClose21>diEnvelopes22 && diEnvelopes23<diOpen24 && diStochastic25>80 && diStochastic26>80)) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); return(0); } if ((diClose27<diEnvelopes28 && diOpen29<diEnvelopes30 && diStochastic31<20 && diStochastic32<20 && diMACD33<0 && diMACD34<diMACD35)) { if(Bid-OrderOpenPrice()>Points*TrailingStop) { if(OrderStopLoss()<Bid-Points*TrailingStop) { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Points*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } else { if(TrailingStop>0) { if((OrderOpenPrice()-Ask)>(Points*TrailingStop)) { if(OrderStopLoss()==0.0 || OrderStopLoss()>(Ask+Points*TrailingStop)) { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Points*TrailingStop,OrderTakeProfit(),0,Red); return(0); } } } } } } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open prices of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Indicators Used:
MACD Histogram
Envelopes indicator
Stochastic 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: