Skip to content
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

Implement SqueezeMomentum (SM) indicator #8462

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JosueNina
Copy link
Contributor

Description

This pull request introduces the Squeeze Momentum Indicator (SM), which combines the Bollinger Bands and Keltner Channels to identify periods of low volatility in the market, signaling potential future price movements. The indicator highlights when the market is "squeezed" and a breakout may be imminent

Related Issue

Closes #4166

Motivation and Context

The Squeeze Momentum Indicator is important for traders who wish to identify periods of consolidation in the market. By identifying when volatility is low, it helps to predict possible breakouts, enhancing decision-making for entry and exit points.

Requires Documentation Change

Yes, the documentation should be updated to include usage instructions for the Squeeze Momentum Indicator and explain its parameters.

How Has This Been Tested?

The Squeeze Momentum Indicator has been tested using historical data from the SPY and compared against values generated using the Talib library.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@JosueNina JosueNina changed the title Implement SqueezeMomentum (SM) indicator Feature 4166 squeeze momentum indicator Implement SqueezeMomentum (SM) indicator Dec 12, 2024
Copy link
Collaborator

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thank you! Leaving a few minor comments

/// Gets the warm-up period required for the indicator to be ready.
/// This is determined by the warm-up period of the Bollinger Bands indicator.
/// </summary>
public int WarmUpPeriod => _bollingerBands.WarmUpPeriod;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the warm up period consider also the average true range period? IsReady waits for both to be ready

/// <summary>
/// The Bollinger Bands indicator used to calculate the upper, lower, and middle bands.
/// </summary>
private readonly BollingerBands _bollingerBands;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to also use the KeltnerChannels indicator? To leverage the existing indicators

/// <param name="selector">Selects a value from the BaseData to send into the indicator. If null, defaults to the Value property of BaseData (x => x.Value).</param>
/// <returns>The configured Squeeze Momentum indicator.</returns>
[DocumentationAttribute(Indicators)]
public SqueezeMomentum SM(Symbol symbol, int bollingerPeriod = 20, decimal bollingerMultiplier = 2m, int keltnerPeriod = 20, decimal keltnerMultiplier = 1.5m, Resolution? resolution = null, Func<IBaseData, IBaseDataBar> selector = null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - might split the really long line 😅

public SqueezeMomentum(string name, int bollingerPeriod, decimal bollingerMultiplier, int keltnerPeriod, decimal keltnerMultiplier) : base(name)
{
_bollingerBands = new BollingerBands(bollingerPeriod, bollingerMultiplier);
_averageTrueRange = new AverageTrueRange(keltnerPeriod, MovingAverageType.Simple);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice for the user to be able to select the moving average type, as an argument to the indicator. Maybe optional with Simple as default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Squeeze Momentum Indicator
2 participants