freqtrade / technical

Various indicators developed or collected for the Freqtrade

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using timeperiod in VWMA

straj-granicy opened this issue · comments

Hi.
I found interesting strategy on TradingView
https://ru.tradingview.com/script/LjT0cZUy-ATR-VWAP-Alert/
One of the indicators in VWMA.
In this strategy 2 VWMA been used. One with length 13, the other is with the lenght 62.
This indicator is implemeneted in Freqtrade.
Basically I'm trying to do this

from technical.indicators import vwma

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
#VWMA

    dataframe['vwma13'] = vwma (dataframe, timeperiod=13)
    dataframe['vwma62'] = vwma (dataframe, timeperiod=62)

When backtesting, I've got the following error

dataframe['vwma13'] = vwma (dataframe, length=13)
TypeError: vwma() got an unexpected keyword argument 'timeperiod'
I thought that we can choose the length of VWMA, as we can do for example with EMA
dataframe['ema3'] = ta.EMA(dataframe, timeperiod=3)

Or my thougths are completely wrong?

The correct parameter for vwma's timeperiod is is window, not timeperiod.

def vwma(df, window):
return (df["close"] * df["volume"]).rolling(window).sum() / df.volume.rolling(window).sum()

I'd recommend using a editor with code-completion setup (pycharm / vscode) - which will give you code completion, as well as hints as to what possible parameters are (many indicators don't have just 1 parameter, but 3 or 4).