Quant League is evolving into Strategies, our new home for sharing, discovering, and exploring trading strategies, with improved organization and a better overall experience. Q4-2025 will be the final Quant League.
LEAN is the open-source algorithmic trading engine powering QuantConnect.
Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join Our Discord Channel
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
This research is under review. To publish this research attract three community upvotes.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Nate Betz
361 Pro
,
No, but just thinking out loud about how it could generally be implemented, I'm guessing you would look at a RollingWindow of price bars of some size, calculate the slope/regression line of the Lows, as well as the slope/regression line of the Highs, and compare them, looking for a ratio that signals the desired pattern.. A new price bar that is some variance outside of one of the regression lines would signal a break-out of the pattern.
JayJayD
42.9k Pro
,
I can help, if there are some mathematical (rigorous) definitions of each pattern.
Damien Peck
321 Pro
,
I saw this recently using MathNet.Numerics:
 var line = Fit.Line(x, y);
If you have three rolling windows of data, time, highs, lows and then fit them you could project an intersection where high equation minus low equation = 0. This would be the intersection, point of the triangle. If the two never intersect it would indicate widening highs and lows.
IMHO triangle patterns have the same prediction performance as other price only indicators; but are just harder to implement. The human brain is the master pattern recognition engine; but they also add in a touch of rosy glow which ignores the failure cases.
Alexandre Catarino
108.7k Pro
,
If your quant team will look into Nate Betz and Damien Peck's suggestion, please remember that Lean/QuantConnect does have an indicator for evaluation of a series slope (LeastSquaresMovingAverage):
private LeastSquaresMovingAverage _hiLsma;
private LeastSquaresMovingAverage _loLsma;
// In Initialize
_hiLsma = LSMA("SPY", 200, Resolution.Daily, Field.High);
_loLsma = LSMA("SPY", 200, Resolution.Daily, Field.Low);
// In OnData
var hiSlope = _hiLsma.Slope;
var loSlope = _loLsma.Slope;
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp. You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!
Allocate to this Strategy
Institutional clients can contact the author and allocate capital to this strategy.
Nate Betz
No, but just thinking out loud about how it could generally be implemented, I'm guessing you would look at a RollingWindow of price bars of some size, calculate the slope/regression line of the Lows, as well as the slope/regression line of the Highs, and compare them, looking for a ratio that signals the desired pattern.. A new price bar that is some variance outside of one of the regression lines would signal a break-out of the pattern.
JayJayD
I can help, if there are some mathematical (rigorous) definitions of each pattern.
Damien Peck
I saw this recently using MathNet.Numerics:
 var line = Fit.Line(x, y);If you have three rolling windows of data, time, highs, lows and then fit them you could project an intersection where high equation minus low equation = 0. This would be the intersection, point of the triangle. If the two never intersect it would indicate widening highs and lows.
IMHO triangle patterns have the same prediction performance as other price only indicators; but are just harder to implement. The human brain is the master pattern recognition engine; but they also add in a touch of rosy glow which ignores the failure cases.
Alexandre Catarino
If your quant team will look into Nate Betz and Damien Peck's suggestion, please remember that Lean/QuantConnect does have an indicator for evaluation of a series slope (LeastSquaresMovingAverage):
private LeastSquaresMovingAverage _hiLsma; private LeastSquaresMovingAverage _loLsma; // In Initialize _hiLsma = LSMA("SPY", 200, Resolution.Daily, Field.High); _loLsma = LSMA("SPY", 200, Resolution.Daily, Field.Low); // In OnData var hiSlope = _hiLsma.Slope; var loSlope = _loLsma.Slope;Ray Bohac
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!