-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
base: master
Are you sure you want to change the base?
Implement SqueezeMomentum (SM) indicator #8462
Conversation
There was a problem hiding this 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
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
Checklist:
bug-<issue#>-<description>
orfeature-<issue#>-<description>