
この戦略は123の反転指標とRAVI指標を組み合わせて取引信号を生成する.その中,123の反転は反転戦略であり,株価の2日連続の動きを利用して将来の価格動きを判断する.RAVI指標は,価格が超買い超売り領域に入っているかどうかを判断する.この戦略は,2つの信号の総合的な判断によって,空白を余計にすることを決定する.
この指標は,ランダムな指標K値に基づいている.具体的には,当日の閉盘価格が前2日より低く,そして9日のランダムな慢線が50より低ければ多すぎる.当日の閉盘価格が前2日より高く,そして9日のランダムな快線が50より高ければ空いている.このように,逆転点によって入場を確認する.
この指標は,快線と慢線の離散によって買いを判断する.具体的には,7日平均線と65日平均線の離散である.あるパラメータより大きい時は多し,あるパラメータより小さい時は空し.快慢線金叉死叉によって超買超売り区間判断する.
123の反転とRAVIの同向多空の時に信号が生成する。多空の信号は2つの指標に同1であり,空の信号は2つの指標に同-1である。このように,二重指標によって確認し,単一の指標の誤信号を避ける。
この戦略は,反転要因とトレンド要因を総合的に考慮し,双指標確認によって誤信号発射の確率を減らす.次のステップは,機械学習アルゴリズムを導入し,自適應パラメータの最適化を実現する.または,戦略の組み合わせを考慮し,他の戦略タイプとの組み合わせを形成し,利益を維持しながら最大限の反転を減らす.
/*backtest
start: 2023-11-20 00:00:00
end: 2023-12-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 31/05/2021
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
// The strategy sells at market, if close price is lower than the previous close price
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Second strategy
// The indicator represents the relative convergence/divergence of the moving
// averages of the financial asset, increased a hundred times. It is based on
// a different principle than the ADX. Chande suggests a 13-week SMA as the
// basis for the indicator. It represents the quarterly (3 months = 65 working days)
// sentiments of the market participants concerning prices. The short moving average
// comprises 10% of the one and is rounded to seven.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
vFast = sma(stoch(close, high, low, Length), KSmoothing)
vSlow = sma(vFast, DLength)
pos = 0.0
pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0)))
pos
RAVI(LengthMAFast, LengthMASlow, TradeLine) =>
pos = 0.0
xMAF = sma(close, LengthMAFast)
xMAS = sma(close, LengthMASlow)
xRAVI = ((xMAF - xMAS) / xMAS) * 100
pos:= iff(xRAVI > TradeLine, 1,
iff(xRAVI < TradeLine, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & Range Action Verification Index (RAVI)", shorttitle="Combo", overlay = true)
line1 = input(true, "---- 123 Reversal ----")
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
line2 = input(true, "---- Range Action Verification Index (RAVI) ----")
LengthMAFast = input(title="Length MA Fast", defval=7)
LengthMASlow = input(title="Length MA Slow", defval=65)
TradeLine = input(0.14, step=0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posRAVI = RAVI(LengthMAFast, LengthMASlow, TradeLine)
pos = iff(posReversal123 == 1 and posRAVI == 1 , 1,
iff(posReversal123 == -1 and posRAVI == -1, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1 )
strategy.entry("Long", strategy.long)
if (possig == -1 )
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )