RSI as an OHLC indicator ?

 

Hi all, I looking for an indicator that represents the RSI as a candle, with Open/High/Low and Close values.  Googled it but no luck.

I can code in MQL4. How can I store the OHLC values of an RSI throughout a period of time (H1, H4 etc) ?

Your help would be really appreciated. Any sample code on how to do it, would be great. Thanks.

 

I suppose you could try to modify Heikin Ashi Indicator.

It already has the candlestick skeleton code if you just mess around and mod the formula but depending on your coding skills of course.

 
Marco vd Heijden:

I suppose you could try to modify Heikin Ashi Indicator.

It already has the candlestick skeleton code if you just mess around and mod the formula but depending on your coding skills of course.

How is this request related to Heiken Ashi indicator ?
 

Hi Marco, thanks for the suggestion. I just looked in to the Heikin Ashi indicator, but the OHLC is price based. They are already built-in the MT4 logic.

What I need to do is store ex. Open RSI[i], High RSI[i], Low RSI[i] and Close RSI[i] for every tick.

How can I do it ? 

 
Alain Verleyen: How is this request related to Heiken Ashi indicator ?

I thought it was obvious: "It already has the candlestick skeleton code"

Joao: What I need to do is store ex. Open RSI[i], High RSI[i], Low RSI[i] and Close RSI[i] for every tick. How can I do it ? 

HA already has buffers for OHLC. On a new bar set them. On each new tick change the high if higher, change the low if lower, store the current value in close. 

 
Joao:

Hi Marco, thanks for the suggestion. I just looked in to the Heikin Ashi indicator, but the OHLC is price based. They are already built-in the MT4 logic.

What I need to do is store ex. Open RSI[i], High RSI[i], Low RSI[i] and Close RSI[i] for every tick.

How can I do it ? 

Store every tick ? Monitor it every tick but just save the OHLC.

Save them in a file.

 
whroeder1:

I thought it was obvious: "It already has the candlestick skeleton code"

HA already has buffers for OHLC. On a new bar set them. On each new tick change the high if higher, change the low if lower, store the current value in close. 

HA is indicator in main window. RSI is between 0 and 100, it needs to be in a sub-window, HA indicator will not work as is to draw candlestick in a sub-window.

I was thinking the issue is how to get the values, not how to draw candlestick.

 

Yes, that's exactly the problem. When the indicator processes old bars, there will only be one RSI value for each.

Only on the "NEW Bar" (i=0), when new ticks are processed, the OHLC values can be calculated. But as soon as you shut down MT4, the RSI OHLC will be lost again.

 
Alexander Voronkov:

I believe that if you really want to, you can fly to space !)


That's exactly what I'm looking for. Where can I get that indicator ?

 
Alain Verleyen:
How is this request related to Heiken Ashi indicator ?

Yes well we are programmers and we make things work there are always possibilities.

My idea was to drop the open and close and just use the regular price levels for those, and then create a conversion for high and low.

It is indeed a weird request but certainly do-able.

This Heiken Ashi indicator already has the candle sticks you can use modify it and use it's buffers i have done this many times its actually a very good template to start something new off.

 

No need to do anything with ticks. The key to RSI OHLC is using the bar OHLC. Since the RSI is using close prices, on the RSI calculation for the current bar (selected by index) you would change the close price to the high,low,etc.

   double Rsi(const int applied,const int i)
   {
      #define POS_BUFFER 1
      #define NEG_BUFFER 2
      double rsi=0;
      double prev_pos = iCustom(Symbol(),Period(),"RSI",m_rsi_period,POS_BUFFER,i+1);
      double prev_neg = iCustom(Symbol(),Period(),"RSI",m_rsi_period,NEG_BUFFER,i+1);
      double diff=0;
      if(applied==PRICE_CLOSE)
         diff=m_rates.rates[i].close - m_rates.rates[i+1].close;
      else 
      if(applied==PRICE_OPEN)
         diff=m_rates.rates[i].open - m_rates.rates[i+1].close;
      else 
      if(applied==PRICE_HIGH)
         diff=m_rates.rates[i].high - m_rates.rates[i+1].close;
      else 
      if(applied==PRICE_LOW)
         diff=m_rates.rates[i].low - m_rates.rates[i+1].close;  
         
      double curr_pos = (prev_pos*(m_rsi_period-1)+(diff>0.0?diff:0.0))/m_rsi_period;
      double curr_neg = (prev_neg*(m_rsi_period-1)+(diff<0.0?-diff:0.0))/m_rsi_period;
      if(curr_neg!=0.0)
         rsi=100.0-100.0/(1+curr_pos/curr_neg);
      else
      {
         if(curr_pos!=0.0)
            rsi=100.0;
         else
            rsi=50.0;
      }
      return rsi;
   }

Anyway... I got a little bit carried away with it.. here's the indicator.

Files:
RsiBar.mqh  4 kb
RSIBars.mq4  2 kb
Reason: