Download MetaTrader 5

Can´t create and access an ARRAY of a "not built" in indicator

To add comments, please log in or register
Daniel Arges
129
Daniel Arges  

Does anybody faced this issue?

I´m hardly trying to create an Array for a not built in indicator (Bollinger Bands Width), and use it in my main code.

The problem is:

- "Not built in" indicators doesn´t pass Arrays by iCustom();

- "Not built in" indicators doesn´t work with CoppyBuffer().

 

I tried with For operator, but I havent succeed neither. Something like that:


class CiBBW : public CIndicator
{               
        public:
           double upper[], lower[], bbWidth[];
           int Init(string pSymbol,ENUM_TIMEFRAMES pTimeframe,int pPeriod,int pShift,double pDeviation,ENUM_APPLIED_PRICE pPrice);
           double Upper(int pShift=0);
           double Lower(int pShift=0);
           double BbwArray (int pShift=0);
           CiBBW();
};

CiBBW::CiBBW(void)
{
        ArraySetAsSeries(upper,true);
        ArraySetAsSeries(lower,true);
        ArraySetAsSeries(bbWidth,true);
}

int CiBBW::Init(string pSymbol,ENUM_TIMEFRAMES pTimeframe,int pPeriod,int pShift,double pDeviation,ENUM_APPLIED_PRICE pPrice)
{
        handle = iBands(pSymbol,pTimeframe,pPeriod,pShift,pDeviation,pPrice);
        return(handle);
}

double CiBBW::Upper(int pShift=0)
{
        CopyBuffer(handle,1,0,MAX_COUNT,upper);
        double value = NormalizeDouble(upper[pShift],0);
        return(value);
}

double CiBBW::Lower(int pShift=0)
{
        CopyBuffer(handle,2,0,MAX_COUNT,lower);
        double value = NormalizeDouble(lower[pShift],0);
        return(value);
}

double CiBBW::BbwArray(int pShift=0)
{

   for(int i = 0; i < MAX_COUNT; i++)
     {
            bbWidth[i] = floor((upper[i]-lower[i]));

     }
     
        CopyBuffer(handle,3,0,MAX_COUNT,bbWidth);
        double value = NormalizeDouble(bbWidth[pShift],0);
        return(value);
}
Alain Verleyen
Moderator
32512
Alain Verleyen  

- "Not built in" indicators doesn´t work with CoppyBuffer().

Of course custom indicators are using CopyBuffer().

But you are using iBands() so what is the problem ?

To add comments, please log in or register