Implement multi-timeframe support for indicators
- Enhanced the `UserIndicator` class to include an optional `timeframe` attribute for custom indicator timeframes. - Updated the `get_indicator_data` method in `MarketDataIntegrator` to fetch and calculate indicators based on the specified timeframe, ensuring proper data alignment and handling. - Modified the `ChartBuilder` to pass the correct DataFrame for plotting indicators with different timeframes. - Added UI elements in the indicator modal for selecting timeframes, improving user experience. - Updated relevant JSON templates to include the new `timeframe` field for all indicators. - Refactored the `prepare_chart_data` function to ensure it returns a DataFrame with a `DatetimeIndex` for consistent calculations. This commit enhances the flexibility and usability of the indicator system, allowing users to analyze data across various timeframes.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"description": "Bollinger Bands volatility indicator",
|
||||
"type": "bollinger_bands",
|
||||
"display_type": "overlay",
|
||||
"timeframe": null,
|
||||
"default_parameters": {
|
||||
"period": 20,
|
||||
"std_dev": 2.0
|
||||
@@ -20,7 +21,12 @@
|
||||
"min": 0.5,
|
||||
"max": 5.0,
|
||||
"default": 2.0,
|
||||
"description": "Standard deviation multiplier"
|
||||
"description": "Standard deviation for Bollinger Bands"
|
||||
},
|
||||
"timeframe": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Indicator timeframe (e.g., '1h', '4h'). Null for chart timeframe."
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"description": "Exponential Moving Average indicator",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"timeframe": null,
|
||||
"default_parameters": {
|
||||
"period": 12
|
||||
},
|
||||
@@ -13,6 +14,11 @@
|
||||
"max": 200,
|
||||
"default": 12,
|
||||
"description": "Period for EMA calculation"
|
||||
},
|
||||
"timeframe": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Indicator timeframe (e.g., '1h', '4h'). Null for chart timeframe."
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"description": "Moving Average Convergence Divergence",
|
||||
"type": "macd",
|
||||
"display_type": "subplot",
|
||||
"timeframe": null,
|
||||
"default_parameters": {
|
||||
"fast_period": 12,
|
||||
"slow_period": 26,
|
||||
@@ -28,11 +29,17 @@
|
||||
"min": 2,
|
||||
"max": 30,
|
||||
"default": 9,
|
||||
"description": "Signal line period"
|
||||
"description": "Signal line period for MACD"
|
||||
},
|
||||
"timeframe": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Indicator timeframe (e.g., '1h', '4h'). Null for chart timeframe."
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
"color": "#fd7e14",
|
||||
"line_width": 2
|
||||
"line_width": 2,
|
||||
"macd_line_color": "#007bff"
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"description": "RSI oscillator indicator",
|
||||
"type": "rsi",
|
||||
"display_type": "subplot",
|
||||
"timeframe": null,
|
||||
"default_parameters": {
|
||||
"period": 14
|
||||
},
|
||||
@@ -13,6 +14,11 @@
|
||||
"max": 50,
|
||||
"default": 14,
|
||||
"description": "Period for RSI calculation"
|
||||
},
|
||||
"timeframe": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Indicator timeframe (e.g., '1h', '4h'). Null for chart timeframe."
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"description": "Simple Moving Average indicator",
|
||||
"type": "sma",
|
||||
"display_type": "overlay",
|
||||
"timeframe": null,
|
||||
"default_parameters": {
|
||||
"period": 20
|
||||
},
|
||||
@@ -13,6 +14,11 @@
|
||||
"max": 200,
|
||||
"default": 20,
|
||||
"description": "Period for SMA calculation"
|
||||
},
|
||||
"timeframe": {
|
||||
"type": "string",
|
||||
"default": null,
|
||||
"description": "Indicator timeframe (e.g., '1h', '4h'). Null for chart timeframe."
|
||||
}
|
||||
},
|
||||
"default_styling": {
|
||||
|
||||
20
config/indicators/user_indicators/ema_b869638d.json
Normal file
20
config/indicators/user_indicators/ema_b869638d.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"id": "ema_b869638d",
|
||||
"name": "EMA 12 (15 minutes)",
|
||||
"description": "",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 12
|
||||
},
|
||||
"styling": {
|
||||
"color": "#007bff",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"timeframe": "15m",
|
||||
"visible": true,
|
||||
"created_date": "2025-06-06T06:56:54.181578+00:00",
|
||||
"modified_date": "2025-06-06T06:56:54.181578+00:00"
|
||||
}
|
||||
20
config/indicators/user_indicators/ema_bfbf3a1d.json
Normal file
20
config/indicators/user_indicators/ema_bfbf3a1d.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"id": "ema_bfbf3a1d",
|
||||
"name": "EMA 12 (5 minutes)",
|
||||
"description": "",
|
||||
"type": "ema",
|
||||
"display_type": "overlay",
|
||||
"parameters": {
|
||||
"period": 12
|
||||
},
|
||||
"styling": {
|
||||
"color": "#007bff",
|
||||
"line_width": 2,
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"timeframe": "5m",
|
||||
"visible": true,
|
||||
"created_date": "2025-06-06T07:02:34.613543+00:00",
|
||||
"modified_date": "2025-06-06T07:02:34.613543+00:00"
|
||||
}
|
||||
@@ -15,7 +15,8 @@
|
||||
"opacity": 1.0,
|
||||
"line_style": "solid"
|
||||
},
|
||||
"timeframe": "1h",
|
||||
"visible": true,
|
||||
"created_date": "2025-06-04T04:16:35.459602+00:00",
|
||||
"modified_date": "2025-06-04T04:16:35.459602+00:00"
|
||||
"modified_date": "2025-06-06T07:03:58.642238+00:00"
|
||||
}
|
||||
Reference in New Issue
Block a user