//+------------------------------------------------------------------+ //| OsHMA.mq4 | //| Copyright © 2009, Meta Quotes & sealdo | //| sealdo@yandex.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, Meta Quotes & sealdo" #property link "http://www.metaquotes.net/" //---- indicator settings #property indicator_separate_window //#property indicator_chart_window #property indicator_buffers 1 #property indicator_color1 DarkOrchid #property indicator_width1 2 //---- indicator parameters extern int FastHMA = 12; extern int SlowHMA = 26; //---- indicator buffers double OsmaBuffer[]; double PreHMA1[]; double PreHMA2[]; //+------------------------------------------------------------------+ int pF, pS; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 4 additional buffers are used for counting. IndicatorBuffers(3); //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM); //SetIndexDrawBegin(0,SignalSMA); IndicatorDigits(Digits+2); //---- 5 indicator buffers mapping SetIndexBuffer(0,OsmaBuffer); SetIndexBuffer(1,PreHMA1); SetIndexBuffer(2,PreHMA2); //---- name for DataWindow and indicator subwindow label IndicatorShortName("OsHMA("+FastHMA+","+SlowHMA+")"); pF = MathSqrt(FastHMA); pS = MathSqrt(SlowHMA); //---- initialization done return(0); } //+------------------------------------------------------------------+ double WMA(int x, int p) { return(iMA(NULL, 0, p, 0, MODE_LWMA, PRICE_CLOSE, x)); } //+------------------------------------------------------------------+ //| Moving Average of Oscillator | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- preparing the HMA for(int i=0; i