Page 1 of 1

Exponential Moving Average

Posted: Mon Oct 23, 2017 11:45 am
by murphy
Hello Everyone,

I was hoping to get some help or advice, i want to plot a bollinger band based on a exponential moving average with a .25 std deviation.

I did notice the bollinger classic indicator but it is based on a simple moving average.

My coding abilities would be similar to a goldfish and iv been harrassing Earik enough already :D

Best Regards,

Peter.

Re: Exponential Moving Average

Posted: Wed Oct 25, 2017 4:31 pm
by earik
Hi Peter,

Try this:

Code: Select all

input: price(close),length(14),standarddev(0.25),color(red);

sdev = stdev(price,length);
xavg = xaverage(price,length);

bb_up = xavg + (standarddev * sdev);
bb_dn = xavg - (standarddev * sdev);

plot1 = bb_up;
color1 = color;
plot2 = bb_dn;
color2 = color;
Copy that, paste into a new script, set the scaling to "price" in QScript Properties, Build it, and it will show up in the "Technicals" menu. Let me know if you get stuck.

Earik

Re: Exponential Moving Average

Posted: Wed Oct 25, 2017 6:51 pm
by murphy
Hi Earik,
Thanks for the quick reply.
Im getting the following when I try to compile the script:

ERROR:Unknown function"stdev" (Line3)
ERROR: Illegal Math expression. (Line3)

Re: Exponential Moving Average

Posted: Thu Oct 26, 2017 5:05 pm
by earik
Oops. Try stddev rather than stdev (two d's vs just one). Typo on my part...

Regards,

Earik

Re: Exponential Moving Average

Posted: Thu Oct 26, 2017 5:20 pm
by murphy
Earik that worked perfect.

A boring indicator to some,but a very important part of my price action studies.

Thank you very much. :D :D