How can I add a custom indicator to a chart from a script?

 

I want to open charts from a script and attach a customer indicator to each chart. Opening the charts is easy:

   void OnStart()
   {
      long chart1 = ChartOpen("AUDJPY",PERIOD_H4);
      long chart2 = ChartOpen("AUDNZD",PERIOD_H4);
      long chart3 = ChartOpen("AUDUSD",PERIOD_H4); 
      ...
   }



I cannot find a function to attach my customer indicator to each of the charts.
This is puzzling as there is a function to remove an indicator - ChartIndicatorDelete(...)

Can anyone tell me how to add a customer indicator to a chart from a script?

Thanks.

 

Please use the SRC button when adding code. I've fixed it for you this time

 
robertscolaro:

I want to open charts from a script and attach a customer indicator to each chart. Opening the charts is easy:



I cannot find a function to attach my customer indicator to each of the charts.
This is puzzling as there is a function to remove an indicator - ChartIndicatorDelete(...)

Can anyone tell me how to add a customer indicator to a chart from a script?

Thanks.

What about ChartIndicatorAdd() ?
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
 

Thank you.

 I could not find it. I am using MQL4 and it is not defined there. It is defined in MQL5, so I will have to update to MQL5.

 
robertscolaro:

Thank you.

 I could not find it. I am using MQL4 and it is not defined there. It is defined in MQL5, so I will have to update to MQL5.

Right, you can't do it with mql4.

What you can do is create a template with your indicator, and attache it to a chart with ChartApplyTemplate().