The volume-weighted average price (VWAP) is a popular ratio used in intraday trading. In this article we will modify the standard VWAP into a more flexible version. You can use it for any time period – not only intraday. But before we start with our multi-day version of the VWAP, let us start with some basics.
The standard VWAP works only intraday
What is the VWAP? It is the average price weighted against its trading volume within a particular time frame. Basically you multiply the price with volume for each bar and cumulate this figure bar by bar. At the same time you also cumulate the volume figures. The division of both components makes the VWAP. In the example below, you can see the Brent contract on a 5 minute basis in Tradesignal. The software calculates and visualises the VWAP for the current day starting at the first bar. On the next day, the procedure starts again with the open price.
How about a Multi-Day VWAP?
But how about using the VWAP for a longer period of time? This could be an interesting indicator to use for analysis or systematic trading. Please take a look at the chart below. It shows the Brent contract on an hourly basis. I already added the multi-day VWAP indicator we would like to code later on. Each VWAP starts at a different date and the software calculates it until the last data point instead of stopping at the end of the day. I picked two significant lows, because then we can track the price-volume-behavior since the end of each correction.
How to code the indicator in Equilla
And now let`s take a look at the code for this special VWAP indicator.
- In line 6 we define an input which enables us to pick a date when the VWAP calculation should start
- Lines 9 to 12 contain all variables we need for the calculation
- The calculation takes places in lines 16 to 19 (comments are highlighted in green)
- The main trick is to cumulate the results by referring to the previous value of each variable (  ) and adding the current value
As you can see, with a little bit of coding you can modify any existing indicator and create your own version of it. Start coding and implement this kind of indicator into your trading strategy – whether as a filter or entry or exit command.
Tradesignal® is a registered trademark of Tradesignal GmbH. Unauthorized use or misuse is strictly prohibited. Data by Thomson Reuters Eikon.