I'm calculating the Bollinger values for current bar and past 2 period bars, but I get incorrect values. When I try to go back to historical bar using "int barsAgo" and calculate the Bollinger values, I'm not getting the correct number? Could you please check?
Bollinger(ISeries<double> input, double numStdDev, int period).Lower[int barsAgo]
Bollinger(ISeries<double> input, double numStdDev, int period).Upper[int barsAgo]
//bollinger for 15 min time frame - current or recently closed bar
bollingerALT = (Bollinger(BarsArray[1],2,8).Upper[0] - Bollinger(BarsArray[1],2,8).Lower[0]);
bollingerUpLT = Bollinger(BarsArray[1],2,8).Upper[0];
bollingerBLT = Math.Round((bollingerALT / bollingerUpLT) * 100, 2);
//bollinger for 15 min time frame - barsAgo[2]
bollingerALT = (Bollinger(1, 14).Upper[2] - Bollinger(1, 14).Lower[2]);
bollingerUpLT = Bollinger(1, 14).Upper[2];
bollingerBLT = Math.Round((bollingerAST / bollingerUpST) * 100, 2);
Print(string.Format("{0} | Time[2]: {1}, Bollinger Value [2]:{2}", Time[0], Time[2], bollingerBLT));
#### Output ####
3/14/2022 9:00:00 PM - Current bollinger -15 min time frame - 0.27
3/14/2022 9:00:00 PM | Time[2]: 3/14/2022 8:30:00 PM, Bollinger Value [2]:0.21
3/14/2022 9:15:00 PM Current bollinger -15 min time frame - 0.27
3/14/2022 9:15:00 PM | Time[2]: 3/14/2022 8:45:00 PM, Bollinger Value [2]:0.21
3/14/2022 9:30:00 PM Current bollinger -15 min time frame- 0.33
3/14/2022 9:30:00 PM | Time[2]: 3/14/2022 9:00:00 PM, Bollinger Value [2]:0.2
3/14/2022 9:45:00 PM - Current bollinger -15 min time frame- 0.49
3/14/2022 9:45:00 PM | Time[2]: 3/14/2022 9:15:00 PM, Bollinger Value [2]:0.3
3/14/2022 10:00:00 PM Current bollinger -15 min time frame- bollingerBLT - 0.54
3/14/2022 10:00:00 PM | Time[2]: 3/14/2022 9:30:00 PM, Bollinger Value [2]:0.37
Comment