fxDreema

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

    Working boolean condition returns warning when compiling: "expression is always false" - I must be doing something wrong

    Questions & Answers
    2
    4
    1468
    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.
    • S
      safv6 last edited by

      Hi Radoslav,

      I have a question regarding using boolean values inside conditions. I must be doing something wrong...

      Whenever I make a condition like the one you see on Init in the shared example below, it works just fine, but MetaEditor returns this warning when trying to compile the mq4 file: "expression is always false".
      Again, it works just fine and I understand a boolean value is basically just 0 or 1 internally, but maybe you know what I could do to prevent the warning message when using bool conditions?

      Here's a working example where the condition "on Init" triggers block 6 "on Tick" to go on: https://fxdreema.com/shared/IaoNWwzae
      Here's the warning MetaEditor shows when compiling: https://drive.google.com/file/d/0B9owZMPMRrkSRlpDLTZBZVpEOEk/view

      Any advice or help would be much appreciated!
      Best regards,

      Saf

      1 Reply Last reply Reply Quote 0
      • fxDreema
        fxDreema last edited by

        These warnings appear because of some additional checks in "Condition". Thei check whether one of the operands is equal to EMPTY_VALUE or not. The idea is to prevent "Condition" from activating it's outputs if one of both operands is EMPTY_VALUE, which sometimes happens with indicators or objects. Now there are warnings because the compiler can see that the operand always equals to true. I just don't have additional optimization of the output code to remove these checks in this situation.

        Warnings are not scary in general. They are hints that something can be written better, but this is universal EA Builder after all and the code that it generates is not very compact and optimized, as you can see 🙂 But it works most of the time!

        1 Reply Last reply Reply Quote 0
        • S
          safv6 last edited by

          Ah thanks so much for the extensive answer!

          Right after posting this question though, I realised that I already answered my own question by saying that boolean values are just a numeric (0 or 1) value internally. So the actual answer to my question should be: Make the right operand "Numeric" "1", instead of "Boolean" "True", and there you go! The warning message is gone! 🙂
          (correct me if I'm wrong though)

          https://fxdreema.com/shared/uFAvkIh7b

          Gotta love fxd 🙂
          Thanks again!

          Cheers

          1 Reply Last reply Reply Quote 0
          • fxDreema
            fxDreema last edited by

            It will work. Data types are a little bit weird in MQL4/MQL5 and in the C/C++ world, especially floating numbers, but comparing booleans with 1 or 0 normally works.

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

            Online Users

            E
            A

            10
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors