-- ============================================
-- INDICATOR VALUES TABLE
-- ============================================

CREATE TABLE IF NOT EXISTS `indicator_values` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `symbol` VARCHAR(20) NOT NULL,
    `timeframe` INT NOT NULL,
    `indicator` VARCHAR(50) NOT NULL COMMENT 'Indicator name (ATR, SUPERTREND, etc)',
    `value` DECIMAL(20,8) NOT NULL COMMENT 'Indicator value',
    `direction` VARCHAR(10) DEFAULT NULL COMMENT 'Direction for trend indicators (UP/DOWN)',
    `candle_open_time` DATETIME NOT NULL COMMENT 'Candle start time',
    `candle_close_time` DATETIME NOT NULL COMMENT 'Candle end time',
    `source` VARCHAR(10) DEFAULT 'LIVE' COMMENT 'Data source (LIVE/TEST/PAPER)',
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY `unique_indicator` (`symbol`, `timeframe`, `indicator`, `candle_open_time`),
    KEY `idx_symbol_tf` (`symbol`, `timeframe`),
    KEY `idx_indicator` (`indicator`),
    KEY `idx_candle_time` (`candle_open_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
COMMENT='Stores calculated indicator values for each candle';
