
    'i                     F    d dl mZmZmZmZ ddlmZmZmZ  G d de      Z	y)    )absolute_importdivisionprint_functionunicode_literals   )	IndicatorMovAvATRc                   J     e Zd ZdZdZdZddej                  ffZ fdZ	 xZ
S )PrettyGoodOscillatora  
    The "Pretty Good Oscillator" (PGO) by Mark Johnson measures the distance of
    the current close from its simple moving average of period
    Average), expressed in terms of an average true range (see Average True
    Range) over a similar period.

    So for instance a PGO value of +2.5 would mean the current close is 2.5
    average days' range above the SMA.

    Johnson's approach was to use it as a breakout system for longer term
    trades. If the PGO rises above 3.0 then go long, or below -3.0 then go
    short, and in both cases exit on returning to zero (which is a close back
    at the SMA).

    Formula:
      - pgo = (data.close - sma(data, period)) / atr(data, period)

    See also:
      - http://user42.tuxfamily.org/chart/manual/Pretty-Good-Oscillator.html

    )PGOPrettyGoodOsc)pgo)period   _movavc                 8   | j                   j                  | j                  | j                   j                        }t	        | j                  | j                   j                        }| j                  |z
  |z  | j
                  _        t        t        | '          y )N)r   )
pr   datar   r
   linesr   superr   __init__)selfmovavatr	__class__s      h/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/prettygoodoscillator.pyr   zPrettyGoodOscillator.__init__7   sd    dii>$))DFFMM2))e+s2

"D24    )__name__
__module____qualname____doc__aliasr   r	   Simpleparamsr   __classcell__)r   s   @r   r   r      s1    * &EEx68F5 5r   r   N)

__future__r   r   r   r    r   r	   r
   r    r   r   <module>r*      s#   ** * $ # 59  5r   