Libraryless. Click here for Pure Java version (10640L/59K).
1 | // Note: First one will not be exact |
2 | static L<TradingCandle> convertToHeikinAshi(L<TradingCandle> candles) {
|
3 | L<TradingCandle> heikinAshi = emptyList(candles); |
4 | TradingCandle prevHA = null; |
5 | for i over candles: {
|
6 | var c = candles.get(i); |
7 | TradingCandle ha = c.clone(); |
8 | ha.close((c.low()+c.high()+c.open()+c.close())/4); |
9 | if (prevHA != null) |
10 | ha.open((prevHA.open()+prevHA.close())/2); |
11 | ha.low(min(ha.low(), ha.open())); |
12 | ha.high(max(ha.high(), ha.open())); |
13 | heikinAshi.add(ha); |
14 | prevHA = ha; |
15 | } |
16 | ret heikinAshi; |
17 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036496 |
| Snippet name: | convertToHeikinAshi |
| Eternal ID of this version: | #1036496/4 |
| Text MD5: | f52fb186d75dfa09db8478e218ab67af |
| Transpilation MD5: | e39691df4b9824ae126fba24eca7e68f |
| Author: | stefan |
| Category: | javax / trading |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-12-27 20:49:43 |
| Source code size: | 564 bytes / 17 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 456 / 595 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |