Commit Graph

97 Commits

Author SHA1 Message Date
9883d1bea9 feat: enhance strategy simulation with Inverse Perpetual support, effective leverage caps, and advanced charting 2026-03-03 23:07:03 +01:00
50c525a0bd Refactor strategy simulation to track BTC quantity and enhance chart markers
- Switch simulation to track BTC quantity instead of USD notional only
- Use current candle price for entry/exit quantity and PnL calculations
- Correctly weight average entry price by BTC quantity
- Update chart markers to display total position in format: ( / BTC size)
- Improve equity chart accuracy by accounting for BTC value fluctuations
2026-03-03 16:05:46 +01:00
633a146e8e Refine strategy simulation with pyramiding, partial exits, and fixed marker logic
- Implement position pyramiding and 15% partial profit-taking
- Add mutual exclusion between entry and exit in the same candle
- Optimize simulation to use cached indicator results
- Revert Hurst Bands signal logic to cross-down (dip entry)
- Add safety filter for chart markers to prevent rendering errors
2026-03-03 15:39:59 +01:00
d92af6903d Implement Strategy tab with Ping-Pong backtesting and crossover-based signal logic
- Add 'Strategy' tab to sidebar for backtesting simulations
- Create strategy-panel.js for Ping-Pong and Accumulation mode simulations
- Refactor all indicators (MA, HTS, RSI, MACD, BB, STOCH, Hurst) to use strict crossover-based signal calculation
- Update chart.js with setSimulationMarkers and clearSimulationMarkers support
- Implement single-entry rule in Ping-Pong simulation mode
2026-03-03 13:15:29 +01:00
73f325ce19 Fix indicator preset saving and update Hurst Bands defaults
- Include visual settings (line width, color, markers) in saved presets
- Change default line width to 1px for indicators
- Update Hurst Bands to use grey markers and custom shapes by default
- Add robust userPresets initialization and error handling in savePreset
2026-03-03 12:19:13 +01:00
cf1aca8855 Add Hurst Bands indicator with buy/sell signal markers 2026-03-03 08:36:26 +01:00
9d7647fde5 Add signal markers on main chart with configurable shapes and colors
- Create signal-markers.js module to calculate crossover markers for indicators
- Add marker configuration options to indicator config panel:
  - Show/hide markers toggle
  - Buy/sell shape selection (built-in or custom Unicode)
  - Buy/sell color pickers
- Integrate markers with lightweight-charts using createSeriesMarkers API
- Markers recalculate when indicators change or historical data loads
2026-03-02 12:49:49 +01:00
d332748411 fixed params handling in analysis panel 2026-03-02 10:46:03 +01:00
b888c03e8e show only period param in analysis panel 2026-03-02 10:45:00 +01:00
7191cd293f fixed params display in analysis panel 2026-03-02 10:39:50 +01:00
c2f92cc5fb show indicator params like MA(44) in active list and analysis panel 2026-03-02 10:36:03 +01:00
ece1e8b56a added indicator params to analysis panel 2026-03-02 10:31:16 +01:00
cf190cf918 fixed: crosshair time now uses timezone config 2026-03-02 09:15:04 +01:00
3ffec846dc added RSI crossover detection in historical crossovers for timestamp 2026-03-02 09:09:20 +01:00
dd1cc521e9 fixed syntax error in signals-calculator 2026-03-02 09:05:33 +01:00
a84a1c9091 added RSI crossover signals: BUY when crosses up oversold, SELL when crosses down overbought 2026-03-02 09:03:18 +01:00
767c0bef67 added centralized timezone config with UI selector in hamburger menu 2026-03-02 08:55:16 +01:00
87b7cea567 fixed: check pane element exists before observing 2026-03-01 22:53:18 +01:00
f7aaa709bc fixed: use getHTMLElement instead of domNode 2026-03-01 22:52:28 +01:00
32bbdc2248 fixed: default pane height 120px, save to localStorage on resize 2026-03-01 22:51:29 +01:00
00aae46c16 fixed: preserve pane assignments across redraws instead of clearing 2026-03-01 22:49:05 +01:00
6dd4d1c5dd fixed: remember RSI pane height across data updates 2026-03-01 22:45:44 +01:00
ea49c9b15a fixed timezone: removed duplicate +1h from formatDate (tickMarkFormatter already handles it) 2026-03-01 22:33:54 +01:00
28abdb15a2 fixed: always update timestamp from current data, not stale cache 2026-03-01 22:25:59 +01:00
af79268621 simplified crossover detection: find first candle where price crosses MA 2026-03-01 22:16:12 +01:00
12689ad8f3 fixed: use correct candle timestamp (newer candle) for crossover 2026-03-01 22:06:22 +01:00
34cccce6b4 fixed: use correct crossover timestamp for signal, clear signal state on param change 2026-03-01 21:57:34 +01:00
38557e75d4 fixed: assign drawIndicatorsOnChart to window so it can be called from chart.js 2026-03-01 21:34:26 +01:00
e727f069e1 also call updateIndicatorCandles on new data 2026-03-01 21:28:21 +01:00
264ce72737 reverted order method - not available in lightweight-charts v5 2026-03-01 21:25:51 +01:00
37b41caedc fixed z-order so indicators appear on top of price candles 2026-03-01 21:24:43 +01:00
ef43b128d5 removed duplicate scrollToRealTime that may interfere with indicator redraw 2026-03-01 21:18:38 +01:00
780ecfdfb5 improved indicator redraw on new candles with error handling 2026-03-01 21:15:24 +01:00
9c560a5786 fixed time zone to UTC+1 for Warsaw 2026-03-01 20:29:18 +01:00
e52b177102 Fix: Move timeFormatter to localization object
The timeFormatter must be inside localization.timeScale to properly format
time axis labels. This ensures the x-axis time labels display UTC+1 time correctly.
2026-03-01 20:20:30 +01:00
234e293256 Fix: Show UTC+1 time on chart and fix indicator redrawing
Changes:
1. UTC+1 Time Display
   - Updated formatDate() to add 1 hour offset for Central European Time (UTC+1)
   - Added timeFormatter to chart timeScale for x-axis labels
   - Both signal display and chart time axis now show UTC+1 time

