Parameter "chart_id" of ObjectCreate()... when it can be useful?

 

I wonder in what situation the "chart_id" parameter of the ObjectCreate() function can be useful.

All the examples I have seen so far have this parameter equal to zero.

Can someone give me a little explanation or provide a link where I can see an example of its use when it is different from zero?

Thank you very much!!

 

If you want to create an object on a different chart to which the EA or Indicator is attached, then you will use the ID of that chart.

eg. My indicator may be monitoring a number of symbols and sometimes it may open a new chart of the relevant symbol and place objects on it.

 
Keith Watford:

If you want to create an object on a different chart to which the EA or Indicator is attached, then you will use the ID of that chart.

eg. My indicator may be monitoring a number of symbols and sometimes it may open a new chart of the relevant symbol and place objects on it.

100% understood !! :-)
Thank you so much Keith !!

 
Keith Watford # :

Se você deseja criar um objeto em um gráfico diferente ao qual o EA ou Indicador está anexado, você usará o ID desse gráfico.

por exemplo. Meu indicador pode estar monitorando vários símbolos e, às vezes, pode abrir um novo gráfico do símbolo relevante e colocar objetos nele.

OK... So if 0 means current chart, what number represents another chart? For example... My current chart is EURUSD, and I insert a line with an arrow on GBPUSD. ObjectCreate(0...) would be on EURUSD, so what would be the number I should put for GBPUSDObjectCreate(?...)

 
civil.luciano #: OK... So if 0 means current chart, what number represents another chart?

You have to find the chart you want.

Perhaps you should read the manual. ChartNext - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

 
Chart ID and sub_window id's are important when adding multiple of the same indicator to a single chart.  If your indicator creates objects in the separate window, you need to know which sub window id is running.  As for chart_id, if you want to update another chart with an object then you will need to have separate chart id's.  This is equivalent to a *pointer or handle to the window.
 
karp wak:

I wonder in what situation the "chart_id" parameter of the ObjectCreate() function can be useful.

All the examples I have seen so far have this parameter equal to zero.

Can someone give me a little explanation or provide a link where I can see an example of its use when it is different from zero?

Thank you very much!!

For example, my EA draws indicators on other charts. For this I need the chart ID.

Reason: