
    Q-j`                         d dl mZ d dlmZmZmZmZmZ d dlm	Z	 d dl
mZmZmZ d dlmZmZmZ  ed      d        Z	 	 	 	 dd
e	dededededededede	fdZy	)    )njit)cosexpnansqrt
zeros_like)Series)DictLikeIntIntFloat)v_offsetv_pos_defaultv_seriesT)cachec                 4   | j                   d|z  |z  }}t        | |z        }d|z  t        d|z        z  }	||z  |	z
  dz   }
t        |       }t        |       }t        |       }t	        d|      D ]4  }d|
z  | |   | |dz
     z   z  |	||dz
     z  z   ||z  ||dz
     z  z
  ||<   6 t	        ||      D ]b  }d}t	        d|      D ]  }|||   |||z
     z
  z  } ||z  }||z  |z  d|z
  ||dz
     z  z   ||<   ||   dk7  sO|t        ||         z  ||<   d |S )N         g      ?r   g        )sizer   r   r   ranger   )xnkalphapisqrt2mratioabc_f_msresulti_sumjs                    g/Users/jameslopez/projects/TradingBot25/.venv/lib/python3.12/site-packages/pandas_ta/trend/trendflex.pynb_trendflexr)      s^   vvq5y1}uARC%KA	AC%K  A	A	AA	AB
Q-C]F1a[a1Q4!AE(?+a"QU)m;a!ebQi>OO1  1a[q!ABqEBq1uI%%D 	$E	SQZ'??Aq6S=tCF|+F1I  M    Ncloselengthsmoothr   r   r   offsetkwargsreturnc                    t        |d      }t        |d      }t        | t        ||      dz         } | yt        |d      }t        |d      }t        |d      }t        |      }| j	                         }t        ||||||      }	t        |	d| t        |	| j                        }	|dk7  r|	j                  |      }	d	|v r|	j                  |d	   d
       d| d| d| |	_        d|	_        |	S )u}  Trendflex

    This trend indicator, by John F. Ehlers, complements the "reflex"
    indicator.

    Sources:
        * [rengel8](https://github.com/rengel8) (2021-08-11) based on the
          implementation from "ProRealCode" (2021-08-11)
        * [prorealcode](https://www.prorealcode.com/prorealtime-indicators/reflex-and-trendflex-indicators-john-f-ehlers/)
        * [traders](http://traders.com/Documentation/FEEDbk_docs/2020/02/TradersTips.html)

    Parameters:
        close (Series): ```close``` Series
        length (int): The period. Default: ```20```
        smooth (int): Super Smoother period. Default: ```20````
        alpha (float): Alpha weight. Default: ```0.04```
        pi (float): Ehlers's truncated value: ```3.14159```.
            Default: ```3.14159```
        sqrt2 (float): Ehlers's truncated value: ```1.414```.
            Default: ```1.414```
        offset (int): Post shift. Default: ```0```

    Other Parameters:
        fillna (value): ```pd.DataFrame.fillna(value)```

    Returns:
        (Series): 1 column

    Note:
        John F. Ehlers introduced two indicators within the article
        "Reflex: A New Zero-Lag Indicator” in February 2020, TASC magazine.
        One of which is Reflex, a lag reduced cycle indicator. Both indicators
        (Reflex/Trendflex) are oscillators that complement each other with the
        focus for cycle and trend.
       r   Ng{Gz?gn!	@g9v?)indexr   fillnaT)inplace
TRENDFLEX__trend)r   r   maxr   to_numpyr)   r   r	   r3   shiftr4   namecategory)
r+   r,   r-   r   r   r   r.   r/   np_closer$   s
             r(   	trendflexr?   '   s   T 62&F62&FUC/!34E}%&E	r7	#B%'EfF ~~H(FFE2uEFF7FOF%++.F {f% 6fX&5 vhaxq8FKFOMr*   )NNNNNN)numbar   numpyr   r   r   r   r   pandasr	   pandas_ta._typingr
   r   r   pandas_ta.utilsr   r   r   r)   r?    r*   r(   <module>rF      s     1 1  5 5 = = D 6 "&*.+/	HHHH'H 	H !)H 	H #+	H
 Hr*   