better pivots

This commit is contained in:
Dobromir Popov
2025-10-21 11:45:57 +03:00
parent a8ea9b24c0
commit 68b91f37bd
7 changed files with 1318 additions and 26 deletions

View File

@@ -4331,11 +4331,13 @@ class CleanTradingDashboard:
# Get Williams pivot levels with trend analysis
try:
pivot_levels = self.data_provider.get_williams_pivot_levels(symbol)
# Use 1m base timeframe for pivots on 1m chart (natural alignment)
# Need enough L1 pivots to form higher levels (L2-L5); 5000 candles should give plenty
pivot_levels = self.data_provider.get_williams_pivot_levels(symbol, base_timeframe='1m', limit=5000)
except Exception as e:
logger.warning(f"Error getting Williams pivot levels: {e}")
return
if not pivot_levels:
logger.debug(f"No Williams pivot levels available for {symbol}")
return
@@ -4343,7 +4345,7 @@ class CleanTradingDashboard:
# Get chart time range for pivot display
chart_start = df_main.index.min()
chart_end = df_main.index.max()
# Convert to timezone-naive for comparison
from datetime import timezone
import pytz
@@ -4370,7 +4372,7 @@ class CleanTradingDashboard:
if not pivot_points:
continue
# Separate highs and lows
# Separate highs and lows (no additional de-duplication; 1m data produces at most one pivot per candle by design)
highs_x, highs_y = [], []
lows_x, lows_y = [], []
@@ -4409,8 +4411,8 @@ class CleanTradingDashboard:
# Add high pivots for this level
if highs_x:
fig.add_trace(
go.Scatter(
fig.add_trace(
go.Scatter(
x=highs_x, y=highs_y,
mode='markers',
name=f'L{level_num} Pivot High',
@@ -4423,14 +4425,14 @@ class CleanTradingDashboard:
),
showlegend=(level_num == 1), # Only show legend for Level 1
hovertemplate=f"Level {level_num} High: ${{y:.2f}}<extra></extra>"
),
row=row, col=1
)
),
row=row, col=1
)
# Add low pivots for this level
if lows_x:
fig.add_trace(
go.Scatter(
fig.add_trace(
go.Scatter(
x=lows_x, y=lows_y,
mode='markers',
name=f'L{level_num} Pivot Low',
@@ -4443,9 +4445,9 @@ class CleanTradingDashboard:
),
showlegend=(level_num == 1), # Only show legend for Level 1
hovertemplate=f"Level {level_num} Low: ${{y:.2f}}<extra></extra>"
),
row=row, col=1
)
),
row=row, col=1
)
# Build external legend HTML (no annotation on chart to avoid scale distortion)
legend_children = []