(df, n)
return out(SETTINGS, df, result)
Vortex Indicator
Vortex Indicator
Vortex Indicator
def Vortex(df, n):
    """
    Vortex Indicator
    """
    i = 0
    TR = [0]
    while i < len(df) - 1:  # df.index[-1]:
        Range = 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.append(Range)
        i = i + 1
    i = 0
    VM = [0]
    while i < len(df) - 1:  # df.index[-1]:
        Range = abs(df.iat[i + 1, df.columns.get_loc('High')] - df.iat[i, df.columns.get_loc('Low')]) - abs(df.iat[i + 1, df.columns.get_loc('Low')] - df.iat[i, df.columns.get_loc('High')])
        VM.append(Range)
        i = i + 1
    result = pd.Series(pd.Series(VM).rolling(n).sum() / pd.Series(TR).rolling(n).sum(), name='Vortex_' + str(n))
    return out(SETTINGS, df, result)
def Vortex ( df , n ) : i = 0 TR = [ 0 ] while i < len ( df ) - 1 : # df.index[-1]: Range = 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 . append ( Range ) i = i + 1 i = 0 VM = [ 0 ] while i < len ( df ) - 1 : # df.index[-1]: Range = abs ( df . iat [ i + 1 , df . columns . get_loc ( 'High' ) ] - df . iat [ i , df . columns . get_loc ( 'Low' ) ] ) - abs ( df . iat [ i + 1 , df . columns . get_loc ( 'Low' ) ] - df . iat [ i , df . columns . get_loc ( 'High' ) ] ) VM . append ( Range ) i = i + 1 result = pd . Series ( pd . Series ( VM ) . rolling ( n ) . sum ( ) / pd . Series ( TR ) . rolling ( n ) . sum ( ) , name = 'Vortex_' + str ( n ) ) return out ( SETTINGS , df , result )