//+------------------------------------------------------------------+ //| Keltner Channel.mq5 | //| Copyright © 2011, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ // For the indicator to work, place the file SmoothAlgorithms.mqh | // in the terminal_data_catalogue\MQL5\Include | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- 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 3 //---- 3 plots are used #property indicator_plots 3 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //---- drawing of the indicator as a line #property indicator_type1 DRAW_LINE //---- use yellow color for the indicator line #property indicator_color1 Yellow //---- indicator line is a solid curve #property indicator_style1 STYLE_SOLID //---- Indicator line width is equal to 1 #property indicator_width1 1 //---- displaying of the the indicator label #property indicator_label1 "Upper Keltner" //---- drawing of the indicator as a line #property indicator_type2 DRAW_LINE //---- use gray color for the indicator line #property indicator_color2 Gray //---- indicator line is a solid curve #property indicator_style2 STYLE_SOLID //---- Indicator line width is equal to 1 #property indicator_width2 1 //---- displaying of the indicator label #property indicator_label2 "Middle Keltner" //---- drawing of the indicator as a line #property indicator_type3 DRAW_LINE //---- Magenta color is used for indicator line #property indicator_color3 Magenta //---- indicator line is a solid curve #property indicator_style3 STYLE_SOLID //---- Indicator line width is equal to 1 #property indicator_width3 1 //---- displaying of the the indicator label #property indicator_label3 "Lower Keltner" //+-----------------------------------+ //| INDICATOR INPUT PARAMETERS | //+-----------------------------------+ enum Applied_price_ //Type of constant { PRICE_CLOSE_ = 1, //PRICE_CLOSE PRICE_OPEN_, //PRICE_OPEN PRICE_HIGH_, //PRICE_HIGH PRICE_LOW_, //PRICE_LOW PRICE_MEDIAN_, //PRICE_MEDIAN PRICE_TYPICAL_, //PRICE_TYPICAL PRICE_WEIGHTED_, //PRICE_WEIGHTED PRICE_SIMPLE_, //PRICE_SIMPLE PRICE_QUARTER_, //PRICE_QUARTER_ PRICE_TRENDFOLLOW0_, //PRICE_TRENDFOLLOW0_ PRICE_TRENDFOLLOW1_ //PRICE_TRENDFOLLOW1_ }; input int KeltnerPeriod=20; //Period of averaging input ENUM_MA_METHOD MA_Method_=MODE_SMA; //Method of averaging input double Ratio=1.0; input Applied_price_ IPC=PRICE_CLOSE_;//Price constant /* , used for calculation of the indicator (1-CLOSE, 2-OPEN, 3-HIGH, 4-LOW, 5-MEDIAN, 6-TYPICAL, 7-WEIGHTED, 8-SIMPLE, 9-QUARTER, 10-TRENDFOLLOW, 11-0.5 * TRENDFOLLOW.) */ input int Shift=0; // Horizontal shift of the indicator in bars //---+ //Indicator buffers double UpperBuffer[]; double MiddleBuffer[]; double LowerBuffer[]; //---- Declaration of the integer variables for the start of data calculation int StartBar; //+------------------------------------------------------------------+ // Declaration of classes of averaging | //+------------------------------------------------------------------+ #include //+------------------------------------------------------------------+ // calculation of the half of the Keltner Channel width | //+------------------------------------------------------------------+ double GetKeltner(int period,int bar,const double &High[],const double &Low[]) { //---- double Resalt,sum=0; for(int iii=0; iii