//+------------------------------------------------------------------+ //| FTLM-STLM.mq5 | //| Copyright 2002, Finware.ru Ltd. | //| http://www.finware.ru/ | //+------------------------------------------------------------------+ //---- copyright #property copyright "Copyright 2002, Finware.ru Ltd." //---- URL #property link "http://www.finware.ru/" //---- version #property version "1.00" //---- indicator is plotted in a separate window #property indicator_separate_window //---- number of buffers used #property indicator_buffers 2 //---- number of indicator plots #property indicator_plots 2 //+--------------------------------------+ //| STLM plot parameters | //+--------------------------------------+ //---- draw STLM as a histogram #property indicator_type1 DRAW_HISTOGRAM //---- histogram color #property indicator_color1 Blue //---- line style #property indicator_style1 STYLE_SOLID //---- line width #property indicator_width1 2 //---- label of STLM indicator #property indicator_label1 "STLM" //+--------------------------------------+ //| FTLM plot parameters | //+--------------------------------------+ //---- draw FTLM as a line #property indicator_type2 DRAW_LINE //---- line color #property indicator_color2 Red //---- line style #property indicator_style2 STYLE_DASHDOTDOT //---- line width #property indicator_width2 2 //---- label of FTLM indicator #property indicator_label2 "FTLM" //---- input parameters input int STLMShift=0; // horizontal shift of STLM (in bars) input int FTLMShift=0; // horizontal shift of FTLM (in bars) //---- declaration and initialization of variables, used for the calculated data int STLMPeriod=91; int FTLMPeriod=44; //---- declaration of dynamic arrays, used as indicator buffers double ExtLineBuffer1[],ExtLineBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- set ExtLineBuffer1[] array as indicator buffer SetIndexBuffer(0,ExtLineBuffer1,INDICATOR_DATA); //---- set plot draw begin PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,STLMPeriod); //---- set plot label PlotIndexSetString(0,PLOT_LABEL,"STLM"); //---- set empty values PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- set ExtLineBuffer2[] array as indicator buffer SetIndexBuffer(1,ExtLineBuffer2,INDICATOR_DATA); //---- set plot draw begin PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,FTLMPeriod); //---- set plot label PlotIndexSetString(1,PLOT_LABEL,"FTLM"); //---- set empty values PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- a variable used for indicator short name string shortname="FTLM-STLM"; //--- indicator short name IndicatorSetString(INDICATOR_SHORTNAME,shortname); //--- set precision IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1); //---- } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, // rates total const int prev_calculated, // bars, processed at last call const int begin, // begin const double &price[] // price array ) { //---- //---- checking of bars if(rates_totalrates_total || prev_calculated<=0) // at first call { first=STLMPeriod-1+begin; // starting bar index //---- increase position if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,begin+STLMPeriod); } else first=prev_calculated-1; // starting bar index //---- STLM calculation loop for(bar=first; barrates_total || prev_calculated<=0) // at first call { first=FTLMPeriod-1+begin; // starting bar index //---- increase position if(begin>0) PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,begin+FTLMPeriod); } else first=prev_calculated-1; // starting bar index //---- FTLM calculation loop for(bar=first; bar