Experiencing an issue with objects when two separate window indicators are on the same chart

 

I wanted to create a text object to measure the "power" on the last histogram bar for the bears power and bulls power indicators. It seems that there are no issues with the placement of the text object if I load one single indicator on the chart (either bulls or bears). 

Chart with only bears indicator:

bears indicator


Chart with only bulls indicator:

bulls indicator


now when I load both the bulls indicator and bears indicator on the same chart, the two distinct text objects stick inside the same indicator window:

text object issue


I'm not sure why. I'm attaching the code files

Files:
Bears.mq5  5 kb
Bulls.mq5  5 kb
 

You have hard-coded your "sub-window" parameter when creating the graphical objects.

ObjectCreate(chart_id, name, OBJ_TEXT, 1, time, price);

Use the following to find out which sub-window the Indicator is using ...

ChartWindowFind

Returns the number of a subwindow where an indicator is drawn

Basically ...

ObjectCreate(chart_id, name, OBJ_TEXT, ChartWindowFind(), time, price);

But that is not good programming. It is just an example so you understand the idea.

Documentation on MQL5: Chart Operations / ChartWindowFind
Documentation on MQL5: Chart Operations / ChartWindowFind
  • www.mql5.com
The function returns the number of a subwindow where an indicator is drawn. There are 2 variants of the function. 1. The function searches in the...
 

Thanks