// ============================================================ // FORMAT HOLD STATUS — fires every cycle when not trading // Toggle SEND_STATUS to enable/disable Telegram status messages // ============================================================ const SEND_STATUS = true; // send hold status every cycle for diagnostics const sd = $getWorkflowStaticData('global'); const dec = $('Decision Engine').first().json; const btc = dec.btcSignal || {}; const pos = sd.position; const NL = '\n'; let posLine = 'Position: none'; if (pos) { const heldMins = pos.entryTime ? +((Date.now() - new Date(pos.entryTime).getTime()) / 60000).toFixed(1) : 0; const heldPrice = dec.bestCandidate && dec.bestCandidate.symbol === pos.symbol ? (dec.bestCandidate.price || pos.entry) : pos.entry; const pct = pos.entry > 0 ? +((heldPrice - pos.entry) / pos.entry * 100).toFixed(2) : 0; posLine = 'Pos: ' + pos.symbol + ' ' + (pct >= 0 ? '+' : '') + pct + '% | ' + heldMins + 'min'; } const best = dec.bestCandidate || {}; const checks = dec.entryChecks || {}; const checksLine = checks.pass !== undefined ? 'Checks: ' + checks.pass + '/5 RSI:' + (checks.rsiOk ? '\u2713' : '\u2717') + ' EMA:' + (checks.emaTrendOk ? '\u2713' : '\u2717') + ' Slope:' + (checks.slopeOk ? '\u2713' : '\u2717') + ' Vol:' + (checks.volOk ? '\u2713' : '\u2717') + ' Wick:' + (checks.noReversal ? '\u2713' : '\u2717') : 'Checks: no kline data'; const scan = dec.scanSummary || []; const scanLine = scan.length > 0 ? 'Top3: ' + scan.slice(0,3).map(c => c.symbol.replace('USDT','') + ' ' + (c.score||0) + 'pt').join(' | ') : 'Scan: 0 candidates'; const holdReasons = (dec.trade && dec.trade.holdReasons) ? dec.trade.holdReasons : []; const holdLine = holdReasons.length > 0 ? '\u26D4 Skip: ' + holdReasons.join(', ') : ''; const now3 = new Date(Date.now() + 3 * 3600000); const msg = '\u23F1 SCAN ' + now3.toISOString().slice(11, 16) + ' UTC+3' + NL + 'Capital: $' + (+(sd.capital||0).toFixed(2)) + ' | Today: ' + (sd.todayTrades||0) + ' trades' + NL + posLine + NL + 'BTC: ' + (btc.trend||'?').toUpperCase() + ' score:' + (btc.score||0) + ' RSI:' + (btc.rsi||0) + ' ROC5:' + (btc.roc5||0) + '%' + NL + 'Best: ' + (best.symbol||'none') + ' score:' + (best.score||0) + ' +' + (+(best.change24h||0)).toFixed(2) + '%' + NL + scanLine + NL + checksLine + NL + holdLine; return [{ json: { message: msg, sendMessage: SEND_STATUS } }];