//+------------------------------------------------------------------+ //| ColorLaguerre.mq5 | //| Copyright © 2011, Nikolay Kositsin | //| Khabarovsk, farria@mail.redcom.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Nikolay Kositsin" #property link "farria@mail.redcom.ru" //---- indicator version #property version "1.00" //---- drawing the indicator in a separate window #property indicator_separate_window //---- number of indicator buffers 2 #property indicator_buffers 2 //---- only one plot is used #property indicator_plots 1 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //---- drawing of the indicator as a three-colored line #property indicator_type1 DRAW_COLOR_LINE //---- the following colors are used for a three-colored line #property indicator_color1 CLR_NONE,Lime,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 "Signal Line" //---- blue color is used as the color of the horizontal levels line #property indicator_levelcolor Blue //---- line style #property indicator_levelstyle STYLE_DASHDOTDOT //+-----------------------------------+ //| Indicator input parameters | //+-----------------------------------+ input double gamma=0.7; input int HighLevel=85; input int MiddleLevel=50; input int LowLevel=15; //+-----------------------------------+ //---- declaration of dynamic arrays that //---- will be used as indicator buffers double ColorBuffer[],ExtLineBuffer[]; //+------------------------------------------------------------------+ //| Painting the indicator in two colors | //+------------------------------------------------------------------+ void PointIndicator(int Min_rates_total, double &IndBuffer[], double &ColorIndBuffer[], double HighLevel_, double MiddleLevel_, double LowLevel_, int bar) { //---- if(barHighLevel_) Level0=HighLev; else if(IndVelue>MiddleLevel_)Level0=HighLevMiddle; if(IndVelueHighLevel_) Level1=HighLev; else if(IndVelue>MiddleLevel_)Level1=HighLevMiddle; if(IndVeluerates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator { first=begin+1; // starting number for calculation of all bars //---- the starting initialization of calculated coefficients L0_ = price[first]; L1_ = price[first]; L2_ = price[first]; L3_ = price[first]; L0A_ = price[first]; L1A_ = price[first]; L2A_ = price[first]; L3A_ = price[first]; } else first=prev_calculated-1; // starting number for calculation of new bars //---- restore values of the variables L0 = L0_; L1 = L1_; L2 = L2_; L3 = L3_; L0A = L0A_; L1A = L1A_; L2A = L2A_; L3A = L3A_; //---- main calculation for(bar=first; bar= L1) CU = L0 - L1; else CD = L1 - L0; if(L1 >= L2) CU += L1 - L2; else CD += L2 - L1; if(L2 >= L3) CU += L2 - L3; else CD += L3 - L2; //---- if(CU+CD!=0) LRSI=CU/(CU+CD); LRSI*=100; //---- set value to ExtLineBuffer[] ExtLineBuffer[bar]=LRSI; //---- indicator coloring PointIndicator(31,ExtLineBuffer,ColorBuffer,HighLevel,MiddleLevel,LowLevel,bar); } //---- return(rates_total); } //+------------------------------------------------------------------+