//+------------------------------------------------------------------+ //| FineTuningMA.mq5 | //| Copyright © 2010, gumgum | //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, gumgum" #property link "" //---- indicator version number #property version "1.00" //---- description of the indicator #property description "Moving Average with a more fine tuning" //---- drawing the indicator in the main window #property indicator_chart_window //---- number of indicator buffers #property indicator_buffers 1 //---- only one plot is used #property indicator_plots 1 //+-----------------------------------+ //| Parameters of indicator drawing | //+-----------------------------------+ //---- drawing the indicator as a line #property indicator_type1 DRAW_LINE //---- RoyalBlue color is used for the indicator line #property indicator_color1 clrRoyalBlue //---- the indicator line is a continuous curve #property indicator_style1 STYLE_SOLID //---- the width of indicator line is 3 #property indicator_width1 3 //---- displaying the indicator label #property indicator_label1 "FineTuningMA" //+-----------------------------------+ //| Declaration of enumerations | //+-----------------------------------+ enum Applied_price_ //Type od 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_SIMPL_, //Simpl Price (OC/2) PRICE_QUARTER_, //Quarted Price (HLOC/4) PRICE_TRENDFOLLOW0_, //TrendFollow_1 Price PRICE_TRENDFOLLOW1_ //TrendFollow_2 Price }; //+-----------------------------------+ //| Input parameters of the indicator| //+-----------------------------------+ input uint FTMA=10; input double rank1=2; input double rank2=2; input double rank3=2; input double shift1=1; input double shift2=1; input double shift3=1; input Applied_price_ IPC=PRICE_TYPICAL;//price constant /* , used for calculation of the indicator ( 1-CLOSE, 2-OPEN, 3-HIGH, 4-LOW, 5-MEDIAN, 6-TYPICAL, 7-WEIGHTED, 8-SIMPL, 9-QUARTER, 10-TRENDFOLLOW, 11-0.5 * TRENDFOLLOW.) */ input int Shift=0; // horizontal shift of the indicator in bars input int PriceShift=0; // vertical shift of the indicator in points //+-----------------------------------+ //---- declaration of a dynamic array that further // will be used as an indicator buffer double LineBuffer[]; //---- double PM[]; //---- Declaration of the average vertical shift value variable double dPriceShift; //---- declaration of the integer variables for the start of data calculation int min_rates_total; //+------------------------------------------------------------------+ //| FineTuningMA indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- initialization of the vertical shift dPriceShift=_Point*PriceShift; //---- memory distribution for variables' arrays ArrayResize(PM,FTMA); //---- Initialization of variables double sum=0; for(int h=0; hrates_total || prev_calculated<=0) // checking for the first start of calculation of an indicator first=min_rates_total; // starting index 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; barOpen[bar])return(High[bar]); else { if(Close[bar]Open[bar])return((High[bar]+Close[bar])/2.0); else { if(Close[bar]