전략 시간봉 오류 수정

This commit is contained in:
Macbook
2026-05-28 00:36:49 +09:00
parent 2713b2951d
commit 4f6694b206
16 changed files with 285 additions and 127 deletions
+16 -1
View File
@@ -68,12 +68,27 @@ export function resolveHistogramDownColor(plot: PlotDef): string {
return plot.histogramDownColor ?? DEFAULT_HIST_DOWN;
}
/** MACD histogram 막대 색 (상승·하락/음수 구분) */
/** MACD 히스토그램 — histogramUp/DownColor 로 0선 위·아래 색 분리 */
export function isMacdDualHistogramPlot(plot: PlotDef): boolean {
return plot.type === 'histogram'
&& plot.histogramUpColor != null
&& plot.histogramDownColor != null;
}
/**
* histogram 막대 색.
* - MACD(상·하 색 지정): 0선 기준 — 양수=상승색, 음수=하락색 (전봴 대비 혼합 없음)
* - 기타: 전봴 대비 방향 + 음수 영역 하락색
*/
export function histogramBarColor(
value: number,
prev: number | null | undefined,
plot: PlotDef,
): string {
if (isMacdDualHistogramPlot(plot)) {
const raw = value < 0 ? resolveHistogramDownColor(plot) : resolveHistogramUpColor(plot);
return withHistogramAlpha(raw);
}
const isDown = prev != null && !isNaN(prev) && value < prev;
const isNeg = value < 0;
const raw = (isDown || isNeg) ? resolveHistogramDownColor(plot) : resolveHistogramUpColor(plot);