feat: Chandelier-Trailing-Stop
This commit is contained in:
11
src/server/strategy/chandelier.ts
Normal file
11
src/server/strategy/chandelier.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
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) };
|
||||
}
|
||||
Reference in New Issue
Block a user