Download MetaTrader 5

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

To add comments, please log in or register
All activity of the MQL5.community members is displayed on a single page!
robertscolaro
11
robertscolaro 2015.01.26 11:37 

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.

Stuart Browne
5815
Stuart Browne 2015.01.26 11:50  

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

Alain Verleyen
Moderator
30743
Alain Verleyen 2015.01.26 12:29  
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
robertscolaro
11
robertscolaro 2015.01.26 13:42  

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.

Alain Verleyen
Moderator
30743
Alain Verleyen 2015.01.26 16:42  
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().

To add comments, please log in or register