(df)
return out(SETTINGS, df, result)
Ultimate Oscillator
Ultimate Oscillator
Ultimate Oscillator
def ULTOSC(df):
    """
    Ultimate Oscillator
    """
    i = 0
    TR_l = [0]
    BP_l = [0]
    while i < len(df) - 1:  # df.index[-1]:
        TR = max(df.iat[i + 1, df.columns.get_loc('High')], df.iat[i, df.columns.get_loc('Close')]) - min(df.iat[i + 1, df.columns.get_loc('Low')], df.iat[i, df.columns.get_loc('Close')])
        TR_l.append(TR)
        BP = df.iat[i + 1, df.columns.get_loc('Close')] - min(df.iat[i + 1, df.columns.get_loc('Low')], df.iat[i, df.columns.get_loc('Close')])
        BP_l.append(BP)
        i = i + 1
    result = pd.Series((4 * pd.Series(BP_l).rolling(7).sum() / pd.Series(TR_l).rolling(7).sum()) + (2 * pd.Series(BP_l).rolling(14).sum() / pd.Series(TR_l).rolling(14).sum()) + (pd.Series(BP_l).rolling(28).sum() / pd.Series(TR_l).rolling(28).sum()), name='Ultimate_Osc')
    return out(SETTINGS, df, result)
def ULTOSC ( df ) : i = 0 TR_l = [ 0 ] BP_l = [ 0 ] while i < len ( df ) - 1 : # df.index[-1]: TR = max ( df . iat [ i + 1 , df . columns . get_loc ( 'High' ) ] , df . iat [ i , df . columns . get_loc ( 'Close' ) ] ) - min ( df . iat [ i + 1 , df . columns . get_loc ( 'Low' ) ] , df . iat [ i , df . columns . get_loc ( 'Close' ) ] ) TR_l . append ( TR ) BP = df . iat [ i + 1 , df . columns . get_loc ( 'Close' ) ] - min ( df . iat [ i + 1 , df . columns . get_loc ( 'Low' ) ] , df . iat [ i , df . columns . get_loc ( 'Close' ) ] ) BP_l . append ( BP ) i = i + 1 result = pd . Series ( ( 4 * pd . Series ( BP_l ) . rolling ( 7 ) . sum ( ) / pd . Series ( TR_l ) . rolling ( 7 ) . sum ( ) ) + ( 2 * pd . Series ( BP_l ) . rolling ( 14 ) . sum ( ) / pd . Series ( TR_l ) . rolling ( 14 ) . sum ( ) ) + ( pd . Series ( BP_l ) . rolling ( 28 ) . sum ( ) / pd . Series ( TR_l ) . rolling ( 28 ) . sum ( ) ) , name = 'Ultimate_Osc' ) return out ( SETTINGS , df , result )