本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=3
study("Mean Reversion Algo", overlay=true)
average(src, len) => sum(src, len) / len
src = input(close)
mean_period_short=input(5)
mean_period_long=input(20)
buy_threshold=input(1., step=0.01)
sell_threshold=input(1., step=0.01)
mean_short = average(src, mean_period_short)
mean_long = average(src, mean_period_long)
beta = mean_short / mean_long
plotshape(hlc3 > mean_long and beta > buy_threshold, location=location.bottom, style=shape.square, color=green, transp=70)
plotshape(hlc3 < mean_short and beta < sell_threshold, location=location.bottom, style=shape.square, color=red, transp=70)