-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable Index Dynamic Average VIDYA #116
Comments
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. |
thanks buddy i will try and inform you about it works properly... |
oh well, you bet (RMI + VWMACD + TKE are in #117) 👍 |
thenx man i add my indicators file...that is corrrect results...thank you for help.... |
Thanks for the feedback, added it to #117 too. |
hi, indicator calculation does not match tradingview. |
well the link is for a completely different indicator (OTT) - so i'm not sure how that comment is relevant here. |
Thank you for the answer.
|
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, ...). |
https://tr.tradingview.com/script/64ynXU2e/
can anyone help write this indicator ?
it is a good filter..
The text was updated successfully, but these errors were encountered: