Navigation:Home > Content >

vazz.mq5

Time: 2017-06-23 | Download file:vazz.mq5

//+------------------------------------------------------------------+
//|                                                              vaZZ|
//|                                              Copyright 2013,  J.B|
//+------------------------------------------------------------------+
#property copyright "Copyright © 2013, J.B"

#property version   "1.00"

#include 

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   1
#property indicator_type1   DRAW_COLOR_ZIGZAG
#property indicator_color1  clrBlack,clrCyan,clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3
#property indicator_label1  "vaZZ"

input int vaMA_period=15;
input bool use_double_smooth=1;

double vaMA_buffer[],ZZhigh_buffer[],ZZlow_buffer[],ZZColor_buffer[],EMA[];
//+------------------------------------------------------------------+
//| vaZZ initialization function                                     |
//+------------------------------------------------------------------+  
void OnInit()
  {
   SetIndexBuffer(0,ZZhigh_buffer,INDICATOR_DATA);
   SetIndexBuffer(1,ZZlow_buffer,INDICATOR_DATA);
   SetIndexBuffer(2,ZZColor_buffer,INDICATOR_COLOR_INDEX);
   SetIndexBuffer(3,EMA,INDICATOR_CALCULATIONS);
   SetIndexBuffer(4,vaMA_buffer,INDICATOR_CALCULATIONS);
  }
//+------------------------------------------------------------------+
//| vaZZ iteration function                                          |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,const int begin,const double &price[])
  {
   int first,bar;
   double vel,acc,aaa;

   ExponentialMAOnBuffer(rates_total,prev_calculated,begin,vaMA_period,price,EMA);

   if(rates_totalvaMA_buffer[bar]) ZZColor_buffer[bar]=2;
      
      if(ZZColor_buffer[bar]-ZZColor_buffer[bar-1]==1)
      ZZhigh_buffer[bar-1]=price[bar-1];
        
      if(ZZColor_buffer[bar]-ZZColor_buffer[bar-1]==-1)
      ZZlow_buffer[bar-1]=price[bar-1]; 
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

Recommend