
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to calculate a VWAP indicator where the averaging period increases as time elapses from the start of the trading day. Right now, however, I can only design an indicator that calculates VWAP using a fixed period.
In general, VWAP is calculated as:
SUM(PiQi) / SUM(Qi)
Where Pi is the price for the given moment and Qi is the volume for the same moment
If someone could show me how to get my VWAP period to increase as time elapses from the start of each new day I would be very grateful. The formula should go something like this:
Time 1: (P1*Q1) / (Q1)
Time 2: (P1*Q1)+(P2*Q2) / (Q1+Q2)
Time 3: (P1*Q1)+(P2*Q2)+(P3*Q3) / (Q1+Q2+Q3)
...
Time24: (P1*Q1)+(P2*Q2)+(P3*Q3)...+(P24*Q24) / (Q1+Q2+Q3...+Q24)
Time1: (P1*Q1) / (Q1)
...
Here is the code that I have so far. Notice that the variable VWAP_Period is fixed at 20.
//---------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
}//----------------------------------------------------------------------------------------
Thank you for any help you can provide.