create OBJ_HLINE on a subchart

 

Why can I not create a OBJ_HLINE on a subchart?

ObjectCreate(ChartID(), "theSubChart", OBJ_CHART, 0, 0, 0)
ObjectSetInteger(ChartID(), "theSubChart", OBJPROP_CORNER, CORNER_LEFT_UPPER);
...

bool res = ObjectCreate(ChartID(), "xyz", OBJ_HLINE, 1, 0, 1.137);

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.

 
  1. 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.

  2. 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
[Deleted]  
Uwe Dörl:

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.

use O for the currentChart

 

@William Roeder

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.
 

Sample

This is the main chart and the subchart. I would like to add objects to the subchart from my expert programm. Objects to the main chart are simple at all.

 
I think there is a different between the chart object OBJ_CHART and the indicator subwindow below the main chart. :(
 

"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."

Objects Chart