On Balance Volume - Color Packed Patch'em

OBV is provided as a built-in by TradingView.

This contribution grew out of reading about trend discovery, and since the library kept on this end was lacking in a volume-centric indicator, it looked like a good time to play around.

This approach isn't all that much different than many others with the possible exception of its color scheme.

Should you decide to use the script, it might be worth your while to work with the logic of color and line, to produce alerts.


Release Notes: While the script is flawed, in the sense scaling does not employ an alpha, and the script, by consequence, does not work with all exchanges, or all symbols from an individual exchange, some improvements have been made.

Now you can set the Scale/Invert factor to reframe the context of calculations pertaining to volume relating to either high-close or close-low, fuchsia and lime lines, respectively.

To do this, simply change the sign before one or both of the scaling factors while leaving the factor in both cases the same. If you change only one sign, you invert the line in question and it intersects the other on the timeline. Changing the sign on both flips their positions, being mainly above or below their counterpart. Observing this, it's easy to see you can also jockey the lines using the MA length and different scaling factors. If you come up with an optimal setting, or fixes for problems you see, drop a comment, or send me a message, and I'll consider making changes to take the script down a better path.

Another feature, not remotely guaranteed to produce good results, results from breaking out enter and exit conditionals into more manageable functions which are better suited to encapsulating more complex conditionals. As stated, results can't be guaranteed here, mainly because the conditionals are not optimized.

And on that score, the conditionals now employed, while germane to producing alerts, are only loosely coupled to the setup of the analysis out of the box. Any changes you make to the settings before registering enter and/or exit alerts will be carried into how the alerts fire, and these new alert conditions are carried into alerts with the current code and settings, permanently, making use of the script with custom settings close to accurate only if you craft the settings and the conditionals together. You have to delete any alerts you've created, using your own naming convention for each alert as a guide as to which settings you've registered the alert to cover. It's a compromise of variations which does not resolve in the organization of the UX around the data flow to allow fine grained refactoring of alerts, or the conditionals they would cover; the api, as it stands does not allow it or 'recenter' it at that workflow juncture.

Still, it's all good. You've also got a zero point to use as a reference, directly relating to the core input for this indicator, volume.

I hope it serves all users' needs and brings each of you some enjoyment.

Happy coding and trading.
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. You can favorite it to use it on a chart.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?