전략 시간봉 오류 수정
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user