Warning: session_start(): open(/var/lib/php/sessions/sess_o7e1cvgi31335kos4e3dr3m2g7, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass RSI extends CandleBasedIndicator {
settable int smoothingPeriod;
settable SmoothedMovingAverage up;
settable SmoothedMovingAverage down;
settable double rsi = Double.NaN;
Double value() { ret rsi(); }
{
length = 25;
onCandleAdded((IVF1) c -> {
if (isNull(up())) init();
var x = c.move();
var u = max(x, 0.0);
var d = neg(min(x, 0.0));
up().add(u);
down().add(d);
var rs = div(up()!, down()!);
rsi(100-100/(1+rs));
});
}
void init() {
up = new SmoothedMovingAverage(this.length());
down = new SmoothedMovingAverage(this.length());
}
TickerSequence asTicker(L candles) {
var seq = new TickerSequence("RSI");
fOr (candle : candles) {
feed(candle);
var value = this.get();
if (not(isNaN(value)))
seq.addIfPriceChanged(value, candle.endTime().toLong());
}
ret seq;
}
}