添加macd周期参数设置
This commit is contained in:
+182
-9
@@ -764,6 +764,91 @@
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.macd-config-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 10000;
|
||||
display: none;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.macd-config-content {
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
width: 360px;
|
||||
max-width: 90vw;
|
||||
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
||||
}
|
||||
.macd-config-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 20px;
|
||||
color: #333;
|
||||
}
|
||||
.macd-config-form {
|
||||
display: grid;
|
||||
gap: 14px;
|
||||
}
|
||||
.macd-config-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.macd-config-label {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #555;
|
||||
}
|
||||
.macd-config-input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.macd-config-input:focus {
|
||||
outline: none;
|
||||
border-color: #0d6efd;
|
||||
box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
|
||||
}
|
||||
.macd-config-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.macd-config-btn {
|
||||
padding: 8px 18px;
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.macd-config-btn-primary {
|
||||
background: #0d6efd;
|
||||
color: white;
|
||||
}
|
||||
.macd-config-btn-primary:hover {
|
||||
background: #0b5ed7;
|
||||
}
|
||||
.macd-config-btn-secondary {
|
||||
background: #f8f9fa;
|
||||
color: #6c757d;
|
||||
}
|
||||
.macd-config-btn-secondary:hover {
|
||||
background: #e9ecef;
|
||||
}
|
||||
.macd-config-hint {
|
||||
font-size: 12px;
|
||||
color: #999;
|
||||
margin-top: 2px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -854,6 +939,7 @@
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" id="showMacd" checked>
|
||||
<label class="form-check-label" for="showMacd">ChanMACD</label>
|
||||
<button class="btn btn-sm btn-outline-secondary ms-1 p-0" onclick="showMacdConfig()" style="width:22px;height:22px;line-height:1;font-size:12px;" title="MACD参数设置">⚙</button>
|
||||
</div>
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<label for="refreshInterval" class="form-label me-2 mb-0">自动刷新:</label>
|
||||
@@ -1783,6 +1869,56 @@
|
||||
$('#showMacd').change(function() {
|
||||
updateChartDisplay();
|
||||
});
|
||||
|
||||
function showMacdConfig() {
|
||||
$.get('/api/macd_config', function(data) {
|
||||
$('#macdFastPeriod').val(data.fast);
|
||||
$('#macdSlowPeriod').val(data.slow);
|
||||
$('#macdSignalPeriod').val(data.signal);
|
||||
$('#macdConfigModal').css('display', 'flex');
|
||||
});
|
||||
}
|
||||
|
||||
function hideMacdConfig() {
|
||||
$('#macdConfigModal').css('display', 'none');
|
||||
}
|
||||
|
||||
function resetMacdConfig() {
|
||||
$('#macdFastPeriod').val(24);
|
||||
$('#macdSlowPeriod').val(52);
|
||||
$('#macdSignalPeriod').val(9);
|
||||
}
|
||||
|
||||
function saveMacdConfig() {
|
||||
const fast = parseInt($('#macdFastPeriod').val());
|
||||
const slow = parseInt($('#macdSlowPeriod').val());
|
||||
const signal = parseInt($('#macdSignalPeriod').val());
|
||||
if (fast >= slow) {
|
||||
alert('快线周期必须小于慢线周期');
|
||||
return;
|
||||
}
|
||||
if (fast < 2 || slow < 2 || signal < 2) {
|
||||
alert('周期值必须大于等于2');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
url: '/api/macd_config',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({ fast: fast, slow: slow, signal: signal }),
|
||||
success: function() {
|
||||
hideMacdConfig();
|
||||
updateChart();
|
||||
},
|
||||
error: function() {
|
||||
alert('保存MACD参数失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).on('click', '#macdConfigModal', function(e) {
|
||||
if (e.target === this) hideMacdConfig();
|
||||
});
|
||||
|
||||
// 添加原始K线复选框变更事件
|
||||
$('#showOriginalKline').change(function() {
|
||||
@@ -6585,21 +6721,29 @@
|
||||
// 首先同步时间轴设置
|
||||
syncTimeScaleSettings();
|
||||
|
||||
// 然后让主图表适应内容
|
||||
mainChart.timeScale().fitContent();
|
||||
// 显示最近 200 根K线而非全部挤压(避免K线过多时重叠)
|
||||
const totalBars = candles ? candles.length : 0;
|
||||
const visibleBarsCount = 200;
|
||||
if (totalBars > visibleBarsCount) {
|
||||
const rangeFrom = totalBars - visibleBarsCount;
|
||||
const rangeTo = totalBars + 12;
|
||||
mainChart.timeScale().setVisibleLogicalRange({ from: rangeFrom, to: rangeTo });
|
||||
} else {
|
||||
mainChart.timeScale().fitContent();
|
||||
}
|
||||
|
||||
// 立即同步其他图表到主图表的范围
|
||||
setTimeout(() => {
|
||||
const visibleRange = mainChart.timeScale().getVisibleRange();
|
||||
if (visibleRange) {
|
||||
console.log('🔧 同步可见范围:', visibleRange);
|
||||
volumeChart.timeScale().setVisibleRange(visibleRange);
|
||||
atrChart.timeScale().setVisibleRange(visibleRange);
|
||||
const logRange = mainChart.timeScale().getVisibleLogicalRange();
|
||||
if (logRange) {
|
||||
console.log('🔧 同步可见范围:', logRange);
|
||||
volumeChart.timeScale().setVisibleLogicalRange(logRange);
|
||||
atrChart.timeScale().setVisibleLogicalRange(logRange);
|
||||
if (showMacd && macdChart) {
|
||||
macdChart.timeScale().setVisibleRange(visibleRange);
|
||||
macdChart.timeScale().setVisibleLogicalRange(logRange);
|
||||
}
|
||||
if (showMacd && chanMacdChart) {
|
||||
chanMacdChart.timeScale().setVisibleRange(visibleRange);
|
||||
chanMacdChart.timeScale().setVisibleLogicalRange(logRange);
|
||||
}
|
||||
console.log('🔧 时间轴同步完成');
|
||||
}
|
||||
@@ -10461,5 +10605,34 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MACD参数配置弹窗 -->
|
||||
<div id="macdConfigModal" class="macd-config-modal">
|
||||
<div class="macd-config-content">
|
||||
<div class="macd-config-title">ChanMACD 参数设置</div>
|
||||
<div class="macd-config-form">
|
||||
<div class="macd-config-group">
|
||||
<label class="macd-config-label">快线周期 (Fast)</label>
|
||||
<input type="number" id="macdFastPeriod" class="macd-config-input" value="24" min="2" max="200">
|
||||
<div class="macd-config-hint">默认: 24 (12×2)</div>
|
||||
</div>
|
||||
<div class="macd-config-group">
|
||||
<label class="macd-config-label">慢线周期 (Slow)</label>
|
||||
<input type="number" id="macdSlowPeriod" class="macd-config-input" value="52" min="2" max="500">
|
||||
<div class="macd-config-hint">默认: 52 (26×2)</div>
|
||||
</div>
|
||||
<div class="macd-config-group">
|
||||
<label class="macd-config-label">信号线周期 (Signal)</label>
|
||||
<input type="number" id="macdSignalPeriod" class="macd-config-input" value="9" min="2" max="200">
|
||||
<div class="macd-config-hint">默认: 9</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="macd-config-actions">
|
||||
<button class="macd-config-btn macd-config-btn-secondary" onclick="hideMacdConfig()">取消</button>
|
||||
<button class="macd-config-btn macd-config-btn-secondary" onclick="resetMacdConfig()">恢复默认</button>
|
||||
<button class="macd-config-btn macd-config-btn-primary" onclick="saveMacdConfig()">应用</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user