//+------------------------------------------------------------------+ //| Donchian Fibo | //| Copyright © 2015, Guilherme Santos | //| fishguil@gmail.com | //| | //| Modified Version of Donchian Channels | //| By Luis Guilherme Damiani | //| http://www.damianifx.com.br | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015, Guilherme Santos" #property link "fishguil@gmail.com" //---- indicator version number #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers #property indicator_buffers 7 //---- 7 plots are used #property indicator_plots 7 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //Escalas Fibo: 1, .786, .618, .5, .382, .214, .0 //---- drawing of the indicator as a line #property indicator_type1 DRAW_LINE //---- use olive color for the indicator line #property indicator_color1 Blue //---- indicator line is a solid curve #property indicator_style1 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width1 2 //---- indicator label display #property indicator_label1 "Fibo 1.000" //---- //---- drawing of the indicator as a line #property indicator_type2 DRAW_LINE //---- use gray color for the indicator line #property indicator_color2 DeepSkyBlue //---- indicator line is a solid curve #property indicator_style2 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width2 1 //---- indicator label display #property indicator_label2 "Fibo 0.786" //---- //---- drawing of the indicator as a line #property indicator_type3 DRAW_LINE //---- use pale violet red color for the indicator line #property indicator_color3 Aqua //---- indicator line is a solid curve #property indicator_style3 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width3 1 //---- indicator label display #property indicator_label3 "Fibo 0.618" //---- //---- drawing of the indicator as a line #property indicator_type4 DRAW_LINE //---- use pale violet red color for the indicator line #property indicator_color4 White //---- indicator line is a solid curve #property indicator_style4 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width4 2 //---- indicator label display #property indicator_label4 "Fibo 0.500" //---- //---- drawing of the indicator as a line #property indicator_type5 DRAW_LINE //---- use pale violet red color for the indicator line #property indicator_color5 Yellow //---- indicator line is a solid curve #property indicator_style5 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width5 1 //---- indicator label display #property indicator_label5 "Fibo 0.382" //---- //---- drawing of the indicator as a line #property indicator_type6 DRAW_LINE //---- use pale violet red color for the indicator line #property indicator_color6 Orange //---- indicator line is a solid curve #property indicator_style6 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width6 1 //---- indicator label display #property indicator_label6 "Fibo 0.214" //---- //---- drawing of the indicator as a line #property indicator_type7 DRAW_LINE //---- use pale violet red color for the indicator line #property indicator_color7 Red //---- indicator line is a solid curve #property indicator_style7 STYLE_SOLID //---- indicator line width is equal to 1 #property indicator_width7 2 //---- indicator label display #property indicator_label7 "Fibo 0.000" //+-----------------------------------+ //| Enumeration declaration | //+-----------------------------------+ enum Applied_Extrem //type of extreme points { HIGH_LOW, HIGH_LOW_OPEN, HIGH_LOW_CLOSE, OPEN_HIGH_LOW, CLOSE_HIGH_LOW }; //+-----------------------------------+ //| Input parameters of the indicator | //+-----------------------------------+ input int FiboPeriod=72; // Period of averaging input Applied_Extrem Extremes=HIGH_LOW; // Type of extreme points input int Margins=-2; input int Shift=0; // Horizontal shift of the indicator in bars //+-----------------------------------+ //---- indicator buffers double Buffer1000[]; double Buffer0786[]; double Buffer0618[]; double Buffer0500[]; double Buffer0382[]; double Buffer0214[]; double Buffer0000[]; //+------------------------------------------------------------------+ //| 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]