Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bollinger Bands - use EMA? #213

Open
tredondo opened this issue Apr 5, 2020 · 5 comments
Open

Bollinger Bands - use EMA? #213

tredondo opened this issue Apr 5, 2020 · 5 comments

Comments

@tredondo
Copy link

tredondo commented Apr 5, 2020

What type of MA does BB use? I don't see any docs.

I assume it uses SMA? Is there an option to use EMA?

@anandanand84
Copy link
Owner

BB uses SMA, currently it is not possible to use EMA, pull request welcome, similar feature is implemented in MACD, https://github.com/anandanand84/technicalindicators/blob/master/src/moving_averages/MACD.ts#L31

@tredondo
Copy link
Author

tredondo commented Apr 7, 2020

I tried installing the package but it broke at canvas.

Is there a lightweight way of adding tests? If I just add an option to an indicator, seems like a test should just compare the output to an array.

@djflux
Copy link

djflux commented May 16, 2020

@tredondo what OS are you using to do development? I had the same issue as you did getting canvas installed. Currently using node v12.16.3 on macOS Catalina.

I've played around with the packages.json file a little and I think I got it working but can't seem to get things rolling.

Let me know.

Thanks,
Flux

@tredondo
Copy link
Author

tredondo commented Aug 6, 2020

@djflux: I was using Ubuntu and I submitted a patch to add EMA support for Bollinger Bands.

Hope it gets merged.

@jere-0
Copy link

jere-0 commented Sep 12, 2021

You can just copy the original script and change SMA to EMA on the 6th line.
Or copy and paste the below script to the blank pine editor and save accordingly.

//@Version=4
study(shorttitle="BB", title="Bollinger Bands", overlay=true, resolution="")
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ema(src, length) //<--------------------------------------CHANGED FROM SMA TO EMA
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants