Get Updates:
Email
Twitter
RSS

Update: Wordpress chopped a line out of the code. It has since been fixed.

I was messing around with some moving average stuff and threw this one together to see what it looked like. It’s pretty simple: 1 = buy, -1 = sell, 0 = neutral. You can experiment with the filter percentage and period to suit your taste. I’ll probably incorporate this into other scripts as a filter.

Kaufman's Adaptive Moving Average Binary Wave

Kaufman's Adaptive Moving Average Binary Wave

# KAUFMANBINARYWAVE
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 27 Feb 2009

declare lower;
input price = close;
input period = 20;
input filterPercent = 10;
def diff = AbsValue(price - price[1]);
def signal = AbsValue(price - price[period]);
def noise = sum(diff, period);
def efRatio = signal / noise;
def fastSC = 0.6022;
def slowSC = 0.0645;
def smooth = Power(efratio * fastSC + slowSC, 2);
rec ama = compoundValue(period, "visible data" = ama[1] + smooth * (price - ama[1]), "historical data" = price
);
def filter = filterPercent/100 * stdev(ama - ama[1], period);
rec amaLow = if(ama < ama[1], ama, amaLow[1]);
rec amaHigh = if(ama > ama[1], ama, amaHigh[1]);
plot BinaryWave = if ama - amalow > filter then 1 else if amaHigh - ama > filter then -1 else 0;
BinaryWave.setDefaultColor(color.red);

4 Responses to “Kaufman’s Adaptive Moving Average Binary Wave”

  1. Gary says:

    Great looking indicator. I copied and pasted the script, but I am getting a few errors.

    Invalid statement: rec at 21:1
    No such variable: amalow at 22:28
    No such variable: amaHigh at 22:59
    doCalc: Invalid parameter

    Any idea why it wouldn’t work 1 for 1 on my setup? After putting an extra comma in the if statement where it seems on should go amaLow seems to be defined, but amaHigh is never declared? Any thoughts? I hope you had a great Friday night. ;) Thanks

  2. thinkscripter says:

    Sorry all – Bitten once again by Wordpress’ HTML editor which randomly throws things out when it doesn’t like them.

    The code is fixed now.

    -TS

  3. mac says:

    hi,
    finally, i found somebody in the www, who shares the same idea with me. I also developed a binary wave system in 2004 and i realy interested how your system works live. Can you explain your wave, please? Wich underlyings do you use?

    kind regards

    mac

Leave a Reply