Add B7 Trailing Stops family (6 indicators) (#193)
Adds the **Trailing Stops** family deepening (B7), six new indicators (434 -> 440):
- **KaseDevStop** — Cynthia Kase's volatility stop on the standard deviation of the two-bar true range.
- **ElderSafeZone** — Alexander Elder's stop offset by a multiple of average market noise.
- **AtrRatchet** — Kaufman ATR ratchet that tightens its multiple by a per-bar increment.
- **Nrtr** — Nick Rypock Trailing Reverse (percentage band).
- **TimeBasedStop** — exits after a fixed number of bars (scalar fraction of elapsed life).
- **ModifiedMaStop** — moving-average based trailing stop.
("Wilder Volatility System" is intentionally skipped — it overlaps the existing VoltyStop/Psar/SarExt.)
Each takes Candle input; the five band/structure stops emit a {value, direction} struct, TimeBasedStop a scalar. Wired across core, Python/Node/WASM bindings, fuzz target and tests. Verified locally: 3560 core lib + 398 doc tests, clippy clean, 515 node tests, 852 pytest, counter 440.
This commit is contained in:
@@ -356,6 +356,7 @@ const candleScalar = {
|
||||
Qstick: { make: () => new wickra.Qstick(10), step: (ind, i) => ind.update(open[i], close[i]), batch: (ind) => ind.batch(open, close) },
|
||||
VolatilityRatio: { make: () => new wickra.VolatilityRatio(14), step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
ProjectionOscillator: { make: () => new wickra.ProjectionOscillator(14), step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
TimeBasedStop: { make: () => new wickra.TimeBasedStop(5), step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
};
|
||||
|
||||
for (const [name, d] of Object.entries(candleScalar)) {
|
||||
@@ -447,6 +448,11 @@ const multi = {
|
||||
BomarBands: { make: () => new wickra.BomarBands(4, 0.85), fields: ['upper', 'middle', 'lower'], step: (ind, i) => ind.update(close[i]), batch: (ind) => ind.batch(close) },
|
||||
MedianChannel: { make: () => new wickra.MedianChannel(5, 2.0), fields: ['upper', 'middle', 'lower'], step: (ind, i) => ind.update(close[i]), batch: (ind) => ind.batch(close) },
|
||||
ProjectionBands: { make: () => new wickra.ProjectionBands(3), fields: ['upper', 'middle', 'lower'], step: (ind, i) => ind.update(high[i], low[i]), batch: (ind) => ind.batch(high, low) },
|
||||
KaseDevStop: { make: () => new wickra.KaseDevStop(3, 1.0), fields: ['value', 'direction'], step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
ElderSafeZone: { make: () => new wickra.ElderSafeZone(14, 2.0), fields: ['value', 'direction'], step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
AtrRatchet: { make: () => new wickra.AtrRatchet(14, 4.0, 0.1), fields: ['value', 'direction'], step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
Nrtr: { make: () => new wickra.Nrtr(2.0), fields: ['value', 'direction'], step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
ModifiedMaStop: { make: () => new wickra.ModifiedMaStop(14), fields: ['value', 'direction'], step: (ind, i) => ind.update(high[i], low[i], close[i]), batch: (ind) => ind.batch(high, low, close) },
|
||||
};
|
||||
|
||||
for (const [name, d] of Object.entries(multi)) {
|
||||
|
||||
Vendored
+94
@@ -149,6 +149,26 @@ export interface DonchianStopValue {
|
||||
stopLong: number
|
||||
stopShort: number
|
||||
}
|
||||
export interface KaseDevStopValue {
|
||||
value: number
|
||||
direction: number
|
||||
}
|
||||
export interface ElderSafeZoneValue {
|
||||
value: number
|
||||
direction: number
|
||||
}
|
||||
export interface AtrRatchetValue {
|
||||
value: number
|
||||
direction: number
|
||||
}
|
||||
export interface NrtrValue {
|
||||
value: number
|
||||
direction: number
|
||||
}
|
||||
export interface ModifiedMaStopValue {
|
||||
value: number
|
||||
direction: number
|
||||
}
|
||||
/** Vortex Indicator pair: `VI+` and `VI-`. */
|
||||
export interface VortexValue {
|
||||
plus: number
|
||||
@@ -1668,6 +1688,15 @@ export declare class ProjectionOscillator {
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type TimeBasedStopNode = TimeBasedStop
|
||||
export declare class TimeBasedStop {
|
||||
constructor(maxBars: number)
|
||||
update(high: number, low: number, close: number): number | null
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type StochNode = Stochastic
|
||||
export declare class Stochastic {
|
||||
constructor(kPeriod: number, dPeriod: number)
|
||||
@@ -2328,6 +2357,71 @@ export declare class RenkoTrailingStop {
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type KaseDevStopNode = KaseDevStop
|
||||
export declare class KaseDevStop {
|
||||
constructor(period: number, dev: number)
|
||||
update(high: number, low: number, close: number): KaseDevStopValue | null
|
||||
/**
|
||||
* Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
* Warmup positions are `NaN`.
|
||||
*/
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type ElderSafeZoneNode = ElderSafeZone
|
||||
export declare class ElderSafeZone {
|
||||
constructor(period: number, coeff: number)
|
||||
update(high: number, low: number, close: number): ElderSafeZoneValue | null
|
||||
/**
|
||||
* Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
* Warmup positions are `NaN`.
|
||||
*/
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type AtrRatchetNode = AtrRatchet
|
||||
export declare class AtrRatchet {
|
||||
constructor(atrPeriod: number, startMult: number, increment: number)
|
||||
update(high: number, low: number, close: number): AtrRatchetValue | null
|
||||
/**
|
||||
* Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
* Warmup positions are `NaN`.
|
||||
*/
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type NrtrNode = Nrtr
|
||||
export declare class Nrtr {
|
||||
constructor(pct: number)
|
||||
update(high: number, low: number, close: number): NrtrValue | null
|
||||
/**
|
||||
* Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
* Warmup positions are `NaN`.
|
||||
*/
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type ModifiedMaStopNode = ModifiedMaStop
|
||||
export declare class ModifiedMaStop {
|
||||
constructor(period: number)
|
||||
update(high: number, low: number, close: number): ModifiedMaStopValue | null
|
||||
/**
|
||||
* Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
* Warmup positions are `NaN`.
|
||||
*/
|
||||
batch(high: Array<number>, low: Array<number>, close: Array<number>): Array<number>
|
||||
reset(): void
|
||||
isReady(): boolean
|
||||
warmupPeriod(): number
|
||||
}
|
||||
export type TypicalPriceNode = TypicalPrice
|
||||
export declare class TypicalPrice {
|
||||
constructor()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -2922,6 +2922,59 @@ impl ProjectionOscillatorNode {
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(js_name = "TimeBasedStop")]
|
||||
pub struct TimeBasedStopNode {
|
||||
inner: wc::TimeBasedStop,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl TimeBasedStopNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(max_bars: u32) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::TimeBasedStop::new(max_bars as usize).map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(&mut self, high: f64, low: f64, close: f64) -> napi::Result<Option<f64>> {
|
||||
Ok(self.inner.update(cnd(high, low, close, 0.0)?))
|
||||
}
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let mut out = Vec::with_capacity(high.len());
|
||||
for i in 0..high.len() {
|
||||
out.push(
|
||||
self.inner
|
||||
.update(cnd(high[i], low[i], close[i], 0.0)?)
|
||||
.unwrap_or(f64::NAN),
|
||||
);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[napi(object)]
|
||||
pub struct StochValue {
|
||||
pub k: f64,
|
||||
@@ -6591,6 +6644,372 @@ impl RenkoTrailingStopNode {
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Kase DevStop ==============================
|
||||
|
||||
#[napi(object)]
|
||||
pub struct KaseDevStopValue {
|
||||
pub value: f64,
|
||||
pub direction: f64,
|
||||
}
|
||||
|
||||
#[napi(js_name = "KaseDevStop")]
|
||||
pub struct KaseDevStopNode {
|
||||
inner: wc::KaseDevStop,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl KaseDevStopNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(period: u32, dev: f64) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::KaseDevStop::new(period as usize, dev).map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(
|
||||
&mut self,
|
||||
high: f64,
|
||||
low: f64,
|
||||
close: f64,
|
||||
) -> napi::Result<Option<KaseDevStopValue>> {
|
||||
Ok(self
|
||||
.inner
|
||||
.update(cnd(high, low, close, 0.0)?)
|
||||
.map(|o| KaseDevStopValue {
|
||||
value: o.value,
|
||||
direction: o.direction,
|
||||
}))
|
||||
}
|
||||
/// Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
/// Warmup positions are `NaN`.
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let n = high.len();
|
||||
let mut out = vec![f64::NAN; n * 2];
|
||||
for i in 0..n {
|
||||
if let Some(o) = self.inner.update(cnd(high[i], low[i], close[i], 0.0)?) {
|
||||
out[i * 2] = o.value;
|
||||
out[i * 2 + 1] = o.direction;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Elder SafeZone ==============================
|
||||
|
||||
#[napi(object)]
|
||||
pub struct ElderSafeZoneValue {
|
||||
pub value: f64,
|
||||
pub direction: f64,
|
||||
}
|
||||
|
||||
#[napi(js_name = "ElderSafeZone")]
|
||||
pub struct ElderSafeZoneNode {
|
||||
inner: wc::ElderSafeZone,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl ElderSafeZoneNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(period: u32, coeff: f64) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::ElderSafeZone::new(period as usize, coeff).map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(
|
||||
&mut self,
|
||||
high: f64,
|
||||
low: f64,
|
||||
close: f64,
|
||||
) -> napi::Result<Option<ElderSafeZoneValue>> {
|
||||
Ok(self
|
||||
.inner
|
||||
.update(cnd(high, low, close, 0.0)?)
|
||||
.map(|o| ElderSafeZoneValue {
|
||||
value: o.value,
|
||||
direction: o.direction,
|
||||
}))
|
||||
}
|
||||
/// Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
/// Warmup positions are `NaN`.
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let n = high.len();
|
||||
let mut out = vec![f64::NAN; n * 2];
|
||||
for i in 0..n {
|
||||
if let Some(o) = self.inner.update(cnd(high[i], low[i], close[i], 0.0)?) {
|
||||
out[i * 2] = o.value;
|
||||
out[i * 2 + 1] = o.direction;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== ATR Ratchet ==============================
|
||||
|
||||
#[napi(object)]
|
||||
pub struct AtrRatchetValue {
|
||||
pub value: f64,
|
||||
pub direction: f64,
|
||||
}
|
||||
|
||||
#[napi(js_name = "AtrRatchet")]
|
||||
pub struct AtrRatchetNode {
|
||||
inner: wc::AtrRatchet,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl AtrRatchetNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(atr_period: u32, start_mult: f64, increment: f64) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::AtrRatchet::new(atr_period as usize, start_mult, increment)
|
||||
.map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(
|
||||
&mut self,
|
||||
high: f64,
|
||||
low: f64,
|
||||
close: f64,
|
||||
) -> napi::Result<Option<AtrRatchetValue>> {
|
||||
Ok(self
|
||||
.inner
|
||||
.update(cnd(high, low, close, 0.0)?)
|
||||
.map(|o| AtrRatchetValue {
|
||||
value: o.value,
|
||||
direction: o.direction,
|
||||
}))
|
||||
}
|
||||
/// Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
/// Warmup positions are `NaN`.
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let n = high.len();
|
||||
let mut out = vec![f64::NAN; n * 2];
|
||||
for i in 0..n {
|
||||
if let Some(o) = self.inner.update(cnd(high[i], low[i], close[i], 0.0)?) {
|
||||
out[i * 2] = o.value;
|
||||
out[i * 2 + 1] = o.direction;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== NRTR ==============================
|
||||
|
||||
#[napi(object)]
|
||||
pub struct NrtrValue {
|
||||
pub value: f64,
|
||||
pub direction: f64,
|
||||
}
|
||||
|
||||
#[napi(js_name = "Nrtr")]
|
||||
pub struct NrtrNode {
|
||||
inner: wc::Nrtr,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl NrtrNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(pct: f64) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::Nrtr::new(pct).map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(&mut self, high: f64, low: f64, close: f64) -> napi::Result<Option<NrtrValue>> {
|
||||
Ok(self
|
||||
.inner
|
||||
.update(cnd(high, low, close, 0.0)?)
|
||||
.map(|o| NrtrValue {
|
||||
value: o.value,
|
||||
direction: o.direction,
|
||||
}))
|
||||
}
|
||||
/// Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
/// Warmup positions are `NaN`.
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let n = high.len();
|
||||
let mut out = vec![f64::NAN; n * 2];
|
||||
for i in 0..n {
|
||||
if let Some(o) = self.inner.update(cnd(high[i], low[i], close[i], 0.0)?) {
|
||||
out[i * 2] = o.value;
|
||||
out[i * 2 + 1] = o.direction;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Modified MA Stop ==============================
|
||||
|
||||
#[napi(object)]
|
||||
pub struct ModifiedMaStopValue {
|
||||
pub value: f64,
|
||||
pub direction: f64,
|
||||
}
|
||||
|
||||
#[napi(js_name = "ModifiedMaStop")]
|
||||
pub struct ModifiedMaStopNode {
|
||||
inner: wc::ModifiedMaStop,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
impl ModifiedMaStopNode {
|
||||
#[napi(constructor)]
|
||||
pub fn new(period: u32) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: wc::ModifiedMaStop::new(period as usize).map_err(map_err)?,
|
||||
})
|
||||
}
|
||||
#[napi]
|
||||
pub fn update(
|
||||
&mut self,
|
||||
high: f64,
|
||||
low: f64,
|
||||
close: f64,
|
||||
) -> napi::Result<Option<ModifiedMaStopValue>> {
|
||||
Ok(self
|
||||
.inner
|
||||
.update(cnd(high, low, close, 0.0)?)
|
||||
.map(|o| ModifiedMaStopValue {
|
||||
value: o.value,
|
||||
direction: o.direction,
|
||||
}))
|
||||
}
|
||||
/// Returns `[value0, direction0, value1, direction1, ...]`, length `2 * n`.
|
||||
/// Warmup positions are `NaN`.
|
||||
#[napi]
|
||||
pub fn batch(
|
||||
&mut self,
|
||||
high: Vec<f64>,
|
||||
low: Vec<f64>,
|
||||
close: Vec<f64>,
|
||||
) -> napi::Result<Vec<f64>> {
|
||||
if high.len() != low.len() || low.len() != close.len() {
|
||||
return Err(NapiError::from_reason(
|
||||
"high, low, close must be equal length".to_string(),
|
||||
));
|
||||
}
|
||||
let n = high.len();
|
||||
let mut out = vec![f64::NAN; n * 2];
|
||||
for i in 0..n {
|
||||
if let Some(o) = self.inner.update(cnd(high[i], low[i], close[i], 0.0)?) {
|
||||
out[i * 2] = o.value;
|
||||
out[i * 2 + 1] = o.direction;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
#[napi]
|
||||
pub fn reset(&mut self) {
|
||||
self.inner.reset();
|
||||
}
|
||||
#[napi(js_name = "isReady")]
|
||||
pub fn is_ready(&self) -> bool {
|
||||
self.inner.is_ready()
|
||||
}
|
||||
#[napi(js_name = "warmupPeriod")]
|
||||
pub fn warmup_period(&self) -> u32 {
|
||||
self.inner.warmup_period() as u32
|
||||
}
|
||||
}
|
||||
|
||||
// ============================== Typical Price ==============================
|
||||
|
||||
#[napi(js_name = "TypicalPrice")]
|
||||
|
||||
Reference in New Issue
Block a user