//+------------------------------------------------------------------+ //| 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 1 #property indicator_color1 Yellow //---- input parameters extern int ChannelPeriod=30; //---- buffers double MediumBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,MediumBuffer); SetIndexLabel(0, "MidCh"); SetIndexDrawBegin(0, ChannelPeriod); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i,limit, counted_bars = IndicatorCounted(); int k; //---- if(Bars <= ChannelPeriod) return(0); //---- initial zero if(counted_bars < 1) for(i = 1;i <= ChannelPeriod; i++) MediumBuffer[Bars-i] = 0.0; //---- i = Bars - ChannelPeriod - 1; if(counted_bars >= ChannelPeriod) i = Bars - counted_bars - 1; //---- Comment(i); while (i>=0) { double high=High[iHighest(NULL,0,2,ChannelPeriod,i)]; double low=Low[iLowest(NULL,0,1,ChannelPeriod,i)]; double high1=High[iHighest(NULL,0,2,ChannelPeriod,i+1)]; double low1=Low[iLowest(NULL,0,1,ChannelPeriod,i+1)]; //UpBuffer[i]=iHighest(High,PeriodPR,i); //DownBuffer[i]=iLowest(Low,PeriodPR,i); if (MathAbs(((high+low)/2.0)-(high1+low1)/2.0)