diff --git a/docs/binance-orderbook-trade-development.md b/docs/binance-orderbook-trade-development.md index 276e7c2..fefb09f 100644 --- a/docs/binance-orderbook-trade-development.md +++ b/docs/binance-orderbook-trade-development.md @@ -112,7 +112,7 @@ scripts/ The chart alert is timeframe-agnostic and evaluates closed bars only. It supports TradingView second, minute, hour, day, and week resolutions; month resolutions are intentionally unsupported because their duration is calendar-dependent. It scans every closed bar already loaded in TradingView and does not issue a separate market-data request or force the chart to load older history. The active-page poll exports the current window once per second. Detection runs again when the `count:firstTime:lastTime` window or any closed-bar OHLC content changes; unchanged content is compared against a compact numeric snapshot instead of serializing the whole history on every poll. The cached signal set is reconciled with live TradingView shape IDs on every poll. Loading older chart history therefore expands the annotated range even when the latest bar is unchanged, and a TradingView chart refresh can no longer leave the alert registry pointing at evicted markers. -A bearish setup requires the Bollinger middle line to cross down through SMA60 while the band center is declining. A bullish setup is generated by the exact price-axis mirror: OHLC values are transformed as `open=-open`, `high=-low`, `low=-high`, `close=-close`, and the indicator axes are transformed as `middle=-middle`, `upper=-lower`, `lower=-upper`, `ma60=-ma60`. This yields a middle-line cross up through SMA60, pre-cross closes in the middle/upper channel, and post-cross middle-line support without maintaining a second drifting detector. Both directions use the same warning/confirmation/reversal lifecycle. Warning dots are yellow; bearish confirmation is a red down arrow and bullish confirmation is a green up arrow. A reversal uses the opposite colored/directional arrow. Mirrored marker prices remain on the corresponding side of the candle (bullish confirmation below the low, bearish confirmation above the high). If overlapping setups in one direction reverse on the same candle, the newest setup owns that direction's visual reversal; opposite-direction signals retain distinct IDs and are both rendered. +A bearish setup requires the Bollinger middle line to cross down through SMA60 while the band center is declining. A bullish setup is generated by the exact price-axis mirror: OHLC values are transformed as `open=-open`, `high=-low`, `low=-high`, `close=-close`, and the indicator axes are transformed as `middle=-middle`, `upper=-lower`, `lower=-upper`, `ma60=-ma60`. This yields a middle-line cross up through SMA60, pre-cross closes in the middle/upper channel, and post-cross middle-line support without maintaining a second drifting detector. Both directions use the same warning/confirmation/reversal lifecycle. Bearish warning dots are red and remain above the candle high; bullish warning dots are green and remain below the candle low. Bearish confirmation is a red down arrow and bullish confirmation is a green up arrow. A reversal uses the opposite colored/directional arrow. Mirrored marker prices remain on the corresponding side of the candle (bullish confirmation below the low, bearish confirmation above the high). If overlapping setups in one direction reverse on the same candle, the newest setup owns that direction's visual reversal; opposite-direction signals retain distinct IDs and are both rendered. The current Binance `trading-platform-30` chart runtime exposes `exportData()` as row-major numeric-keyed OHLC objects. The parser deliberately enforces that observed contract and fails if the schema changes. Every asynchronous export and marker creation revalidates the active chart instance, route symbol, and resolution so a stale task cannot annotate a newly selected chart. diff --git a/scripts/binance-orderbook-trade.user.js b/scripts/binance-orderbook-trade.user.js index d5d8b26..af5125c 100644 --- a/scripts/binance-orderbook-trade.user.js +++ b/scripts/binance-orderbook-trade.user.js @@ -3,7 +3,7 @@ // @namespace binance.orderbook.trade // @icon data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E // @icon64 data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E -// @version 2.7.190 +// @version 2.7.191 // @author jackhai9 // @description 单击订单簿价格,按当前开仓/平仓 tab 自动填数量并执行下单,内置数量倍率面板 // @match https://www.binance.com/*/futures/* @@ -5296,7 +5296,7 @@ shape: "icon", icon: 61713, overrides: { - color: "#F0B90B", + color: isBullish ? "#0ECB81" : "#F6465D", size: 10 } }; diff --git a/src/binance-orderbook-trade/dom/tradingview-bearish-alerts.js b/src/binance-orderbook-trade/dom/tradingview-bearish-alerts.js index 034de4e..4f826bd 100644 --- a/src/binance-orderbook-trade/dom/tradingview-bearish-alerts.js +++ b/src/binance-orderbook-trade/dom/tradingview-bearish-alerts.js @@ -292,7 +292,7 @@ function markerOptions(signal) { shape: 'icon', icon: 0xf111, overrides: { - color: '#F0B90B', + color: isBullish ? '#0ECB81' : '#F6465D', size: 10, }, }; diff --git a/src/binance-orderbook-trade/index.user.js b/src/binance-orderbook-trade/index.user.js index 401934e..9d768a7 100644 --- a/src/binance-orderbook-trade/index.user.js +++ b/src/binance-orderbook-trade/index.user.js @@ -3,7 +3,7 @@ // @namespace binance.orderbook.trade // @icon data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E // @icon64 data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E -// @version 2.7.190 +// @version 2.7.191 // @author jackhai9 // @description 单击订单簿价格,按当前开仓/平仓 tab 自动填数量并执行下单,内置数量倍率面板 // @match https://www.binance.com/*/futures/* diff --git a/test/dom/binance-orderbook-trade/tradingview-bearish-alerts.test.js b/test/dom/binance-orderbook-trade/tradingview-bearish-alerts.test.js index 52df7c9..e1b01dd 100644 --- a/test/dom/binance-orderbook-trade/tradingview-bearish-alerts.test.js +++ b/test/dom/binance-orderbook-trade/tradingview-bearish-alerts.test.js @@ -247,7 +247,7 @@ test('renders warning, bearish confirmation, and bullish reversal markers', asyn const records = [...shapes.values()]; assert.equal(records[0].properties.shape, 'icon'); assert.equal(records[0].properties.icon, 0xf111); - assert.equal(records[0].properties.overrides.color, '#F0B90B'); + assert.equal(records[0].properties.overrides.color, '#F6465D'); assert.equal(records[1].properties.shape, 'arrow_down'); assert.equal(records[1].properties.overrides.arrowColor, '#F6465D'); assert.equal(records[2].properties.shape, 'arrow_up'); @@ -292,7 +292,7 @@ test('renders mirrored bullish marker shapes and colors in the shared layer', as const records = [...shapes.values()]; assert.equal(records[0].properties.shape, 'icon'); - assert.equal(records[0].properties.overrides.color, '#F0B90B'); + assert.equal(records[0].properties.overrides.color, '#0ECB81'); assert.equal(records[1].properties.shape, 'arrow_up'); assert.equal(records[1].properties.overrides.arrowColor, '#0ECB81'); assert.equal(records[2].properties.shape, 'arrow_down'); diff --git a/test/unit/binance-orderbook-trade/bearish-bollinger-pattern.test.js b/test/unit/binance-orderbook-trade/bearish-bollinger-pattern.test.js index 029f6fd..c6d22b3 100644 --- a/test/unit/binance-orderbook-trade/bearish-bollinger-pattern.test.js +++ b/test/unit/binance-orderbook-trade/bearish-bollinger-pattern.test.js @@ -133,6 +133,10 @@ test('implements bullish detection as the strict price-axis mirror of bearish de bullishSignals.map((signal) => signal.id), bearishSignals.map((signal) => `${signal.setupTime}:bullish:${signal.type}`), ); + const bearishWarning = bearishSignals.find((signal) => signal.type === 'warning'); + const bullishWarning = bullishSignals.find((signal) => signal.type === 'warning'); + assert.ok(bearishWarning.markerPrice > bearishPattern.bars[bearishPattern.warningIndex].high); + assert.ok(bullishWarning.markerPrice < bullishBars[bearishPattern.warningIndex].low); assert.deepEqual(bullishBars, originalBullishBars); });