//+------------------------------------------------------------------+ //| MiddleDiapazon.mq4 | //| Copyright © 2009, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Nikolaj Ostapjuk" #property link "nikost3@inbox.lv" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 Red #property indicator_color2 Blue #property indicator_color3 Brown //------- Буферы индикатора ------------------------------------------ double pivot1[]; double pivot2[]; double pivot3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorShortName("MiddleDiapazon "); SetIndexBuffer(0,pivot1); SetIndexStyle(0,DRAW_LINE,STYLE_DOT); SetIndexEmptyValue(0,EMPTY_VALUE); SetIndexBuffer(1,pivot2); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexEmptyValue(1,EMPTY_VALUE); SetIndexBuffer(2,pivot3); SetIndexStyle(2,DRAW_LINE,STYLE_DOT); SetIndexEmptyValue(2,EMPTY_VALUE); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { double dMax1,dMin1,P1,dMax2,dMin2,P2,dMax3,dMin3,P3; int i,nsb1,nsb2,nsb3; int TFBar1=1440; int TFBar2=10080; int TFBar3=43200; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if(counted_bars==0) limit--; for(i= limit;i>=0;i--) { nsb1=iBarShift(NULL,TFBar1,Time[i]); dMax1=iHigh(NULL, TFBar1, nsb1); dMin1=iLow (NULL, TFBar1, nsb1); P1=(dMax1+dMin1)/2.0; nsb2=iBarShift(NULL,TFBar2,Time[i]); dMax2=iHigh(NULL, TFBar2, nsb2); dMin2=iLow (NULL, TFBar2, nsb2); P2=(dMax2+dMin2)/2.0; nsb3=iBarShift(NULL,TFBar3,Time[i]); dMax3=iHigh(NULL, TFBar3, nsb3); dMin3=iLow (NULL, TFBar3, nsb3); P3=(dMax3+dMin3)/2.0; nsb3=iBarShift(NULL,TFBar3,Time[i]); pivot1[i] = P1; pivot2[i] = P2; pivot3[i] = P3; } } //+------------------------------------------------------------------+