
    'i                     ^    d dl mZmZmZmZ d dlZddlmZm	Z	  G d dej                        Zy)    )absolute_importdivisionprint_functionunicode_literalsN   )SMAROC100c                   j     e Zd ZdZdZdZdddddd	d
dddg dfdefdeffZ edg      Z	 fdZ
 xZS )KnowSureThinga  
    It is a "summed" momentum indicator. Developed by Martin Pring and
    published in 1992 in Stocks & Commodities.

    Formula:
      - rcma1 = MovAv(roc100(rp1), period)
      - rcma2 = MovAv(roc100(rp2), period)
      - rcma3 = MovAv(roc100(rp3), period)
      - rcma4 = MovAv(roc100(rp4), period)

      - kst = 1.0 * rcma1 + 2.0 * rcma2 + 3.0 * rcma3 + 4.0 * rcma4
      - signal = MovAv(kst, speriod)

    See:
      - http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:know_sure_thing_kst

    Params

      - ``rma1``, ``rma2``, ``rma3``, ``rma4``: for the MovingAverages on ROCs
      - ``rp1``, ``rp2``, ``rp3``, ``rp4``: for the ROCs
      - ``rsig``: for the MovingAverage for the signal line
      - ``rfactors``: list of factors to apply to the different MovAv(ROCs)
      - ``_movav`` and ``_movavs``, allows to change the Moving Average type
        applied for the calculation of kst and signal

    )KST)kstsignal)rp1
   )rp2   )rp3   )rp4   )rma1r   )rma2r   )rma3r   )rma4r   )rsignal	   rfactors)g      ?g       @g      @g      @_rmovav_smovavg        )
plothlinesc           	         | j                   j                  t        | j                   j                        | j                   j                        }| j                   j                  t        | j                   j
                        | j                   j                        }| j                   j                  t        | j                   j                        | j                   j                        }| j                   j                  t        | j                   j                        | j                   j                        }t        t        | j                   j                  ||||g      D cg c]
  \  }}||z   c}}      | j                  _        | j                   j!                  | j                  j                  | j                   j"                        | j                  _        t&        t(        | W          y c c}}w )N)period)pr   r	   r   r   r   r   r   r   r   r   sumzipr   lr   r   r   r   superr   __init__)selfrcma1rcma2rcma3rcma4rfirci	__class__s          W/var/www/app/trading-bot/venv/lib/python3.12/site-packages/backtrader/indicators/kst.pyr(   zKnowSureThing.__init__D   s5   vTVVZZ8MvTVVZZ8MvTVVZZ8MvTVVZZ8MdffooueU/KLNS#) N O
 tvvzz$&&..ImT+-	Ns   *G7
)__name__
__module____qualname____doc__aliaslinesr   paramsdictplotinfor(   __classcell__)r0   s   @r1   r   r      sa    4 EE[+{lL,	)*	C	CF u%H	. 	.    r   )
__future__r   r   r   r   
backtraderbt r   r	   	Indicatorr    r<   r1   <module>rC      s'   ** *  1.BLL 1.r<   