// Note: First one will not be exact static L convertToHeikinAshi(L candles) { L heikinAshi = emptyList(candles); TradingCandle prevHA = null; for i over candles: { var c = candles.get(i); TradingCandle ha = c.clone(); ha.close((c.low()+c.high()+c.open()+c.close())/4); if (prevHA != null) ha.open((prevHA.open()+prevHA.close())/2); ha.low(min(ha.low(), ha.open())); ha.high(max(ha.high(), ha.open())); heikinAshi.add(ha); prevHA = ha; } ret heikinAshi; }