(df, r1, r2, r3, r4, n1, n2, n3, n4)
return out(SETTINGS, df, result)
KST Oscillator
KST Oscillator
KST Oscillator
def KST(df, r1, r2, r3, r4, n1, n2, n3, n4):
    """
    KST Oscillator
    """
    M = df['Close'].diff(r1 - 1)
    N = df['Close'].shift(r1 - 1)
    ROC1 = M / N
    M = df['Close'].diff(r2 - 1)
    N = df['Close'].shift(r2 - 1)
    ROC2 = M / N
    M = df['Close'].diff(r3 - 1)
    N = df['Close'].shift(r3 - 1)
    ROC3 = M / N
    M = df['Close'].diff(r4 - 1)
    N = df['Close'].shift(r4 - 1)
    ROC4 = M / N
    result = pd.Series(ROC1.rolling(n1).sum() + ROC2.rolling(n2).sum() * 2 + ROC3.rolling(n3).sum() * 3 + ROC4.rolling(n4).sum() * 4, name='KST_' + str(r1) + '_' + str(r2) + '_' + str(r3) + '_' + str(r4) + '_' + str(n1) + '_' + str(n2) + '_' + str(n3) + '_' + str(n4))
    return out(SETTINGS, df, result)
def KST ( df , r1 , r2 , r3 , r4 , n1 , n2 , n3 , n4 ) : M = df [ 'Close' ] . diff ( r1 - 1 ) N = df [ 'Close' ] . shift ( r1 - 1 ) ROC1 = M / N M = df [ 'Close' ] . diff ( r2 - 1 ) N = df [ 'Close' ] . shift ( r2 - 1 ) ROC2 = M / N M = df [ 'Close' ] . diff ( r3 - 1 ) N = df [ 'Close' ] . shift ( r3 - 1 ) ROC3 = M / N M = df [ 'Close' ] . diff ( r4 - 1 ) N = df [ 'Close' ] . shift ( r4 - 1 ) ROC4 = M / N result = pd . Series ( ROC1 . rolling ( n1 ) . sum ( ) + ROC2 . rolling ( n2 ) . sum ( ) * 2 + ROC3 . rolling ( n3 ) . sum ( ) * 3 + ROC4 . rolling ( n4 ) . sum ( ) * 4 , name = 'KST_' + str ( r1 ) + '_' + str ( r2 ) + '_' + str ( r3 ) + '_' + str ( r4 ) + '_' + str ( n1 ) + '_' + str ( n2 ) + '_' + str ( n3 ) + '_' + str ( n4 ) ) return out ( SETTINGS , df , result )