create OBJ_HLINE on a subchart
- Uwe Dörl: I created a subchart and found it on the object list.
Charts are not found on the object list. Objects have nothing to do with charts or sub_window IDs.
-
bool res = ObjectCreate(ChartID(), "xyz", OBJ_HLINE, 1, 0, 1.137);
Where did you get the sub_window ID being one? Use ChartWindowFind - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
I am not using an indicator. I create a simple expert chart with one subchart. The sub_window Nr should be 1.
@Hanife Abdourahamane Maman Issa
On the main chart you have to use the sub_window=0, but on a subchart you need sub_window>0.
https://www.mql5.com/en/docs/objects/objectcreate
sub_window [in] Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist, otherwise the function returns false.
"It is important to note that you can add indicators to chart objects and apply tpl templates, including those with Expert Advisors. However, you cannot create objects inside chart objects."

Why can I not create a OBJ_HLINE on a subchart?
I created a subchart and found it on the object list.
These ObjectCreate OBJ_HLINE return without errors and the res was true. But I got nothing on the subchart and the object list.