Navigation:Home > Content >

MACD_Sample_(5).mq4

Time: 2018-04-06 | Download file:MACD_Sample_(5).mq4

javazi°яЯЪаАяк[KйянШx)˜*oрCdщЅHџ‘‚°CЪtР•pCOпвИЉЪрCЕuB@	˜АC:ќп@u2EАCЇЖњ@кZтАC$пI@_ѓџАCљц@Ф¬LАC	@Ј@	IФщАC	†ЄЂ	Б>o@	ыЦ4h
вёh
6\ПHC
pн¶а
«ЏЙC
ж$Ђ ёvC[LМЂ•б#CРuyЂJ˜@CPвА‚sE@CЖ
јАч›т@C;3iАlДџ@CІњЯбнL@C'ЕЊWщ@Cњо9ОnЂCжCЁЂC‡?“ёРИЂCю©@-щuЂCsСµ@Ј""ЂCиъb@JПЂC^#@ЏґDАCУKј@ЬсАCHti@zћАCїЭЮЂп.KАC5‹ЂdVшАCЄ/8ЂЫАnCWеЂPйC”Ђ’ЂЖИC	©?Ђ;:uCЃґА°c"Cц;aА%‹ПCkdАњхD@CаЊ»Ас@CUµhА‡Fћ@CНЮьoK@CBG‹q—ш@C·p8йmЂC,˜е^*ЂCЎБ’УRЗЂCк?H{tЂCЋSґ@Ѕ¤!ЂC|a@2МОЂCxҐ@Є6CАCнН»@^рАCbцh@”‡ќАCЪ_ЭЂ	°JАCO€ЉЂ~ШчАCД±7Ђф¤АC9ЩдЂkkCЇ‘Ђа“ЗC$+>Ђ%Qг'ЂоbЂ\?Ђ6оЂ(яяяяmЭ	яяяяmЭ%QЅt¬'2,26,9,PRICE_CLOSE,MODE_MAIN,0);
   MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
   SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
   MaCurrent=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0);
   MaPrevious=iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1);

   total=OrdersTotal();
   if(total<1) 
     {
      // no opened orders identified
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money. Free Margin = ", AccountFreeMargin());
         return(0);  
        }
      // check for long position (BUY) possibility
      if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious(MACDOpenLevel*Point) && MaCurrent>MaPrevious)
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"macd sample",16384,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
           }
         else Print("Error opening BUY order : ",GetLastError()); 
         return(0); 
        }
      // check for short position (SELL) possibility
      if(MacdCurrent>0 && MacdCurrentSignalPrevious && 
         MacdCurrent>(MACDOpenLevel*Point) && MaCurrent0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
           }
         else Print("Error opening SELL order : ",GetLastError()); 
         return(0); 
        }
      return(0);
     }
   // it is important to enter the market correctly, 
   // but it is more important to exit it correctly...   
   for(cnt=0;cnt0 && MacdCurrentSignalPrevious &&
               MacdCurrent>(MACDCloseLevel*Point))
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position
                 return(0); // exit
                }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()SignalCurrent &&
               MacdPrevious(MACDCloseLevel*Point))
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position
               return(0); // exit
              }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
  }
// the end.

Recommend