Topic: Help needed modifying BollingerBands Indicator
Can anyone please help me with a small modification of the Bollinger bands indicator, because I am just not able to do even this simple thing. The calculation should be modified so that it is based on the close for the last 19 bars and on the open for the actual bar.
here is an example written in the amibroker formula language:
Len = 20;
SumCO = Ref(Sum(C, Len -1), -1) + O;
SMA = SumCO / Len;
SumSqr = Ref(Sum(C^2, Len - 1), -1) + Sum(O^2, 1);
stabw = ( sqrt(SumSqr * Len - SumCO^2) / Len ) *2;
BBandTop0 = SMA + stabw;
BBandBot0 = SMA - stabw;
Plot(BBandTop0, "BBtop", colorRed, styleLine|styleNoRescale);
Plot(BBandBot0, "BBbot", colorRed, styleLine|styleNoRescale);
The idea behind this is to open an position when the bar opens outside the Bollinger bands, in the strategy trader it can be done with open logic “the bar opens below the lower band” and vice versa and the “use previous bar value” option is unchecked. This works but when you try to backtest it, its doing more trades then actually occurred because the Bollinger band move within the actual bar and then it looks like the bar opened outside but actually it doesn’t.
Hope this explanation helps.
Thank you in advance!