-
Notifications
You must be signed in to change notification settings - Fork 197
Description
I get performance issues when running Position Sizer. I've tester each indicator 1 by 1, and Position Sizer gets cycles to 2 trillion, bugging chart until restart MT5. This behaviour can be seen by pressing F2 on MT5.
When chatting with AI, it said:
Critical Performance Problems Found
- Timer Recalculation Every 200ms (Lines 1380-1390 in MQ5)
- RefreshValues() is MASSIVE (Lines 1949-2063 in MQH)
- RecalculatePositionSize() is a Monster (Lines 2517-2923 in MQH)
- DisplayValues() Updates Everything (Lines 1323-1556 in MQH)
The Solution: Smart Caching + Dirty Flags
Step 1: Add Dirty Flags to Settings Class
Step 2: Cache Heavy Calculations
Step 3: Smart RefreshValues()
Step 4: Optimize Timer Frequency
Step 5: Mark Events as Dirty
Implementation Priority
Do these in order:
✅ Timer frequency (line 1380 in MQ5) - 60% immediate gain
✅ Calculation cache (add before RefreshValues) - 70% gain when combined
✅ Smart RefreshValues (replace existing) - Prevents unnecessary work

This image shows the problems when Position Sizer is put in the chart
I'm not a programmer, nor I feel confortable editing the code with AI prompts...
I deeply thank the authors behind this EA; Because for free, it's a great piece of work, and i've been using it since ~2020, just wanted to contribute the way I can.
Thanks, best regards!