Colour of the standard indicator - page 2

 

Good afternoon, Yedelkin!

Sorry, here are the answers to your questions.

MqlParam params[5];
int ma_handle;

params[0].type = TYPE_INT;
        params[0].integer_value = 10;
        
        params[1].type = TYPE_INT;
        params[1].integer_value = 0;
        
        params[2].type = TYPE_INT;
        params[2].integer_value = MODE_SMA;
        
        params[3].type = TYPE_INT;
        params[3].integer_value = PRICE_MEDIAN;
        
        params[4].type = TYPE_COLOR;
        params[4].integer_value = clrBlue;
        
        ma_handle = IndicatorCreate( NULL, PERIOD_CURRENT, IND_MA, 5, params );
        if ( ma_handle != INVALID_HANDLE )
      {
        ChartIndicatorAdd( 0, 0, ma_handle );
      }

The indicator is created, but its colour is RED.

One more thing. The previous message was not meant for you, but for stringo,

except for the MA indicator parameters.

If it offended you in any way, I apologise.

Sincerely, Mikhail.

 
Mikalas:

One more thing. The previous message was not meant for you, but for stringo,

I usually read exactly what it says: "Good afternoon, stringo and Yedelkin!". Urain already noted yesterday that I "can't read between the lines".

From the main response it's clear that zeroing of params array is not performed (and each variable ofMqlParam type has 4 fields, not 2). You can't see the answer to the comment: "Also, the IND_MA(iMA) indicator doesn't have such parameter as "Color", while you have it. You can see an example of how to use iMA here: MQL5 Reference / Access to timeseries and indicators / IndicatorCreate".

The returned error code is not specified.

 

Dear Yedelkin!

There is no need to zero the params array, because it is a static array (params[5]) and I

fill in all its fields. by the way, filling in 2 fields is enough. I think depending on TYPE one of 3

subsequent fields.

Noerror (ma_handle != INVALID_HANDLE), the indicator is created.

Tell me, how many parameters does the indicator have in the picture?

MA

Mikhail

 
Mikalas:

Noerror code, the indicator is created.

First you write"This code should have worked, BUT.... alas...". Now it turns out that"the indicator is being created". ....To "No error code" - there is always an error code, even if it is zero.

About the picture. You repeatedly reduce the question to a discussion of a possible, in your opinion, bug. But you have originally started to speak about using the IndicatorCreate() function in your code. As you yourself understand, the IndicatorCreate() function does not work with pictures. Once again I suggest: look through the documentation and its examples. Find (guess) why in the parameters tab appears the option "Style", but in the input parameters of the iMA indicator you don't have such an option. Find out what input parameters are provided for the indicator you've chosen and which of them should be reflected in the function IndicatorCreate().

 

I see, thank you.

 
Mikalas:

Tell me, how many parameters does the indicator have in the picture?

There are 7 parameters on this tab.
 

Unlike iMA(4 parameters), the function

IndicatorCreate function must enter all possible parameters

MQL5 Reference:

int IndicatorCreate(
string symbol, // symbol name
ENUM_TIMEFRAMES period, // period
ENUM_INDICATOR indicator_id, // indicator type from the ENUM_INDICATOR enumeration
int parameters_cnt=0, // number of parameters
const MqlParam& parameters_array[]=NULL, // array of parameters
);

parameters_array[]=NULL

[in] Array of MqlParam type, the elements of which contain the type and value of each input parameter of a technical indicator.

You are sending me to the reference book, but you're not reading it?

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Типы индикаторов
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Типы индикаторов
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Типы индикаторов - Документация по MQL5
 
Mikalas:

You're referring me to a guidebook and you haven't read it yourself?

Here we go. With that approach, you may find yourself alone with your problem.

On the subject. The fact that you looked in the handbook is good. Now re-open it on the same page. You see the following line: "An array of MqlParam type, the elements of which contain the type and value of each input parameter of the technical indicator". What is "input parameter" is "input parameter"(MQL5 Reference / MQL5 Basics / Variables / Input variables). Now look for the answer to the question "how many input parameters does the iMA technical indicator have ?

Mikalas:

Unlike iMA (4 parameters), the IndicatorCreate function must enter all possible parameters

So, if iMA has 4 input parameters, how many input parameters should I "input" to IndicatorCreate()? Once again: IndicatorCreate() does not work with pictures. To be more exact, IndicatorCreate() does not work with pictures, but with input parameters of the indicator, which it passes directly to the indicator. Where will it pass the "Style" picture option if the indicator doesn't have such input parameter?
 

The MA indicator has 7 parameters!

For the iMA function 4 parameters are enough

ma_handle = iMA( _Symbol, TimeFrame, 10, 0, MODE_SMA, PRICE_MEDIAN );,

but forthe IndicatorCreate() function all 7 indicator parameters must be possible

parameters_array[]=NULL

[in] Array of type MqlParam the elements of which contain type and value of each input parameter of the technical indicator.

One more thing... What is your profession?

 
Mikalas:

and all 7 indicator parametersmust be possible forIndicatorCreate().

This is your conclusion and you have to live with it :) Service Desk to help.