admin管理员组文章数量:1356032
I'm trying to create a simple volatility indicator in Indie but keep getting an error when trying to import the standard deviation algorithm. I'm new to Indie language after coming from Pine.
I'm getting this error:
Error: 3:39 package indie.algorithms does not contain symbol Stdev
Here's my code:
# indie:lang_version = 5
from indie import indicator, param, plot, color, source, MainContext
from indie.algorithms import Stdev, Ema
@indicator("StdDev Volatility Indicator")
@param.int("length", default=20, min=1, title="StdDev Period")
@param.int("smooth_length", default=10, min=1, title="Smoothing Period")
@param.float("threshold_high", default=2.0, title="High Volatility Threshold")
@param.float("threshold_medium", default=1.0, title="Medium Volatility Threshold")
@param.source("source", default=source.CLOSE, title="Price Source")
@plot.line(title="StdDev", color=color.BLUE)
@plot.line(title="Smoothed StdDev", color=color.RED)
@plot.line(title="High Threshold", color=color.RED(0.5))
@plot.line(title="Medium Threshold", color=color.YELLOW(0.5))
class Main(MainContext):
def calc(self, length, smooth_length, threshold_high, threshold_medium, source):
stddev = Stdev.new(source, length)
smoothed_stddev = Ema.new(stddev, smooth_length)
avg_stddev = Ema.new(stddev, length * 3)[0]
high_threshold = avg_stddev * threshold_high
medium_threshold = avg_stddev * threshold_medium
return (
stddev[0], # Raw standard deviation
smoothed_stddev[0], # Smoothed standard deviation
high_threshold, # High volatility threshold line
medium_threshold # Medium volatility threshold line
)
Has anyone encountered this before? Is there a different way to calculate standard deviation in Indie?
I know in Pine Script I could just use ta.stdev()
but I'm not sure what the equivalent is here.
I'm trying to create a simple volatility indicator in Indie but keep getting an error when trying to import the standard deviation algorithm. I'm new to Indie language after coming from Pine.
I'm getting this error:
Error: 3:39 package indie.algorithms does not contain symbol Stdev
Here's my code:
# indie:lang_version = 5
from indie import indicator, param, plot, color, source, MainContext
from indie.algorithms import Stdev, Ema
@indicator("StdDev Volatility Indicator")
@param.int("length", default=20, min=1, title="StdDev Period")
@param.int("smooth_length", default=10, min=1, title="Smoothing Period")
@param.float("threshold_high", default=2.0, title="High Volatility Threshold")
@param.float("threshold_medium", default=1.0, title="Medium Volatility Threshold")
@param.source("source", default=source.CLOSE, title="Price Source")
@plot.line(title="StdDev", color=color.BLUE)
@plot.line(title="Smoothed StdDev", color=color.RED)
@plot.line(title="High Threshold", color=color.RED(0.5))
@plot.line(title="Medium Threshold", color=color.YELLOW(0.5))
class Main(MainContext):
def calc(self, length, smooth_length, threshold_high, threshold_medium, source):
stddev = Stdev.new(source, length)
smoothed_stddev = Ema.new(stddev, smooth_length)
avg_stddev = Ema.new(stddev, length * 3)[0]
high_threshold = avg_stddev * threshold_high
medium_threshold = avg_stddev * threshold_medium
return (
stddev[0], # Raw standard deviation
smoothed_stddev[0], # Smoothed standard deviation
high_threshold, # High volatility threshold line
medium_threshold # Medium volatility threshold line
)
Has anyone encountered this before? Is there a different way to calculate standard deviation in Indie?
I know in Pine Script I could just use ta.stdev()
but I'm not sure what the equivalent is here.
1 Answer
Reset to default 1In Indie, it's called StdDev
. You can import it this way from indie.algorithms import StdDev
You can read StdDev docs and use built-in indicators as examples.
So your code will be:
# indie:lang_version = 5
from indie import indicator, param, plot, color, source, MainContext
from indie.algorithms import StdDev, Ema
@indicator("StdDev Volatility Indicator")
@param.int("length", default=20, min=1, title="StdDev Period")
@param.int("smooth_length", default=10, min=1, title="Smoothing Period")
@param.float("threshold_high", default=2.0, title="High Volatility Threshold")
@param.float("threshold_medium", default=1.0, title="Medium Volatility Threshold")
@param.source("source", default=source.CLOSE, title="Price Source")
@plot.line(title="StdDev", color=color.BLUE)
@plot.line(title="Smoothed StdDev", color=color.RED)
@plot.line(title="High Threshold", color=color.RED(0.5))
@plot.line(title="Medium Threshold", color=color.YELLOW(0.5))
class Main(MainContext):
def calc(self, length, smooth_length, threshold_high, threshold_medium, source):
stddev = StdDev.new(source, length)
smoothed_stddev = Ema.new(stddev, smooth_length)
avg_stddev = Ema.new(stddev, length * 3)[0]
high_threshold = avg_stddev * threshold_high
medium_threshold = avg_stddev * threshold_medium
return (
stddev[0], # Raw standard deviation
smoothed_stddev[0], # Smoothed standard deviation
high_threshold, # High volatility threshold line
medium_threshold # Medium volatility threshold line
)
本文标签: Standard Deviation Indicator in IndieImport ErrorStack Overflow
版权声明:本文标题:Standard Deviation Indicator in Indie - Import Error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744055928a2583250.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论