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.

Bollinger Bands are a volatility indicator. Here are some common interpretations based on your data:

'; const smaPeriod = parseInt(smaPeriodInput.value); const prices = calculatedResults.filter(r => r.middleBand !== null); // Only analyze where bands are calculated if (prices.length < 2) { bollingerBandsAnalysisOutput.innerHTML = '

Insufficient data to perform meaningful analysis after band calculation.

'; return; } // Squeeze and Expansion detection (requires a few data points) let bandWidths = prices.map(p => p.upperBand - p.lowerBand); let recentBandWidths = bandWidths.slice(-smaPeriod); // Look at recent bandwidths if (recentBandWidths.length > 0) { const avgBandWidth = recentBandWidths.reduce((a, b) => a + b, 0) / recentBandWidths.length; const minBandWidth = Math.min(...recentBandWidths); const maxBandWidth = Math.max(...recentBandWidths); // Simple check for squeeze/expansion const lastBandWidth = bandWidths[bandWidths.length - 1]; if (lastBandWidth < avgBandWidth * 0.8) { // If last width is significantly lower than recent average analysisHtml += '

Band Squeeze: The bands are narrowing, indicating decreasing volatility. This often precedes a period of high volatility or a significant price move.

'; } else if (lastBandWidth > avgBandWidth * 1.2) { // If last width is significantly higher analysisHtml += '

Band Expansion: The bands are widening, indicating increasing volatility. This typically occurs during strong trends or significant price swings.

'; } else { analysisHtml += '

Normal Volatility: The bands are maintaining a relatively stable width, suggesting typical market volatility for the given period.

'; } } // Price interaction analysis (last few data points) analysisHtml += '

Recent Price-Band Interaction:

'; const lastDataPoints = prices.slice(-5); // Analyze the last 5 calculated points if (lastDataPoints.length > 0) { lastDataPoints.forEach((data, index) => { const price = data.price; const upper = data.upperBand; const lower = data.lowerBand; const middle = data.middleBand; analysisHtml += `

Index ${data.index}: Price ($${price.toFixed(2)})

`; if (price > upper) { analysisHtml += `

- Price is above the Upper Band ($${upper.toFixed(2)}): This can suggest the asset is overbought or a strong uptrend is in play. Watch for reversals.

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

- 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