//+------------------------------------------------------------------+ //| Objective.mq5 | //| Copyright © 2011, LeMan. | //| b-market@mail.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, LeMan." #property link "b-market@mail.ru" #property description "Objective" //---- indicator version #property version "1.00" //---- drawing the indicator in the main window #property indicator_chart_window //+-----------------------------------+ //| Declaration of constants | //+-----------------------------------+ #define LINES_TOTAL 8 // The constant for the number of the indicator lines #define RESET 0 // the constant for getting the command for the indicator recalculation back to the terminal //---- number of indicator buffers #property indicator_buffers LINES_TOTAL //---- total number of graphical plots #property indicator_plots LINES_TOTAL //+-----------------------------------+ //| Indicators drawing parameters | //+-----------------------------------+ //---- drawing the indicators as lines #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_LINE #property indicator_type5 DRAW_LINE #property indicator_type6 DRAW_LINE #property indicator_type7 DRAW_LINE #property indicator_type8 DRAW_LINE //---- selection of the lines colors #property indicator_color1 Red #property indicator_color2 Red #property indicator_color3 Red #property indicator_color4 Red #property indicator_color5 Green #property indicator_color6 Green #property indicator_color7 Green #property indicator_color8 Green //---- lines are dott-dash curves #property indicator_style1 STYLE_DASHDOTDOT #property indicator_style2 STYLE_DASHDOTDOT #property indicator_style3 STYLE_DASHDOTDOT #property indicator_style4 STYLE_DASHDOTDOT #property indicator_style5 STYLE_DASHDOTDOT #property indicator_style6 STYLE_DASHDOTDOT #property indicator_style7 STYLE_DASHDOTDOT #property indicator_style8 STYLE_DASHDOTDOT //---- lines 1 width #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 1 #property indicator_width6 1 #property indicator_width7 1 #property indicator_width8 1 //+-----------------------------------+ //| Declaration of enumerations | //+-----------------------------------+ enum ENUM_APPLIED_PRICE_ // Type of constant { PRICE_CLOSE_ = 1, // Close PRICE_OPEN_, // Open PRICE_HIGH_, // High PRICE_LOW_, // Low PRICE_MEDIAN_, // Median Price (HL/2) PRICE_TYPICAL_, // Typical Price (HLC/3) PRICE_WEIGHTED_, // Weighted Close (HLCC/4) PRICE_SIMPLE, // Simple Price (OC/2) PRICE_QUARTER_, // Quarted Price (HLOC/4) PRICE_TRENDFOLLOW0_, // TrendFollow_1 Price PRICE_TRENDFOLLOW1_ // TrendFollow_2 Price }; //+-----------------------------------+ //| Indicator input parameters | //+-----------------------------------+ input int Sample=20; input int Quartile_1 = 25; input int Quartile_2 = 50; input int Quartile_3 = 75; input int Shift=0; // Horizontal shift of the indicator in bars //+-----------------------------------+ //---- declaration of global variables int n0,n1,n2,n3; double HOArray[],OLArray[]; //---- Declaration of the integer variables for the start of data calculation int min_rates_total,N_; //+------------------------------------------------------------------+ //| Variables arrays for the indicator buffers creation | //+------------------------------------------------------------------+ class CIndicatorsBuffers { public: double IndBuffer[]; }; //+------------------------------------------------------------------+ //| Indicator buffers creation | //+------------------------------------------------------------------+ CIndicatorsBuffers Ind[LINES_TOTAL]; //+------------------------------------------------------------------+ //| Variables arrays for the indicator buffers creation | //+------------------------------------------------------------------+ int GetValue(string InValueName,int InValue) { //---- if(InValue>100) { Print("Parameter "+InValueName+" cannot be above 100! Default value equal to 100 will be used!"); return(100); } if(InValue<0) { Print("Parameter "+InValueName+" cannot be below 0! Default value equal to 0 will be used!"); return(0); } //---- return(InValue); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- initialization of constants double P1=GetValue("Quartile_1",Quartile_1); double P2=GetValue("Quartile_2",Quartile_2); double P3=GetValue("Quartile_3",Quartile_3); N_=Sample; if(N_<3){N_=3;Print("Sample parameter cannot be less than 3! Default value equal to 3 will be used!");} min_rates_total=N_; n0=N_-1; n1=int(MathRound(N_*P1/100)); if(!n1) n1=100; n2=int(MathRound(N_*P2/100)); if(!n2) n2=100; n3=int(MathRound(N_*P3/100)); if(!n3) n3=100; //---- memory distribution for variables' arrays if(ArrayResize(HOArray,N_)