How to draw / redraw lines on different charts from one indicator/script ?

 

Hi,

Have constructed an indicator that collects differend parameters from differend securities and display the figures in a separate windows.

High Low Close from previous week. But how to draw those lines in the different chart-windows ?

Regards

Erik

 

Indicators/Scripts/EAs can draw objects only on the chart (main chart window and subwindows) attached to.

 
stringo:

Indicators/Scripts/EAs can draw objects only on the chart (main chart window and subwindows) attached to.


Thanks for helping stringo.

Does'nt understand you can collect information on different currency pairs and not to be able to visualies this info on open chart windows and or open new windows to make visible this info.

Nothing is perfect !

Regards

Erik

 
I want to do that too .but sadly  it immposible
 
mhr09381321500 Mohamadhasan #:
I want to do that too .but sadly  it immposible

Unless I'm not understanding correctly, it's definitely possible.

When creating an object, you are required to specify the chart ID and subwindow.

bool  ObjectCreate(
   long          chart_id,      // chart ID
   string        object_name,   // object name
   ENUM_OBJECT   object_type,   // object type
   int           sub_window,    // window index
   datetime      time1,         // time of the first anchor point
   double        price1,        // price of the first anchor point
   ...
   datetime      timeN=0,       // time of the N-th anchor point
   double        priceN=0       // price of the N-th anchor point
   );

To get the ChartID, you would cycle through the charts looking for the desired Symbol (and maybe Timeframe) that you want to draw the object on.

long chartID          = ChartFirst();
bool isNotEndOfCharts = chartID != -1;

while (isNotEndOfCharts) {
  const string symbol = ChartSymbol(chartID);
  const int period    = ChartPeriod(chartID);

  // do something
  
  chartID          = ChartNext(chartID);
  isNotEndOfCharts = chartID != -1;
}
 
mhr09381321500 Mohamadhasan #: I want to do that too .but sadly  it immposible

It was not possible using the old MQL4 that did not have a Chart ID parameter. However, it is now totally possible using the modern MQL4+ that does have that parameter and @Alexander Martinez has shown how to do it in his post above. Read the MQL4 documentation for more information: Object Functions - MQL4 Reference

 
Fernando Carreiro #:

It was not possible using the old MQL4 that did not have a Chart ID parameter. However, it is now totally possible using the modern MQL4+ that does have that parameter and @Alexander Martinez has shown how to do it in his post above. Read the MQL4 documentation for more information: Object Functions - MQL4 Reference

Interesting. Thanks for the explanation, Fernando.
 
Alexander Martinez #: Interesting. Thanks for the explanation, Fernando.

You are welcome!

Reason: