This script enhances the Desktop Version of TradingView by automating the centering of the Level 2 (Depth of Market, or DOM) view, a feature no longer natively supported. In fast-moving markets, manually scrolling or clicking the auto-center icon can be tedious. This Python-based system tray application solves this by automatically centering the DOM when active.
- Operating System: Windows 11
- Python Version: Python 3.13
- TradingView: Desktop Version
-
Install Python 3.13:
- Download the latest Python 3.13 installer from python.org.
- Run the installer, ensuring you check the box to "Add Python to PATH" during installation.
- Verify installation by opening a Command Prompt and typing
python --version(orpython3 --versionifpythondoesn't work). You should seePython 3.13.x.
-
Install Dependencies:
- Clone this repository or download the script file.
- Open a Command Prompt, navigate to the script's directory, and run:
pip install -r requirements.txt - The
requirements.txtfile includes only the necessary packages:pystray,pillow,pyautogui, andpynput.
-
Run the Script:
- Open a Command Prompt, navigate to the script's directory, and run:
python domAutoCenter.py
- Open a Command Prompt, navigate to the script's directory, and run:
-
System Tray Icon:
-
Controls:
- Select "Auto-Centering" (to toggle activate/deactivate) or select "Exit" to stop the script.
- Icon States:
The script monitors the active window for TradingView (detected by specific title keywords like "%", "+", or "−"). When enabled and focused on a compatible TradingView tab, it automatically sends the Shift + Alt + C key combination to center the DOM at regular intervals. It runs in the background via the system tray, updating its icon color to reflect its status. It does not interfere with core functionalities such as placing trades or other TradingView operations.
To automatically start the script when your Windows machine boots, follow these steps:
- Create a Shortcut:
- Locate the
domAutoCenter.pyfile in its directory. - Right-click the file, select "Create shortcut," and move the shortcut to a convenient location (e.g., your Desktop).
- Locate the
- Open Startup Folder:
- Press
Win + R, typeshell:startup, and press Enter. This opens the Startup folder for the current user.
- Press
- Add Shortcut:
- Drag the shortcut into the Startup folder, or copy and paste it there.
- (Optional) Edit Shortcut:
- Right-click the shortcut, select "Properties," and in the "Target" field, ensure it includes the full path to Python and the script, e.g.,
"C:\Python313\python.exe" "C:\path\to\domAutoCenter.py". Adjust paths as needed. - Click "OK" to save.
- Right-click the shortcut, select "Properties," and in the "Target" field, ensure it includes the full path to Python and the script, e.g.,
- Test:
- Restart your computer to confirm the script starts automatically. The system tray icon should appear.
Note: Ensure Python is added to your system PATH during installation, or specify the full Python executable path in the shortcut.





