Skip to content

feat(REI): Add Range Expansion Index (REI) indicator #806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jun 18, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 26, 2025

This PR implements the Range Expansion Index (REI) indicator according to the specification in issue #805.

The Range Expansion Index (REI) is a volatility indicator developed by Thomas DeMark that compares the current day's price range to the average range over a specified period. It measures whether the current price range represents a contraction or expansion compared to the average.

Implementation Details:

  • Created both REI and FasterREI classes, following the project's pattern for Big.js and primitive number implementations
  • The indicator requires the high and low price values to calculate the price range
  • Added comprehensive tests verifying the calculation accuracy and edge cases
  • REI values are interpreted as:
    • REI > 100: Above average volatility (range expansion)
    • REI = 100: Average volatility
    • REI < 100: Below average volatility (range contraction)

Example Usage:

import {REI} from 'trading-signals';

// Create REI with interval of 14
const rei = new REI(14);

// Update with price data
rei.update({high: 100, low: 90, close: 95});

// Check if indicator has produced a result
if (rei.isStable) {
  console.log(rei.getResult().toString());
}

Fixes #805.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Feature request: REI indicator Add Range Expansion Index (REI) indicator May 26, 2025
@Copilot Copilot AI requested a review from bennycode May 26, 2025 09:53
Copilot finished work on behalf of bennycode May 26, 2025 09:53
@bennycode bennycode marked this pull request as ready for review May 26, 2025 10:18
@bennycode bennycode changed the title Add Range Expansion Index (REI) indicator feat(REI): Add Range Expansion Index (REI) indicator May 26, 2025
@bennycode
Copy link
Owner

bennycode commented Jun 9, 2025

TODO:

  • Add getSignal()
  • Move signal to directory (momentum)
  • Backtest with "trading-candles" package
  • Support conversion of MetaTrader CSV files to JSON

Copy link
Contributor Author

Copilot AI commented Jun 9, 2025

TODO:

  • Add getSignal()
    ...

Both TODO items have been completed:

  1. ✅ Added getSignal() method to REI and FasterREI classes that returns:

    • 'overbought' when REI > +60
    • 'oversold' when REI < -60
    • 'neutral' when REI is between -60 and +60
    • null when not stable
  2. ✅ Moved REI indicator to momentum directory: /src/momentum/REI/

Commit: 645c31d

Copilot finished work on behalf of bennycode June 9, 2025 11:43
@bennycode bennycode merged commit aef5cf5 into main Jun 18, 2025
3 checks passed
@bennycode bennycode deleted the copilot/fix-805 branch June 18, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: REI indicator
2 participants