changing properties of standard indicators using the function "ChartIndicatorAdd"

 

Hi, 


I can't find in the "help" of MT5 how I can change some properties of an added indicator using the "ChartIndicatorAdd" function.

For instance: I've added a standard exponential moving average using the code:

indicator_handle = iMA(Symbol(),Period(), 20, 0, MODE_EMA, PRICE_CLOSE);

 window=0;

 if (ChartIndicatorAdd(0,window,indicator_handle))

 {

 Print (__FUNCTION__, " Adding EMA's succesfull");

 }   

Now I would like to change the color of the EMA-curve and the thinkness of the line.

Is there a way to do this ?


thx for your help !!

Danny




 
When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
          Messages Editor
 
change some properties of an added indicator using the "ChartIndicatorAdd" function.

https://www.mql5.com/en/forum/38961

Set Indicator Line Color Through EA
Set Indicator Line Color Through EA
  • 2015.01.07
  • www.mql5.com
Hi guys, How to change an indicator line color after add it to the chart by an expert advisor...
 
With the help of ChartSaveTemplate/ChartApplyTemplate it is possible to do this. The example for understanding.
 

Thx for your help everybody !!

Until now, I think the only way out is creating the indicator myself with adding extra parameters for the colors, type and thickness.


Keep on posting !


Thx

 

Hi Alain an dear all,

I am currently working on exchanging und mixing data from several indicators ( https://www.mql5.com/de/articles/19 does not function, since I have a 64-bit machine and Alex provides only a exchng.dll for 32 bit).

My solution so far is, to outsource all the indicator calculation in a header(class).

/+------------------------------------------------------------------+
//|                                                          ATR.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2023, Kurt Beiersdörfer"
#property link        "kbeiersdoerfer@hotmail.com"
#property description "universal Indicator"

// Includes:
#include <..\Include\Indicators1\IndikatorBerechnung.mqh>

//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1

//--- input parameters Perioden:
input int InpPeriod1=14;  // 1. period_input
//--- input parameters Farbe:
input color InpColor1 = clrBlueViolet;
//--- input parameters Visability:
input bool InpVisible = true;

//--- indicator buffers
double    D_Buffer1[];  // 1. Data-Buffer
double    C_Buffer1[];  // 1. Calculate-Buffer
// Klasseninstanz:

CalcInd CalcART;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
      CalcART.Init_ATR(D_Buffer1,C_Buffer1,InpPeriod1, InpColor1);
  }
//+------------------------------------------------------------------+
//| Average True Range                                               |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,const datetime &Time[],const double &Open[],const double &High[],
                const double &Low[],const double &Close[],const long &TickVolume[],const long &Volume[],const int &Spread[])
  {

  const int ret_val_ART =  CalcART.Berechne_ATR(rates_total,prev_calculated,Time,Open,High,
                                                Low,Close,TickVolume,Volume,Spread,InpPeriod1,D_Buffer1,C_Buffer1);
                              
  
  return ret_val_ART;
  }

It would be very supportive for making the code more general and  flexible, if the property declaration:

//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1

could be made within a function.

On the page https://www.mql5.com/en/docs/customind/propertiesandfunctions, we can see,  that these property setting are the only ones, which can nor be set by a function.


Sehr einfach: Der Datenaustausch zwischen Indikatoren
Sehr einfach: Der Datenaustausch zwischen Indikatoren
  • www.mql5.com
Wir möchten eine Umgebung erschaffen, die den Zugriff auf Daten von Indikatoren ermöglicht, die an ein Diagramm angehängt sind, und deshalb die folgenden Eigenschaften aufweist: kein Kopieren von Daten; minimale Veränderung des Codes verfügbarer Methoden, wenn wir sie nutzen müssen; MQL-Code ist zu bevorzugen (natürlich müssen wir DLL nutzen, doch wir verwenden nur ein Dutzend Strings C++-Code). Dieser Beitrag beschreibt eine einfache Methode zur Entwicklung einer Programmumgebung für das MetaTrader-Terminal, die eine Zugriffsmöglichkeit auf Indikatorpuffer aus anderen MQL-Programmen bietet.
 
Brazzelhuber #:

Hi Alain an dear all,

I am currently working on exchanging und mixing data from several indicators ( https://www.mql5.com/de/articles/19 does not function, since I have a 64-bit machine and Alex provides only a exchng.dll for 32 bit).

My solution so far is, to outsource all the indicator calculation in a header(class).

It would be very supportive for making the code more general and  flexible, if the property declaration:

could be made within a function.

On the page https://www.mql5.com/en/docs/customind/propertiesandfunctions, we can see,  that these property setting are the only ones, which can nor be set by a function.


For sure it would be nice.

But we have to deal with that as it is I am afraid.

Reason: