How can I change the styles and colors in the indicator with EA?

 

Hello,

I have tried for days to change the styles and colors with the indicator with EA. Unfortunately, I've come to now no solution. Find no solution in the forum. Can someone correct this code? Thanks!

// Indicators
#include <Indicators\Indicators.mqh>

int OnInit()

{

  int EMA_HIGH_20_Handle = iMA(_Symbol,_Period,20,MAShift,MODE_EMA,PRICE_HIGH);  <-- This should be Color of BLUE and the style as STYLE_DOT
  ChartIndicatorAdd(ChartID(), 0, EMA_HIGH_20_Handle);
  int EMA_LOW_20_Handle = iMA(_Symbol,_Period,20,MAShift,MODE_EMA,PRICE_LOW); <-- This should be Color of RED and the style as STYLE_DOT
  ChartIndicatorAdd(ChartID(), 0, EMA_LOW_20_Handle);

}



Documentation on MQL5: Chart Operations / ChartIndicatorAdd
Documentation on MQL5: Chart Operations / ChartIndicatorAdd
  • www.mql5.com
Chart Operations / ChartIndicatorAdd - Documentation on MQL5
 
Deaf77:

Hello,

I have tried for days to change the styles and colors with the indicator with EA. Unfortunately, I've come to now no solution. Find no solution in the forum. Can someone correct this code? Thanks!

...

Please edit your post and use SRC button when you post code.

You can't change Color and Style outside (in an EA) an indicator.

 
angevoyageur:

...

You can't change Color and Style outside (in an EA) an indicator.

No. You are wrong. With this function EventChartCustom() can be done. EA should send events, and the indicator takes them and makes the appropriate action.  

 
tol64:

No. You are wrong. With this function EventChartCustom() can be done. EA should send events, and the indicator takes them and makes the appropriate action.  

Very interesting, thanks. But technically it's not changed inside the EA so I am not wrong
 
angevoyageur:
 ... But technically it's not changed inside the EA so I am not wrong 
Yes. You are right. But most importantly, it's possible. :)
 
Deaf77:

Hello,

I have tried for days to change the styles and colors with the indicator with EA. Unfortunately, I've come to now no solution. Find no solution in the forum. Can someone correct this code? Thanks!

...
So using the technique indicated by tol64, you have to create or modify a custom indicator which will catch an event send by your EA. And modify your EA to use iCustom instead of iMA.
Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 
tol64:
Yes. You are right. But most importantly, it's possible. :)
Of course, I had not thought of this method. It's really a good thing Russian programmers come here to help us.