forked from LengKundee/MQL5-Google-Onedrive
- Python orchestrator with JSON config, logging, and monitoring - Windows batch script for simple automation - PowerShell script with scheduled task creation - Linux/WSL shell script with systemd/cron support - Detailed documentation and quick start guides - Example custom script template - Configuration file with MT5 paths - Updated .gitignore for logs and temp files Co-authored-by: Mouy-leng <199350297+Mouy-leng@users.noreply.github.com>
5.6 KiB
5.6 KiB
Windows Task Scheduler Setup
This guide shows how to set up automatic startup using Windows Task Scheduler for MQL5 trading automation.
Method 1: Automated Setup (Easiest)
Open PowerShell as Administrator and run:
cd C:\path\to\MQL5-Google-Onedrive
powershell -ExecutionPolicy Bypass -File scripts\startup.ps1 -CreateScheduledTask
This automatically creates a scheduled task named MQL5_Trading_Automation_Startup.
Method 2: Manual Setup
Step 1: Open Task Scheduler
Press Win + R, type taskschd.msc, and press Enter.
Step 2: Create New Task
- In the right panel, click "Create Task..." (not "Create Basic Task")
Step 3: General Settings
- Name:
MQL5 Trading Automation - Description:
Automatically start MT5 terminal and trading scripts - Check ☑ "Run with highest privileges"
- Configure for: Windows 10 (or your version)
- Security options:
- Select "Run whether user is logged on or not"
- Check "Do not store password"
Step 4: Triggers
- Go to Triggers tab
- Click New...
- Settings:
- Begin the task:
At startup - Delay task for:
30 seconds(recommended to let system initialize) - Check ☑ Enabled
- Begin the task:
- Click OK
Step 5: Actions
- Go to Actions tab
- Click New...
- Settings:
- Action:
Start a program - Program/script:
powershell.exe - Add arguments:
-ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\path\to\MQL5-Google-Onedrive\scripts\startup.ps1" -NoWait - Start in:
C:\path\to\MQL5-Google-Onedrive
- Action:
- Click OK
Step 6: Conditions
- Go to Conditions tab
- Power:
- Uncheck ☐ "Start the task only if the computer is on AC power"
- Uncheck ☐ "Stop if the computer switches to battery power"
- Network:
- Check ☑ "Start only if the following network connection is available"
- Select "Any connection"
Step 7: Settings
- Go to Settings tab
- Configure:
- Check ☑ "Allow task to be run on demand"
- Check ☑ "Run task as soon as possible after a scheduled start is missed"
- Check ☑ "If the task fails, restart every:"
5 minutes - Set "Attempt to restart up to:"
3 times - Uncheck ☐ "Stop the task if it runs longer than"
- Click OK
Step 8: Save and Test
- Click OK to save the task
- You may be prompted to enter your password
- To test immediately:
- Right-click the task in the list
- Select Run
- Check the Last Run Result column (should show "Success" or 0x0)
Verification
Check if Task is Running
Get-ScheduledTask -TaskName "MQL5*" | Get-ScheduledTaskInfo
View Task History
- In Task Scheduler, select your task
- Click the History tab at the bottom
- Enable history if disabled: Actions → Enable All Tasks History
Test the Task
# Start the task manually
Start-ScheduledTask -TaskName "MQL5_Trading_Automation_Startup"
# Check status
Get-ScheduledTask -TaskName "MQL5_Trading_Automation_Startup" | Select-Object State, LastRunTime, LastTaskResult
Troubleshooting
Task Doesn't Run at Startup
- Check if task is Enabled
- Verify Trigger is set to "At startup"
- Ensure "Run whether user is logged on or not" is selected
- Check Task History for error details
Task Runs But Nothing Happens
- Check logs in
logs/directory - Run PowerShell script manually to see errors:
cd C:\path\to\MQL5-Google-Onedrive .\scripts\startup.ps1 -Verbose - Verify MT5 path in
config/startup_config.json
Permission Errors
Run Task Scheduler as Administrator:
Start-Process taskschd.msc -Verb RunAs
Task Doesn't Start MT5
- Test MT5 path in PowerShell:
Test-Path "C:\Program Files\Exness Terminal\terminal64.exe" - Update path in
config/startup_config.jsonif different
Alternative: Startup Folder
For simpler setup (runs after login only):
-
Create a shortcut to
startup.ps1:- Right-click
scripts\startup.ps1→ Create shortcut - Right-click shortcut → Properties
- Target:
powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\path\to\MQL5-Google-Onedrive\scripts\startup.ps1" -NoWait
- Right-click
-
Move shortcut to Startup folder:
# Open Startup folder explorer shell:startup # Copy shortcut here
Removing the Task
Using PowerShell
Unregister-ScheduledTask -TaskName "MQL5_Trading_Automation_Startup" -Confirm:$false
Using Task Scheduler GUI
- Open Task Scheduler
- Find your task in the list
- Right-click → Delete
Security Notes
- The task runs with your user privileges
- Credentials are encrypted by Windows
- Scripts are executed with
ExecutionPolicy Bypassfor this task only - Consider using a dedicated trading account on your PC
- Never share your scheduled task export with others (contains credentials)
Advanced: Export/Import Task
Export task to XML (for backup or transfer):
Export-ScheduledTask -TaskName "MQL5_Trading_Automation_Startup" -TaskPath "\" | Out-File -FilePath "C:\path\to\backup\task.xml"
Import task on another machine:
Register-ScheduledTask -Xml (Get-Content "C:\path\to\backup\task.xml" | Out-String) -TaskName "MQL5_Trading_Automation_Startup"