//+------------------------------------------------------------------+ //| DVI.mq5 | //| DV Intermediate Oscillator (DVI) 2009 | //| by David Varadi (https://cssanalytics.wordpress.com/) | //| ported by fxborg 2016 (http://fxborg-labo.hateblo.jp/) | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.01" #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 1 #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_level1 20.0 #property indicator_level2 50.0 #property indicator_level3 80.0 #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrRed,clrLightGreen #property indicator_width1 2 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ input int InpLookBack=252; // LockBack Period input int InpSmoothing=3; // Smoothing double MAIN[]; double CLR[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,MAIN,INDICATOR_DATA); SetIndexBuffer(1,CLR,INDICATOR_COLOR_INDEX); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { for(int i=(int)MathMax(prev_calculated-1,0); i=50)?1:0; } //--- return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double Series[][10]; int PRICE=0; int R=1; int B=2; int R5MA=3; int R100=4; int R100MA=5; int B10=6; int B100=7; int MAG=8; int STR=9; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double calcDVI(double price,int smooth,int lookback,int r,int bars) { double v; if(ArrayRange(Series,0)!=bars) ArrayResize(Series,bars); Series[r][PRICE]=price; //--- if(r==0)return 0; Series[r][B] = price > Series[r-1][PRICE] ? 1 : -1; int i1st=smooth; if(r<=i1st) return 0; //--- v=0.0; for(int j=0;j