Scripts to open a chart and draw something on the opened chart? Possible?

 

Hi, 

So far whenever I am facing a problem, I always can find a solution from MQL or online. However, I got stuck on this problem. Maybe this is a limitation from MT4.

The task is to open a chart using Chartopen(), and then draw something(lines) on the opened chart, but not the one we run script on.

For example, I have one USDCAD chart in my terminal, there is a script which is executed on the USDCAD. The script is to open GBPUSD chart, and draw a line on GBPUSD(not on USDCAD), is it possible?

Many thanks,

 
Yes it's possible.
 
Alain Verleyen :
Yes it's possible.

can I open two exchanges (usd / jpy-gbp / usd) in the same chart and compare the respective prices?

 
#include <chartobjects/chartobjectslines.mqh>
#include <charts/chart.mqh>

void OnStart()
{
   CChartObjectVLine vline;
   CChart chart;
   chart.Open("GBPUSD", PERIOD_CURRENT);
   vline.Create(chart.ChartId(), "vline_test", 0, TimeCurrent());
   chart.Redraw();
   Sleep(5000);
   chart.Close();
}
 

Wow! that really works. Many thanks. nicholi.

That is definitely advanced programming for me. It is worth learning C++.

See, any problem has a solution, I believe. so far at least.

Reason: