My RSI Indicator Does Not Work.

 

I changed a little on the official RSI indicator, but it does not work. 

No error in compile. 

Please anyone give some comments. Thank you. 

Files:
 
  1. “Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. (2004)
              When asking about code
              Be precise and informative about your problem

  2. #property indicator_chart_window
    #property indicator_minimum    0
    #property indicator_maximum    100

    Your indicator is drawing 50±30. Your chart's price is 0.98765±0.00200. Why would you expect to see it on the chart?

 
William Roeder #:
  1. “Doesn't work” is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. (2004)
              When asking about code
              Be precise and informative about your problem

  2. Your indicator is drawing 50±30. Your chart's price is 0.98765±0.00200. Why would you expect to see it on the chart?

Thank you, that's my fault.  I update myindicator.mp4 as attached. 

But something strange happened which I don't understand. 

Here the the code.  In the for(;;),  if I place i<90, the result number is correct. ExtmyBuffer[i] is within[-1,1]. If I use i< rates_total && !IsStopped(), the result is out of range.

   for(i=pos; i< 90; i++)  // for(i=pos; i< rates_total && !IsStopped(); i++)
     {
      diff=close[i]-close[i-1];
      Print("diff=",diff);
      ExtPosBuffer[i]= ExtPosBuffer[i-1]+(diff>0.0?diff:0.0);
      Print("ExtPosBuffer[i]=",ExtPosBuffer[i]);
      Print("ExtPosBuffer[i-1]=",ExtPosBuffer[i-1]);
      ExtNegBuffer[i]= ExtNegBuffer[i-1]+(diff<0.0?diff:0.0);
      Print("ExtNegBuffer[i]=",ExtNegBuffer[i]);
      Print("ExtNegBuffer[i-1]=",ExtNegBuffer[i-1]);
      ExtmyBuffer[i]= (ExtPosBuffer[i]+ExtNegBuffer[i])/(ExtPosBuffer[i]-ExtNegBuffer[i]);
      Print("ExtmyBuffer[i]=",ExtmyBuffer[i]);
     }

update:

rolling window is 20 bars.

When I set to i< rates_total && !IsStopped(),   ExtPosBuffer[i-1] starts with 3.876029999999998 but not ExtPosBuffer[20], which should less than 0.5. It seems get the sum of all diff at first. 

this is the terminal journal:  2021.09.21 22:47:43.635 myindicator EURUSD,H1: ExtPosBuffer[i-1]=3.876029999999998


Update:

I tried MT5, the similar code says:

'for' - expressions are not allowed on a global scope myindicator5.mq5 90 4



Files:
 

More strange things. 

Though I modified from official RSI.mp4, but this is a different file with different formula. 

Every time I import it to terminal, it shows the line of official RSI but keeps the levels in myindicator.mp4 file. 

I attached the latest indicator file. 

Files:
Reason: