feat: add EMA144 as separate market chart indicator

Optional EMA144 line on hub K-line main chart, independent from EMA 21/55 cross.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-06 03:32:26 +08:00
parent 22b2db34fc
commit 43cd98f2d5
2 changed files with 20 additions and 4 deletions
+18 -3
View File
@@ -191,6 +191,7 @@
const elFsBtn = document.getElementById("market-chart-fullscreen"); const elFsBtn = document.getElementById("market-chart-fullscreen");
const elFsExit = document.getElementById("market-chart-fs-exit"); const elFsExit = document.getElementById("market-chart-fs-exit");
const elIndEma = document.getElementById("market-ind-ema"); const elIndEma = document.getElementById("market-ind-ema");
const elIndEma144 = document.getElementById("market-ind-ema144");
const elIndMacd = document.getElementById("market-ind-macd"); const elIndMacd = document.getElementById("market-ind-macd");
const elIndRsi = document.getElementById("market-ind-rsi"); const elIndRsi = document.getElementById("market-ind-rsi");
const elPrevCloseLine = document.getElementById("market-prev-close-line"); const elPrevCloseLine = document.getElementById("market-prev-close-line");
@@ -210,12 +211,14 @@
const HUB_MARKET_POS_CTX_KEY = "hubMarketPosContext"; const HUB_MARKET_POS_CTX_KEY = "hubMarketPosContext";
const EMA_FAST = 21; const EMA_FAST = 21;
const EMA_SLOW = 55; const EMA_SLOW = 55;
const EMA_TREND = 144;
let chartFullscreen = false; let chartFullscreen = false;
const indicatorState = { ema: false, macd: false, rsi: false }; const indicatorState = { ema: false, ema144: false, macd: false, rsi: false };
const indSeries = { const indSeries = {
ema21: null, ema21: null,
ema55: null, ema55: null,
ema144: null,
macdLine: null, macdLine: null,
macdSignal: null, macdSignal: null,
macdHist: null, macdHist: null,
@@ -505,6 +508,7 @@
function readIndicatorState() { function readIndicatorState() {
indicatorState.ema = !!(elIndEma && elIndEma.checked); indicatorState.ema = !!(elIndEma && elIndEma.checked);
indicatorState.ema144 = !!(elIndEma144 && elIndEma144.checked);
indicatorState.macd = !!(elIndMacd && elIndMacd.checked); indicatorState.macd = !!(elIndMacd && elIndMacd.checked);
indicatorState.rsi = !!(elIndRsi && elIndRsi.checked); indicatorState.rsi = !!(elIndRsi && elIndRsi.checked);
} }
@@ -896,6 +900,17 @@
if (indSeries.ema55) indSeries.ema55.setData(buildEmaSeries(lastCandles, EMA_SLOW)); if (indSeries.ema55) indSeries.ema55.setData(buildEmaSeries(lastCandles, EMA_SLOW));
} }
if (indicatorState.ema144) {
const pf144 = tickToPriceFormat(priceTick);
indSeries.ema144 = createLineSeries({
color: "#5ce0b8",
title: "EMA144",
priceScaleId: "right",
priceFormat: pf144,
});
if (indSeries.ema144) indSeries.ema144.setData(buildEmaSeries(lastCandles, EMA_TREND));
}
let rsiDiv = []; let rsiDiv = [];
let macdDiv = []; let macdDiv = [];
@@ -2515,7 +2530,7 @@
lastCandles = merged; lastCandles = merged;
indexCandles(lastCandles); indexCandles(lastCandles);
readIndicatorState(); readIndicatorState();
if (indicatorState.ema || indicatorState.macd || indicatorState.rsi) { if (indicatorState.ema || indicatorState.ema144 || indicatorState.macd || indicatorState.rsi) {
try { try {
updateIndicators(); updateIndicators();
} catch (indErr) {} } catch (indErr) {}
@@ -3272,7 +3287,7 @@
setChartFullscreen(false); setChartFullscreen(false);
}); });
} }
[elIndEma, elIndMacd, elIndRsi].forEach(function (el) { [elIndEma, elIndEma144, elIndMacd, elIndRsi].forEach(function (el) {
if (!el) return; if (!el) return;
el.addEventListener("change", function () { el.addEventListener("change", function () {
updateIndicators(); updateIndicators();
+2 -1
View File
@@ -316,6 +316,7 @@
<summary>技术指标</summary> <summary>技术指标</summary>
<div class="market-ind-options"> <div class="market-ind-options">
<label class="market-ind-opt"><input type="checkbox" id="market-ind-ema" value="ema" /> EMA交叉(21/55)</label> <label class="market-ind-opt"><input type="checkbox" id="market-ind-ema" value="ema" /> EMA交叉(21/55)</label>
<label class="market-ind-opt"><input type="checkbox" id="market-ind-ema144" value="ema144" /> EMA144</label>
<label class="market-ind-opt"><input type="checkbox" id="market-ind-macd" value="macd" /> MACD</label> <label class="market-ind-opt"><input type="checkbox" id="market-ind-macd" value="macd" /> MACD</label>
<label class="market-ind-opt"><input type="checkbox" id="market-ind-rsi" value="rsi" /> RSI</label> <label class="market-ind-opt"><input type="checkbox" id="market-ind-rsi" value="rsi" /> RSI</label>
</div> </div>
@@ -1147,7 +1148,7 @@
<div id="toast"></div> <div id="toast"></div>
<script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script> <script src="https://unpkg.com/lightweight-charts@4.2.0/dist/lightweight-charts.standalone.production.js"></script>
<script src="/assets/chart_draw.js?v=20260609-market-day-split"></script> <script src="/assets/chart_draw.js?v=20260609-market-day-split"></script>
<script src="/assets/chart.js?v=20260626-market-tail-patch"></script> <script src="/assets/chart.js?v=20260706-ema144"></script>
<script src="/assets/plan.js?v=20260614-plan-refresh"></script> <script src="/assets/plan.js?v=20260614-plan-refresh"></script>
<script src="/assets/calculator.js?v=3"></script> <script src="/assets/calculator.js?v=3"></script>
<script src="/assets/trade_stats_calendar.js?v=3"></script> <script src="/assets/trade_stats_calendar.js?v=3"></script>