RSI on ROC (Momentum Pinball Indicator) Not Working - What am I doing wrong?

 

Dear All,

Here is the indicator code...it compiles ok but doesn't show any values. In debugging, I found that it is unable to populate ROC array..what am I doing wrong?

************************************************************************************************

//+------------------------------------------------------------------+
//| Momentum Pinball.mq4 |
//| Copyright © 2008, For all the hopeful traders in the world |
//| fxmaratha at yahoo dot com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, For all the hopeful traders in the world"
#property link "fxmaratha at yahoo dot com"

#property indicator_separate_window
#property indicator_minimum -5
#property indicator_maximum 5
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int ROC_Period=1;
extern int RSI_Period=3;
//---- buffers
double RSIonROC[];
double ROC[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,RSIonROC);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
for (i=0;i<Bars;i++) ROC[i]=iClose(NULL,0,i)-iClose(NULL,0,i+ROC_Period);
for (i=0;i<Bars;i++) RSIonROC[i]=iRSIOnArray(ROC,Bars,RSI_Period,i);
return(0);
}
//+------------------------------------------------------------------+

************************************************************************************************

Files:
 

You will have to either manually delcare the storage space for ROC or assign it as an indicator index, and MT4 will manage it. In this case, I would assign it as an indicator index.

 
phy wrote >>

You will have to either manually delcare the storage space for ROC or assign it as an indicator index, and MT4 will manage it. In this case, I would assign it as an indicator index.

Dear Phy,

Wonderful! Thanks for that hint!! Now, it works fine...here is the changed code.

 
Maratha wrote >>

Dear Phy,

Wonderful! Thanks for that hint!! Now, it works fine...here is the changed code.

Maratha
wrote
>>

Dear Phy,

Wonderful! Thanks for that hint!! Now, it works fine...here is the changed code.

Hi Maratha,

Trying to understand the Momentum Pinball oscillator more - it's a 3 period RSI on a one period rate of change. What would this look like expressed as plain math? Wilder's RSI is this:

RSI = 100 – [100/1 +RS]
RS = Average of n periods closes up/Average of n periods closes down.

Would Momentum Pinball be this?

RSI = 100 – [100/1 +ROC]
ROC 3 period = [(Today's close - Yesterday's close) + (Yesterday's close - Close 2 days ago) + (Close 2 days ago - Close 3 days ago)]/3

 

Hello


I would really like to be able to drag and drop another indicator,say Bollinger Bands or Keltner Channels onto this "RSI On ROC Monentum Pinball Indicator" to see when this indicator is at its extremes.


When I have the "RSI on ROC Monentum Pinball Indicator" loaded/displayed on a chart and the Data Window open, I have two indicator values: "MomentumkPinballcIn: 0.0166" and "Value2: 71.59".


I have tried changing the Bollinger Bands "Apply to" between "Previous Indicators Data" and "First Indicators Data" but it makes no difference. The BB's seem to compute off the very small 0.0166 value and do not display the BB lines over the pinball indicator.


I tried changing the code around ie. Swapping the RISonROC lines/entries with ROC lines/entries but this did not make any difference either.....


I would really appreaciate someone's help if they would not mind offering a little of their time. Many thanks in advance.....


The indicator code is posted here:


//+------------------------------------------------------------------+
//| Momentum Pinball Indicator.mq4 |
//| FX Maratha |
//| Free to use and modify for all aspiring and established traders |
//+------------------------------------------------------------------+
#property copyright "FX Maratha"
#property link "Free to use and modify for all aspiring and established traders"

#property indicator_separate_window
#property indicator_minimum -100
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 RoyalBlue
//---- input parameters
extern int ROC_Period=1;
extern int RSI_Period=3;
//---- buffers
double ROC[];
double RSIonROC[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,ROC);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,RSIonROC);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i;
for(i=0;i<Bars;i++) ROC[i]=iClose(NULL,0,i)-iClose(NULL,0,i+ROC_Period);
for(i=0;i<Bars;i++) RSIonROC[i]=iRSIOnArray(ROC,Bars,RSI_Period,i);
return(0);
}
//+------------------------------------------------------------------+
 

I am no computer programmer but I can normally change code around to make it work the way I want it too but this code is totally foreign to me, any assistance would be very much appreciated thanks.


Regards Simon

Reason: