ChartIndicatorAdd and drawing style

 

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
 
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.

 

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
  }
 
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.
 
ok, thanks anyway
 

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

 
Amir Yacoby:

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

do you mean as custom indicator?
Reason: