Skip to content

Instantly share code, notes, and snippets.

@benfasoli
Last active May 15, 2020 13:10
Show Gist options
  • Save benfasoli/324a727f6dc923e5844104a38208baba to your computer and use it in GitHub Desktop.
Save benfasoli/324a727f6dc923e5844104a38208baba to your computer and use it in GitHub Desktop.
thinkorswim WaveTrend Oscillator
# Ben Fasoli
# Last updated: 12/21/2016
#
# Ported from LazyBear's Pine script port
# https://www.tradingview.com/u/LazyBear/
#
# For an introduction, watch
# https://www.youtube.com/watch?v=7vhIsk51_Ro
# https://www.youtube.com/watch?v=MqJ1czF220M
def ap = hlc3;
def esa = ExpAverage(ap, 10);
def d = ExpAverage(AbsValue(ap - esa), 10);
def ci = (ap - esa) / (0.015 * d);
def tci = ExpAverage(ci, 21);
def wt1 = Round(tci, 1);
def wt2 = Average(wt1, 4);
plot WT_Fast = wt1;
plot WT_Slow = wt2;
plot WT_Diff = wt1 - wt2;
plot Zero = 0;
plot OS1 = -60;
plot OS2 = -53;
plot OB1 = 60;
plot OB2 = 53;
WT_Fast.SetDefaultColor(Color.CYAN);
WT_Slow.SetDefaultColor(Color.RED);
WT_Diff.SetDefaultColor(Color.ORANGE);
Zero.SetDefaultColor(Color.GRAY);
OS1.SetDefaultColor(Color.GREEN);
OS2.SetDefaultColor(Color.GREEN);
OB1.SetDefaultColor(Color.RED);
OB2.SetDefaultColor(Color.RED);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment