File size: 4,139 Bytes
cc84631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
document.addEventListener('DOMContentLoaded', function() {
    // Theme switcher functionality
    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'));
        });
    }

    // Check for saved theme preference
    if (localStorage.getItem('darkMode') === 'true') {
        document.documentElement.classList.add('dark');
    } else {
        document.documentElement.classList.remove('dark');
    }

    // Simulate live data updates
    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); // Random change between -1% and +1%
            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');
                }
            }
        }
    }

    // Update every 5 seconds
    setInterval(updateLiveData, 5000);

    // Mobile menu toggle
    const mobileMenuButton = document.getElementById('mobile-menu-button');
    const mobileMenu = document.getElementById('mobile-menu');
    if (mobileMenuButton && mobileMenu) {
        mobileMenuButton.addEventListener('click', function() {
            mobileMenu.classList.toggle('hidden');
        });
    }
});
// Leledc Exhaustion Indicator Logic
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;

    // Update indices
    if (data[i].close > data[i-4].close) {
      bIndex++;
    }
    if (data[i].close < data[i-4].close) {
      sIndex++;
    }

    // Check for major signals
    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; // Bearish signal
    }
    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; // Bullish signal
    }

    // Check for minor signals
    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; // Bearish signal
    }
    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; // Bullish signal
    }

    results.push({ major, minor });
  }

  return results;
}

// Simulated trading bot functions
class TradingBot {
    constructor() {
        this.isRunning = false;
    }

    start() {
        this.isRunning = true;
        console.log('Trading bot started');
        // Add actual trading logic here
    }

    stop() {
        this.isRunning = false;
        console.log('Trading bot stopped');
    }

    getStatus() {
        return this.isRunning ? 'Running' : 'Stopped';
    }
}

// Initialize a new trading bot instance
const bot = new TradingBot();