persistable sclass TradingCandles extends NotifyingList { *() {} *(List *list) { super(list); } // how high a high is (lol) IntPair highLevel(int idx) { ret intPair(highLeft(idx), highRight(idx)); } int highLeft(int idx) { double high = get(idx).high(); for (int j = 1; j < idx; j++) if (get(idx-j).high() > high) ret j-1; ret idx; } int highRight(int idx) { double high = get(idx).high(); int n = size(); for (int j = 1; j < n-idx; j++) if (get(idx+j).high() > high) ret j-1; ret n-idx; } // how low a low is (see highs) IntPair lowLevel(int idx) { ret intPair(lowLeft(idx), lowRight(idx)); } int lowLeft(int idx) { double low = get(idx).low(); for (int j = 1; j < idx; j++) if (get(idx-j).low() < low) ret j-1; ret idx; } int lowRight(int idx) { double low = get(idx).low(); int n = size(); for (int j = 1; j < n-idx; j++) if (get(idx+j).low() < low) ret j-1; ret n-idx; } }