Skip to content

Performance Issues lag with Position Sizer #126

@etikmatters

Description

@etikmatters

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

  1. Timer Recalculation Every 200ms (Lines 1380-1390 in MQ5)
  2. RefreshValues() is MASSIVE (Lines 1949-2063 in MQH)
  3. RecalculatePositionSize() is a Monster (Lines 2517-2923 in MQH)
  4. 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
⚠️ Dirty flags in event handlers - Do gradually as needed

Image
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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions