You are declaring a dynamic array
but you don't size it, you have to use ArrayResize
OK , I went one step forward, but there is still a problem:
I am using the following code, but the problem is I want to calculate MA -> period=5, MA method=Exponential, shift=0, on RSI with (period=14, Apply to=Open).
MA of RSI for bar 1 in the indicators that I have installed on the chart is = 66.4862 but the following code says it is :
2014.11.01 15:09:07.336 maOnRSI GBPJPY,M15: MA of RSI for bar= 1 = 0.1348944125100005
what am I doing wrong now?
void OnTimer() { //--- double RSIBuffer[]; double MAofRSIBuffer[]; ArrayResize(RSIBuffer,Bars+1); ArrayResize(MAofRSIBuffer,Bars+1); for(int i=0 ; i<=Bars ; i++) { RSIBuffer[i]=NormalizeDouble( iRSI(NULL,0,14,PRICE_OPEN,i) ,4); } for(int i=0; i <= 4; i++) { MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,5,0,MODE_EMA,i); Print ("IMAOnArray for ",i," = ",NormalizeDouble (iMAOnArray(RSIBuffer,0,5,0,MODE_EMA,i) ,4)); } Print ("rsi = ",RSIBuffer[1]); Print ("MA of RSI for bar= ", 1," = ",MAofRSIBuffer[1]); }
OK , I went one step forward, but there is still a problem:
I am using the following code, but the problem is I want to calculate MA -> period=5, MA method=Exponential, shift=0, on RSI with (period=14, Apply to=Open).
MA of RSI for bar 1 in the indicators that I have installed on the chart is = 66.4862 but the following code says it is :
2014.11.01 15:09:07.336 maOnRSI GBPJPY,M15: MA of RSI for bar= 1 = 0.1348944125100005
what am I doing wrong now?
OK , I went one step forward, but there is still a problem:
I am using the following code, but the problem is I want to calculate MA -> period=5, MA method=Exponential, shift=0, on RSI with (period=14, Apply to=Open).
MA of RSI for bar 1 in the indicators that I have installed on the chart is = 66.4862 but the following code says it is :
2014.11.01 15:09:07.336 maOnRSI GBPJPY,M15: MA of RSI for bar= 1 = 0.1348944125100005
what am I doing wrong now?
Try this
void OnTimer() { //--- int i,j; int signal=5; double RSIBuffer[]; double MAofRSIBuffer[]; ArrayResize(RSIBuffer,signal*2); ArrayResize(MAofRSIBuffer,signal+2); for(i=0 ; i<signal*2 ; i++) { RSIBuffer[i] = iRSI(NULL,0,14,PRICE_OPEN,i); } ArraySetAsSeries(RSIBuffer,true); for(i=0; i <signal+2; i++) { MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,siganl,0,MODE_EMA,i); Print ("IMAOnArray for ",i," = ",iMAOnArray(RSIBuffer,0,signal,0,MODE_EMA,i)); } Print ("rsi = ",RSIBuffer[1]); Print ("MA of RSI for bar= ", 1," = ",MAofRSIBuffer[1]); }
pipPod: Try this |
WithArraySetAsSeries(rsi,true);Before filling in the values. |
pipPod: Try this | With Before filling in the values. |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to calculate MA of RSI .
SO far I could come this far with this code:
but when I compile the above EA I see this message in Experts tab of MT4:
2014.11.01 14:28:07.723 array out of range in 'maOnRSI.mq4' (50,10)
how can I solve this? what am I doing wrong?
Please help.
Thanks