This here is my take on the popular indicator with several novel features including:
- Dual smoothing.
- Arithmetic and Mean plots.
- Custom Anchor feat. Intraday Session Sizes.
- 2 Pairs of Bands.
- Side Input for Connection to other Indicator.
This can be used 'out of the box' as a replacement , benefitting from smoother transitions and easy-to-use custom alerts.
By design however, this is intended to be a highly customisable alternative with many adjustable parameters and a pseudo-modular input system to connect with another indicator. Well suited for the tweakers around here and those who like to get a little more creative.
I made this primarily for crypto although it should work for other markets. Default settings are best suited to 15m timeframe - the anchor of 1 week is ideal for crypto which often follows a cyclical nature from Monday through Sunday. In 15m, the default length of 21 means that the wap comes to match a standard towards the end of Monday. If using higher chart timeframes, i recommend decreasing the length to closely match this principle (suggested: for 1h chart, try length = 8; for 4h chart, length = 2 or 3 should suffice).
Note: the use of mean calculations will cause problems on any data source incorporating both positive and negative values, it may also return unusable results on extremely low-value charts (eg: low-sat coins in / btc pairs).
The development of this project was one driven more by experimentation than a specific end-goal, however i have tried to fine-tune everything into a coherent usable end-product. With that in mind then, this walkthrough will follow something of a development chronology as i dissect the various functions.
At its core this is based upon / adapted from the standard indicator provided by TradingView although I have modified and changed most of it. The first mod is the dual smoothing. Rather than simply applying an to the output of the standard function, instead i have incorporated the in a manner analogous to the way smas are used within a standard . Sticking for now with the arithmetic mean, the basic calculation is simply sum(source * ) / sum( ) across the anchored period. In this case i have simply applied an to each of the numerator and denominator values resulting in (sum(source * )) / (sum( )) with the length independent of the anchor. This results in smoother (albeit slower) transitions than the aforementioned post-vwap method. Furthermore in the case when anchor period is equal to current timeframe, the result is a basic volume-weighted .
The example below shows a standard (1week anchor) in blue, a 21-ema applied to the in purple and a dual-21-ema smoothed wap in gold . Notably both types come to effectively resemble the standard after around 24 hours into the new anchor session but how they behave in the meantime is very different. The dual-ema transitions quite gradually while the post-vwap immediately sets about trying to catch up. Incidentally. a similar and slower variation of the dual-ema can be achieved with dual-rma although i have not included it in this indicator, attempted analogues using or were far less useful however.
STANDARD DEVIATION AND BANDS
With this updated calculation, a corresponding update to the standard deviation is also required. The has its own anchored volume-weighted st.dev but this cannot be used in combination with the smoothing so instead it has been recalculated appropriately. There are two pairs of bands with separate multipliers (stepped to 0.1x) and in both cases high and low bands can be activated or deactivated individually. An example usage for this would be to create different upper and lower bands for profit and stoploss targets. Alerts can be set easily for different crossing conditions, more on this later.
Alongside the bands, i have also added the option to shift ('Deviate') the entire indicator up or down according to a multiple of the corrected st.dev value. This has many potential uses, for example if we want to bias our analysis in one direction it may be useful to move the wap in the opposite. Or if the asset is trading within a narrow range and we are waiting on a breakout, we could shift to the desired level and set alerts accordingly. The 'Deviate' parameter applies to the entire indicator including the bands which will remain centred on the main WAP.
Ever thought about using a with anchor periods smaller than a day? Here you can do just that. I've removed the /Dividends/Splits options from the basic and added an 'Intraday' option instead. When selected, a custom anchor length can be created as a multiple of minutes (default steps of 60 mins but can input any value from 0 - 1440). While this may not seem at first like a useful feature for anyone except hi-speed scalpers, this actually offers more interesting potential than it appears.
When set to 0 minutes the current timeframe is always used, turning this into the basic volume-weighted mentioned earlier. When using other low time frames the anchor can act as a pre-ema filter creating a stepped effect akin to an . Used in combination with the bands, the result is a kind of volume-weighted adaptive exponential ; if such a thing does not already exist then this is where you create it. Alternatively, by combining two instances you may find potential interesting crosses between an intraday wap and a standard timeframe wap. Below is an example set to intraday with 480 mins, 2x st.dev bands and length 21. Included for comparison in purple is a standard 21 .
I'm sure there are many potential uses to be found here, so be creative and please share anything you come up with in the comments.
ARITHMETIC AND MEAN CALCULATIONS
The standard uses the arithmetic mean in its calculation. Indeed, most mean calculations tend to be arithmetic: being the most widely used example. When weighting is involved though this can lead to a slight bias in favour of upward moves over downward. While the effect of this is minor, over longer anchor periods it can become increasingly significant. The mean, on the other hand, has the opposite effect which results in a value that is always lower than the arithmetic mean. By viewing both arithmetic and waps together, the extent to which they diverge from each other can be used as a visual reference of how much price has changed during the anchored period.
Furthermore, the mean may actually be the more appropriate one to use during downtrends or periods, in principle at least. Consider that a short trade is functionally the same as a long trade on the inverse of the pair (eg: selling BTC /USD is the same as buying USD/ BTC ). With the mean being an inverse of the arithmetic then, it makes sense to use it instead. To illustrate this below is a snapshot of LUNA/USDT on the left with its inverse 1/(LUNA/USDT) = USDT/LUNA on the right. On both charts is a wap with identical settings, note the resistance on the left and its corresponding support on the right. It should be easy from this to see that the lower wap on the left corresponds to the upper arithmetic wap on the right. Thus, it would appear that the mean should be used in a downtrend. In principle, at least...
In reality though, it is not quite so black and white. Rarely are these values exact in their predictions and the sort of range one should allow for inaccuracies will likely be greater than the difference between these two means. Furthermore, the smoothing has already introduced some lag and thus additional inaccuracies. Nevertheless, the symmetry warrants its inclusion.
SIDE INPUT & ALERTS
Finally we move on to the pseudo-modular component here. While TradingView allows some interoperability between indicators, it is limited to just one connection. Any attempt to use multiple source inputs will remove this functionality completely. The workaround here is to instead use custom 'string' input menus for additional sources, preserving this function in the sole 'source' input. In this case, since the wap itself is dependant only price and , i have repurposed the full 'source' into the second 'side' input. This allows for a separate indicator to interact with this one that can be used for triggering alerts. You could even use another instance of this one (there is a hidden wap:mid plot intended for this use which is the midpoint between both means). Note that deleting a connected indicator may result in the deletion of those connected to it.
Preset alertconditions are available for crossings of the side input above and below the main wap, alongside several customisable alerts with corresponding visual markers based upon selectable conditions. Alerts for band crossings apply only to those that are active and only crossings of the type specified within the 'crosses' subsection of the indicator settings. The included options make it easy to create buy alerts specific to certain bands with sell alerts specific to other bands. The chart below shows two instances with differing anchor periods, both are connected with buy and sell alerts enabled for visible bands.
Okay... So that just about covers it here, i think. As mentioned earlier this is the product of various experiments while i have been learning my way around PineScript. Some of those experiments have been branched off from this in order to not over-clutter it with functions. The pseudo-modular design and the 'side' input are the result of an attempt to create a connective framework across various projects. Even on its own though, this should offer plenty of tweaking potential for anyone who likes to venture away from the usual standards, all the while still retaining its core purpose as a traders tool.
Thanks for checking this out. I look forward to any feedback below.
When I first published this I was not aware that the 'indicator on indicator' function required to fully utilise the side input was restricted by Tradingview to Premium and Pro+ accounts only, meaning that many of you have been unable to use this feature as intended. I have noted this limitation in the tooltips and consequently added a bunch of standard MAs to the 'Side' section so now everyone can at least make use of the crossings and alerts.
Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.