INNER CODE UNIT · TypeScript
maDiff
alexanderwanyoike/the0 · example-bots/typescript-price-alerts/main.ts:282
const maDiff = (shortMA - longMA) / longMA;
if (Math.abs(maDiff) > 0.001) {
const direction = maDiff > 0 ? "long" : "short";
const confidence = Math.min(Math.abs(maDiff), 0.95);
return {
symbol,
direction,
confidence: Math.round(confidence * 100) / 100,
reason: `MA${shortPeriod} ${direction === "long" ? "above" : "below"} MA${longPeriod}`,
};
}
return null;
}
// Export main for the runtime