2. Fix Indicator Redrawing
   - Added missing getActiveIndicators() call in drawIndicatorsOnChart
   - Fixed variable scope issue where activeIndicators wasn't defined
   - Ensures indicators are properly removed and recreated when new candles close
2026-03-01 20:17:14 +01:00
9513f5b426 Fix: Track actual historical crossovers and force indicator redraw
Issue 1: Track actual crossovers from history
- Added calculateHistoricalCrossovers() function
- Scans candle history backwards to find most recent crossover
- Updates lastSignalTimestamp when BUY→SELL or SELL→BUY crossover is detected
- Date now reflects when the price actually crossed the MA line

Issue 2: Force full redraw of indicator series
- Changed updateIndicatorCandles() to remove and recreate all series
- Instead of using setData() which may not work reliably
- Full redraw ensures overlay indicators (MA) refresh correctly
- Now indicator lines update properly when new candles finish

Both implementations ensure:
1. Date shows actual crossover time (when candle crossed MA)
2. Indicator lines redraw on new candle completion
3. Works for both overlay (MA, BB, HTS) and pane (RSI, MACD, etc.) indicators
2026-03-01 20:12:19 +01:00
0df8547d96 Fix: Signal date tracking and indicator real-time updates
Issue 1: Only update lastSignalDate when signal type changes (BUY→SELL or SELL→BUY)
- Modified clearIndicatorCaches() to accept clearSignalState parameter
- When new candle completes: only clear cachedResults/cachedMeta (not signal state)
- When timeframe changes: clear everything including signal tracking
- This preserves signal change history across multiple candles

Issue 2: Indicator lines not updating when new candles arrive
- Added updateIndicatorCandles() function to update existing series
- Instead of removing and recreating series, now uses .setData() to update
- Called when new candle is detected to update indicator lines
- Chart renders correctly with new data after each candle completion

Both issues now resolved:
1. Shows last crossover date only when signal actually changes
2. Indicator lines update in real-time when new candles complete
2026-03-01 20:07:12 +01:00
61aaa2d122 Add indicator recalculation on timeframe change and new candle
Changes:
- Added lastCandleTimestamp to track candle completion
- Detect new candle when timestamp increases
- Clear indicator caches when new candle detected
- Clear indicator caches when timeframe changes
- Recalculate indicators and signals in both cases
- Refresh chart when new candle is detected

This ensures indicators are always recalculated with fresh data when:
1. Timeframe is switched
2. A new candle completes

