How do I change the colour of the standard indicator programme?
I've never done this before, but here's an idea. You should open the code of standard indicator and find there lines with indicator_color*
Something like.
//--- японские свечи будут рисоваться цветом clrDodgerBlue #property indicator_color1 clrDodgerBlue
Then you will insert the required colour. Also see MQL5 Reference / Custom Indicators / Relation between Indicator Properties and Functions and MQL5 Reference / Standard Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Thank you, of course.
But it turns out that every time I have to correct the code?
Mikhail
Thank you, of course.
But does that mean you have to change the code every time?
Thank you, of course.
But it turns out that you have to correct the code every time?
There's something about your logic. Your original question was:
How to change the colour of the standard indicator programmatically?
There's something about your logic. You asked originally:
Dear abolk!
Obviously, from your code.
Mikhail
Make the "in-house" indicator your own, - and insert your options into it. For example (pure idea): put colours in input parameters, and then process them in Oninit() by function PlotIndexSetInteger(N-1, PLOT_LINE_COLOR, nColor). The examples in the Reference can help. Then you can not edit the code itself, but set the desired colour through the properties of the indicator when you start or change it.
Thank you very much.
Too bad the developers didn't think of that.
This code should have worked, BUT.... alas...
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].double_value = clrBlue; ma_handle = IndicatorCreate( NULL, PERIOD_CURRENT, IND_MA, 5, params ); if ( ma_handle != INVALID_HANDLE ) { ChartIndicatorAdd( 0, 0, ma_handle ); }
This code should have worked, BUT.... alas...
Didn't work with IndicatorCreate() function - it turned out to be easier to create your custom indicators. Nevertheless, since you have cited only a part of the code, a question: did you zeroize the variable params before using it? For example, like this:
MqlParam params; ZeroMemory(params);
And what error code does your entry reclaim?
You did:
ArrayResize(params,5);?
Also, the IND_MA(iMA) indicator has no such parameter as "Colour", and you have it specified. Take a look at example of iMA usage here: MQL5 Reference / Access to timeseries and indicators / IndicatorCreate.
This code should have worked
Why is that? First explain why the colour is a real number?
params[4].type = TYPE_COLOR; params[4].double_value = clrBlue;
Good afternoon, stringo and Yedelkin!
You probably didn't read my message carefully, which said
"Too bad the developers didn't think of that. "
Now, let me explain why I wrote the above code.
From the settings of Moving Average, you can clearly see that the indicator has 7 parameters (5 main parameters + 2 lines).
This is what it says in the tab "Parameters".
If you can change ALL parameters "manually", it means there must be
what the developers have done - to change ALL parameters programmatically!
In the IndicatorCreate function, but not to the end ( or it's a BAG).
MqlParam structure allows you to enter a colour - TYPE_COLOR(ENUM_DATATYPE);
From MQL5 reference:
The colortype is designed to store colour information and occupies 4 bytes in memory. The first byte is ignored, the remaining 3 bytes contain the RGB components.
......
Integer representation is written as hexadecimal or decimal number. Ahexadecimal number is 0x00BBGGRR
//--- integer representation
0xFFFFFFFF //white
16777215 //white
0x008000 //green
32768 //green
End of quote.
struct MqlParam
{
ENUM_DATATYPE type; // input parameter type, ENUM_DATYPE enumeration value
long integer_value; // field for storing an integer value
double double_value; // field for storage of double or float value
string string_value; // field for storage of value of string type
};
(I first tried long didn't work, and then I tried double - didn't work either, which remains in the code).
It should be like this:
MqlParam params[5];
.........
params[4].type = TYPE_COLOR;
params[4].integer_value = clrBlue; // - blue colour 0x00FF0000 (16711680)
stringo, I answered your question "why the hell not"?
Once again, it's a pity the developers didn't do a colour change.
Respectfully, Mikhail
Good afternoon, stringo and Yedelkin!
You probably didn't read my message carefully, which said
"Too bad the developers didn't think of that. "
Mikalas, there are already so many experts here jumping to conclusions for others that it's scary. Don't increase their number, please.
Next, I helped you by asking specific unemotional questions. Instead of answering them you tell me "how you got to this point in your life". What do you want? -Convince someone that there are bugs you've detected, or "programmatically" improve your code? If you see some "bug" - contact Service Desk with a full description of the situation. If you want to "programmatically" work - go deep into the creation and operation of the indicators.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good afternoon!
How do you change the colour of the standard indicator?
Thank you, Mikhail