<!--
--  Uploaded on : https://haxor.my.id/open/nasrun-kamis-2024.html
--  Official Web : https://prinsh.com
--  script-deface-generator.prinsh.com
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>nasrundezz - simulasi trading</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        #container {
            width: 600px;
            margin: 0 auto;
            text-align: center;
        }
        #price {
            font-size: 24px;
            margin-bottom: 20px;
        }
        button {
            padding: 10px 20px;
            font-size: 18px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="container">
        <h1>Simulasi Trading Forex</h1>
        <div id="price">Harga: $100</div>
        <button onclick="buy()">Beli</button>
        <button onclick="sell()">Jual</button>
        <p id="message"></p>
    </div>

    <script>
        let price = 100; // Harga awal
        let balance = 1000; // Saldo awal

        function updatePrice() {
            // Mengupdate harga secara acak (untuk simulasi)
            const minChange = -5;
            const maxChange = 5;
            const change = Math.floor(Math.random() * (maxChange - minChange + 1)) + minChange;
            price += change;
            document.getElementById('price').innerText = `Harga: $${price}`;
        }

        function buy() {
            balance -= price;
            updatePrice();
            displayMessage('Beli berhasil.');
            updateBalance();
        }

        function sell() {
            balance += price;
            updatePrice();
            displayMessage('Jual berhasil.');
            updateBalance();
        }

        function displayMessage(msg) {
            document.getElementById('message').innerText = msg;
        }

        function updateBalance() {
            document.getElementById('balance').innerText = `Saldo: $${balance}`;
        }

        // Mengupdate harga setiap 3 detik
        setInterval(updatePrice, 3000);
    </script>
</body>
</html>