fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Zero divide after EA / MT4 restart

    Questions & Answers
    2
    3
    2608
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mantadiver last edited by

      Hello,

      I am testing an EA to ensure it can cope with an MT4 restart.

      After a restart I am getting zero divide errors.

      The first is in a custom mql block at the point:- MarketInfo(Symbol(),MODE_TICKVALUE)
      It finds the correct value when run normally but after a restart it returns zero. (I have got it to write to the log on restart).

      If I remove that piece of code it then gets stuck on an internal function LotStep.

      lowerlots = MathRound(lowerlots/LotStep)*LotStep;

      which can be traced back to:-

      double LotStep = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);

      Again it is the SYMBOL_VOLUME_STEP that is returning a zero.

      Any ideas why this would work on first load but not after a restart ?

      Many thanks

      1 Reply Last reply Reply Quote 0
      • M
        miro1360 last edited by miro1360

        you can avoid this issue with adding if else statement ...

        double LotStep = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP);
        if (LotStep != 0)
        { lowerlots = MathRound(lowerlots/LotStep)*LotStep; }
        else { lowerlots = some_default_value; )

        Between trading and gambling is a very small gap, be careful.

        1 Reply Last reply Reply Quote 0
        • M
          Mantadiver last edited by

          Works great, many thanks.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post

          Online Users

          L
          K
          H
          N

          16
          Online

          146.7k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors