I am working on a trading bot that computes values for several indicators including the RSI. I subscribe to real time minute-level market data from an exchanges, and as new data arrives, I get the most recent tick, and re-compute indicators. Let's assume the RSI calculation period is 1 hour.

Average gain is computed as:

05:00 as [Prev Avg Gain x 13 + (Price at 05:00 - Price 04:00)]/14.

06:00 as [Prev Avg Gain x 13 + (Price at 06:00 - Price 05:00)]/14.

What is the right way to compute RSI at a minute level? I generate trade signals (buy/sell) every 5 minutes. What is the right way to update RSI at 05:05 i.e, at a smaller granular period (5 minutes) than the calculation period (1 hour)? I don't want to wait one until 06:00 to get the RSI for the one hour period. I have two options:

Compute Current Gain = (Price at 05:05) - (Price at 05:00).


Compute Current Gain = (Price at 05:05) - (Price at 04:05). And do this for each of the previous intervals so that average gain also follows this formula - essentially adding a 5 minute shift to each computation.

Any suggestions are welcome.


use Current Gain = (Price at 05:05) - (Price at 05:00)

so at 05:59 it should be almost exactly as the new level at 06:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.