- Accumulation Distribution Indicator
- RSI Calculation Example and Formula
- Strategy Frameworks vs Black Boxes
- Serializing Brush Parameters
- How to Add Complete Time Value Selector to NinjaTrader Parameters
- Using INotifyPropertyChanged with NinjaTrader
- How to deal with ugly plot starting from zero
- OnTick vs OnBarUpdate Execution
- The Road Map to Coding Strategies & Indicators for NinjaTrader
- How to Release Products for NinjaTrader
- Stop Orders Getting Rejected Again
- In Sample and Out of Sample Optimization Techniques
- Closing Position at End of Historical Data to Increase Optimization Speed
- Syncing Data in Multiseries Indicators and Strategies
- Using Pivot Analysis Divergence for Confirming Market Direction
- How to Add Buttons to NinjaTrader 8 Toolbar
- How to Get Bar Values using TimeStamps in NinjaTrader
- Use UVOL DVOL Market Internals for Building Effective Entries on NQ
- How to Set Stop Loss in NinjaTrader using Dollar Values
- How to Pass Parameters from Strategy into Optimization Algorithm
- Main Points to Consider with NinjaTrader UnManaged Order Processing
- DI+ DI- NinjaTrader Indicator Creation Process & Code
- Adding WPF Windows to Strategy or Indicator
- Common Multi Timeframe Strategy Initialization Issue
- IsFirstTickOfBar and OnEachTick execution Issues
- Stop Orders Above Market Order Rejected Error (Part 2)
- Stop Orders Above Market Order Rejected Error (Part 1)

The Relative Strength Index (RSI) is a momentum oscillator used in technical analysis that measures the speed and change of price movements. RSI oscillates between zero and 100 and is typically used to identify overbought or oversold conditions.

The RSI is calculated using the following steps:

**Calculate Average Gains and Losses:**This is typically done over a 14-day period. For each day, determine whether the price has gone up or down from the previous day. Sum up all the gains and losses respectively and then divide each by the period (e.g., 14 days).**Compute Relative Strength (RS):**This is the ratio of average gain to average loss.`RS = Average Gain / Average Loss`

**Calculate RSI:**The RSI formula is then applied to get the final value.`RSI = 100 - (100 / (1 + RS))`

Assume you have the following daily closing prices over 15 days:

- Day 1: $100, Day 2: $102, Day 3: $101, Day 4: $105, Day 5: $103, Day 6: $110,
- Day 7: $108, Day 8: $109, Day 9: $112, Day 10: $115, Day 11: $117, Day 12: $120,
- Day 13: $118, Day 14: $121, Day 15: $123

Follow these steps to calculate the initial RSI:

**Calculate Daily Changes:**Compute the change from one day's closing price to the next and identify gains and losses.**Sum Gains and Losses:**From these changes, calculate the total gains and losses over the 14-day period after the first day.**Calculate Averages:**Average Gain = Total Gains / 14, Average Loss = Total Losses / 14.**Calculate RS and RSI:**Use the formulas provided above to calculate RS and then RSI.

To calculate the RSI for the next day, you can use the following updated formula:

**Calculate the New Change:**Determine if the new closing price (Day 16) is higher or lower than the previous day (Day 15).**Update the Average Gain and Loss:**The formulae to update are:`New Average Gain = (Previous Average Gain * 13 + New Gain) / 14`

`New Average Loss = (Previous Average Loss * 13 + New Loss) / 14`

**Compute the New RS and RSI:**`RS = New Average Gain / New Average Loss`

`RSI = 100 - (100 / (1 + RS))`

Example: If the new closing price on Day 16 is $125 (a gain), and the closing price on Day 15 was $123:

- New Gain = $2, New Loss = $0
- Update and calculate the RSI as shown.

If the new closing price on Day 16 is $120 (a loss):

- New Gain = $0, New Loss = $3
- Update and calculate the RSI similarly.