PINE LIBRARY
Cập nhật DominantCycle

Collection of Dominant Cycle estimators. Length adaptation used in the Adaptive Moving Averages and the Adaptive Oscillators try to follow price movements and accelerate/decelerate accordingly (usually quite rapidly with a huge range). Cycle estimators, on the other hand, try to measure the cycle period of the current market, which does not reflect price movement or the rate of change (the rate of change may also differ depending on the cycle phase, but the cycle period itself usually changes slowly). This collection may become encyclopaedic, so if you have any working cycle estimator, drop me a line in the comments below. Suggestions are welcome. Currently included estimators are based on the work of John F. Ehlers
mamaPeriod(src, dynLow, dynHigh) MESA Adaptation - MAMA Cycle
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
Returns: Calculated period
Based on MESA Adaptive Moving Average by John F. Ehlers
Performs Hilbert Transform Homodyne Discriminator cycle measurement
Unlike MAMA Alpha function (in LengthAdaptation library), this does not compute phase rate of change
Introduced in the September 2001 issue of Stocks and Commodities
Inspired by the everget implementation:
Inspired by the anoojpatel implementation:
paPeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Pearson Autocorrelation
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hann Windowing prefilter
Returns: Calculated period
Based on Pearson Autocorrelation Periodogram by John F. Ehlers
Introduced in the September 2016 issue of Stocks and Commodities
Inspired by the blackcat1402 implementation:![[blackcat] L2 Ehlers Adaptive CCI 2013](https://s3.tradingview.com/9/9CbjlKjz_mid.png)
Inspired by the rumpypumpydumpy implementation:
Corrected many errors, and made small speed optimizations, so this could be the best implementation to date (still slow, though, so may revisit in future)
High Pass and Super Smoother prefilters are used in the original implementation
dftPeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Discrete Fourier Transform
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hann Windowing prefilter
Returns: Calculated period
Based on Spectrum from Discrete Fourier Transform by John F. Ehlers
Inspired by the blackcat1402 implementation:![[blackcat] L2 Ehlers DFT-Adapted RSI](https://s3.tradingview.com/v/V6wCdSwQ_mid.png)
High Pass, Super Smoother and Hann Windowing prefilters are used in the original implementation
phasePeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Phase Accumulation
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hamm Windowing prefilter
Returns: Calculated period
Based on Dominant Cycle from Phase Accumulation by John F. Ehlers
High Pass and Super Smoother prefilters are used in the original implementation
doAdapt(type, src, len, dynLow, dynHigh, chandeSDLen, chandeSmooth, chandePower, preHP, preSS, preHP) Execute a particular Length Adaptation or Dominant Cycle Estimator from the list
Parameters:
type: Length Adaptation or Dominant Cycle Estimator type to use
src: Series to use
len: Reference lookback length
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
chandeSDLen: Lookback length of Standard deviation for Chande's Dynamic Length
chandeSmooth: Smoothing length of Standard deviation for Chande's Dynamic Length
chandePower: Exponent of the length adaptation for Chande's Dynamic Length (lower is smaller variation)
preHP: Use High Pass prefilter for the Estimators that support it (default)
preSS: Use Super Smoother prefilter for the Estimators that support it (default)
preHP: Use Hann Windowing prefilter for the Estimators that support it
Returns: Calculated period (float, not limited)
doEstimate(type, src, dynLow, dynHigh, preHP, preSS, preHP) Execute a particular Dominant Cycle Estimator from the list
Parameters:
type: Dominant Cycle Estimator type to use
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter for the Estimators that support it (default)
preSS: Use Super Smoother prefilter for the Estimators that support it (default)
preHP: Use Hann Windowing prefilter for the Estimators that support it
Returns: Calculated period (float, not limited)
mamaPeriod(src, dynLow, dynHigh) MESA Adaptation - MAMA Cycle
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
Returns: Calculated period
Based on MESA Adaptive Moving Average by John F. Ehlers
Performs Hilbert Transform Homodyne Discriminator cycle measurement
Unlike MAMA Alpha function (in LengthAdaptation library), this does not compute phase rate of change
Introduced in the September 2001 issue of Stocks and Commodities
Inspired by the everget implementation:

Inspired by the anoojpatel implementation:

paPeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Pearson Autocorrelation
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hann Windowing prefilter
Returns: Calculated period
Based on Pearson Autocorrelation Periodogram by John F. Ehlers
Introduced in the September 2016 issue of Stocks and Commodities
Inspired by the blackcat1402 implementation:
![[blackcat] L2 Ehlers Adaptive CCI 2013](https://s3.tradingview.com/9/9CbjlKjz_mid.png)
Inspired by the rumpypumpydumpy implementation:

Corrected many errors, and made small speed optimizations, so this could be the best implementation to date (still slow, though, so may revisit in future)
High Pass and Super Smoother prefilters are used in the original implementation
dftPeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Discrete Fourier Transform
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hann Windowing prefilter
Returns: Calculated period
Based on Spectrum from Discrete Fourier Transform by John F. Ehlers
Inspired by the blackcat1402 implementation:
![[blackcat] L2 Ehlers DFT-Adapted RSI](https://s3.tradingview.com/v/V6wCdSwQ_mid.png)
High Pass, Super Smoother and Hann Windowing prefilters are used in the original implementation
phasePeriod(src, dynLow, dynHigh, preHP, preSS, preHP) Phase Accumulation
Parameters:
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter (default)
preSS: Use Super Smoother prefilter (default)
preHP: Use Hamm Windowing prefilter
Returns: Calculated period
Based on Dominant Cycle from Phase Accumulation by John F. Ehlers
High Pass and Super Smoother prefilters are used in the original implementation
doAdapt(type, src, len, dynLow, dynHigh, chandeSDLen, chandeSmooth, chandePower, preHP, preSS, preHP) Execute a particular Length Adaptation or Dominant Cycle Estimator from the list
Parameters:
type: Length Adaptation or Dominant Cycle Estimator type to use
src: Series to use
len: Reference lookback length
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
chandeSDLen: Lookback length of Standard deviation for Chande's Dynamic Length
chandeSmooth: Smoothing length of Standard deviation for Chande's Dynamic Length
chandePower: Exponent of the length adaptation for Chande's Dynamic Length (lower is smaller variation)
preHP: Use High Pass prefilter for the Estimators that support it (default)
preSS: Use Super Smoother prefilter for the Estimators that support it (default)
preHP: Use Hann Windowing prefilter for the Estimators that support it
Returns: Calculated period (float, not limited)
doEstimate(type, src, dynLow, dynHigh, preHP, preSS, preHP) Execute a particular Dominant Cycle Estimator from the list
Parameters:
type: Dominant Cycle Estimator type to use
src: Series to use
dynLow: Lower bound for the dynamic length
dynHigh: Upper bound for the dynamic length
preHP: Use High Pass prefilter for the Estimators that support it (default)
preSS: Use Super Smoother prefilter for the Estimators that support it (default)
preHP: Use Hann Windowing prefilter for the Estimators that support it
Returns: Calculated period (float, not limited)
Phát hành các Ghi chú
v2 library updateThư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Tips in TradingView Coins are appreciated
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Tips in TradingView Coins are appreciated
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.