OPEN-SOURCE SCRIPT

+ WaveTrend Oscillator

Updated
I'm guessing most of you are familir with LazyBear's adaptation of the Wavetrend Oscillator; it's one of the most popular indicators on TradingView. I know others have done adaptations of it, but I thought I might as well, because that's kind of a thing I like doing.

In this version I've added a second Wavetrend plot. This is a thing I like to do. The longer plot gives you a longer timeframe momentum bias, and the shorter plot gives you entries and/or exits. Here we have one plot with a lookback period of 55, and another with the default set to 6 (change this to 14 if you think you might prefer something slower and that will plot similarly to the default RSI settings). With the traditional Wavetrend Oscillator there is a simple moving average on the WTO that is to help provide entries and exits. I've done away with this as there are already two plots, and I felt more would just clutter the indicator. Instead of plotting the SMA I've plotted the crosses along the bottom and top of the indicator. Also, as is not the case in LazyBear's version, this SMA length is adjustable. By default it is set to 3, which is the default setting on the original indicator.

I've also plotted background colors for when there is what I call a momentum shift. If one or the other oscillators crosses the centerline a colored bar is plotted. By default it is turned on for both WTOs, though in practice you might only want it on for the longer one.

I would say use of the indicator is similar to the original WTO or many other oscillators. Buying oversold and selling overbought, but being mindful of the momentum of the market. If the longer WTO is above the centerline it's best to be looking for dips to the centerline, or for an overbought signal by the faster WTO, and vice versa if the longer WTO is below the centerline. That said, you can also adjust the length of the SMA on the faster WTO to fine tune entries or exits, which is kind of how you would trade LazyBear's version. In this case you have that additional confirmation of market momentum.

You can set colored candles to either of the WTO plots via a dropdown menu.

There are alerts for overbought and oversold situations, centerline crosses, and Wavetrend crosses.

That's about it. Hope you enjoy this particular implementation of LazyBear's well known indicator.

Ah yes, last thing: Original version the source is set to hlc3. I've given you the opportunity to change that, so if you prefer using close you can, or whatever you want.
Release Notes
I've been adding auto-plotting divergences to my oscillator indicators over the past several days. In this edition I've made it optional to select whether they are drawn from the primary wavetrend or the secondary wavetrend.

I also added an additional candle coloring element for those who are very particular about candle colors. I've added an option that does not color in a gradient, but colors based on if the oscillator is in overbought or oversold zones, or somewhere in between. Additionally I've made it so that these zones are adjustable. There is information in the tooltip that I added, but essentially the thought is that you very rarely, in trending environments, see oscillators reverse all the way back to what might be considered oversold or overbought, but instead pullback anywhere from the center of the oscillator to maybe the mid section of the upper or lower half (if even that). Here you can adjust the level to where you might expect that pullback to come, so that, perhaps if you're not in a trade, you might receive some visual indication that here is a spot you might want to enter.
I likely went entirely overboard with this addition, but mostly it was just a port from something similar in my overlay version of the indicator that plots shapes at the top or bottom of the chart instead of coloring the candles. It's also probably only pertinent to people who use color to highlight things in specific ways, but, eh, like most of this stuff, you don't have to use it if you don't want to.

Below we see a chart with colors set to default settings. No color indications for spotting possible pullbacks, and a good amount of blue, illustrating a strong downtrend.
snapshot

Here, I have the inputs adjusted so that '40' is set as "overbought", and now we see visual cues in the candles where we might want to place a short (or get out of an underwater long). Furthermore, I set the as "oversold" -80. That probably doesn't matter so much, and it might actually be more useful to set it to a less negative number, and use the plotted bull divs to get into some risky fade longs, if you like higher risk setups such as that.
snapshot
Release Notes
fixed a display discrepancy in the style tab. carry on, nothing has changed. :)
Release Notes
added alerts for divergences
Release Notes
- updated to pinescript v5
- in the second wavetrend plot fixed what was supposed to be an SMA, but for some reason was an EMA, back to an SMA
Release Notes
- fixed an issue with changing the opacity of indicator plots--it actually works now
- added a couple of new candle color options, same as the overlay version
Release Notes
- just added an alert for the wavetrend crossing its moving average (the little blue and red dots above and below the oscillator)
Release Notes
- fixed a mistake in the calculation for second Wavetrend
- changed default values to calculations I prefer to use
Release Notes
I'm publishing updates to all of my indicators, so I'm just going to comment on everything here since most of the updates are common across most of my indicators.

User Non-Visible Updates (basically backend stuff that makes:
- changes in code legibility and consistency across all indicators (basically standardizing the coding across as many indicators as possible)
- implementation of libraries into my indicators; which helps significantly in doing what I typed above; which in turn will make creating any new indicators, if they are of the type to use these libraries, much simpler
- updated descriptions for all indicators, which should (it's possible I've forgotten things) reflect changes I've made recently and any I may have made in the past after first publication (this is very minor, but as I was changing so much I thought I may as well--I don't intend to update these much, if at all, in the future)

User Visible Updates:
- as I mentioned everything now uses my moving averages library and volatility bands library--this cuts down the total amount of code significantly, and has made it easier for me to add moving averages, or volatility bands to these indicators because I only had to/have to add it one time (to the library) rather than multiple times across all indicators*
- since creating these libraries I've added several new moving averages (Kaufman Adaptive, Laguerre Filter, McGinley Dynamic (doesn't work for all), and Zero-lag) to them while retaining all the previous with the exception of the UMA, which wasn't implemented consistently across all indicators anyway
- eliminated having two Bollinger Bands with different standard deviations and a fill between them in exchange for one with the band fill implementation that I use on my Donchian Channels Bands
- part of my code consistency across all indicators resulted in a much needed organization of the 'style' tab

*(affects all but the Wavetrend Oscillator, Wavetrend Oscillator Overlay, Jurik KDJ, Average Candle Bodies Range, Bollinger Bands Width, ALMA Trend Detector, Ultimate Moving Average, Donchian Channels, and Dynamic Donchian Channels)
barcolorCandlestick analysisDivergenceMomentum OscillatorsMoving AveragesnononsenseforexnononsensefxOscillatorswavetrendindicatorwavetrendoscillator

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer