Indicator in 2 windows?

 

Hi,


I want to write an indicator that draws 2 symbols (e.g. Gold and Silver) in the main window and their difference in the subwindow.

How to do that when I must declare the property indicator_chart_window or indicator_separate_window?

 

You can write a chart window indicator that seeks separate window and draws object on them. You have to manually attach a blank separate window though. 

But why not write them simply as two indies? 

 
cameofx:

You can write a chart window indicator that seeks separate window and draws object on them. You have to manually attach a blank separate window though.

But why not write them simply as two indies?

You mean to draw both symbols on the main window and then run external indi that draws their difference? If so, I don't know how to pass the data to the second indi...

 

By 'drawing 2 symbols (e.g. Gold and Silver)' do you mean something like Candles Overlay indicator? 

I'm thinking : the main charts are, for example, Gold. The overlay indicator would be 'Silver' and the indicator in separate window will call Gold's price and Silver's buffers and calculate/draws their difference.  

You can access other indicator values by using iCustom (if they use drawing buffer allocated by SetIndexBuffer()).  

 
cameofx:

By 'drawing 2 symbols (e.g. Gold and Silver)' do you mean something like Candles Overlay indicator?

I'm thinking : the main charts are, for example, Gold. The overlay indicator would be 'Silver' and the indicator in separate window will call Gold's price and Silver's buffers and calculate/draws their difference.

You can access other indicator values by using iCustom (if they use drawing buffer allocated by SetIndexBuffer()).

Yes, I am thinking about something like that.
 
cameofx:

By 'drawing 2 symbols (e.g. Gold and Silver)' do you mean something like Candles Overlay indicator?

I'm thinking : the main charts are, for example, Gold. The overlay indicator would be 'Silver' and the indicator in separate window will call Gold's price and Silver's buffers and calculate/draws their difference.

You can access other indicator values by using iCustom (if they use drawing buffer allocated by SetIndexBuffer()).

Hm.. I am still having problem.

How to pass array to the second indi? By external param I cannot do that. I can repeat calculations and fill array in the second indi of course but maybe it is a better way to do that?

You mentioned to use SetIndexBuffer() but it doesn't work or maybe I am doing something wrong :-( ?

 
cornelius:

Hm.. I am still having problem.

How to pass array to the second indi? By external param I cannot do that. I can repeat calculations and fill array in the second indi of course but maybe it is a better way to do that?

You mentioned to use SetIndexBuffer() but it doesn't work or maybe I am doing something wrong :-( ?

Show your code. You'll have better chance of getting help.
 
cameofx:
Show your code. You'll have better chance of getting help.

Thanks Cameofx.


I attach the indicator. Buffer1 holds scaled data to be displayed in the chart together with the original symbol.

Buffer2 holds difference of the 2 symbols and that I would like to display in the subwindow. I was trying this with iCustom but I think it would not work.

Maybe there is a way to open subwindow and then display buffer in it?


Kind regards,

Piotr

Files:
2_windows.mq4  3 kb
 
This is only an example of drawing with object trend. I switch the buffers since the difference buffer doesn't correlate with the price.
Files:
 
cameofx:
This is only an example of drawing with object trend. I switch the buffers since the difference buffer doesn't correlate with the price.

Excellent, it is exactly what I wanted!

Many thanks, cameofx!

cornelius

 

I have noticed a strange thing while testing the indicator (than is to put two symbols on one chart).

1. Open chart with CADJPY (green), run indicator and added Crude Oil (QMF1 - red).

2, Open another chart with Crude Oil (green).

3. Set a time line like on the first chart (2010.06.16 0:00) and on another chart (with only Crude Oil) find the same time, looking at the curve, not the time axis.

4. Read time on the time axis.

I have got the time 2010.05.12 0:00 !!! So it is over a month difference (on daily chart).

It is not a fault of the indicator, I guess as other pairs (e.g. Gold and NZDUSD) are displayed correctly.


Does anyone have an idea where is the issue? Maybe you could check with your broker's data?

cornelius



Reason: