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.
This research is under review. To publish this research attract three community upvotes.
This discussion is a draft. Click here to publish this discusison.
Indicator - Pivot Point High Low
Hey everyone,
Has anyone had any experience trying to code in Pivot Point High Low in python? I'm really struggling with tryna get a working PPHiLo, has anyone had any experience with this? Any tips etc...
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.
Rahul Chowdhury
40k
,
Hi Tomer,
Although Lean does not have a built-in pivot point high/low indicator, you can implement it yourself. Let's say we want to create a 5 period pivot point high indicator. We can accomplish this using a rolling window of size 11, which will let us analyze the previous 11 bars.
self.window = RollingWindow[TradeBar](11)
Then we can use our window to calculate if the middle bar is a pivot point.
middleBar = self.window[5]
middleHigh = middleBar.High
for i in range(5):
if self.window[i].High > middleHigh:
return False
for i in range(6, 11):
if self.window[i].High > middleHigh:
return False return True
Best Rahul
Shner
833
,
Very nice, I changed it slightly so it will always find the index in the middle of the window, as long as the len(self.window) is an odd number.
@classmethod
def GetMidIndex(cls, lst):
if len(lst) % 2 != 0:
return int((len(lst) / 2) - 0.5)
else:
raise Exception('Length list not odd')
def PivotPointHigh(self):
lst = list(self.window)
mid_index = self.GetMidIndex(lst)
mid_bar = lst[mid_index]
lst2 = [x for index, x in enumerate(lst) if index != mid_index]
for bar in lst2:
if bar.High >= mid_bar.High:
return False
return True
Louis Szeto
45.8k
,
Hi All
Please be noted that LEAN now supports PivotPointHighLow candlestick indicator. Please refer to this page for details.
Best Louis
Shner
833
,
Hey Louis Szeto, I see there are two documentation URL's, one for lean V1 and for version 2, is there any difference between them ? more specifically for indicators that are present only in Lean V2 (like the SuperTrend and Pivot Point H/L) Shner,
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.
Rahul Chowdhury
Hi Tomer,
Although Lean does not have a built-in pivot point high/low indicator, you can implement it yourself. Let's say we want to create a 5 period pivot point high indicator. We can accomplish this using a rolling window of size 11, which will let us analyze the previous 11 bars.
self.window = RollingWindow[TradeBar](11)Then we can use our window to calculate if the middle bar is a pivot point.
middleBar = self.window[5] middleHigh = middleBar.High for i in range(5): if self.window[i].High > middleHigh: return False for i in range(6, 11): if self.window[i].High > middleHigh: return False return TrueBest
Rahul
Shner
Very nice, I changed it slightly so it will always find the index in the middle of the window, as long as the len(self.window) is an odd number.
Louis Szeto
Hi All
Please be noted that LEAN now supports PivotPointHighLow candlestick indicator. Please refer to this page for details.
Best
Louis
Shner
Hey Louis Szeto, I see there are two documentation URL's, one for lean V1 and for version 2, is there any difference between them ?
more specifically for indicators that are present only in Lean V2 (like the SuperTrend and Pivot Point H/L)
Shner,
Vladimir
Louis Szeto
Thank you for the good news.
In the attached backtest, I'm trying to compare two PivotPointHighLow candlestick indicators.
self.pphld is based on daily data, and self.pphl is based on a resampled 390-minute bar.
For some reason, the commented out part of the code throws an error.
Tomer Fridland
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!