python-tradingview-ta icon indicating copy to clipboard operation
python-tradingview-ta copied to clipboard

add Volatility request

Open classicalBit opened this issue 4 years ago • 9 comments

Hey Brian,

I wanted to ask you if it is possible to add the volatility indicator (for crypto screener).

Thanks a lot!

classicalBit avatar Aug 26 '21 15:08 classicalBit

Hi @classicalBit,

I couldn't find the volatility indicator. Is it a custom script? TradingView-TA does not support Pine Script at the moment.

If it's not, you can use the add_indicators() function to add a built-in indicator. This isn't in the documentation yet.

folfcoder avatar Aug 27 '21 01:08 folfcoder

Hey,

no, sorry its not really an indicator. You can find it on the crypto screener at the cloumn settings. There is the option: volatility, volatility week and volatility month. (the three dots on the far right of the colums)

Maybe I will try the add indicator function :)

classicalBit avatar Aug 27 '21 06:08 classicalBit

@brian-the-dev Hello Brian, I have another question.

I managed to add new indicators to the single analysis, like this:

`handler = TA_Handler( symbol="MANAUSDT", exchange="binance", screener="crypto", interval=Interval.INTERVAL_1_DAY )

handler.add_indicators(["Volatility.D"])

analysis = handler.get_analysis() print("MANAUSDT", analysis.indicators["Volatility.D"])`

But I want to add new indicators to the get_multiple_analysis and I don´t know how to do that. Could you help me out?

classicalBit avatar Sep 13 '21 12:09 classicalBit

This is currently not implemented, but there is a workaround:

Just append "Volatility.D" to TradingView.indicators:

from tradingview_ta import *

# Add this line below
TradingView.indicators.append("Volatility.D")

analysis = get_multiple_analysis(screener="crypto", interval=Interval.INTERVAL_1_DAY, symbols=["binance:ethusdt", "binance:manausdt", "binance:btcusdt"])

# print(analysis["BINANCE:BTCUSDT"].indicators["Volatility.D"])
# Output: 6.32796553

Make sure to append only once, at the beginning of the code (preferably below import).

folfcoder avatar Sep 13 '21 14:09 folfcoder

@brian-the-dev Thanks a lot, it works but unfortunately only on the 1_DAY Interval, even if the volatility value is exactly the same on the 5 mins - 4h Intervals. For the single analysis it works also on the lower Intervals. Strange...

classicalBit avatar Sep 13 '21 14:09 classicalBit

sorry I made a mistake, it doesn´t work on the lower Intervals at all. Thats unfortunate because as I said, the value for the 1 min- 1 Day Interval, no matter what Interval, is the same. And i really like the set the Interval to 5 min and get the Volatility value....

classicalBit avatar Sep 13 '21 15:09 classicalBit

Hello Brian @brian-the-dev , I have another question.

I want to append those indicators to the multiple_analysis just like you did in the example above:

"change_abs|15", "change|15", "change_abs|60", "change|60", "change_abs|1", "change|1", "change_abs|240", "change|240", "change_abs|5", "change|5",

It doesnt work, even though it works on other indicators. (for example "ROC" or "Volatility.D") Am I doing something wrong?

classicalBit avatar Oct 07 '21 14:10 classicalBit

I want to add that they do work, but only for the 1 Day Interval. Is it possible to make it work for the other Intervals too?

classicalBit avatar Oct 07 '21 16:10 classicalBit

Normally, you don't need to add "|1", "|5", etc as tradingview-ta will automatically append them based on the interval. "change" indicator should work for all intervals. By default, "change" indicator is already included (in percentage) so you don't need to add it. If you want to get the absolute change instead of percentage, add the "change_abs" indicator.

If you're unable to get the change, a workaround is to calculate it manually:

  • Change (absolute) = close price - open price
analysis.indicators["close"]-analysis.indicators["open"]
  • Change (percentage) = absolute change / open price * 100
(analysis.indicators["close"]-analysis.indicators["open"]) / analysis.indicators["open"] * 100

folfcoder avatar Oct 11 '21 01:10 folfcoder