Hit LONG or SHORT in Setup to begin
0) ? _mtBalance : 0; let avail = (typeof _mtAvailable !== 'undefined' && _mtAvailable > 0) ? _mtAvailable : bal; let dayPnl = (typeof _mtRealizedDayPnl !== 'undefined') ? _mtRealizedDayPnl : 0; if(bal === 0) { try { const c = JSON.parse(localStorage.getItem('mt_bal_cache') || '{}'); bal = c.bal || 0; avail = c.avail || bal; } catch(_){} } if(dayPnl === 0) { try { const c = JSON.parse(localStorage.getItem('mt_daypnl_cache') || '{}'); dayPnl = c.pnl !== undefined ? c.pnl : 0; } catch(_){} } let unrealSp = 0; if(_spState) { const mark = window.livePrice || _spState.entry; unrealSp = (mark - _spState.entry) * _spState.size * (_spState.dir === 'LONG' ? 1 : -1); } let unrealMt = 0; try { if(typeof _mtCurrentPos !== 'undefined' && _mtCurrentPos) { const qty = parseFloat(_mtCurrentPos.positionAmt || 0); const ep = parseFloat(_mtCurrentPos.entryPrice || 0); const mk = window.livePrice || ep; if(qty !== 0 && ep > 0) unrealMt = (mk - ep) * qty; } } catch(_){} const combined = avail + unrealSp + unrealMt; const totalDay = dayPnl + unrealSp + unrealMt; const dayPct = bal > 0 ? (totalDay / bal) * 100 : 0; const set = (id, val, color) => { const el = document.getElementById(id); if(el) { el.textContent = val; if(color !== undefined) el.style.color = color; } }; set('sp-acct-bal', bal > 0 ? '$' + bal.toFixed(2) : '—', ''); set('sp-acct-combined',bal > 0 ? '$' + combined.toFixed(2) : '—', combined >= bal ? '#00e5cc' : 'var(--pink)'); set('sp-acct-daypnl', (totalDay >= 0 ? '+' : '') + totalDay.toFixed(2), totalDay >= 0 ? '#00e5cc' : 'var(--pink)'); set('sp-acct-daypct', (dayPct >= 0 ? '+' : '') + dayPct.toFixed(2) + '%', dayPct >= 0 ? '#00e5cc' : 'var(--pink)'); } >