Error Martingale

 

Hello,

I'm encountering an issue with my Martingale implementation in my EA. The lot size progression is inconsistent, even though I set the multiplier to 2.0 (or other values). Instead of the expected progression ( 0.1 , 0.2 , 0.4 , 0.8 , 1.6 for 2.0 multiplier), the lot sizes jump unexpectedly (e.g., 0.1 , 0.8 , 1.6 ). This happens even when I ensure the MartingaleMultiplier and Martingale_CurrentLevel are set properly.

Here’s a summary of my current setup:

  1. Inputs:

    • BaseLotSize : 0.1
    • MartingaleMultiplier : Configurable ( 1.5 , 2.0 , 3.0 tested)
    • MartingaleMaxMultiplier : 5

    • Expected Behavior: The lot size should progress as:

      • For multiplier 2.0 : 0.1 , 0.2 , 0.4 , 0.8 , 1.6 .
      • For multiplier 1.5 : 0.1 , 0.15 , 0.225 , 0.3375 , 0.50625 .

      • Observed Behavior:

        • The lot size jumps irregularly, e.g., 0.1 → 0.8 → 1.6 .

        • Lot Size Calculation Code: Here's the core function for calculating lot size:

        Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

        1. Update Martingale State Code: I increment the Martingale level after a losing trade:

        Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

        Code button in editor

        Hover your mouse over your post and select "edit" ... 

        1. Debugging Observations:
          • Martingale_CurrentLevel seems to behave correctly based on wins/losses.
          • The lot size calculation appears to add unexpected increments, especially at the start of new trades.

        Has anyone encountered this before? Are there specific areas in my implementation that need adjustment? I’ve checked my Martingale_CurrentLevel handling and MathPow logic but still can’t pinpoint the issue.

        Any help or insight would be appreciated!

         
        When you post code please use the CODE button (Alt-S) !
         
        Your topic has been moved to the section: Expert Advisors and Automated Trading
        Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893