Files
trade-kuns/src/server/strategy/chandelier.ts
2026-06-09 20:22:46 +00:00

12 lines
505 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export interface TrailState {
highestHigh: number;
stop: number;
}
/** Chandelier-Stop: hh mult×ATR, wandert nur aufwärts. Aufruf pro abgeschlossener 4h-Candle. */
export function updateChandelier(state: TrailState, barHigh: number, atrValue: number, mult: number): TrailState {
const highestHigh = Math.max(state.highestHigh, barHigh);
const candidate = Number.isNaN(atrValue) ? -Infinity : highestHigh - mult * atrValue;
return { highestHigh, stop: Math.max(state.stop, candidate) };
}