Download MetaTrader 5
To add comments, please log in or register
Log in to MQL5.community using OpenID. It is convenient!
n22alpha
63
n22alpha 2015.02.21 21:03 

Hi guys below is a code for a simple moving average add to chart expert. How would I change the colour of the indicator from the code??? What if I had several indicators such as bollinger bands, momentum in a sub-window and two moving averages what would be the easiest way to change the colour???

 Is there anyway to do it by calling a method of the "_EMA" variable???

 Thank you for help again. 

 

//+------------------------------------------------------------------+
//|                                                      testing.mq5 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <Expert\Expert.mqh>
#include <Indicators\Trend.mqh>

CExpert ExtExpert;

CiMA *_EMA = new CiMA;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  
 if(!ExtExpert.Init(Symbol(),Period(),false, 10089))
     {
      //--- failed
      Alert(GetLastError(),": error initializing expert");
      return(INIT_FAILED);
     }
     
       if(_EMA==NULL)
     {
      //--- failed
      Alert(GetLastError(), ": error creating signal, _EMA");
      return(INIT_FAILED);
     }
     
   bool EMAcreate =_EMA.Create(_Symbol, _Period, 100, 0, MODE_EMA, PRICE_CLOSE);
   
    if (!EMAcreate)
   {
   Alert(GetLastError(), ": error creating indicator, _EMA");
      return(INIT_FAILED);
   }

   _EMA.AddToChart(0,0);
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
Alain Verleyen
Moderator
29640
Alain Verleyen 2015.02.21 21:24  
You can't change indicator's colors from an EA.
n22alpha
63
n22alpha 2015.02.21 22:57  
ok thank you for reply :)
Mehrdad Shiri
4409
Mehrdad Shiri 2015.02.22 13:26  
angevoyageur:
You can't change indicator's colors from an EA.

hi Alain,

if we use " ChartIndicatorAdd "  in our indicator, in this case can change as we want ?

Alain Verleyen
Moderator
29640
Alain Verleyen 2015.02.22 13:42  
TIMisthebest:

hi Alain,

if we use " ChartIndicatorAdd "  in our indicator, in this case can change as we want ?

No, the standard indicator's colors can't be changed by an EA.

To do that you need to change the indicator's code in some way. Either by using input parameters for colors or any other technique.

/
To add comments, please log in or register