本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © NS91 2020
//@version=4
study("Reversal finder", overlay=true)
lookback = input(20, "Lookback period for highs and lows")
malen = input(20, "SMA length for candles range")
avrange = sma((high-low), malen)
mult = input(2.0, "Range multiple", type=input.float)
rangethreshold = input(33, "Range threshold (% of candle range)", maxval=99)/100
barcol = input(false, "Highlight signal bars?", type=input.bool)
longsig = (high-low)>=(avrange*mult) and ((low<lowest(low[1],lookback))) and (close>=(high-((high-low)*rangethreshold)))
shortsig = (high-low)>=(avrange*mult) and ((high>highest(high[1], lookback))) and (close<=(low+((high-low)*rangethreshold)))
plotshape(longsig, title="Long signal", style=shape.labelup, color=color.yellow, transp=1, location=location.belowbar, size=size.tiny)
plotshape(shortsig, title="Short signal", style=shape.labeldown, color=color.yellow, transp=1, location=location.abovebar, size=size.tiny)
barcolor(barcol ? barcol and longsig ? #00FF03 : barcol and shortsig ? #FF0000 : #4F4F4F : na)