Skip to content

fix: Improve TradingView UI compatibility and debugging for parameter…#276

Open
alorbach wants to merge 1 commit intoakumidv:mainfrom
alorbach:delta-uifix-2025-07
Open

fix: Improve TradingView UI compatibility and debugging for parameter…#276
alorbach wants to merge 1 commit intoakumidv:mainfrom
alorbach:delta-uifix-2025-07

Conversation

@alorbach
Copy link

@alorbach alorbach commented Jul 6, 2025

… name mismatches

This commit addresses critical issues with TradingView's evolving UI and adds robust debugging capabilities for parameter name mismatches that cause runtime errors.

  • Added comprehensive debugging instructions at the top of the file for troubleshooting "Net profit: All Error on runtime" issues

  • Implemented automatic parameter name detection and correction system:

    • logAvailableParameters(): Logs all available parameters from TradingView reports
    • findBestNetProfitParam(): Intelligently finds correct "Net profit" parameter variations
    • setOptParamName(): Manual parameter name override function for debugging
  • Enhanced error handling in getInitBestValues(), getTestIterationResult(), and getResWithBestValue() to handle parameter name mismatches gracefully

  • Added parameter name patterns matching for various TradingView versions:

    • 'Net profit: All', 'Net Profit: All', 'Net P&L: All', etc.
  • Improved fallback mechanisms when expected parameter names don't exist

  • Added new selectors for TradingView's updated deep backtesting UI:

    • strategyDeepTestDateRangeButton: Date range button selector
    • strategyDeepTestCustomDateRangeButton: Custom date range option
    • strategyDeepTestDateInputs: Date input fields
    • strategyDeepTestSelectButton: Select button for date confirmation
    • strategyDeepTestUpdateReportButton: Update report button
  • Added selectors for loading state detection:

    • strategyReportLoadingSnackbar: Loading indicator
    • strategyReportSuccessSnackbar: Success confirmation
  • Completely rewrote setDeepTestDateRange() function to handle new TradingView UI flow:

    1. Click date range button → 2. Click "Custom date range..." → 3. Set dates → 4. Click "Select"
  • Added fallback support for older TradingView UI versions

  • Improved error handling with try/catch blocks and graceful degradation

  • Added comprehensive debug logging for troubleshooting date setting issues

  • Integrated "Update report" button handling into main process flow in getPerformance()

  • Added intelligent loading state detection with snackbar monitoring

  • Enhanced debug logging throughout the performance analysis process

  • Improved error detection and process state management

  • Added timeout handling for report update operations (30-second max wait)

  • Added 170+ lines of new functionality in backtest.js

  • Enhanced 27 selectors in selector.js for UI compatibility

  • Expanded 241 lines in tv.js for improved deep backtesting support

  • Comprehensive error handling and logging throughout

  • Backward compatibility maintained with older TradingView versions

  • Fixed parameter name mismatch errors causing "Net profit: All Error on runtime"

  • Resolved deep backtesting date range setting issues with new TradingView UI

  • Improved handling of TradingView's asynchronous report generation

  • Enhanced detection of completed backtesting processes

This update ensures the extension continues to work reliably with TradingView's UI changes while providing better debugging capabilities for troubleshooting parameter-related issues.

@alorbach
Copy link
Author

alorbach commented Jul 8, 2025

  • Updated 2025-07-08 *
    Refactors the deep backtest date range setting functionality to be more resilient and robust against recent TradingView UI changes.
  • Updates selectors for the date picker dialog to be more specific, targeting buttons and inputs more accurately.
  • Implements a more reliable method for clearing date input fields by simulating keyboard events (Ctrl+A + Backspace).
  • Adds a pre-check to verify if the correct dates are already set, avoiding unnecessary changes by canceling the dialog.
  • Introduces logic to handle cases where an invalid date is selected. If the "Select" button is disabled, the "Select first available date" button is clicked automatically to correct the range.

@alorbach alorbach force-pushed the delta-uifix-2025-07 branch 2 times, most recently from 44bffde to d132608 Compare July 10, 2025 12:20
… name mismatches

This commit addresses critical issues with TradingView's evolving UI and adds robust
debugging capabilities for parameter name mismatches that cause runtime errors.

- Added comprehensive debugging instructions at the top of the file for troubleshooting
  "Net profit: All Error on runtime" issues
- Implemented automatic parameter name detection and correction system:
  - `logAvailableParameters()`: Logs all available parameters from TradingView reports
  - `findBestNetProfitParam()`: Intelligently finds correct "Net profit" parameter variations
  - `setOptParamName()`: Manual parameter name override function for debugging
