I was trying to build an indicator that calculates the RSI from a CCI indicator.
The main problem is that I don’t know why this indicator doesn’t calculates in real time properly. When I open in real time, only the past data is ok, every new tick that is received change dramatically the indicator (in time = 0). If I close the graphic and openit again, or if I remove the indicator and add it again, both will show corrects results for the past, where before had an error.
Anyone knows why it’s happening?
#property copyright ""#property link ""#property indicator_separate_window#property indicator_buffers 1#property indicator_color1 Lime//---- Indicator Parameters ----//externint Periodo_RSI = 4;
externint Periodo_CCI = 20;
externint TimeFrame =0;
double CCI[];
double RSI[];
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicators
IndicatorBuffers(2);
SetIndexStyle(0, DRAW_HISTOGRAM);
SetIndexBuffer(0,RSI);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1,CCI);
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start()
{
int counted_bars=IndicatorCounted();
int limit;
int total= ArraySize(CCI);
ArraySetAsSeries(CCI,true) ;
//---- Data ckecking ----//if (counted_bars==0)
{
limit=Bars-1;
}
if (counted_bars>0)
{
limit=Bars-counted_bars;
}
for(int i=limit;i>=0;i--) // Count down for one pass
{
CCI[i]= iCCI(Symbol(),
TimeFrame,
Periodo_CCI,
PRICE_CLOSE,
i);
RSI[i]= iRSIOnArray(CCI,
total,
Periodo_RSI,
i)-50;
}
//----return(0);
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi everybody,
I was trying to build an indicator that calculates the RSI from a CCI indicator.
The main problem is that I don’t know why this indicator doesn’t calculates in real time properly. When I open in real time, only the past data is ok, every new tick that is received change dramatically the indicator (in time = 0). If I close the graphic and open it again, or if I remove the indicator and add it again, both will show corrects results for the past, where before had an error.
Anyone knows why it’s happening?
Thanks