Seeking help with price array passwed to Bollinger Bands when dropped on indicator vs in code referencing data array

 

Hello Everyone,


When I drop the built-in Bollingers Bands on to an indicator and set the Apply to the First Indicator's Data I get the correct results. (see first two images)


Now when I try to program the BB and the underlying 'price' in one indicator to mimic the results of dropping the BB on the indicator in the chart I get very different results.

as you can see in the bottom part of the image the Red Dash line is the underlying 'price' and when I compare its values it is the say as in the upper part of the image. Now the BB upper/lower bands in the bottom image are totally different in shape and in values to the dropped BB above it.


Here are the two indicators and again what I am trying to do is add the LaguerreFilter to the code of the bollinger bands code and have it mimic the shape and values as if I dropped the built-in BB on the LaguerreFilter.

What I think is causing my problem is;

while(k>=i)
{
   newres=Close[k]-oldval;
   sum+=newres*newres;
   k--;
}

the BB references the close in the calculation but I am not sure what the built-in BB uses when it is dropped on an indicator and the price is set to 'First Indicator'

Any help is greatly appreciated.

Thank you for your Time

EK

 

I finally realized that I can just use iBandsOnArray and achieve the results I am looking for.


Thanks

Reason: