Download MetaTrader 5

ChartIndicatorAdd and drawing style

To add comments, please log in or register
Need mobile version of MetaTrader 5? Download it and trade!
Nicola Grippaldi
71
Nicola Grippaldi 2015.07.27 10:45 

I tested the EA in https://www.mql5.com/en/docs/chart_operations/chartindicatoradd and works well.

Now I wish modify indicator's style/width/color, is there a way?

Thanks

Nicola

Documentation on MQL5: Chart Operations / ChartIndicatorAdd
Documentation on MQL5: Chart Operations / ChartIndicatorAdd
  • www.mql5.com
Chart Operations / ChartIndicatorAdd - Reference on algorithmic/automated trading language for MetaTrader 5
JD4
1101
JD4 2015.07.27 19:43  
Nicola Grippaldi:

I tested the EA in https://www.mql5.com/en/docs/chart_operations/chartindicatoradd and works well.

Now I wish modify indicator's style/width/color, is there a way?

Thanks

Nicola

Short answer, yes.

Check on this page to get you started.

Nicola Grippaldi
71
Nicola Grippaldi 2015.07.27 20:59  

I tried this solution, but doesn't work

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   int indicator_handle=iMA(Symbol(),0,_period,_shift,MODE_SMA,apr);
   if(indicator_handle==INVALID_HANDLE)
     {
      Print("Failed to create MA indicator. Error code ",GetLastError());
      return(INIT_FAILED);
     }
   bool added=ChartIndicatorAdd(0,0,indicator_handle);
   if(!added)
     {
      PrintFormat("Failed to add MA indicator on %d chart window. Error code  %d",
                  0,GetLastError());
      return(INIT_FAILED);
     }
   PlotIndexSetInteger(0,PLOT_LINE_STYLE,STYLE_DASHDOT);     //  <------------------------- does nothing
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
// Expert Advisor performs nothing
  }
Alain Verleyen
Moderator
30723
Alain Verleyen 2015.07.28 13:32  
Nicola Grippaldi:

I tested the EA in https://www.mql5.com/en/docs/chart_operations/chartindicatoradd and works well.

Now I wish modify indicator's style/width/color, is there a way?

Thanks

Nicola

You can't change indicator's style/with/color by "external" code, you can only do it within the indicator.
Nicola Grippaldi
71
Nicola Grippaldi 2015.07.29 18:10  
ok, thanks anyway
Amir Yacoby
1192
Amir Yacoby 2015.07.29 19:30  

Add input parameters to indicator and then you can change them from external ea.

Nicola Grippaldi
71
Nicola Grippaldi 2015.07.30 10:12  
Amir Yacoby:

Add input parameters to indicator and then you can change them from external ea.

do you mean as custom indicator?
To add comments, please log in or register