fxDreema

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

    How to create custom block for a Between checker

    Bug Reports
    2
    4
    1336
    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
      MetaTrader last edited by

      I very often check if a value is inside a channel.

      I use a simple function:

      
      bool isBetween(double needle, double border_a, double border_b, bool includingBorders = FALSE){
         double temp;
         if (border_a > border_b){
            temp = border_b;
            border_b = border_a;
            border_a = temp;
         }
         if (includingBorders){
            if ((border_a <= needle) && (needle <= border_b)) {return (TRUE);} else {return (FALSE);}
         }
         if ((border_a < needle) && (needle < border_b)) {return (TRUE);} else {return (FALSE);}
      }
      
      

      How to create a custom block from this?

      If you could give a simple sample with some lines of comment how to create custom blocks would be really relly helpful.

      ** indicator moves within limits** is similiar but not doing the job

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

        viewtopic.php?p=11013#p11013

        Custom blocks are functions. Whatever code you write, it will be put into a function. This function does not have real input arguments and should not have. The input parameters from the block are hard-coded into the function, at the top, this happens automatically while generating the EA.

        What you have is a function. Instead of custom block, you can try to put this into a function. While you are in the Studio, look at the right side on the bottom. Then click New and paste this code. Then you should be able to use this function in the blocks... but by name, like in MQL

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

          Jepp i got this and use it often but there is a way to create custom blocks.

          On the uper right side I can define the inputs for the block but how define the red and yellow output?

          Is there any description how to do this?

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

            Outputs are not defined there. Outputs are defined here with ~next~ and ~inext~ http://i.prntscr.com/925dfd57926e46abb2 ... a47a1e.png

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

            Online Users

            K
            A
            D
            S
            G

            16
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors