Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us
Home/ Questions/Q 2453
Next
In Process
seric29
seric29

seric29

  • 3 Questions
  • 3 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
seric29
Asked: December 26, 20202020-12-26T12:17:57+00:00 2020-12-26T12:17:57+00:00In: Forex Expert Advisors

Is it possible to increase the number of function arguments?Is it possible to return the number of arguments to a function?

  • 0

For example there is a primitive entry

int Funk(bool Er,int q1,int q2,int q3)
{return 0;}

This entry declares the arguments int q1, int q2,int q3. When calculating it so happened that you need to use the algorithm of this function, but the number of parameters of the int type is already greater. The values of these parameters will be passed to the array and used directly in the program. What can be done in this case?
Well, this raises the second question how can I find out how many arguments the function has in my case four (bool Er, int q1, int q2, int q3)? How to check and find out how many parameters a function has. Please do not be rude I am certainly a valenok but I really need such properties for writing programs. Is it possible to implement any of this? Here I have a sample code.

template<class T> void Fun(T a[], size_t args...)
{}
int main()
{
int *mas1[2][2] = { {1,4},{2,6} };
int mas2[2][2][2];
Fun(*mas1, 2, 2); / /number of arguments 3
Fun (**mas2, 2, 2, 2);//number of arguments 4
}

