Kamikaze MACD EA

cavemann  

Hi Guys,

I using a MACD EA that ships with MT4, i have backtested extensively to establish ideal parameters to use for M1/M5 charts, out of the blue instead of opening 1 or 2 trades (which it used to), it will open 70 - 80 almost instantly, i have coded a message window alert when a trade is opened, and declared variables for OrderSend parameters, question is "Why does it behave like this.?"

Code:

   double MacdCurrent, MacdPrevious, SignalPrevious;
   double SignalCurrent, MaCurrent, MaPrevious;
   int    cnt, ticket, total;
   double TakeProfitBuy = Bid+(TakeProfit*Point); //Bid+(TakeProfit*Point);
   double TakeProfitSell = Ask-(TakeProfit*Point); //Ask-(TakeProfit*Point);
   double Deviation = Slippage*10;
   double TStopBuy = Bid-(TrailingStop*Point); //Bid-(TrailingStop*Point);
   double TStopSell = Ask+(TrailingStop*Point); //Ask+(TrailingStop*Point);

   MacdCurrent=iMACD(NULL,0,FastMA,SlowMA,Signals,PRICE_CLOSE,MODE_MAIN,0);
   MacdPrevious=iMACD(NULL,0,FastMA,SlowMA,Signals,PRICE_CLOSE,MODE_MAIN,1);
   SignalCurrent=iMACD(NULL,0,FastMA,SlowMA,Signals,PRICE_CLOSE,MODE_SIGNAL,0);
   SignalPrevious=iMACD(NULL,0,FastMA,SlowMA,Signals,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);
  
   if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
      MathAbs(MacdCurrent)>MACDOpenLevel*Point && MaCurrent>MaPrevious)
         {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Deviation,0,TakeProfitBuy,"MACD Optimized",MagicNumber,0,clrNONE);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
            MessageBox(Symbol() + " BUY Order." + "\n" + "Opened Long @ " + OrderOpenPrice(),"ORDER ENTRY",0);
            }
      else
         Print("Error Opening BUY Order! : " + Symbol() + " : "  + GetLastError());
         return;
         }
      //--- check for short position (SELL) possibility
      if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
      MacdCurrent>MACDOpenLevel*Point && MaCurrent<MaPrevious)
         {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Deviation,0,TakeProfitSell,"MACD Optimized",MagicNumber,0,clrNONE);
         if(ticket>0)
            {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
            MessageBox(Symbol() + " SELL Order." + "\n" + "Opened Short @ " + OrderOpenPrice(),"ORDER ENTRY",0);
            }
         else
            Print("Error Opening SELL Order! : " + Symbol() + " : " + GetLastError());
         }
         //--- exit from the "no opened orders" block
         return;


I really would like someone to help here, thanks in advance..

Cavemann.

cavemann  

Cheers Carl,

I'll give the waiting time a try.

Many thanks.