//+------------------------------------------------------------------+ //| Sredina.mq4 | //| Copyright © 2010, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- input parameters int BarsHistory=4; //---- buffers double HighBuffer[]; double LowBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,119); SetIndexBuffer(0,HighBuffer); SetIndexLabel(0,"High"); SetIndexDrawBegin(0,BarsHistory); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,119); SetIndexBuffer(1,LowBuffer); SetIndexLabel(1,"Low"); SetIndexDrawBegin(1,BarsHistory); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i,limit; int k; //---- if(Bars<=BarsHistory) return(0); int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; i=Bars-counted_bars; if(counted_bars==0) i-=1+5; double H,L; while(i>=0) { /*H=0; L=0; for(k=i+1;k<=i+BarsHistory;k++) { H=H+High[k]; L=L+Low[k]; } //HighBuffer[i]=H/BarsHistory;*/ if(Volume[i+2]>(Volume[i+3]+Volume[i+4]+Volume[i+5])/3 && iFractals(NULL,0,MODE_UPPER,i+2)==High[i+2]) { HighBuffer[i]=High[i+2]+Point+MarketInfo(Symbol(),MODE_SPREAD)*Point; } else { HighBuffer[i]=HighBuffer[i+1]; } if(Volume[i+2]>(Volume[i+3]+Volume[i+4]+Volume[i+5])/3 && iFractals(NULL,0,MODE_LOWER,i+2)==Low[i+2]) { LowBuffer[i]=Low[i+2]-Point; } else { LowBuffer[i]=LowBuffer[i+1]; } //else MediumBuffer[i]=0.0; i--; } //---- return(0); } //+------------------------------------------------------------------+