Ethereum: Trend Engine

The Ethereum Trend Engine is an automated technical analysis dashboard engineered to filter out short-term market fluctuations and present a clear, consolidated view of asset momentum. The widget dynamically fetches real-time market data to calculate an array of essential parameters, specifically evaluating a 14-day logarithmic return baseline, a 20-period Simple Moving Average (SMA), a 14-day Relative Strength Index (RSI), and Moving Average Convergence Divergence (MACD) trends.

By weighting the core direction against current trading volume metrics, the engine integrates these multi-faceted indicators into a singular, responsive percentage that maps the path of least resistance for the upcoming 1 to 14 days. Beyond tracking the immediate trajectory, the widget translates complex mathematical signals into high-level, situational alerts tailored for long-term holding.

The interface highlights potential strategic actions, changing layout behaviors and color states only when conditions reach notable thresholds. If the calculated 14-day RSI hits or falls below 35.00, it triggers an active accumulation flag; if the indicator climbs to 75.00 or above, it signals a phase of distribution. In the absence of extreme data points, the engine reliably identifies consolidation phases, allowing you to monitor the asset's underlying daily trend without needing to launch elaborate charting suites.

WARNING: This widget is an informational tool designed for daily trend analysis and must not be treated as a definitive financial advisor or a standalone execution trigger. Because the calculations rely on daily-based metrics - including the 20-period SMA, 14-day RSI, MACD, and on-chain supply data - it is inherently a lagging tool that cannot capture rapid intra-day volatility or sudden, high-speed price spikes. Furthermore, the interface depends on aggregated historical and on-chain data feeds that can experience reporting latency or unexpected inconsistencies. Always verify these metrics across independent charting platforms, and use them in conjunction with broader, personal risk-management strategies before making any investment decisions.

