sclass BollingerBands { new Welford welford; settable int length = 20; // Bollinger length (how many candles to look at) settable double deviation = 2; new CircularFifoBuffer lastCandles; settable DoubleRange range; Candle lastCandle() { ret lastCandles.last(); } void add(TradingCandle candle) { if (lastCandle() != null && candle.startTime <= lastCandle().startTime) ret; candles.removeToSize(length-1); candles.add(candle); } bCandles <- dropLast < syncTakeLast (bollingerLength plus 1) < candles liveCandles prices <- toDoubleArray for candle in bCandles { candle endPrice } as <- averageAndStandardDeviation prices print +as boll <- bollingerRange(as, deviation); print +boll }