| | document.addEventListener('DOMContentLoaded', function() { |
| | |
| | const themeToggle = document.getElementById('theme-toggle'); |
| | if (themeToggle) { |
| | themeToggle.addEventListener('click', function() { |
| | document.documentElement.classList.toggle('dark'); |
| | localStorage.setItem('darkMode', document.documentElement.classList.contains('dark')); |
| | }); |
| | } |
| |
|
| | |
| | if (localStorage.getItem('darkMode') === 'true') { |
| | document.documentElement.classList.add('dark'); |
| | } else { |
| | document.documentElement.classList.remove('dark'); |
| | } |
| |
|
| | |
| | function updateLiveData() { |
| | const priceElement = document.querySelector('.price-display'); |
| | if (priceElement) { |
| | const currentPrice = parseFloat(priceElement.textContent.replace('$', '').replace(',', '')); |
| | const randomChange = (Math.random() * 0.02 - 0.01); |
| | const newPrice = currentPrice * (1 + randomChange); |
| | priceElement.textContent = '$' + newPrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| | |
| | const changeElement = document.querySelector('.price-change'); |
| | if (changeElement) { |
| | if (randomChange > 0) { |
| | changeElement.textContent = '+' + (randomChange * 100).toFixed(2) + '%'; |
| | changeElement.classList.remove('text-red-500'); |
| | changeElement.classList.add('text-green-500'); |
| | } else { |
| | changeElement.textContent = (randomChange * 100).toFixed(2) + '%'; |
| | changeElement.classList.remove('text-green-500'); |
| | changeElement.classList.add('text-red-500'); |
| | } |
| | } |
| | } |
| | } |
| |
|
| | |
| | setInterval(updateLiveData, 5000); |
| |
|
| | |
| | const mobileMenuButton = document.getElementById('mobile-menu-button'); |
| | const mobileMenu = document.getElementById('mobile-menu'); |
| | if (mobileMenuButton && mobileMenu) { |
| | mobileMenuButton.addEventListener('click', function() { |
| | mobileMenu.classList.toggle('hidden'); |
| | }); |
| | } |
| | }); |
| | |
| | function calculateLeledc(data, majQual = 6, majLen = 30, minQual = 5, minLen = 5) { |
| | let bIndex = 0; |
| | let sIndex = 0; |
| | const results = []; |
| |
|
| | for (let i = 4; i < data.length; i++) { |
| | let major = 0; |
| | let minor = 0; |
| |
|
| | |
| | if (data[i].close > data[i-4].close) { |
| | bIndex++; |
| | } |
| | if (data[i].close < data[i-4].close) { |
| | sIndex++; |
| | } |
| |
|
| | |
| | if (bIndex > majQual && data[i].close < data[i].open && |
| | data[i].high >= Math.max(...data.slice(i-majLen, i+1).map(d => d.high))) { |
| | bIndex = 0; |
| | major = -1; |
| | } |
| | if (sIndex > majQual && data[i].close > data[i].open && |
| | data[i].low <= Math.min(...data.slice(i-majLen, i+1).map(d => d.low))) { |
| | sIndex = 0; |
| | major = 1; |
| | } |
| |
|
| | |
| | if (bIndex > minQual && data[i].close < data[i].open && |
| | data[i].high >= Math.max(...data.slice(i-minLen, i+1).map(d => d.high))) { |
| | bIndex = 0; |
| | minor = -1; |
| | } |
| | if (sIndex > minQual && data[i].close > data[i].open && |
| | data[i].low <= Math.min(...data.slice(i-minLen, i+1).map(d => d.low))) { |
| | sIndex = 0; |
| | minor = 1; |
| | } |
| |
|
| | results.push({ major, minor }); |
| | } |
| |
|
| | return results; |
| | } |
| |
|
| | |
| | class TradingBot { |
| | constructor() { |
| | this.isRunning = false; |
| | } |
| |
|
| | start() { |
| | this.isRunning = true; |
| | console.log('Trading bot started'); |
| | |
| | } |
| |
|
| | stop() { |
| | this.isRunning = false; |
| | console.log('Trading bot stopped'); |
| | } |
| |
|
| | getStatus() { |
| | return this.isRunning ? 'Running' : 'Stopped'; |
| | } |
| | } |
| |
|
| | |
| | const bot = new TradingBot(); |