Automated Market Pattern Recognition Tool

Automated Market Pattern Recognition

Analyzed Price Chart

Identified Market Patterns

No patterns identified yet. Enter data and click "Analyze Patterns".

No patterns identified yet. Enter data and click "Analyze Patterns".

'; }; // PDF Download Functionality window.downloadPdf = function() { const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(22); doc.text("Market Pattern Recognition Report", 105, 20, null, null, "center"); doc.setFontSize(12); doc.text(`Report Date: ${new Date().toLocaleDateString()}`, 14, 35); doc.text(`Sensitivity Threshold: ${sensitivityInput.value}%`, 14, 42); let yOffset = 55; // Add Input Data Section doc.setFontSize(16); doc.text("Input Price Data", 14, yOffset); yOffset += 10; doc.setFontSize(10); const inputDataText = priceDataInput.value.replace(/,/g, ', '); // Add space after comma for readability doc.text(inputDataText, 14, yOffset, { maxWidth: 180 }); yOffset = doc.lastAutoTable ? doc.lastAutoTable.finalY + 20 : yOffset + Math.ceil(inputDataText.length / 100) * 5 + 20; // Estimate height based on text length // Add Chart (as SVG text representation for PDF, actual SVG cannot be directly embedded this way) // For a true SVG image in PDF, you'd need a server-side conversion or more complex client-side libraries. // Here, we just state that a chart was generated. doc.setFontSize(16); doc.text("Analyzed Price Chart (Visualized On-Screen)", 14, yOffset); yOffset += 10; doc.setFontSize(10); doc.text("A detailed price chart was generated on-screen based on the input data.", 14, yOffset); doc.text("The chart visually represents the price movements and highlights detected patterns.", 14, yOffset + 5); yOffset += 20; // Add Identified Patterns Section doc.setFontSize(16); doc.text("Identified Market Patterns", 14, yOffset); yOffset += 10; const patterns = []; const patternItems = patternListDiv.querySelectorAll('.pattern-item'); if (patternItems.length === 0) { doc.setFontSize(12); doc.text("No significant patterns identified with the current sensitivity.", 14, yOffset); yOffset += 15; } else { patternItems.forEach(item => { const type = item.querySelector('h4').textContent; const description = item.querySelector('p:nth-of-type(1)').textContent.replace('Description: ', ''); const indices = item.querySelector('p:nth-of-type(2)').textContent.replace('Indices: ', ''); patterns.push([{ content: `Pattern Type: ${type}`, styles: { fontStyle: 'bold', fillColor: [240, 248, 255] } }]); patterns.push([`Description: ${description}`]); patterns.push([`Indices: ${indices}`]); patterns.push(['']); // Add an empty row for spacing }); doc.autoTable({ startY: yOffset, body: patterns, theme: 'plain', // Use 'plain' theme for more control styles: { font: 'helvetica', fontSize: 10, cellPadding: 3, valign: 'top', lineColor: [230, 230, 230], // Light grey borders lineWidth: 0.1 }, didParseCell: function(data) { if (data.cell.raw && data.cell.raw.content && data.cell.raw.content.includes("Pattern Type:")) { data.cell.styles.fontStyle = 'bold'; data.cell.styles.fillColor = [220, 230, 240]; // Light blue background for pattern type } } }); } doc.save(`Market_Pattern_Report.pdf`); }; // Initial chart drawing on load with example data priceDataInput.value = '100, 105, 95, 110, 90, 120, 110, 130, 120, 140, 130, 150'; // Optional: call analyzePatterns() on load if you want an initial view // analyzePatterns(); });
Scroll to Top