I'm trying to port a strategy from tradingview (pinescript) to a framework I built in nodejs.
My strategy uses breakouts on the Bollinger bands. in my pine script I've implemented the BBs with standard deviation ( basically copying the build-in indicator formula) as follows:
length = input(200, "BB Len", minval=1)
mult = input(1.5, "BB STD", minval=0.001, maxval=50, type=input.float)
basis = sma(src, length)
dev = mult * stdev(src, length)
upper1 = basis + dev
lower1 = basis - dev
Based on this a problem arose because of two reasons:
First reason.
As I can see in the explain of the STDDEV function in talib, there are three parameters instead of the two you get in the pine script version:
- inReal: the data serie
- optInNbDev: Deviations, with a default value of 1
- optInTimePeriod: Time Period, with a default value of 5 ( pine script does not have this )
Second reason.
As I noticed in the pine script reference in tradingview, it says that the stdev function is "a biased estimation of standard deviation.". I couldn't find any specific on this topic in the talib's doc, but I am assuming that they are applying the non-biased formula, based on some comments I found googleing here and there.
Based on this, do you think there would be a way to precisely replicate the tradingview behaviour using ta-lib?
question from:
https://stackoverflow.com/questions/65901574/stdev-differences-between-talib-and-pine-script-versions 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…