How to get chart ID?

 

Hi,

I'm new to mql5 but just wondering how do i get the chart id for my current chart. 

I did my research and you have to type this somewhere:

long  ChartID();

But where?

Thanks

Documentation on MQL5: Chart Operations / ChartID
Documentation on MQL5: Chart Operations / ChartID
  • www.mql5.com
ChartID - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
donmfx: I'm new to mql5 but just wondering how do i get the chart id for my current chart. 

You can reference the current chart in most functions by using a chart ID of "0".

For most functions requiring a chart id, the documentation will mention this ...

Parameters

chart_id

[in]  Chart ID. 0 denotes the current chart.

 

However if you want a specific chart id for the current chart, so that you can reference it from a different context, just obtain it with the ChartID() function.

ChartID

Returns the ID of the current chart.

long  ChartID();

Return Value

Value of long type.

Documentation on MQL5: Chart Operations / ChartID
Documentation on MQL5: Chart Operations / ChartID
  • www.mql5.com
ChartID - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.

To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Book and Documentation

Reason: