
    'i
                     B    d dl mZmZmZmZ ddlmZmZ  G d de      Zy)    )absolute_importdivisionprint_functionunicode_literals   )MovingAverageBaseMovAvc                   H     e Zd ZdZdZdZdej                  ffZ fdZ	 xZ
S )HullMovingAveragea6  By Alan Hull

    The Hull Moving Average solves the age old dilemma of making a moving
    average more responsive to current price activity whilst maintaining curve
    smoothness. In fact the HMA almost eliminates lag altogether and manages to
    improve smoothing at the same time.

    Formula:
      - hma = wma(2 * wma(data, period // 2) - wma(data, period), sqrt(period))

    See also:
      - http://alanhull.com/hull-moving-average

    Note:

      - Please note that the final minimum period is not the period passed with
        the parameter ``period``. A final moving average on moving average is
        done in which the period is the *square root* of the original.

        In the default case of ``30`` the final minimum period before the
        moving average produces a non-NAN value is ``34``
    )HMAHullMA)hma_movavc                    | j                   j                  | j                  | j                  j                        }d| j                   j                  | j                  | j                  j                  dz        z  }t        | j                  j                  d      }| j                   j                  ||z
  t        |            | j                  _        t        t        | /          y )N)periodg       @   g      ?)pr   dataparamsr   powintlinesr   superr   __init__)selfwmawma2
sqrtperiod	__class__s       W/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/hma.pyr   zHullMovingAverage.__init__:   s    ffmmDIIdkk.@.@mATVV]]499T[[5G5G15L]MM++S1
tcz#j/J

 	/1    )__name__
__module____qualname____doc__aliasr   r	   WMAr   r   __classcell__)r   s   @r    r   r      s1    , EE #%F2 2r!   r   N)	
__future__r   r   r   r    r   r	   r    r!   r    <module>r,      s!   ** * '%2) %2r!   