Giter Club home page Giter Club logo

Comments (9)

tarantula3535 avatar tarantula3535 commented on May 18, 2024 1

thenx man i add my indicators file...that is corrrect results...thank you for help....
#117 I hope I could help..

from technical.

xmatthias avatar xmatthias commented on May 18, 2024 1

If you think an indicator is wrong and you have a fix, please open a pull request submitting the fix (please with sample code/screenshots showing missalignment / new alignment with tradingview).

Please understand that i'll not be extracting code from issue comments - which will have me repeat the work you already did (compare it with tradingview, ...).

from technical.

xmatthias avatar xmatthias commented on May 18, 2024

I guess the following should work:

def VIDYA(dataframe, length=9, select=True):
    """
    Source: https://www.tradingview.com/script/64ynXU2e/
    Author: Tushar Chande
    Pinescript Author: KivancOzbilgic
    
    To achieve the goals, the indicator filters out the market fluctuations (noises) 
    by averaging the price values of the periods, over which it is calculated. 
    In the process, some extra value (weight) is added to the average prices, 
    as it is done during calculations of all weighted indicators, such as EMA , LWMA, and SMMA. 
    But during the VIDIYA indicator's calculation, every period's price 
    receives a weight increment adapted to the current market's volatility .
        
    select: True = CMO, False= StDev as volatility index
    usage:
      dataframe['VIDYA'] = VIDYA(dataframe)
    """
        df = dataframe.copy()
    alpha = 2 / (length + 1)
    df['momm'] = df['close'].diff()
    df['m1'] = np.where(df['momm'] >= 0, df['momm'], 0.0)
    df['m2'] = np.where(df['momm'] >= 0, 0.0, -df['momm'])
    
    df['sm1'] = df['m1'].rolling(length).sum()
    df['sm2'] = df['m2'].rolling(length).sum()
    
    df['chandeMO'] = 100 * (df['sm1'] - df['sm2']) / (df['sm1'] + df['sm2'])
    if select:
        df['k'] = abs(df['chandeMO']) / 100
    else:
        df['k'] = df['close'].rolling(length).std()
    df.fillna(0.0, inplace=True)

    df['VIDYA'] = 0.0
    for i in range(length, len(df)):
        
        df['VIDYA'].iat[i] = alpha * df['k'].iat[i] * df['close'].iat[i] + (1 - alpha * df['k'].iat[i]) * df['VIDYA'].iat[i-1]
    
    return df['VIDYA']

I'm no expert in pinescript though - so please help me validate this so we can add it to technical in the future.

from technical.

tarantula3535 avatar tarantula3535 commented on May 18, 2024

thanks buddy i will try and inform you about it works properly...
I hope you took a look at my other indicator posts..
i checked it and they are working properly
supertrend , MADR , VWMACD , RMI ... and the others.. @xmatthias

from technical.

xmatthias avatar xmatthias commented on May 18, 2024

oh well, you bet (RMI + VWMACD + TKE are in #117) 👍

from technical.

xmatthias avatar xmatthias commented on May 18, 2024

Thanks for the feedback, added it to #117 too.

from technical.

acemi1 avatar acemi1 commented on May 18, 2024

hi, indicator calculation does not match tradingview.
I found a code that works correctly.
However, I am a beginner in python. I can't give you ready code.

#97 (comment)

from technical.

xmatthias avatar xmatthias commented on May 18, 2024

well the link is for a completely different indicator (OTT) - so i'm not sure how that comment is relevant here.

from technical.

acemi1 avatar acemi1 commented on May 18, 2024

Thank you for the answer.
There is no error in the link. Calculating "vidya" in OTT indicator. Written as df['var'] in the code.
I took the relevant part in the code of the OTT indicator and tried to make it usable. The results are the same as with Tradindview.


def vidya (dataframe=df, length = 4, source="close"):

    alpha = 2 / (length + 1)
    df['ud1'] = np.where(df[source] > df[source].shift(1), (df[source] - df[source].shift()), 0)
    df['dd1'] = np.where(df[source] < df[source].shift(1), (df[source].shift() - df[source]), 0)
    df['UD'] = df['ud1'].rolling(9).sum()
    df['DD'] = df['dd1'].rolling(9).sum()
    df['CMO'] = ((df['UD'] - df['DD']) / (df['UD'] + df['DD'])).fillna(0).abs()


    df['Var'] = 0.0
    for i in range(length, len(df)):
        df['Var'].iat[i] = (alpha * df['CMO'].iat[i] * df[source].iat[i]) + (1 - alpha * df['CMO'].iat[i]) * \
                           df['Var'].iat[
                               i - 1]
    # print("vidya indicator\n", df['Var'])
    return df['Var']

vidya ()

vidya.py.txt

from technical.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.