일목균형표 수정
This commit is contained in:
@@ -28,8 +28,8 @@ export function getIchimokuPlotTitle(plotId: string): string {
|
||||
export const ICHIMOKU_LINE_ROWS: IchimokuLineRowDef[] = [
|
||||
{ plotIndex: 0, plotId: 'plot0', paramKey: 'conversionPeriods' },
|
||||
{ plotIndex: 1, plotId: 'plot1', paramKey: 'basePeriods' },
|
||||
{ plotIndex: 2, plotId: 'plot2', paramKey: 'displacement' },
|
||||
{ plotIndex: 3, plotId: 'plot3' },
|
||||
{ plotIndex: 2, plotId: 'plot2', paramKey: 'chikouDisplacement' },
|
||||
{ plotIndex: 3, plotId: 'plot3', paramKey: 'senkouDisplacement' },
|
||||
{ plotIndex: 4, plotId: 'plot4', paramKey: 'laggingSpan2Periods' },
|
||||
];
|
||||
|
||||
@@ -37,9 +37,28 @@ export const ICHIMOKU_DEFAULT_PARAMS: Record<string, number> = {
|
||||
conversionPeriods: 9,
|
||||
basePeriods: 26,
|
||||
laggingSpan2Periods: 52,
|
||||
/** @deprecated senkouDisplacement 우선 — API·구버전 호환 */
|
||||
displacement: 26,
|
||||
chikouDisplacement: 26,
|
||||
senkouDisplacement: 26,
|
||||
};
|
||||
|
||||
/** 후행·선행 이동 기간 (구 displacement 단일 키 마이그레이션) */
|
||||
export function resolveIchimokuDisplacements(
|
||||
params: Record<string, number | string | boolean> | undefined,
|
||||
): { chikou: number; senkou: number } {
|
||||
const legacy = typeof params?.displacement === 'number' && params.displacement >= 1
|
||||
? params.displacement
|
||||
: 26;
|
||||
const chikou = typeof params?.chikouDisplacement === 'number' && params.chikouDisplacement >= 1
|
||||
? params.chikouDisplacement
|
||||
: legacy;
|
||||
const senkou = typeof params?.senkouDisplacement === 'number' && params.senkouDisplacement >= 1
|
||||
? params.senkouDisplacement
|
||||
: legacy;
|
||||
return { chikou, senkou };
|
||||
}
|
||||
|
||||
export function createDefaultIchimokuParams(): Record<string, number> {
|
||||
return { ...ICHIMOKU_DEFAULT_PARAMS };
|
||||
}
|
||||
@@ -55,12 +74,18 @@ export interface IchimokuCloudColors {
|
||||
bullishColor: string;
|
||||
/** 선행스팬1 < 선행스팬2 (하락 구름) */
|
||||
bearishColor: string;
|
||||
/** 상승 구름 영역 표시 */
|
||||
bullishVisible?: boolean;
|
||||
/** 하락 구름 영역 표시 */
|
||||
bearishVisible?: boolean;
|
||||
}
|
||||
|
||||
/** #RRGGBBAA — 상승 구름 빨강 20%, 하락 구름 청록 20% */
|
||||
export const DEFAULT_ICHIMOKU_CLOUD_COLORS: IchimokuCloudColors = {
|
||||
bullishColor: '#EF535033',
|
||||
bearishColor: '#26A69A33',
|
||||
bullishVisible: true,
|
||||
bearishVisible: true,
|
||||
};
|
||||
|
||||
/** registry plot ID → lightweight-charts-indicators plot ID */
|
||||
@@ -80,19 +105,29 @@ export const ICHIMOKU_LIB_TO_REGISTRY: Record<string, string> = {
|
||||
plot4: 'plot3',
|
||||
};
|
||||
|
||||
export function isIchimokuCloudVisible(config: IndicatorConfig): boolean {
|
||||
/** 선행스팬1·2 라인이 켜져 있어 구름 계산이 가능한지 */
|
||||
export function areIchimokuSpanLinesVisible(config: IndicatorConfig): boolean {
|
||||
return (
|
||||
config.plotVisibility?.['plot2'] !== false &&
|
||||
config.plotVisibility?.['plot3'] !== false
|
||||
config.plotVisibility?.['plot3'] !== false &&
|
||||
config.plotVisibility?.['plot4'] !== false
|
||||
);
|
||||
}
|
||||
|
||||
/** 구름 영역을 그릴 수 있는지 (선행스팬 + 상승/하락 구름 중 하나 이상 on) */
|
||||
export function isIchimokuCloudVisible(config: IndicatorConfig): boolean {
|
||||
if (!areIchimokuSpanLinesVisible(config)) return false;
|
||||
const colors = resolveIchimokuCloudColors(config.cloudColors);
|
||||
return colors.bullishVisible !== false || colors.bearishVisible !== false;
|
||||
}
|
||||
|
||||
export function resolveIchimokuCloudColors(
|
||||
colors?: Partial<IchimokuCloudColors>,
|
||||
): IchimokuCloudColors {
|
||||
return {
|
||||
bullishColor: colors?.bullishColor ?? DEFAULT_ICHIMOKU_CLOUD_COLORS.bullishColor,
|
||||
bearishColor: colors?.bearishColor ?? DEFAULT_ICHIMOKU_CLOUD_COLORS.bearishColor,
|
||||
bullishVisible: colors?.bullishVisible !== false,
|
||||
bearishVisible: colors?.bearishVisible !== false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -110,6 +145,11 @@ export function normalizeIchimokuConfig(config: IndicatorConfig): IndicatorConfi
|
||||
}
|
||||
}
|
||||
|
||||
const { chikou, senkou } = resolveIchimokuDisplacements(params);
|
||||
params.chikouDisplacement = chikou;
|
||||
params.senkouDisplacement = senkou;
|
||||
params.displacement = senkou;
|
||||
|
||||
const plotVisibility: Record<string, boolean> = {
|
||||
...createDefaultIchimokuPlotVisibility(),
|
||||
...config.plotVisibility,
|
||||
|
||||
Reference in New Issue
Block a user