Crypto · 10/29/2025
Stratégie (SMA crossover)

Espace publicitaire (in-article 1)
// src/strategy.ts
import { sma } from './indicators'
export type Signal = 'BUY' | 'SELL' | 'HOLD'
export type Candle = { time: number; open: number; high: number; low: number; close: number; volume: number }
export function generateSignal(candles: Candle[], fast = 20, slow = 50): Signal {
const closes = candles.map(c => c.close)
const f = sma(closes, fast)
const s = sma(closes, slow)
const n = closes.length - 1
if (n < slow) return 'HOLD'
// Croisement récent
const prevUp = f[n - 1] <= s[n - 1] && f[n] > s[n]
const prevDown = f[n - 1] >= s[n - 1] && f[n] < s[n]
if (prevUp) return 'BUY'
if (prevDown) return 'SELL'
return 'HOLD'
}
Espace publicitaire (in-article 2)



