MACD_Entry






#property copyright " "
#property link      " "

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue

//---- input parameters
extern string waveb="alert1.wav";
extern string waves="alert2.wav";
extern int Minutes=0;
extern int BarsToCount = 300;
extern bool Alerts_On = false;
extern bool Sound_Alert = true;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
string TimeFrameStr;
string TradeMsg;
double MACD_Signal,MACD_Main;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
  SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1,Red);
  SetIndexBuffer(0,ExtMapBuffer1);
  SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1, Blue);
  SetIndexBuffer(1,ExtMapBuffer2);
  
switch(Minutes)
   {
      case 1 : TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe"; Minutes=0;
   }
   IndicatorShortName("MACD Entry ("+TimeFrameStr+")");  

 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----

for (int i = 0; i < BarsToCount; i++){
   ExtMapBuffer1[i]=0;
   ExtMapBuffer2[i]=0;
   ExtMapBuffer3[i]=0;
   

   MACD_Signal=iMACD(NULL,Minutes,5,34,5,PRICE_CLOSE,MODE_SIGNAL,i);
   MACD_Main  =iMACD(NULL,Minutes,5,34,5,PRICE_CLOSE,MODE_MAIN,i);
   
   if(MACD_Signal < MACD_Main && MACD_Main > 0)ExtMapBuffer2[i] = 1;
 
   if(MACD_Signal > MACD_Main && MACD_Main < 0)ExtMapBuffer1[i] = 1;
   
   if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
    {ExtMapBuffer3[i] = 1;}

 
 
 // -- There the code I put for alert.
 // -- But run on each ticks.
 
  if (Alerts_On && i == 1 &&  (ExtMapBuffer2[i]) > 0)
  Alert("Check ",Symbol()," Possible Trade BUY");
  if(Sound_Alert && i == 1 &&  (ExtMapBuffer2[i]) > 0) PlaySound(waveb);
    
  if (Alerts_On && i == 1 &&  (ExtMapBuffer1[i]) > 0)
  Alert("Check ",Symbol()," Possible Trade SELL");
  if(Sound_Alert && i == 1 &&  (ExtMapBuffer1[i]) > 0) PlaySound(waves);
    

  
   




  
}
 
 
 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_HISTOGRAM


Indicators Used:

MACD Histogram


Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen
It plays sound alerts