ETHEREUM TREND ENGINE V1.0
CURRENT PRICE (GBP)
--
14-Day Forecast
--%
Daily RSI (14)
--
Strategic Action
Analysing metrics...
ETHEREUM TREND ENGINE V1. 0
<style>
    /* Compact Dark Theme Optimized for Mobile - Width Adjusted */
    .engine-widget-container {
        font-family: system-ui, -apple-system, sans-serif;
        background: #18181b; 
        color: #e4e4e7;
        border-radius: 12px;
        padding: 16px; 
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
        width: 100%;
        max-width: 360px; 
        box-sizing: border-box;
        margin: 10px auto;
        position: relative;
    }

    .engine-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        border-bottom: 1px solid #27272a;
        padding-bottom: 8px;
    }

    .engine-title {
        font-size: 0.8rem; 
        color: #a1a1aa;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .engine-status {
        width: 8px;
        height: 8px;
        background-color: #52525b; 
        border-radius: 50%;
        transition: background-color 0.3s ease;
    }

    .engine-primary-display {
        margin-bottom: 16px;
    }

    .engine-primary-label {
        font-size: 0.75rem;
        color: #a1a1aa; /* Brightened for readability */
        margin-bottom: 4px;
        letter-spacing: 0.03em;
    }

    .engine-primary-value {
        font-size: 2.2rem; 
        font-weight: bold;
        color: #ffffff;
        letter-spacing: -0.02em;
    }

    .engine-supporting-metrics {
        display: flex;
        gap: 12px;
        margin-bottom: 16px;
    }

    .engine-metric-box {
        flex: 1;
        background: #202023;
        border-radius: 8px;
        padding: 12px;
        border: 1px solid #27272a;
        text-align: center;
    }

    .engine-metric-box.active-border {
        border-color: #10b981;
    }

    .engine-metric-label {
        font-size: 0.7rem;
        color: #a1a1aa; /* Brightened for readability */
        margin-bottom: 4px;
        text-transform: uppercase;
        white-space: nowrap; /* Prevents awkward text wrapping */
    }

    .engine-metric-value {
        font-size: 1.15rem; 
        font-weight: bold;
    }

    .engine-action-box {
        margin-bottom: 8px;
    }

    .engine-action-label {
        font-size: 0.75rem;
        color: #a1a1aa; /* Brightened for readability */
        margin-bottom: 4px;
        text-transform: uppercase;
    }

    .engine-action-text {
        font-size: 1.05rem; 
        font-weight: bold;
        color: #e4e4e7;
        line-height: 1.4;
    }

    /* Condition Color Styling */
    .engine-positive { color: #10b981; } 
    .engine-negative { color: #ef4444; } 
    .engine-status.active { background-color: #10b981; }
</style>

<div class="engine-widget-container">
    <div class="engine-header">
        <div class="engine-title">Ethereum Trend Engine</div>
        <div id="engine-status-dot" class="engine-status"></div>
    </div>

    <div class="engine-primary-display">
        <div class="engine-primary-label">CURRENT PRICE (GBP)</div>
        <div id="engine-current-price" class="engine-primary-value">--</div>
    </div>

    <div class="engine-supporting-metrics">
        <div id="box-trend" class="engine-metric-box">
            <div class="engine-metric-label">14-Day Forecast</div>
            <div id="engine-forecast-value" class="engine-metric-value">--%</div>
        </div>
        <div id="box-rsi" class="engine-metric-box">
            <div class="engine-metric-label">Daily RSI (14)</div>
            <div id="engine-rsi-value" class="engine-metric-value">--</div>
        </div>
    </div>

    <div class="engine-action-box">
        <div class="engine-action-label">Strategic Action</div>
        <div id="engine-action-text" class="engine-action-text">Analysing metrics...</div>
    </div>
</div>

<script>
    async function fetchEngineData() {
        try {
            const response = await fetch('https://api.coingecko.com/api/v3/coins/ethereum/market_chart?vs_currency=gbp&days=30&interval=daily');
            const data = await response.json();
            processEngineLogic(data);
        } catch (error) {
            console.error('Data pull failed:', error);
            document.getElementById('engine-current-price').innerText = "Error";
            document.getElementById('engine-action-text').innerText = "Service temporarily offline";
        }
    }

    function processEngineLogic(data) {
        const prices = data.prices.map(item => item[1]);
        const volumes = data.total_volumes.map(item => item[1]);

        const currentPrice = prices[prices.length - 1];
        const currentVolume = volumes[volumes.length - 1];

        const priceStart = prices[Math.max(0, prices.length - 14)];
        const logReturn = Math.log(currentPrice / priceStart);

        const avgVolume = volumes.reduce((sum, v) => sum + v, 0) / volumes.length;
        const volumeWeight = currentVolume / avgVolume;

        const sma20 = prices.slice(-20).reduce((a, b) => a + b, 0) / 20;
        const smaScore = currentPrice > sma20 ? 0.02 : -0.02;

        const rsi14 = calculateEngineRSI(prices, 14);

        const sma12 = prices.slice(-12).reduce((a, b) => a + b, 0) / 12;
        const sma26 = prices.slice(-26).reduce((a, b) => a + b, 0) / 26;
        const macdLine = sma12 - sma26;

        let combinedFormula = (logReturn * volumeWeight) + smaScore + (macdLine / currentPrice);
        let finalPercentage = Math.max(-100, Math.min(100, combinedFormula * 100));

        updateEngineUI(currentPrice, finalPercentage, rsi14);
    }

    function calculateEngineRSI(prices, period) {
        let gains = 0, losses = 0;
        for (let i = prices.length - period; i < prices.length; i++) {
            let diff = prices[i] - prices[i - 1];
            if (diff > 0) gains += diff;
            else losses += Math.abs(diff);
        }
        if (losses === 0) return 100;
        let rs = (gains / period) / (losses / period);
        return (100 - (100 / (1 + rs))).toFixed(2);
    }

    function updateEngineUI(price, forecast, rsi) {
        const priceEl = document.getElementById('engine-current-price');
        const forecastEl = document.getElementById('engine-forecast-value');
        const rsiEl = document.getElementById('engine-rsi-value');
        const actionEl = document.getElementById('engine-action-text');
        const statusDot = document.getElementById('engine-status-dot');
        const boxTrend = document.getElementById('box-trend');
        const boxRsi = document.getElementById('box-rsi');

        priceEl.innerText = new Intl.NumberFormat('en-GB', { 
            style: 'currency', currency: 'GBP', maximumFractionDigits: 2 
        }).format(price);

        const sign = forecast > 0 ? "+" : "";
        forecastEl.innerText = `${sign}${forecast.toFixed(2)}%`;
        forecastEl.className = forecast >= 0 ? "engine-metric-value engine-positive" : "engine-metric-value engine-negative";

        rsiEl.innerText = rsi;

        if (rsi <= 35.00) {
            actionEl.innerText = "Buy Trigger Active (Accumulate)";
            actionEl.className = "engine-action-text engine-positive";
            boxTrend.className = "engine-metric-box";
            boxRsi.className = "engine-metric-box active-border";
        } else if (rsi >= 75.00) {
            actionEl.innerText = "Sell Trigger Active (Distribution)";
            actionEl.className = "engine-action-text engine-negative";
            boxTrend.className = "engine-metric-box";
            boxRsi.className = "engine-metric-box";
        } else {
            actionEl.innerText = forecast >= 0 ? "Consolidation (Upward Momentum)" : "Consolidation (Downward Drift)";
            actionEl.className = "engine-action-text";
            boxTrend.className = "engine-metric-box";
            boxRsi.className = "engine-metric-box";
        }

        statusDot.className = "engine-status active";
    }

    fetchEngineData();
</script>

Post a Comment

0 Comments

Notice:
Comments are moderated and may not appear immediately. Please keep your comments respectful, and relevant to the post. Spam will not be tolerated. My site. My rules.

Post a Comment (0)