Navigation:Home > Content >

ImpulseOsMA_&_alerts.mq4

Time: 2018-01-13 | Download file:ImpulseOsMA_&_alerts.mq4

//+------------------------------------------------------------------+
//|                                                  ImpulseOsMA.mq4 |
//|                                              Дзенчарский Николай |
//|                                               [email protected] |
//+------------------------------------------------------------------+
#property copyright "Дзенчарский Николай"
#property link      "[email protected]"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 LimeGreen
#property indicator_color5 DeepSkyBlue
//---- input parameters
extern int       FastEMA=12;
extern int       SlowEMA=26;
extern int       SignalEMA=9;
extern int       MAPeriod=12;
extern int       MAMode=0; 
extern bool   alertsOn                 = true;
extern bool   alertsOnCurrent          = false;
extern bool   alertsMessage            = true;
extern bool   alertsSound              = true;
extern bool   alertsEmail              = false;
/* Какой метод MA использовать: 0 - SMA, 1 - EMA*/
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double trend[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(6);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexBuffer(5,trend);
   
   IndicatorShortName("ImpulseOsMA ("+FastEMA+","+SlowEMA+","+SignalEMA+","+MAPeriod+","+MAMode+")");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i;
   int bCount;
   int    counted_bars=IndicatorCounted();
   double cur, prev, curMA, prevMA;
//----
   if(counted_bars>0) counted_bars--;
   bCount=Bars-counted_bars;
   for(i=bCount; i>=0; i--)
   {
      ExtMapBuffer1[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      trend[i] = trend[i+1];
      if (ExtMapBuffer1[i]>0) trend[i] =  1;
      if (ExtMapBuffer1[i]<0) trend[i] = -1;
   }      
   for(i=0; iprev && curMA>prevMA)
      {
         ExtMapBuffer3[i]=0;
         ExtMapBuffer4[i]=cur*3;
         ExtMapBuffer5[i]=0;
      }
      else if(cur        

Recommend