
이 전략은 역전환 요인과 대역 통로 요인에 의해 공동으로 구동되는 이중 요인 조합 전략으로, 다중 요인 중첩을 구현하여 다양한 시장 환경에서 전략적 이점을 발휘할 수 있습니다.
이 전략은 다음의 두 가지 세부 전략으로 구성됩니다.
123 역전 전략: 2일 연속으로 하락한 후, 오늘 종료가격이 이전 2일 연속으로 하락한 최저값을 돌파하고, 9일 무작위 지표의 빠른 선에서 느린 선을 통과하면, 더 많이 한다. 2일 연속으로 상승한 후, 오늘 종료가격이 이전 2일 연속으로 최고값을 넘어섰을 때, 동시에 9일 무작위 지표의 빠른 선 아래 느린 선을 통과하면, 공백한다.
파장 필터: 일정 주기 내의 가격의 파장 지표를 계산하여, 파장 지표가 특정 절치값보다 크면 더하고, 파장 지표가 특정 절치값보다 작으면 공백하게 한다.
조합 신호는: 123 역전 전략과 파장 필터 전략이 동조 신호인 경우, 다수 포지션을 취한다. 둘 다 동조 신호인 경우, 동조 포지션을 취한다. 그렇지 않으면 포지션을 청산한다.
이 전략은 복합적으로 반전 인자와 트렌드 인자를 적용하여 다인자 구동의 정량 거래를 구현한다. 이중 인자 검증으로 잘못된 거래의 가능성을 줄여서 전략이 다양한 시장에서 우수한 성능을 발휘한다. 이후 파라미터 조정 및 스톱 손실 설정을 통해 전략의 안정성과 수익성을 향상시킬 수 있다.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 21/05/2019
// This is combo strategies for get
// a cumulative signal. Result signal will return 1 if two strategies
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// 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 related article is copyrighted material from
// Stocks & Commodities Mar 2010
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
//
// 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
Bandpass_Filter(Length, Delta, TriggerLevel) =>
xPrice = hl2
beta = cos(3.14 * (360 / Length) / 180)
gamma = 1 / cos(3.14 * (720 * Delta / Length) / 180)
alpha = gamma - sqrt(gamma * gamma - 1)
BP = 0.0
pos = 0.0
BP := 0.5 * (1 - alpha) * (xPrice - xPrice[2]) + beta * (1 + alpha) * nz(BP[1]) - alpha * nz(BP[2])
pos := iff(BP > TriggerLevel, 1,
iff(BP <= TriggerLevel, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & Bandpass Filter", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthBF = input(20, minval=1)
Delta = input(0.5)
TriggerLevel = input(0)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBandpass_Filter = Bandpass_Filter(LengthBF, Delta, TriggerLevel)
pos = iff(posReversal123 == 1 and posBandpass_Filter == 1 , 1,
iff(posReversal123 == -1 and posBandpass_Filter == -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 ? red: possig == 1 ? green : blue )