//+------------------------------------------------------------------+ //| AroonOscillator.mq5 | //| Copyright © 2011, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ //---- author of the indicator #property copyright "Copyright © 2011, Nikolay Kositsin" //---- link to the website of the author #property link "farria@mail.redcom.ru" //---- Indicator Version Number #property version "1.00" //---- drawing the indicator in a separate window #property indicator_separate_window //---- number of indicator buffers 1 #property indicator_buffers 1 //---- only one plot is used #property indicator_plots 1 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //---- drawing of the indicator as a three color line #property indicator_type1 DRAW_LINE //---- red color is used as the color of the line #property indicator_color1 Red //---- indicator line is a solid one #property indicator_style1 STYLE_SOLID //---- indicator line width is equal to 2 #property indicator_width1 2 //---- displaying label of the signal line #property indicator_label1 "AroonOscillator" //+----------------------------------------------+ //| Horizontal levels display parameters | //+----------------------------------------------+ #property indicator_level1 +50 #property indicator_level2 0 #property indicator_level3 -50 #property indicator_levelcolor Gray #property indicator_levelstyle STYLE_DASHDOTDOT //+----------------------------------------------+ //| Input parameters of the indicator | //+----------------------------------------------+ input int AroonPeriod= 9; // Period of the indicator input int AroonShift = 0; // Horizontal shift of the indicator in bars //+----------------------------------------------+ //---- declaration of dynamic arrays that further // will be used as indicator buffers double ExtLineBuffer[]; //+------------------------------------------------------------------+ //| searching index of the highest bar | //+------------------------------------------------------------------+ int iHighest( const double &array[],// array for searching for maximum element index int count,// the number of the array elements (from a current bar to the index descending), // along which the searching must be performed. int startPos //the initial bar index (shift relative to a current bar), // the search for the greatest value begins from ) { //---- int index=startPos; //----checking correctness of the initial index if(startPos<0) { Print("Bad value in the function iHighest, startPos = ",startPos); return(0); } //---- checking correctness of startPos value if(startPos-count<0) count=startPos; double max=array[startPos]; //---- searching for an index for(int i=startPos; i>startPos-count; i--) { if(array[i]>max) { index=i; max=array[i]; } } //---- returning of the greatest bar index return(index); } //+------------------------------------------------------------------+ //| searching index of the lowest bar | //+------------------------------------------------------------------+ int iLowest( const double &array[],// array for searching for minimum element index int count,// the number of the array elements (from a current bar to the index descending), // along which the searching must be performed. int startPos //the initial bar index (shift relative to a current bar), // the search for the lowest value begins from ) { //---- int index=startPos; //---- checking correctness of the initial index if(startPos<0) { Print("Bad value in the function iLowest, startPos = ",startPos); return(0); } //---- checking correctness of startPos value if(startPos-count<0) count=startPos; double min=array[startPos]; //---- searching for an index for(int i=startPos; i>startPos-count; i--) { if(array[i]rates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator first=AroonPeriod-1; // starting number for calculation of all bars else first=prev_calculated-1; // starting number for calculation of new bars //---- main cycle of calculation of the indicator for(bar=first; bar