I would like to display RSI only on specified bars - page 2

 
フェルナンド・カレイロ #:

まず自分自身に問いかけてください。なぜこれをやりたいのですか?

EAでRSIを計算する際の「負荷」を軽減するためでしょうか?

「はい」の場合、増分計算であることを考慮すると、EMA の使用は完璧な解決策です。 インジケーターを使用する代わりに、EA で RSI を段階的に計算するだけです。

それともこれを望む別の理由がありますか?

Yes, I need it because I want the RSI to use the average of the price movements of each currency pair. However, when I change for(i=pos; i<rates_total;i++) to for(i=pos;i<Max_Bars;i++) in the main loop, the displayed RSI disappears and I am in trouble. The indicator is very heavy when using rates_total, so I want to make it lighter.

What do you think about this code?

for(int i = 0; i<Max_Bars; i++){
   for(j=i; j<=j+RSI_Period;j++){
   }
}
 
Kosei S #: Yes, I need it because I want the RSI to use the average of the price movements of each currency pair. However, when I change for(i=pos; i<rates_total;i++) to for(i=pos;i<Max_Bars;i++) in the main loop, the displayed RSI disappears and I am in trouble. The indicator is very heavy when using rates_total, so I want to make it lighter. What do you think about this code?

I have already explained that the way the RSI is calculated, based on EMA, you can't just reduce the number of bars without greatly affecting the calculations.

You can use SMA instead, but the results will be different. However, you need to understand the maths behind the RSI first, before you can substitute the EMA for SMA.

Code Base

Wilder's Relative Strength Index

Fernando Carreiro, 2023.01.22 18:12

An implementation of the Relative Strength Index indicator by John Welles Wilder Jr. as described in his book—New Concepts in Technical Trading Systems [1978].
 
Fernando Carreiro #:

I have already explained that the way the RSI is calculated, based on EMA, you can't just reduce the number of bars without greatly affecting the calculations.

You can use SMA instead, but the results will be different. However, you need to understand the maths behind the RSI first, before you can substitute the EMA for SMA.

Thank you for your help, Im gonna try it
Realy appreciate

 

Are you sure you took this into account

Kosei S:
   if(Bars<=InpRSIPeriod || InpRSIPeriod<2)
      return(0);
//--- counting from 0 to rates_total
   ArraySetAsSeries(ExtRSIBuffer,false);
   ArraySetAsSeries(ExtPosBuffer,false);
   ArraySetAsSeries(ExtNegBuffer,false);
   ArraySetAsSeries(close,false);

before doing this

Kosei S #:
input int Max_Bars = 500;
for(i=pos; i<Max_Bars&& !IsStopped(); i++)
 
Kosei S:

I would like to display only the specified bars by RSI in order to lighten the indicator, but it is not displayed well. How to display RSI for only specified of bars?

In any case, it's a pointless idea. The depth you are trying to limit is only calculated once after initialization. I think you are trying to save about a few milliseconds not with every tick, but only 1 time when attaching.

It's like trying to turn the ignition key faster in order to drive 1000 kilometers faster.