However, this code is not from mql4. What can be done to implement this and is it possible?

  • 5 5 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    5 Answers

    • Voted
    • Oldest
    • Recent
    1. laryx

      laryx

      • 0 Questions
      • 43 Answers
      • 0 Best Answers
      • 106 Points
      View Profile
      laryx
      2020-12-26T12:18:24+00:00Added an answer on December 26, 2020 at 12:18 pm

      Seric29:

      1st var. I implemented it, but the disadvantage is that there are unnecessary checks.

      2nd var. here it turns out in principle everything is fine but if you declare the array globally then you have to break the if condition fill the array then go back to the logical. the if condition and then continue to finish the work is also not convenient unnecessary checks but working with a dynamic array is very convenient you can immediately access the desired size in the loop. It would be cool if you could fill a dynamic array with data without breaking the logical condition.

      3y vapr. in the classes I felt boots how much I did not study them and did not understand their essence, I only realized that the SPE data combine but what is the point and how they differ from the factory function, I did not understand.

      1-2. If you want a function with a variable number of parameters-checks will be needed in any case. Just in the case of parameters, you check the parameters themselves, in the case of an array-you check the array.

      3. This is a PLO feature. The main benefit of classes is in the connection of data and functions that process them, as well as in encapsulation – users of classes have access only to what they currently need, thereby eliminating the possibility of influencing any other application blocks. To see the benefits of OOP classes, you need to work with fairly complex data structures arranged in a hierarchy. If simple data structures are used, and the application architecture is not very developed, then there is no point in building OOP bells and whistles.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. seric29

      seric29

      • 3 Questions
      • 3 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      seric29
      2020-12-26T12:18:17+00:00Added an answer on December 26, 2020 at 12:18 pm

      Georgiy Merts:

      As I see the options are as follows:

      1. Declare a function with the maximum number of parameters, setting them by default to a value that cannot be passed. Accordingly, when calling – you pass only the required number, the rest-take the default values. Inside the function, you check how many values are actually passed.

      2. Pass parameters inside a dynamic array.

      3. Pass parameters in a special container class that knows the number and type of parameters. Personally, I use the latter case (for transmitting parameters of various indicators), it is good because the parameters can be very different. Moreover, I pass to the function a base class-interface, where all functions for getting parameters are virtual, and their implementation already depends on a specific set of parameters required for this indicator..  

      1st var. I implemented it, but the disadvantage is that there are unnecessary checks.

      2nd var. here it turns out in principle everything is fine but if you declare the array globally then you have to break the if condition fill the array then go back to the logical. the if condition and then continue to finish the work is also not convenient unnecessary checks but working with a dynamic array is very convenient you can immediately access the desired size in the loop. It would be cool if you could fill a dynamic array with data without breaking the logical condition.

      3y vapr. in the classes I felt boots how much I did not study them and did not understand their essence, I only realized that the SPE data combine but what is the point and how they differ from the factory function, I did not understand.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. igorm

      igorm

      • 0 Questions
      • 17 Answers
      • 0 Best Answers
      • 54 Points
      View Profile
      igorm
      2020-12-26T12:18:13+00:00Added an answer on December 26, 2020 at 12:18 pm

      it depends on the desire to create a complex structure and the tasks set

      if there is no desire or ability to make universal complex code, then use the globally described variables and in the function” with an increasing number of function arguments ” just pass a certain command that you will then analyze in the function body, and use the variables themselves from the global scope

      PS: you need to understand that if all the sources in different programming languages could be ported “in 2 clicks” without losing functionality or complicating the code, then there would not be such an abundance of languages – it is simply not necessary

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. alexeyvik

      alexeyvik

      • 1 Question
      • 74 Answers
      • 0 Best Answers
      • 172 Points
      View Profile
      alexeyvik
      2020-12-26T12:18:08+00:00Added an answer on December 26, 2020 at 12:18 pm

      Seric29:

      For example there is a primitive entry

      This entry declares the arguments int q1, int q2,int q3. When calculating it so happened that you need to use the algorithm of this function, but the number of parameters of the int type is already greater. The values of these parameters will be passed to the array and used directly in the program. What can be done in this case?
      Well, this raises the second question how can I find out how many arguments the function has in my case four (bool Er, int q1, int q2, int q3)? How to check and find out how many parameters a function has. Please do not be rude I am certainly a valenok but I really need such properties for writing programs. Is it possible to implement any of this? Here I have a sample code.

      However, this code is not from mql4. What can be done to implement this and is it possible?

      Something like this

      int Funk(bool Er,int q1,int q2,int q3)
      {return 0;}

      int
      Funk(bool Er,int q1,int q2,int q3,int q4)
      {return 0;}

      int
      Funk(bool Er,int q1,int q2,int q3,int q4,int q5)
      {return 0;}

      int
      Funk(bool Er,int q1,int q2,int q3,int q4,int q5,int q6)
      {return 0;}

      Then how many parameters you pass to the function when it is called, that function works. This is the simplest.

      Or you can organize a class and make the overload more literate.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. laryx

      laryx

      • 0 Questions
      • 43 Answers
      • 0 Best Answers
      • 106 Points
      View Profile
      laryx
      2020-12-26T12:18:04+00:00Added an answer on December 26, 2020 at 12:18 pm

      As I see the options are as follows:

      1. Declare a function with the maximum number of parameters, setting them by default to a value that cannot be passed. Accordingly, when calling – you pass only the required number, the rest-take the default values. Inside the function, you check how many values are actually passed.

      2. Pass parameters inside a dynamic array.

      3. Pass parameters in a special container class that knows the number and type of parameters. Personally, I use the latter case (for transmitting parameters of various indicators), it is good because the parameters can be very different. Moreover, I pass to the function a base class-interface, where all functions for getting parameters are virtual, and their implementation already depends on a specific set of parameters required for this indicator..  

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 504
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 681
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Related Questions

    • Brus Agell

      Правельный выбор

      • 0 Answers
    • pinupcasinoo

      Pin Up Casino

      • 0 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 2 Answers
    • c00l777

      During optimization, indicators that are not present in the robot ...

      • 0 Answers
    • c00l777

      Optimization results differ on different accounts

      • 3 Answers

    Users

    Leonardcig

    Leonardcig

    • 0 Questions
    • 0 Answers
    DennisByday

    DennisByday

    • 0 Questions
    • 0 Answers
    Haroldmeary

    Haroldmeary

    • 0 Questions
    • 0 Answers

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved