
    'iM                         d dl mZmZmZmZ ddlmZmZmZm	Z	  G d de      Z
 G d de      Z G d d	e      Z G d
 de      Zy)    )absolute_importdivisionprint_functionunicode_literals   )	IndicatorMaxMinMovAvc                   &     e Zd ZdZdZ fdZ xZS )TrueHighaQ  
    Defined by J. Welles Wilder, Jr. in 1978 in his book *"New Concepts in
    Technical Trading Systems"* for the ATR

    Records the "true high" which is the maximum of today's high and
    yesterday's close

    Formula:
      - truehigh = max(high, close_prev)

    See:
      - http://en.wikipedia.org/wiki/Average_true_range
    )truehighc                     t        | j                  j                  | j                  j                  d            | j                  _        t        t        | #          y N)	r	   datahighcloselinesr   superr   __init__self	__class__s    W/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/atr.pyr   zTrueHigh.__init__+   s8    !$))..$))//"2EF

h&(    __name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      s     E) )r   r   c                   &     e Zd ZdZdZ fdZ xZS )TrueLowaM  
    Defined by J. Welles Wilder, Jr. in 1978 in his book *"New Concepts in
    Technical Trading Systems"* for the ATR

    Records the "true low" which is the minimum of today's low and
    yesterday's close

    Formula:
      - truelow = min(low, close_prev)

    See:
      - http://en.wikipedia.org/wiki/Average_true_range
    )truelowc                     t        | j                  j                  | j                  j                  d            | j                  _        t        t        | #          y r   )	r
   r   lowr   r   r&   r   r%   r   r   s    r   r   zTrueLow.__init__@   s8     		0CD

gt%'r   r   r#   s   @r   r%   r%   0   s     E( (r   r%   c                   *     e Zd ZdZdZdZ fdZ xZS )	TrueRangea  
    Defined by J. Welles Wilder, Jr. in 1978 in his book New Concepts in
    Technical Trading Systems.

    Formula:
      - max(high - low, abs(high - prev_close), abs(prev_close - low)

      which can be simplified to

      - max(high, prev_close) - min(low, prev_close)

    See:
      - http://en.wikipedia.org/wiki/Average_true_range

    The idea is to take the previous close into account to calculate the range
    if it yields a larger range than the daily range (High - Low)
    )TR)trc                     t        | j                        t        | j                        z
  | j                  _        t
        t        |           y )N)r   r   r%   r   r,   r   r*   r   r   s    r   r   zTrueRange.__init__[   s2     +gdii.@@

i')r   )r   r   r    r!   aliasr   r   r"   r#   s   @r   r*   r*   E   s    " EE* *r   r*   c                   P     e Zd ZdZdZdZddej                  ffZd Z	 fdZ
 xZS )AverageTrueRangea{  
    Defined by J. Welles Wilder, Jr. in 1978 in his book *"New Concepts in
    Technical Trading Systems"*.

    The idea is to take the close into account to calculate the range if it
    yields a larger range than the daily range (High - Low)

    Formula:
      - SmoothedMovingAverage(TrueRange, period)

    See:
      - http://en.wikipedia.org/wiki/Average_true_range
    )ATR)atr)period   movavc                     | j                   j                  g}|| j                   j                  g| j                   j                  d      z  z  }|S )Nr5   )pr3   r5   
notdefault)r   plabelss     r   
_plotlabelzAverageTrueRange._plotlabels   s>    66==/DFFLL>DFF$5$5g$>>>r   c                     | j                   j                  t        | j                        | j                   j                        | j
                  _        t        t        | '          y )N)r3   )
r7   r5   r+   r   r3   r   r2   r   r0   r   r   s    r   r   zAverageTrueRange.__init__x   s=    bmDFFMMJ

.0r   )r   r   r    r!   r.   r   r   Smoothedparamsr:   r   r"   r#   s   @r   r0   r0   `   s6     EEw78F
1 1r   r0   N)
__future__r   r   r   r    r   r	   r
   r   r   r%   r*   r0    r   r   <module>rA      sG   ** * ) ()y )*(i (**	 *61y 1r   