Search in sources :

Example 1 with MovingRange

use of suite.trade.analysis.MovingAverage.MovingRange in project suite by stupidsing.

the class BackAllocatorGeneral method donchian.

private BackAllocator donchian(int window) {
    float threshold = .05f;
    return BackAllocator_.byPrices(prices -> {
        MovingRange[] movingRanges = ma.movingRange(prices, window);
        return Quant.fold(0, movingRanges.length, (i, hold) -> {
            MovingRange range = movingRanges[i];
            double min = range.min;
            double max = range.max;
            double price = prices[i];
            // channel wide?
            boolean b = price * threshold < (max - min);
            return b ? Quant.hold(hold, price, min, range.median, max) : hold;
        });
    });
}
Also used : MovingRange(suite.trade.analysis.MovingAverage.MovingRange)

Aggregations

MovingRange (suite.trade.analysis.MovingAverage.MovingRange)1