0

There are 3 RSI indicators, each having its own period.
I want to tie all 3 to one Bollinger Band.
Tell me how to do this better?

 for(i=limit; i>=0; i--) {
     ma=iMAOnArray(RSI,0,bb_period,0,0,i);         // midle
     stdev=iStdDevOnArray(RSI,0,bb_period,0,0,i); // dev
     BBUP[i]=ma+bb_dev*stdev;                    // up
     BBDOWN[i]=ma-bb_dev*stdev;                 // down
     Buff4[i]=0;
     Buff5[i]=0;
 }

 if(limit<Bars-1) limit++;
 for(i=limit; i>0; i--) {
      if(PrevSignal >= 0) {
         if(   RSI[i]    <  BBDOWN[i]
            && RSI[i+1]  <  BBUP[i+1]
            && RSI2[i]   <  BBDOWN[i]
            && RSI2[i+1] <  BBUP[i+1]
            && RSI3[i]   <  BBDOWN[i]
            && RSI3[i+1] <  BBUP[i+1]
               ) {
               Buff4[i]  = Low[i]-5*MarketInfo(Symbol(),MODE_POINT); // MathMin(BBDOWN[i],WPR[i]);  // Low[i]-5*MarketInfo(Symbol(),MODE_POINT);
               PrevSignal = -1;
         }
      }
 }

I want that when all 3 RSI were below BB, then the signal https://i.stack.imgur.com/fKff7.jpg enter image description here

user3666197
  • 1
  • 6
  • 50
  • 92
  • Could you clarify, **what have you tried so far**, so as **to "tie" RSI[] with RSI2[] and RSI3[] together to one BBand**, to meet your expected outputs? Syntax is marginal, when missing the goal. Thanks to edit your post to reflect this missing aspect and to define The Target, right? – user3666197 May 22 '17 at 05:57
  • Possible duplicate of [How to check 3 RSI values against the Bollinger Bands?](https://stackoverflow.com/questions/44132346/how-to-check-3-rsi-values-against-the-bollinger-bands) – kenorb Jun 17 '19 at 09:59

1 Answers1

1

The code AS-IS could be designed with 4x less overhead:

Even before O/P will define the target ( how to tie three values into one ), one might have already detected the code-blocks are sync-stepped / aligned in [i]-indexing, not peeking into the future, non-intervening each to the other's values ( princially indeendent ) and thus redundant, so one could safely save a lot from these "shared" overheads:

int    i;
double ma,
       stdev;
for(i=limit; i>=0; i--) { RSI[ i] = iRSI( Symbol(), Period(), rsi_period,   PRICE_CLOSE, i );
                          RSI2[i] = iRSI( Symbol(), Period(), rsi_period_2, PRICE_CLOSE, i );
                          RSI3[i] = iRSI( Symbol(), Period(), rsi_period_3, PRICE_CLOSE, i );

                       /* the "last" for(){...} code-block body is not included,
                          until the calculus of how to tie three vectors
                          into a common Bollinger Band is defined by O/P,
                          but
                          could fit in this common "stream"-processing too
                          */

                          }

The O/P code has been remarkably changed - may check the revisions


Nota bene: ad-hoc the presented update

Given the Quantitative Finance heritage, from J. Welles Wilder, the author of the said RSI model, the definition says:

Relative Strength Index (RSI) is a momentum oscillator that measures the speed and change of price movements. RSI oscillates between zero and 100.

It turns out, that any attempt to mix apples and oranges leads to just a principal confusion. Taking the apples == the Bollinger Band ( having a clear PriceDOMAIN dimension [CCY2] ) and trying to mix it ( additively, using { ADD | SUB } operations ) with oranges == RSI ( a dimension-less relative / percent indicator ) will yield an uninterpretable result ( has a hidden superposition + scaling uncertainties ).

Still in doubts?

Just let's take XAUUSD for a second. It's Bollinger Band values, bearing in mind any reasonable multiples of sigma ( StDev ), the RSI will always be under the lower-band ... thus such construct will have zero information value, as:
RSI-<0..100> << BollingerBandLOWER-( 1257.000 - ( N * sigma ) )

So a model ought be revised, so as to have some Quantitative Finance support built-in. Mixing apples with oranges simply will not help in any serious business sense.

Community
  • 1
  • 1
user3666197
  • 1
  • 6
  • 50
  • 92
  • 1
    I need to make 2 bands (up and down) bbands and put 3 RSIs in them ... So that I depending on the settings of RSI to Bbands saw different results. RSI and Bbands in my basement ... – user3711927 May 22 '17 at 08:38
  • No need to explain the BB mechanics, it is **the rest, that is not clear**. Given BBaxis == 1.00000, sigma == 0.2, RSI1[0] == x, RSI2[0] == y, RSI3[0] == z, **what would you like to plot with the { x | y | z }-values**, besides the common lines of { 1.20000 | 1.00000 | 0.80000 }-BBands? **Any equation, screenshot or illustration?** – user3666197 May 22 '17 at 08:44