MTF RSI shows wrong values

 

Hello guys. I googled a bit MTF RSI and I found many indicators that did not work. I needed to plot two reading of RSI on one timeframe using two separate buffers.

I noticed at first glance the indicator works but the readings are completely wrong.

#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_color2 Red

extern int history = 1000;
double dailyRsi[], fourHourRsi[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0, dailyRsi);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(1, fourHourRsi);
   SetIndexStyle(1, DRAW_LINE);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int totBars, shift, i;
   
   totBars = Bars;           // Index of the first uncounted
   
   double rsiDailyReading, rsi4Reading;
   ///for (int i = totBars; i >= 0; i--) {
   for (i = 0; i <= totBars; i++) {
      
      shift = iBarShift(Symbol(), PERIOD_D1, iTime(Symbol(), 0, i), false);
      rsiDailyReading = iRSI(Symbol(), PERIOD_D1, 14, PRICE_CLOSE, shift);
      rsi4Reading = iRSI(Symbol(), PERIOD_H4, 14, PRICE_CLOSE, i);
      dailyRsi[i] = rsiDailyReading;
      fourHourRsi[i] = rsi4Reading;
      
      
   }
//----
   
//----
   return(0);
  }


I was wondering if I am doing something wrong. Basically the reading on the daily is the reading of the 4h chart and the 4h chart seems the reading of the 60 minutes timeframe.

 
Most of the problems with MTF indicator stems from the fact that people try to use them on the Null bar. When i=0 the bar(0) information will be un-reliable. Also you have to watch out for Forward-Peaking within the indicator when back-testing. Depending on how it's programmed, some period may know the future price while other are still forming. I recommend searching and reading as much as you can about the woe's of MTF indicators in mt4.
 

MTF Bollinger Band.

There's also some in code base

Files:
band_mtf.mq4  6 kb
 
zen4x:

Hello guys. I googled a bit MTF RSI and I found many indicators that did not work. I needed to plot two reading of RSI on one timeframe using two separate buffers.

I noticed at first glance the indicator works but the readings are completely wrong.

  1. Do you have D1 and H4 history for the time you're looking at?
  2.       shift = iBarShift(Symbol(), PERIOD_D1, iTime(Symbol(), 0, i), false);
          rsiDailyReading = iRSI(Symbol(), PERIOD_D1, 14, PRICE_CLOSE, shift);
          rsi4Reading = iRSI(Symbol(), PERIOD_H4, 14, PRICE_CLOSE, i);
    It correctly shifts for the D1, but the H4 doesn't not. So it can only run on a H4 chart.
  3. Also remember, tester limitation, you can't see bar zero or other TF/pairs.