- Enhanced error handling in `getInitBestValues()`, `getTestIterationResult()`, and
  `getResWithBestValue()` to handle parameter name mismatches gracefully
- Added parameter name patterns matching for various TradingView versions:
  - 'Net profit: All', 'Net Profit: All', 'Net P&L: All', etc.
- Improved fallback mechanisms when expected parameter names don't exist

- Added new selectors for TradingView's updated deep backtesting UI:
  - `strategyDeepTestDateRangeButton`: Date range button selector
  - `strategyDeepTestCustomDateRangeButton`: Custom date range option
  - `strategyDeepTestDateInputs`: Date input fields
  - `strategyDeepTestSelectButton`: Select button for date confirmation
  - `strategyDeepTestUpdateReportButton`: Update report button
- Added selectors for loading state detection:
  - `strategyReportLoadingSnackbar`: Loading indicator
  - `strategyReportSuccessSnackbar`: Success confirmation

- Completely rewrote `setDeepTestDateRange()` function to handle new TradingView UI flow:
  1. Click date range button → 2. Click "Custom date range..." → 3. Set dates → 4. Click "Select"
- Added fallback support for older TradingView UI versions
- Improved error handling with try/catch blocks and graceful degradation
- Added comprehensive debug logging for troubleshooting date setting issues

- Integrated "Update report" button handling into main process flow in `getPerformance()`
- Added intelligent loading state detection with snackbar monitoring
- Enhanced debug logging throughout the performance analysis process
- Improved error detection and process state management
- Added timeout handling for report update operations (30-second max wait)

- Added 170+ lines of new functionality in backtest.js
- Enhanced 27 selectors in selector.js for UI compatibility
- Expanded 241 lines in tv.js for improved deep backtesting support
- Comprehensive error handling and logging throughout
- Backward compatibility maintained with older TradingView versions

- Fixed parameter name mismatch errors causing "Net profit: All Error on runtime"
- Resolved deep backtesting date range setting issues with new TradingView UI
- Improved handling of TradingView's asynchronous report generation
- Enhanced detection of completed backtesting processes

This update ensures the extension continues to work reliably with TradingView's
UI changes while providing better debugging capabilities for troubleshooting
parameter-related issues.

* Updated 2025-07-08 *
Refactors the deep backtest date range setting functionality to be more resilient and robust against recent TradingView UI changes.
- Updates selectors for the date picker dialog to be more specific, targeting buttons and inputs more accurately.
- Implements a more reliable method for clearing date input fields by simulating keyboard events (Ctrl+A + Backspace).
- Adds a pre-check to verify if the correct dates are already set, avoiding unnecessary changes by canceling the dialog.
- Introduces logic to handle cases where an invalid date is selected. If the "Select" button is disabled, the "Select first available date" button is clicked automatically to correct the range.

* Updated 2025-07-08 *
- Fixed potentional memory leak
- Fixed Backtest new UI Updating Report Button DIV detection if no
  Update Report button occurs.
@montereybay
Copy link

montereybay commented Jul 15, 2025

Hi @alorbach,

Thanks for the reply and for maintaining this tool - really appreciate the quick guidance.

Unfortunately, I am still getting the 'error' in about 10% of iterations.

I followed the suggested steps in this thread in order to switch the optimization metric to Sharpe ratio.

Here’s exactly what I did:

  1. **Copied the latest extension files you provided ** (backtest.js, page.js, selector.js, tv.js) into the unpacked extension folder, overwriting the previous versions.

  2. Opened:

    content_scripts/backtest.js
    
  3. Ran a backtest in TradingView and opened DevTools Console. Under:

    === Available Parameters ===
    

    I confirmed:

    "Sharpe ratio": 0.982
    
  4. In backtest.js, updated:

    const backtest = {
      DEF_MAX_PARAM_NAME: 'Sharpe ratio'
    }
  5. Saved the file and reloaded the unpacked extension via chrome://extensions.

  6. Set a delay of 8 seconds between iterations using the plugin popup before launching the optimization.

  7. Re-ran the backtest—but still got an error even though 'Sharpe ratio' is clearly listed in the available parameters.

So while everything seems correctly configured, the extension still seems to fail to recognize the optimization target. Please let me know if there’s another override or step I might have missed.

Thanks again for the help so far!
Paul

@akumidv
Copy link
Owner

akumidv commented Nov 19, 2025

The new version fully reenginered with variables renaming too. Reviewing this pull request demand a lot of efforts and it will be zero results after deploying new version. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants