Enhanced Wave Trend Oscillator For ThinkOrSwim

TG1212

New member
Author states:
The Enhanced WaveTrend Oscillator is a modified version of the original WaveTrend. The WaveTrend indicator is a popular technical analysis tool used to identify overbought and oversold conditions in the market and generate trading signals. The enhanced version addresses certain limitations of the original indicator and introduces additional features for improved analysis and comparison across assets.

WaveTrend:
The original WaveTrend indicator calculates two lines based on exponential moving averages and their relationship to the asset's price. The first line measures the distance between the asset's price and its EMA, while the second line smooths the first line over a specific period. The result is divided by 0.015 multiplied by the smoothed difference ('d' for reference). The indicator aims to identify overbought and oversold conditions by analyzing the relationship between the two lines.

In the original formula, the rudimentary estimation factor 0.015 times 'd' fails to accommodate for approximately a quarter of the data, preventing the indicator from reaching the traditional stationary levels of +-100. This limitation renders the indicator quantitatively biased, as it relies on the user's subjective adjustment of the levels. The enhanced version replaces this factor with the standard deviation of the asset's price, resulting in improved estimation accuracy and provides a more dynamic and robust outcome, we thereafter multiply the result by 100 to achieve a more traditional oscillation.


RmTPtZ0.png


Original Tradingview code found
https://www.tradingview.com/script/9GmOkVyH-Enhanced-WaveTrend-Oscillator/

Must scroll down to the next post for the new ThinkOrSwim code
 
Last edited by a moderator:
check the below:

CSS:
#// Indicator for TOS
#// © EliCobra
# indicator("Enhanced WaveTrend Oscillator", "[Ʌ] -‌ 𝗪𝗮𝘃𝗲𝗧𝗿𝗲𝗻𝗱", false)
# Converted by Sam4Cok@Samer800    - 11/2024
declare lower;

input Source  = {"open", "high", "low", "close", "oc2", "hl2", default "hlc3", "ohlc4", "hlcc4"};
input ChannelLength = 10; #, "Channel
input AverageLength = 21; # "Average
input SignalLength  = 4;  # "Signal
input showSignals = yes;
input ReversionThreshold = { default "100" , "125"}; # "Reversion Threshold",
input barColoring = {default "None", "Midline Cross", "Extremities", "Reversions", "Slope"}; # "Bar Coloring"

def na = Double.NaN;
def last = IsNaN(close);

def src;
switch (Source) {
case "open"  :
    src = open;
case "high"  :
    src = high;
case "low"   :
    src = low;
case "close" :
    src = close;
case "oc2"   :
    src = (open + close) / 2;
case "hl2"   :
    src = hl2;
case "ohlc4" :
    src = ohlc4;
case "hlcc4" :
    src = (high + low + 2 * close) / 4;
default      :
    src = hlc3;
}
def revt;
switch (ReversionThreshold) {
case "125" :
    revt = 125;
default :
    revt = 100;
}

Script wave {
input src = hlc3;
input clen = 10;
input alen = 21;
input slen = 4;
    def m = ExpAverage(src, clen);
    def d = stdev(src, clen);
    def o = ExpAverage  ((src - m) / d * 100, alen);
    def s = ExpAverage  (o                , slen);
    plot oo = o;
    plot ss = s;
    plot hh = o - s;
}

def wto = wave(src, ChannelLength, AverageLength, SignalLength).oo;
def wts = wave(src, ChannelLength, AverageLength, SignalLength).ss;
def wth = wave(src, ChannelLength, AverageLength, SignalLength).hh;

def colof = wto > wts;
def colh = if wth > 0 then (if wth > wth[1] then 2 else 1) else (if wth > wth[1] then -1 else -2);

plot w = wto; # "WT"
plot h = wth; # "H"
plot m = if last then na else 0;

w.SetLineWeight(2);
m.SetDefaultColor(Color.DARK_GRAY);
w.AssignValueColor(if colof then Color.CYAN else Color.MAGENTA);
h.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
h.AssignValueColor(if colh== 2 then Color.GREEN else
                   if colh== 1 then Color.DARK_GREEN else
                   if colh==-1 then Color.DARK_RED else
                   if colh==-2 then Color.RED else Color.GRAY);
#-- cloud
def max = if last then na else 150;
def hh  = if last then na else 125;
def lh  = if last then na else 100;
def min = if last then na else -150;
def ll  = if last then na else -125;
def hl  = if last then na else -100;
def s   = wts; #

AddCloud(max, hh , Color.DARK_ORANGE);
AddCloud(max, lh, Color.DARK_ORANGE);
AddCloud(hl, min , Color.VIOLET);
AddCloud(ll, min, Color.VIOLET);
AddCloud(w , s  , Color.CYAN, Color.MAGENTA);

# signals
def as = (wto Crosses Above wts) and wto < -revt;
def ab = (wto Crosses Below wts) and wto >  revt;
def au = (wto Crosses Above    0);
def ad = (wto Crosses Below    0);
def ax = (wto Crosses Above wts);
def ay = (wto Crosses Below wts);

plot sigDn = if showSignals then if ab then wto + 40 else na else na; # "OB"
plot sigUp = if showSignals then if as then wto - 40 else na else na; # "OS"
sigDn.SetStyle(Curve.POINTS);
sigUp.SetStyle(Curve.POINTS);
sigDn.SetDefaultColor(Color.MAGENTA);
sigUp.SetDefaultColor(Color.CYAN);

#-- bar Color
def col;
Switch (barColoring) {
Case "Midline Cross": col = if wto > 0 then 1 else -1;
Case "Extremities"  : col = if wto > revt then 1 else if wto < -revt then -1 else 0;
Case "Reversions"   : col = if ab then -1 else if as then 1 else 0;
Case "Slope"        : col = if colof then 1 else -1;
Default             : col = 0;
}

AssignPriceColor(if !col then Color.CURRENT else
                 if col>0 then Color.CYAN else
                 if col<0 then Color.MAGENTA else Color.GRAY);

#-- END of CODE
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
330 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top