Libraryless. Click here for Pure Java version (17534L/101K).
persistable sclass ROCIndicator extends CandleBasedIndicator<Double> { // ROC values collected as ticker gettable TickerSequence rocHistory = new TickerSequence("ROC"); // ATR value settable double roc = Double.NaN; Double value() { ret roc(); } *(int *length) {} { length = 10; onCandleAdded((IVF1<TradingCandle>) candle -> { if (l(candles()) >= length) { roc(asPercentIncrease(candle.close(), candles().first().close())); long time = candle.endTime().toLong(); rocHistory?.addIfPriceChanged(roc, time); } }); } TickerSequence asTicker(L<TradingCandle> candles) { feed(candles); ret rocHistory; } void reset :: after { resetFields(this, "roc rocHistory"); } }
Began life as a copy of #1036469
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036488 |
Snippet name: | ROCIndicator [rate of change, trading indicator] |
Eternal ID of this version: | #1036488/4 |
Text MD5: | c5780c08f7a0f075a0b4fea2727761f1 |
Transpilation MD5: | 359dec07458f89292ac74027da45b530 |
Author: | stefan |
Category: | javax / trading |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-18 03:41:52 |
Source code size: | 796 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 150 / 220 |
Version history: | 3 change(s) |
Referenced in: | [show references] |