Open tredondo opened 4 years ago
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
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.
@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
@djflux: I was using Ubuntu and I submitted a patch to add EMA support for Bollinger Bands.
Hope it gets merged.
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))
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?