Exchange Rate Forecasting Model
Exchange Rate Forecast for
Historical Period:
Forecast Period:
Forecast Summary:
*Disclaimer: This tool uses a simplified model for demonstration purposes only. Real-world exchange rate forecasting is highly complex and involves advanced statistical methods, fundamental analysis, and is subject to significant market uncertainties. Past performance or simulated forecasts do not guarantee future results.
${message}
`; document.body.appendChild(messageBox); } // Ensure all JavaScript code executes after the DOM is fully loaded. document.addEventListener('DOMContentLoaded', function() { // --- DOM Element References --- const currencyPairSelect = document.getElementById('currencyPairSelect'); const historicalPeriodSelect = document.getElementById('historicalPeriodSelect'); const forecastPeriodInput = document.getElementById('forecastPeriodInput'); const maPeriodInput = document.getElementById('maPeriodInput'); const generateForecastBtn = document.getElementById('generateForecastBtn'); const downloadPdfBtn = document.getElementById('downloadPdfBtn'); const resultsSection = document.getElementById('resultsSection'); const displayHistoricalPeriod = document.getElementById('displayHistoricalPeriod'); const displayForecastPeriod = document.getElementById('displayForecastPeriod'); const forecastSummary = document.getElementById('forecastSummary'); const resultCurrencyPair = document.getElementById('resultCurrencyPair'); const buttonText = document.getElementById('buttonText'); const loader = document.getElementById('loader'); const forecastingChartCanvas = document.getElementById('forecastingChart'); let currentChart = null; // To hold the Chart.js instance // --- Mock Data Generation --- // Generates plausible, but random, historical closing prices for a given period. // This is for demonstration purposes as real-time/historical data APIs are not integrated directly. function generateMockHistoricalData(days) { const data = []; let lastClose = Math.random() * (1.2 - 0.8) + 0.8; // Starting price for EUR/USD like range for (let i = days - 1; i >= 0; i--) { const date = new Date(); date.setDate(date.getDate() - i); const formattedDate = formatDate(date); // Use the globally available formatDate const open = lastClose + (Math.random() - 0.5) * 0.005; const close = open + (Math.random() - 0.5) * 0.01; // Ensure prices are positive and somewhat realistic for forex lastClose = Math.max(0.0001, parseFloat(close.toFixed(5))); data.push({ date: formattedDate, close: lastClose }); } return data; } // --- Forecasting Logic (Simplified Trend Extrapolation based on Moving Average) --- /** * Calculates a Simple Moving Average (SMA). * @param {Array