donchian-channel.mq4 | //| Copyright © 2011 Forex-indikatoren.com. All rights reserved | //| http://www.forex-indikatoren.com | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011 Forex-indikatoren.com." #property link "http://www.forex-indikatoren.com" //---- indicator settings #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DodgerBlue #property indicator_color2 Tomato #property indicator_width1 1 #property indicator_width2 1 //---- indicator parameters extern int periods=20; //---- indicator buffers double upper[]; double lower[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); //---- indicator buffers mapping SetIndexBuffer(0,upper); SetIndexBuffer(1,lower); //---- name for DataWindow and indicator subwindow label IndicatorShortName("Donchian Channel("+periods+")"); SetIndexLabel(0,"Upper"); SetIndexLabel(1,"Lower"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- calculate values for(int i=0; i