Market Cycle Analysis Tool Market Cycle Analysis Tool Identify market phases using technical indicators. Dashboard Configuration Run Analysis Price Action & Market Phases Download Analysis Report Settings & Data Indicator Settings Market / Ticker Short MA Period Long MA Period Historical Daily Data Date Price Volume Add Day Previous Next ${state.settings.ticker} | As of ${new Date().toLocaleDateString()} Current Market Assessment Current Identified Phase ${kpis.currentPhase} Last Closing Price $${kpis.price.toLocaleString()} Market Cycle Chart `; const pdfTemplate = document.getElementById('pdf-template'); pdfTemplate.innerHTML = reportHtml; pdfTemplate.classList.remove('invisible'); try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(pdfTemplate.querySelector('.pdf-report-container'), { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); pdf.addImage(imgData, 'PNG', 0, 0, pdf.internal.pageSize.getWidth(), (canvas.height * pdf.internal.pageSize.getWidth()) / canvas.width); pdf.save(`${state.settings.ticker.replace(/\s+/g, '_')}_Cycle_Analysis.pdf`); } catch(e) { console.error('PDF Generation Error:', e); } finally { downloadPdfBtn.disabled = false; downloadPdfBtn.textContent = 'Download Analysis Report'; pdfTemplate.classList.add('invisible'); } } downloadPdfBtn.addEventListener('click', generatePdfReport); // --- INITIALIZATION --- generateSampleData(); populateSettingsUI(); renderDataTable(); attachDataListeners(); runAnalysis(); switchTab(0); });