I have 2 timeframes, for example 15 minutes and 4 hours, and want to calculate volume ma on them. I wrote a function for it, now I want to use a for
loop for this purpose. But I have faced some errors.
The function:
def volume_ma(timeframe=M15, length=20):
timeframe['volume_ma'] = ta.sma(timeframe['tick_volume'], length=length)
volume_ma()
Loop:
dataframes = {'M1': M1, 'H4': H4}
for name, sublist in dataframes.items():
volume_ma(name)
Ok,sorry it solved
for name,sublist in dataframes.items():
volume_ma(timeframe=sublist)
and another solution is not using dictionaries. It can be solved just by using a simple list of dataframes like this:
dataframes = [M1,H4]
for dataframe in dataframes:
volume_ma(dataframe= dataframe)