High time frame Pivot Anchored VWAP V1.0

JohnBaron アップデート済   
To provide VWAPs anchored on the high and low pivots. I have seen scripts which anchor VWAP on a session or time frame or indeed a time, but not yet one that anchors on pivot points.

As many have stated, price action tends toward VWAPs. I named the VWAPs anchored on high pivots the Selling VWAP, representing the volume weighted average of the sellers. And the VWAPs anchored on the low pivots, Buying VWAP, representing the volume weighted average of the buyers.

One of these two governs the current price action.

What is unique about this script:
- Locates pivots also found in higher time frames (it does not use the Security Function, technically it does not locate high time frame pivots)
- It uses a simple technique to locate the pivots that avoids using "For Loops" , typically used with HTF Pivots and at times can cause time outs
- VWAPs are then anchored on the pivots
- High Pivots are anchored with a VWAP using the High price as the source
- Low Pivots are anchored with a VWAP using the Low price as the source

How to Use It
- Choose the higher time frame pivots of interest, the script uses current time frame multiplier
- so on a 1 minute chart, 60 is 1 hour. On a 5 min chart the same multiplier would be 5 hours.

- Choose how many of the higher time frame bars define the pivot, the right side and left side
- the default is 8 and 4, for a 60 multiplier on a 1min chart it implies 4hrs right of the pivot and 8 hrs left of the pivot.

- A Vidya moving average is included
- When the ma crosses over the Selling VWAP then the system is dominated by the buyers and the Buying VWAP provides support
- When the ma crosses under the Buying VWAP then the system is dominated by the sellers and the Selling VWAP provides resistance

It helps by keeping you in a trade, also by using the support/resistance to add to a position.

I make those decisions in the script, and display only the dominating VWAP

PineCoders for their functions on managing resolution.
LucF for his work on high time frame pivots.

Future considerations
- Provide option to show both VWAPs
- Use a different ma, such as VWMA, or provide a choice.
- Open the script, version 1.0 being what it is

Two Updates.
- updated the source for the ma to be volume based
- added an option to show the underlying VWAPS
- Minor update to fix one bug and add option to display or remove pivot lines

Scalping example, 2 minute chart, settings at multiple for pivots of 8x chart (16 min), 8,4 and 15.
- Added another custom ma, volatility and volume weighted with choice of using symmetrical weighting
- Added some tool tips
- Added a time based moving VWAP - look back window using a fixed time (this is not anchored)

Added some explainers on the chart.
  • Add search for pivots prior to most recent and to pull the vwap from them
  • Removed the governing vwap and replaced with Buy/Sell labels
  • Target points now shown using historical pivot data
  • Updated VNV MA function
  • Added another moving average which does not take paramters

    How to use
    Set the chart time frame multiplier to find pivots in higher time frames, for example if looking at 5min chart, then multiplier of 12 would generate 1 hour pivots.
    Set your desired MA length - this only applies to the VNVW and Vidya
    Allow one of the ma's to be your signal line and when it crosses a buying or selling vwap then that's a trigger, Buy/Sell target points could also be established by looking at the buy or sell vwap

A wholesale set of improvements in this iteration
  • The choice to limit the number of candles to see the most recent high and low pivot
  • High time frame VWAP now uses parameter-less calculation, not based on bars but based on the security function
  • The ability to define which moving average to use for the cross test, the formula does a test to ensure a real cross occurs - so you will not see an exact cross on the average you choose
  • Color schemes to show you when a pivot other than the most recent is used as an anchor for VWAP
  • Color scheme to show you when a VWAP is held flat because the price moved away from it
  • Better test for a valid historical pivot to use for an anchor
  • Added Bull/Bear markers to highlight when your choice of MA crosses a VWAP
  • More tool tips added on the Input Screen

In the displayed chart, switches are turned on to show the most recent pivots and to show the high time frame VWAP.
Any questions please post for a reply.
An important small change, the script will now re-validate the most recent pivot for the VWAP at each bar. Previously if the most recent VWAP was out of bounds it found a historical pivot to anchor and kept using that historical pivot going forward until the next pivot was found. With this change, the script will check the most recent pivot and see if it is now in bounds and valid.

This is a subtle but important change.
An update for usability and bug fixes.
  • Switched from current chart time multiple to simply selecting the resolution of the pivots
  • Added an error message if the chosen resolution exceeds the bars available in the chart history
  • Removed the choice of length to the left or the right of the pivot. Choosing a different resolution will provide the same results in terms of pivots identified.
  • Fixed an error generate by pine with large numbers for more accurate placement of the pivot
  • Continuous calculation of valid pivot for VWAP anchor, including the most recent pivot
  • Higher resolution parameter-less VWAP is now smoother and does not change with any changes in current time frame
  • Added the choice to see the high/low pivot markers
  • Changed the colors used for pivot lines (if shown) so they are more distinct than vwap lines

Reminder that the script does look back in history to find valid anchors. For example with the selling vwap, those anchored on high pivots, if the price is higher than the most recent high pivot selling vwap, the script will look back and find a higher pivot with an anchored vwap that is higher than the current price. These can be used as targets for trades anticipating the higher vwap to be a point of resistance. Opposite for low pivot anchored vwaps - older and lower pivot anchored vwaps will act as support.