Both cases now force:
- Cache clearing
- Indicator recalculation
- Chart refresh
- Signal recalculation
2026-03-01 19:58:14 +01:00
11c805917c Fix: Change datetime format in Indicator Analysis panel
- Changed date format to DD/MM/YY HH:mm format
- Removed 'Last: ' prefix from signal display
- Added formatDate() helper function for consistent formatting
2026-03-01 19:53:11 +01:00
3779e7c499 Fix: Remove duplicate code in moving_average.js
The file had duplicate calculate() and getMetadata() methods causing syntax errors.
Removed duplicate code from lines 214-251.
Now the file has a single proper implementation.
2026-03-01 19:46:41 +01:00
71bc034590 Fix: Missing closing brace in MAIndicator.calculate() 2026-03-01 19:45:56 +01:00
33f49b1559 Fix MA rendering and simplify signal UI
- Fixed MA plot ID to match return structure (ma vs value)
- Moved Status and Last Signal display to main Indicator Analysis section
- Removed Signal Status section from expanded indicator config
- Simplified signal display to show only status icon/type and last signal date
- Removed strength and reasoning tooltips from signal display
2026-03-01 19:45:28 +01:00
f789f3d4c1 Fix: Restore calculateSummarySignal function 2026-03-01 19:40:20 +01:00
a344a7f0da Refactor: Convert indicators to self-contained files
- Created moving_average.js consolidating ma.js, ma_indicator.js, sma.js, ema.js
- Made all indicators self-contained with embedded:
  * Math logic (no external dependencies)
  * Metadata (getMetadata())
  * Signal calculation (calculateXXXSignal)
  * Base class (inline BaseIndicator)
- Updated macd.js, hts.js to inline EMA/MA calculations
- Added signal functions to RSI, BB, Stochastic, ATR indicators
- Updated indicators/index.js to export both classes and signal functions
- Simplified signals-calculator.js to orchestrate using indicator signal functions
- Removed obsolete files: ma.js, base.js, ma_indicator.js, sma.js, ema.js

All indicators now fully self-contained with no external file dependencies
for math, signal calculation, or base class.
2026-03-01 19:39:28 +01:00
fdab0a3faa Pre-refactor: commit before converting indicators to self-contained files 2026-03-01 19:37:07 +01:00
e457ce3e20 feat: Implement HTS (Higher Timeframe Trend System) strategy
- Add HTS strategy engine with crossover and alignment-based entries
- Implement Auto HTS feature (computes on TF/4 from 1m data)
- Add 1H Red Zone filter to validate long signals
- Add channel-based stop loss with RTL functionality
- Enhanced visualization with 30% opacity channel lines
- Fixed data alignment in simulation (uses htsData instead of mismatched indices)
- Fixed syntax errors in hts-engine.js (malformed template literals)
- Fixed duplicate code in simulation.js
- Added showSimulationMarkers to window object for global access
- Enhanced logging for trade signals and simulation results
- Fix missing prevFastHigh/currFastHigh in hts-visualizer.js
- Disable trend zone overlays to prevent chart clutter
- Implement client-side visualization for trade markers using line series
- MA strategy indicator configuration fixed (was empty during engine run)
- Made entry conditions more permissive for shorter timeframes
- Added comprehensive error handling and console logging
2026-02-27 09:30:43 +01:00
286975b01a Add backup files to gitignore 2026-02-26 23:47:10 +01:00
899d9174e4 Add indicator signals feature with buy/sell/hold analysis
- Add signals-calculator.js module for calculating buy/sell/hold signals for all indicators
- Integrate signals into Trend Analysis panel (renamed to Indicator Analysis)
- Display individual indicator signals with badges, values, strength bars, and detailed reasoning
- Add aggregate summary signal showing overall recommendation from all indicators
- Support signals for RSI, MACD, Stochastic, Bollinger Bands, SMA/EMA, ATR, and HTS
- Provide tooltips on hover showing indicator value, configuration, and reasoning
- Ensure indicators calculate on all available candles, not just recent ones
- Cache indicator calculations for performance while recalculating on historical data loads
- Style improvements: monospace font, consistent button widths, reduced margins
- Add AGENTS.md documentation file with project guidelines
2026-02-26 23:46:33 +01:00
cca89397cf Fix button positioning: Keep buttons on left side with 5px spacing
- Remove justify-content: space-between that centered buttons
- Change gap from 4px to 5px for spacing between buttons
- Buttons now appear after text on left side (not centered/center-right)
2026-02-26 21:24:14 +01:00