Download MetaTrader 5
To add comments, please log in or register
Interested in the Market activity? Come and track!
cyberglassed
612
cyberglassed 2014.06.29 09:27 

Hello, I would like to get a list of parameters type given an indicator type.

for example, some function like:

bool get_indicator_params_type(ENUM_INDICATOR enum_ind, ENUM_DATATYPE &datatype[]) {
    ...
}

/* then I can do: */

void myFunction() {
    ENUM_DATATYPE datatype[];

    get_indicator_params_type(IND_BANDS, datatype);
    /* -> Content of "datatype": {INT, INT, DOUBLE, INT} */

    get_indicator_params_type(IND_MA, datatype);
    /* -> Content of "datatype": {INT, INT, INT, INT} */
}

thanks, Cyberglassed.

cyberglassed
612
cyberglassed 2014.06.29 10:54  

I have tried creating a dummy indicator:

bool get_indicator_params_type(ENUM_INDICATOR enum_ind, ENUM_DATATYPE &datatype[]) {
        int handle = IndicatorCreate(_Symbol, PERIOD_CURRENT, enum_ind);
        MqlParam parameters[];
        ENUM_INDICATOR dummy_type;
        int num_params = IndicatorParameters(handle, dummy_type, parameters);
        PrintFormat("handle: %d, num_params: %d", handle, num_params);
        ArrayResize(datatype, num_params);
        for(int p = 0; p < num_params; p++)
                datatype[p] = parameters[p].type;
        return true;
}

with no results. The output is:

"handle: 10, num_params: -1"

and then the "datatype" var is empty because the loop block is not processed.

Any other ideas?


Thanks, Cyberglassed.

Alain Verleyen
Moderator
28672
Alain Verleyen 2014.06.29 11:35  
cyberglassed:

I have tried creating a dummy indicator:

with no results. The output is:

"handle: 10, num_params: -1"

and then the "datatype" var is empty because the loop block is not processed.

Any other ideas?


Thanks, Cyberglassed.

Please read the documentation :

Return Value

The number of input parameters of the indicator with the specified handle. In case of an error returns -1. For more details about the error call the GetLastError() function.

cyberglassed
612
cyberglassed 2014.06.29 11:54  
angevoyageur:

Please read the documentation :

The error I get is:

"4006: Array of a wrong type, wrong size, or a damaged object of a dynamic array"

so I think in this case the error description is a bit meaningless because I have used those three lines like that with success in other codes:

MqlParam parameters[];
ENUM_INDICATOR dummy_type;
int num_params = IndicatorParameters(handle, dummy_type, parameters);

also I have tried with:

MqlParam parameters[1024];

but also no success.

Alain Verleyen
Moderator
28672
Alain Verleyen 2014.06.29 12:01  
cyberglassed:

The error I get is:

"4006: Array of a wrong type, wrong size, or a damaged object of a dynamic array"

so I think in this case the error description is a bit meaningless because I have used those three lines like that with success in other codes:

also I have tried with:

but also no success.

What is the value of enum_ind ?
cyberglassed
612
cyberglassed 2014.06.29 12:10  
angevoyageur:
What is the value of enum_ind ?

I called the function with:

ENUM_DATATYPE datatype[];
get_indicator_params_type(IND_BANDS, datatype);

so, the value of "enum_ind" is: IND_BANDS


Anyway my goal is to get a list of parameters type given an indicator type,

so, if there is some other way than create a dummy indicator for me is Ok

/
To add comments, please log in or register