这是一个基于拉鲁连费通道指标的反转交易策略。它通过计算过去一定时间周期内的最高价和最低价,来确定当前价格是否处在超买超卖区域。如果价格接近上轨或下轨,则进行反向开仓,等待价格回归中线。
该策略主要基于两个指标:百分比R指标(%R)和拉鲁连费通道上下轨。
百分比R指标是显示当前收盘价距离最近一段时间的最高价和最低价的距离,数值区间为0至-100,数值接近0表示当前收盘价接近最近一段时间的最高点,数值接近-100表示当前收盘价接近最近一段时间的最低点。
拉鲁连费通道由上轨、中线和下轨组成。上轨等于最近一段时间的最高价,下轨等于最近一段时间的最低价,中线为上下轨的平均值。如果价格超过上轨则视为超买,如果价格低于下轨则视为超卖。
该策略首先计算百分比R指标和拉鲁连费通道的上下轨,然后利用两个指标判断目前是否处于超买超卖状态:
如果当前既不处于超买也不处于超卖状态,则在开市时做多开仓。当天收市前平仓退出。
这样通过捕捉价格的反转,可以在短线内获利。
可以通过优化参数,调整做单时间,或与其他指标组合来降低风险。
该策略整体来说较为简单实用,通过反转交易思路设计,适合短线频繁交易。优化空间较大,可以引入更多技术指标组合使用,也可以建立自动止损机制来控制风险。
/*backtest
start: 2023-11-04 00:00:00
end: 2023-12-04 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
//@version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zweiprozent original strategy by larry williams
strategy("Daily PercentR Strategy", overlay=false)
D_High = security(syminfo.tickerid, 'D', high[1])
D_Low = security(syminfo.tickerid, 'D', low[1])
D_Close = security(syminfo.tickerid, 'D', close[1])
D_Open = security(syminfo.tickerid, 'D', open[1])
LowMarker = input(-87,"Low Marker",input.integer)
HighMarker = input(-20,"High Marker",input.integer)
length = input(title="Length", type=input.integer, defval=3)
src = input(close, "Source", type = input.source)
_pr(length) =>
max = highest(length)
min = lowest(length)
100 * (src - max) / (max - min)
percentR = _pr(length)
obPlot = hline(LowMarker, title="Upper Band", color=#606060)
hline(-50, title="Middle Level", linestyle=hline.style_dotted, color=#606060)
osPlot = hline(HighMarker, title="Lower Band", color=#606060)
fill(obPlot, osPlot, title="Background", color=color.new(#9915ff, 90))
plot(percentR, title="%R", color=#3A6CA8, transp=0)
// Go Long - if percentR is not overbought/sold
ordersize=floor(strategy.equity/close)
if percentR<HighMarker and percentR>LowMarker
strategy.entry("Long", strategy.long,comment="Long")
//exit at end of session
if low[0]<high[0]
strategy.close("Long", comment="exit")