Bollinger Bands Analyzer

Minimum 20 data points recommended for meaningful results.
Commonly 20. Must be less than or equal to the number of data points.
Commonly 2. Determines the width of the bands.

Bollinger Bands Calculation Results

Index Price ($) Middle Band ($) Upper Band ($) Lower Band ($)

No results to display yet. Please enter data and click 'Calculate Bollinger Bands'.

Bollinger Bands Analysis & Signals

Analysis will appear here after calculation.

- Price is below the Lower Band ($${lower.toFixed(2)}): This can suggest the asset is oversold or a strong downtrend. Watch for reversals.

`; } else if (price > middle && price <= upper) { analysisHtml += `

- Price is between the Middle and Upper Bands ($${middle.toFixed(2)} - $${upper.toFixed(2)}): Often indicates an uptrend.

`; } else if (price < middle && price >= lower) { analysisHtml += `

- Price is between the Middle and Lower Bands ($${lower.toFixed(2)} - $${middle.toFixed(2)}): Often indicates a downtrend.

`; } else { analysisHtml += `

- Price is near the Middle Band ($${middle.toFixed(2)}): This often indicates consolidation or indecision.

`; } }); } else { analysisHtml += '

Not enough data to analyze recent price-band interactions.

'; } bollingerBandsAnalysisOutput.innerHTML = analysisHtml; } window.resetForm = function() { priceDataInput.value = ''; smaPeriodInput.value = '20'; stdDevMultiplierInput.value = '2'; bollingerBandsResultsTableBody.innerHTML = ''; bollingerBandsAnalysisOutput.innerHTML = '

Analysis will appear here after calculation.

'; noResultsMessage.style.display = 'block'; calculatedResults = []; resultsTabButton.disabled = true; analysisTabButton.disabled = true; resultsTabButton.classList.add('bollinger-bands-btn-disabled'); analysisTabButton.classList.add('bollinger-bands-btn-disabled'); activateTab('input'); // Return to input tab } window.downloadPdf = function() { const element = document.getElementById('bollingerBandsTool'); if (!element) { alert('Tool container not found for PDF generation.'); return; } // Temporarily activate all tabs to ensure all content is rendered for PDF const previouslyActiveTab = document.querySelector('.bollinger-bands-tab-content.active'); tabContents.forEach(content => content.classList.add('active')); // Remove next/prev buttons from the element for PDF export const tempNextButtons = document.querySelectorAll('.bollinger-bands-btn-group .bollinger-bands-btn'); tempNextButtons.forEach(btn => btn.style.display = 'none'); const tempPdfButton = document.querySelector('.bollinger-bands-pdf-download-btn'); if(tempPdfButton) tempPdfButton.style.display = 'none'; const tempTabs = document.querySelector('.bollinger-bands-tabs'); if(tempTabs) tempTabs.style.display = 'none'; html2pdf(element, { margin: 10, filename: 'Bollinger_Bands_Analysis.pdf', image: { type: 'jpeg', quality: 0.98 }, html2canvas: { scale: 2, logging: true, dpi: 192, letterRendering: true }, jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' } }).then(() => { // Restore original state after PDF generation tabContents.forEach(content => content.classList.remove('active')); if (previouslyActiveTab) { previouslyActiveTab.classList.add('active'); } tabButtons.forEach(button => { button.classList.remove('active'); }); const currentActiveButton = document.querySelector(`.bollinger-bands-tab-button[data-tab="${previouslyActiveTab.id.replace('bollingerBands','').replace('Tab','').toLowerCase()}"]`); if(currentActiveButton) currentActiveButton.classList.add('active'); tempNextButtons.forEach(btn => btn.style.display = ''); // Restore button display if(tempPdfButton) tempPdfButton.style.display = ''; if(tempTabs) tempTabs.style.display = ''; }).catch(error => { console.error('Error generating PDF:', error); alert('Failed to generate PDF. Please try again.'); // Ensure elements are restored even on error tabContents.forEach(content => content.classList.remove('active')); if (previouslyActiveTab) { previouslyActiveTab.classList.add('active'); } tabButtons.forEach(button => { button.classList.remove('active'); }); const currentActiveButton = document.querySelector(`.bollinger-bands-tab-button[data-tab="${previouslyActiveTab.id.replace('bollingerBands','').replace('Tab','').toLowerCase()}"]`); if(currentActiveButton) currentActiveButton.classList.add('active'); tempNextButtons.forEach(btn => btn.style.display = ''); // Restore button display if(tempPdfButton) tempPdfButton.style.display = ''; if(tempTabs) tempTabs.style.display = ''; }); } // Initialize UI state resetForm(); });
Scroll to Top