Navigation´╝ÜHome > Content >

mn_Histogram_Stoch.mq4

Time: 2014-10-06 | Download file:mn_Histogram_Stoch.mq4

//+------------------------------------------------------------------+
//|                                                   Stochastic.mq4 |
//+------------------------------------------------------------------+
#property copyright "Mn"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 White
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3

extern int KPeriod = 5;
extern int DPeriod = 3;
extern int Slowing = 3;

double col1[];
double col2[];
double col3[];

//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, col1);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, col2);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(2, col3);
   SetIndexLabel(0, "");
   SetIndexLabel(1, "");
   SetIndexLabel(2, "");
   
   return(0);
  }

//+------------------------------------------------------------------+
int start()
  {
   int    i, k;
   int    counted_bars = IndicatorCounted();
   double price;

   i = Bars - counted_bars;

   while(i >= 0)
     {
      if(iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) > 70 &&
         iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i) <= 70)
        {
         col1[i] = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 1, MODE_MAIN, i);
         col2[i] = 0;
         col3[i] = 0;
        }
      else
        {
         if(iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i + 1) < 30 &&
            iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i) >= 30)
           {
            col2[i] = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i);
            col1[i] = 0;
            col3[i] = 0;
           }
         else
          {
           col3[i] = iStochastic(NULL, 0, KPeriod, DPeriod, Slowing, MODE_SMA, 0, MODE_MAIN, i);
           col1[i] = 0;
           col2[i] = 0;
          }
        }

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

Recommend