Your array MD[] is of integer type?
double MD[]; double ABS[];
It is floating-point constant.
Put whole code.
#property indicator_separate_window #property indicator_buffers 7 #property indicator_color1 Yellow #property indicator_color2 Green #property indicator_color3 Blue #property indicator_color4 Red #property indicator_color5 Yellow #property indicator_color6 Pink #property indicator_color7 Tomato double EMA_CCI[]; double CCI[]; double TP[]; double SMATP[]; double MD[]; double ABS[]; double CCI_CALC[]; int ExtCountedBars=0 ; int init() { SetIndexStyle(0,1); SetIndexStyle(1,1); SetIndexStyle(2,1); SetIndexStyle(3,1); SetIndexStyle(4,1); SetIndexStyle(5,1); SetIndexStyle(6,1); SetIndexBuffer(0,CCI); SetIndexBuffer(1,EMA_CCI); SetIndexBuffer(2,TP); SetIndexBuffer(3,SMATP); SetIndexBuffer(4,MD); SetIndexBuffer(5,ABS); SetIndexBuffer(6,CCI_CALC); IndicatorShortName("EMA_CCI - " ); SetIndexLabel(0,"CCI"); SetIndexLabel(1,"EMA_CCI"); SetIndexLabel(2,"TP"); SetIndexLabel(3,"SMATP"); SetIndexLabel(4,"MD"); SetIndexLabel(5,"ABS"); SetIndexLabel(6,"CCI_CALC"); return(0); } int start() { if(Bars<=10) return(0); ExtCountedBars=IndicatorCounted(); if (ExtCountedBars<0) return(-1); if (ExtCountedBars>0) ExtCountedBars--; int pos = Bars-ExtCountedBars-1; while(pos>=0) { CCI[pos] = iCCI(NULL,0,13,PRICE_TYPICAL,pos) ; // - Simple CCI indicator - works fine // EMA_CCI[pos] = iMA(NULL,0,5,0,1,CCI[pos],pos) ; // - The Main Objective: EMA(CCI(13),5) - doesnt work TP[pos] = ( High[pos] + Low[pos] + Close[pos] ) / 3 ; // - Starting caltulate the CCI manual SMATP[pos] = iMA(NULL,0,13,0,0,PRICE_TYPICAL,pos) ; ABS[pos] = MathAbs( TP[pos] - SMATP[pos] ); MD[pos] = (iMA(NULL,0,13,0,0,ABS[pos],pos)) ; // CCI_CALC[pos] = ( TP[pos]-SMATP[pos] ) / ( MD[pos] * 0.015 ) ; - doesnt work // CCI_CALC[pos] = ( ABS[pos] ) / ( MD[pos] * 0.015 ) ; - doesnt work //--> CCI = ( Typical Price - SMATP ) / ( Mean Deviation x 0.015 ) - An objective - calculate manual the CCI indicator // Then I have discovered this formula is wrong pos--; } return(0); }
Ok, so let's concentrate only my Main Objective, to create the Exponencial Moving Average (period 5) of the CCI (period 13)
indicator.
CCI[pos] = iCCI(NULL,0,13,PRICE_TYPICAL,pos) ; // - Simple CCI indicator - works fine EMA_CCI[pos] = iMA(NULL,0,5,0,1,CCI[pos],pos) ; // - The Main Objective: EMA(CCI(13),5) - doesn't work
Relative:
SMATP[pos] = iMA(NULL,0,13,0,0,PRICE_TYPICAL,pos) ; MD[pos] = (iMA(NULL,0,13,0,0,ABS[pos],pos)) ; EMA_CCI[pos] = iMA(NULL,0,5,0,1,CCI[pos],pos) ; // - The Main Objective: EMA(CCI(13),5) - doesn't work
Again, why are you using integer constant PRICE_TYPICAL for sixth parameter in the first iMA and an element of double array in the others? What logic do you follow?
Perhaps you need to apply iMAOnArray() to the arrays instead.
Hint. Use iMAOnArray() in a separate loop as it needs fully prepared data.
Irtron, thank you very much your hint. This formula works well:
CCI[pos] = iCCI(NULL,0,13,PRICE_TYPICAL,pos) ; // - Simple CCI indicator - works fine EMA_CCI[pos] = iMAOnArray(CCI,0,5,0,MODE_EMA,pos) ; // - The Main Objective: EMA(CCI(13),5)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I'm a beginner MQL4 user. There are lot of little - and smart - things dont know about it.
I'm working on an indicator. I found myself face to an interesting thing about multiplication. I show you:
This row is works well:
But this one doesnt work:
Please help me somebody!
Thank you.
Relative