How to Plot RSI for Combined candle of two different stocks

Dear seniors,

How can we plot indicators like RSI when we plot price of two or more stocks combined on the chart ? It doesn't consider the combined price that we plotted on chart... so is there a possibility for this ? Please advise..

Thanks in advance.

@Hems, your question is not very clear to me.
What do you exactly mean by "stocks combined/combined price"?
Can you provide a code example of such a "combined" chart?

Dear @Beppe,

I have used Setforign() to fetch OHLC of two stocks and den added them to form a single candle of both the prices.. Below is the code I have for Hiekinashi candle

SetChartOptions(1, chartShowArrows | chartShowDates); 

Open1 = Open;
High1 = High;
Low1 = Low;
Close1 = Close;

Open2 = Open;
High2 = High;
Low2 = Low;
Close2 = Close;

CO = Open1 + Open2 ;
CH = High1 + High2  ;
CL = Low1 + Low2  ;
CC = Close1 + Close2  ;

HaClose = (CO + CH + CL + CC)/4; 
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 
HaHigh = Max( CH, Max( HaClose, HaOpen ) ); 
HaLow = Min( CL, Min( HaClose, HaOpen ) ); 
xDiff = (HaHigh - Halow) * 10000;
barcolor1 = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, Hahigh, HaLow, HaClose, "", barcolor1, styleCandle );


I was able to plot the candle for combined prices of both stocks as listed in the code. This is how it looks

Combined Candle

However, The RSI plotted is not of the combined candle rather it is of the stock selected tool bar.

For indicators like moving averages, we can give Combined close as closing price to get them plotted on the chart ( for ex: MA( CC, 20 ) ) where CC is combined close.

I am looking a way to plot RSI kind of oscillators for the combined price. Is it even possible?

Please let me know.

@Hems, I think you can use the RSIa() function passing to it your HaClose array.

1 Like

Thank u @Beppe. That resolves my query. Thanks a lot.


This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.