ChartIndicatorAdd and drawing style

To add comments, please log in or register
Nicola Grippaldi
71
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

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
840
JD4  
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  

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
39055
Alain Verleyen  
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  
ok, thanks anyway
Amir Yacoby
1364
Amir Yacoby  

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

Nicola Grippaldi
71
Nicola Grippaldi  
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