public Bar(List<PriceTick> ticks) { super((PriceTick) getEarliestBarFromCollection(convertTicksToBars(ticks))); int fullTicksSize = ticks.size(); List<Bar> bars = convertTicksToBars(ticks); if (bars.size() > 1) { for (int i = 0; i < bars.size(); i++) { Bar bar = bars.get(i); if (bar.isTick()) { if (i < bars.size() - 1) { children.add(new Bar(bar, bars.get(i + 1))); } } else { children.add(bar); } } boolean negativeDetected = false; boolean positiveDetected = false; boolean opposingDetected = negativeDetected && positiveDetected; // boolean hasZeroes = false; while (!(children.size() <= 2 || childrenFormZigZag() || childrenConsolidatedByDirection())) { // hasZeroes = false; groupSameDirectionBars(fullTicksSize); for (Bar bar : children) { if (bar.direction() == 1) { positiveDetected = true; } else if (bar.direction() == -1) { negativeDetected = true; } } opposingDetected = negativeDetected && positiveDetected; if (children.size() > 3 && opposingDetected) { groupZigZags(); } // grouped = true; } } else { isTick = true; } if (children.size() == 1) { Bar childBar = children.get(0); children.clear(); children = new ArrayList<Bar>(childBar.children); } if (children.size() > 0) { startBar = children.get(0); endBar = children.get(children.size() - 1); } calculateDirection(); if (!isTick() && direction() != 0 && openBid() != 0 && closeBid() != 0) { levels.add(new Level(closeBid(), duration(), direction(), closingTime())); } // printChildren(); }
public Bar(Bar first, Bar second) { super(first); startBar = first; endBar = second; children.add(first); children.add(second); isAtomicDelta = true; calculateDirection(); }