fxDreema

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

    how to declare parameters for custom blocks

    Questions & Answers
    2
    4
    1943
    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

      Hi

      i declare the parameters in the box top right. then it seems I have to declare them at the source again.
      At compile time i get this warning:
      declaration of 'myvar' hides member declaration at line 540

      could you please explain how to define parameters and what is the meaning of the yellow arrow?

      thx

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

        Parameters are only defined in that box top right, not in the code. In the code you only use them. Here is something that I did:
        0_1523112009376_f7787e45-9187-43e4-9be5-575b35ea4461-image.png

        At the end the code looks like this:
        ``
        // "test" model
        template<typename T1>
        class MDL__3066: public BlockCalls
        {
        public: /* Input Parameters */
        T1 Parameter;
        virtual void callback(int r) {return;}

        public: /* Constructor */
        MDL__3066()
        {
        	Parameter = (int)123;
        }
        
        public: /* The main method */
        virtual void _execute_()
        {
        	Print(Parameter);
        }
        

        };
        ``
        _3066 is the id of the custom block, this is automatically generated and you can change it from here:
        0_1523112115090_315bbffd-432b-4c35-9f1e-3ea4b7d38fc4-image.png

        As you can see in the code, the parameter is defined just below that line with /* Input Parameters */
        The code of the block is simply Print(Parameter); and you can see where this is located. So the variable Parameter comes from above, it is a public member of the class and it is automatically placed there.

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

          If you have one of those "Custom" parameters, in the code you should use them like this:
          0_1523112369683_f16a90bc-b97c-465e-8b50-1844993504b9-image.png
          This is actual code of the "Indicator is visible" block.
          That ~datatype:Indicator~ thing is not necessary, you can use double or whatever you have. I think I use it that way only to remove some warning message. People are a little bit scared of those warnings 🙂

          Why ~Indicator~? While in the previous example Parameter is just a variable name, here ~Indicator~ is replaced with an automatically generated function call, it links to another method somewhere in the code.

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

            Thanks a lot for clarifying

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

            Online Users

            M
            M

            24
            Online

            146.7k
            Users

            22.4k
            Topics

            122.6k
            Posts

            Powered by NodeBB Forums | Contributors