twopirllc / pandas-ta

Technical Analysis Indicators - Pandas TA is an easy to use Python 3 Pandas Extension with 150+ Indicators
https://twopirllc.github.io/pandas-ta/
MIT License
5.5k stars 1.08k forks source link

vwap #384

Closed Ylelmon closed 3 years ago

Ylelmon commented 3 years ago

How to have different vwap with different inputs ?

twopirllc commented 3 years ago

Hello @Ylelmon,

There are four required inputs as described in help(ta.vwap). What do you want to input or replace? The more specific you are, the better I can help you.

Kind Regards, KJ

Ylelmon commented 3 years ago

Periods like this cumulativePeriod1 = input(210, "Period") Tpv1 = sum(typicalPriceVolume, cumulativePeriod1) cumulativeVolume1 = sum(volume, cumulativePeriod1) vwapValue1 = tpv/ cumulativeVolume1 And have another Vwap but have different input

twopirllc commented 3 years ago

@Ylelmon,

cumulativePeriod1 = input(210, "Period")

What is input?

I think I understand that:

Tpv1 = sum(typicalPriceVolume, cumulativePeriod1) cumulativeVolume1 = sum(volume, cumulativePeriod1) vwapValue1 = tpv/ cumulativeVolume1

depends on cumulativePeriod1 above. But I still do not understand what you are trying to achieve.



Since vwap has four different inputs: high, low, close, volume, you can replace one of them or any combination of them but you have to do it explicitly.

For instance, if you wanted the vwap of strictly close (or high or low for that matter) and volume, you could do:

df = # your ohlcv data

# Default anchor is D for Daily
vwapc = ta.vwap(df.close, df.close, df.close, df.volume, anchor="D") # Default

Here are the other Timeseries Offset Aliases you can use for an anchor.

Kind Regards, KJ

Ylelmon commented 3 years ago

That one vwap I'm trying to put multiple vwap in the chart and every vwap had different periods like this image

twopirllc commented 3 years ago

@Ylelmon,

Are you sure that is vwap? If so, what is the source (where the image is from)? Are you sure you do not mean vwma, which uses defined periods?

Note: vwma is not vwap. For more info:

import pandas_ta as ta
help(ta.vwma)

KJ

Ylelmon commented 3 years ago

I'm sure it is vwap and the picture from TradingView

That the code

typicalPrice = (high + low + close) / 3 typicalPriceVolume = typicalPrice * volume

cumulativePeriod1 = input(210, "Period") cumulativeTypicalPriceVolume1 = sum(typicalPriceVolume, cumulativePeriod1) cumulativeVolume1 = sum(volume, cumulativePeriod1) vwapValue1 = cumulativeTypicalPriceVolume1 / cumulativeVolume1 plot(vwapValue1,title='210',color=#35e8ff,style=circles)

cumulativePeriod2 = input(400,"Period2") cumulativeTypicalPriceVolume2 = sum(typicalPriceVolume, cumulativePeriod2) cumulativeVolume2 = sum(volume, cumulativePeriod2) vwapValue2 = cumulativeTypicalPriceVolume2 / cumulativeVolume2 plot(vwapValue2,title='400',color=#f995ff,style=circles,transp=1,linewidth=1)

It has the same calculation of the vwap in pandas_ta

Ylelmon commented 3 years ago

imagethat what look like in chart

twopirllc commented 3 years ago

@Ylelmon,

Ahhhh... so https://github.com/twopirllc/pandas-ta/issues/384#issuecomment-912066556 is a TV Pinescript indicator. Please provide an html link to the source.

It has the same calculation of the vwap in pandas_ta

I would not assume that since TV's builtin vwap is anchor based just like Pandas TA's vwap.

Thanks, KJ

Ylelmon commented 3 years ago

What do u mean by HTML ? HTML the language like by python? Or something else because I don't understand what u what

twopirllc commented 3 years ago

@Ylelmon,

Whose code is it?

Screen Shot 2021-09-02 at 3 08 50 PM Screen Shot 2021-09-02 at 3 10 16 PM Screen Shot 2021-09-02 at 3 10 25 PM Screen Shot 2021-09-02 at 3 10 34 PM
Ylelmon commented 3 years ago

You can't find it if u search it in tradingview it files someone code it and u just copy and pasted in the pin scrip

Ylelmon commented 3 years ago

I already sent to u

twopirllc commented 3 years ago

@Ylelmon,

Those are all the public TV vwaps. You must have used one of them. If you are unable to identify which one you used, then I can not help you until you figure it out. Nor am I going to spend my time going through each one to figure it out.

Ylelmon commented 3 years ago

It in my script and u can't search it in tradingview but thx for try to help

twopirllc commented 3 years ago

@Ylelmon,

Ok. To be clear, it's not the same as TV's builtin nor Pandas TA's vwap.