diff --git a/ANNOTATE/core/once there are 2 Low or 2 high Level 2 p b/ANNOTATE/core/once there are 2 Low or 2 high Level 2 p new file mode 100644 index 0000000..46014b7 --- /dev/null +++ b/ANNOTATE/core/once there are 2 Low or 2 high Level 2 p @@ -0,0 +1 @@ +once there are 2 Low or 2 high Level 2 pivots AFTER the trend line prediction, we should make a trend line and do backpropagation to adjust our model predictions of trend \ No newline at end of file diff --git a/ANNOTATE/web/app.py b/ANNOTATE/web/app.py index a1017db..cd8aff9 100644 --- a/ANNOTATE/web/app.py +++ b/ANNOTATE/web/app.py @@ -2976,6 +2976,7 @@ class AnnotationDashboard: 'current_price': current_price, 'price_change': price_change, 'predicted_candle': predicted_candle, # This is what frontend needs! + 'primary_timeframe': '1m', # The main timeframe the model is predicting for 'type': 'transformer_prediction' } diff --git a/ANNOTATE/web/static/js/chart_manager.js b/ANNOTATE/web/static/js/chart_manager.js index 82f9011..86ac474 100644 --- a/ANNOTATE/web/static/js/chart_manager.js +++ b/ANNOTATE/web/static/js/chart_manager.js @@ -2863,45 +2863,66 @@ class ChartManager { /** * Update model predictions on charts + * Draws predictions ONLY on the primary timeframe (the one the model is predicting for) + * Other timeframes are just reference data for the model */ updatePredictions(predictions) { if (!predictions) return; try { - // Use the currently active timeframe from app state - // This ensures predictions appear on the chart the user is watching (e.g., '1s') - const timeframe = window.appState?.currentTimeframes?.[0] || '1m'; + // CRITICAL: Only draw predictions on the PRIMARY timeframe + // The model uses other timeframes as reference, but predictions are for the primary timeframe only + const primaryTimeframe = predictions.transformer?.primary_timeframe || + window.appState?.currentTimeframes?.[0] || + '1m'; + + console.log(`[updatePredictions] Drawing predictions on primary timeframe: ${primaryTimeframe}`); + + // Update only the primary timeframe + this._updatePredictionsForTimeframe(primaryTimeframe, predictions); + + } catch (error) { + console.error('[updatePredictions] Error:', error); + } + } + + /** + * Update predictions for a specific timeframe + * @private + */ + _updatePredictionsForTimeframe(timeframe, predictions) { + try { const chart = this.charts[timeframe]; if (!chart) { - console.warn(`[updatePredictions] Chart not found for timeframe: ${timeframe}`); + console.debug(`[updatePredictions] Chart not found for timeframe: ${timeframe}`); return; } - + // Throttle prediction updates to avoid flickering - const now = Date.now(); - const lastUpdate = this.lastPredictionUpdate[timeframe] || 0; - - // Create a simple hash of prediction data to detect actual changes - const predictionHash = JSON.stringify({ - action: predictions.transformer?.action, - confidence: predictions.transformer?.confidence, - predicted_price: predictions.transformer?.predicted_price, - timestamp: predictions.transformer?.timestamp - }); - - // Skip update if: - // 1. Too soon since last update (throttle) - // 2. Predictions haven't actually changed - if (now - lastUpdate < this.predictionUpdateThrottle && predictionHash === this.lastPredictionHash) { - console.debug(`[updatePredictions] Skipping update (throttled or unchanged)`); - return; - } - - this.lastPredictionUpdate[timeframe] = now; - this.lastPredictionHash = predictionHash; - - console.log(`[updatePredictions] Timeframe: ${timeframe}, Predictions:`, predictions); + const now = Date.now(); + const lastUpdate = this.lastPredictionUpdate[timeframe] || 0; + + // Create a simple hash of prediction data to detect actual changes + const predictionHash = JSON.stringify({ + action: predictions.transformer?.action, + confidence: predictions.transformer?.confidence, + predicted_price: predictions.transformer?.predicted_price, + timestamp: predictions.transformer?.timestamp + }); + + // Skip update if: + // 1. Too soon since last update (throttle) + // 2. Predictions haven't actually changed + if (now - lastUpdate < this.predictionUpdateThrottle && predictionHash === this.lastPredictionHash) { + console.debug(`[updatePredictions] Skipping update for ${timeframe} (throttled or unchanged)`); + return; + } + + this.lastPredictionUpdate[timeframe] = now; + this.lastPredictionHash = predictionHash; + + console.log(`[updatePredictions] Timeframe: ${timeframe}, Predictions:`, predictions); const plotId = chart.plotId; const plotElement = document.getElementById(plotId);