
이 글은 쌍평평선 전략과 무작위 지표의 조합으로 사용되는 양적 거래 전략을 소개한다. 이 전략은 이동평선의 트렌드 추적 능력을 통합적으로 활용하고 무작위 지표의 과매매 특성을 사용하여 거래 신호를 형성한다.
이 전략은 두 부분으로 구성되어 있습니다.
빠른 이동 평균선과 느린 이동 평균선을 사용하여 금포 구매 신호와 죽은 포 판매 신호를 형성한다. 빠른 평균선은 가격 변화의 흐름을 더 빨리 포착할 수 있고, 느린 이동 평균선은 가짜 신호를 필라한다.
무작위 지표의 흔들림 특성을 이용하여 과매매 상황을 식별한다. 무작위 지표가慢線보다 높으면 과매매 신호이며, 무작위 지표가慢線보다 낮으면 과매매 신호이다.
두 부분의 신호를 통합한 후 최종 거래 신호를 형성한다. 쌍평선 전략은 주요 트렌드를 추적하고, 무작위 지표는 불리한 상황을 피하는 것을 보조한다.
최적화 변수 조합을 통해 위험을 줄일 수 있고, 손실을 제어하기 위해 스톱을 추가할 수도 있다.
이 전략은 다음과 같은 측면에서 최적화될 수 있습니다.
이 전략은 쌍평선 전략과 무작위 지표의 장점을 통합적으로 사용한다. 시장의 주요 추세를 추적하면서 불리한 행태의 반전을 피한다. 변수 조합을 최적화하여 더 나은 전략 효과를 얻을 수 있다.
/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 24/11/2020
// 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
// As the name suggests, High low bands are two bands surrounding the underlying’s
// price. These bands are generated from the triangular moving averages calculated
// from the underlying’s price. The triangular moving average is, in turn, shifted
// up and down by a fixed percentage. The bands, thus formed, are termed as High
// low bands. The main theme and concept of High low bands is based upon the triangular
// moving average.
//
// 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
HLB(Length, PercentShift) =>
pos = 0.0
xTMA = sma(sma(close, Length), Length)
xHighBand = xTMA + (xTMA * PercentShift / 100)
xLowBand = xTMA - (xTMA * PercentShift / 100)
pos :=iff(close > xHighBand, 1,
iff(close <xLowBand, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & High Low Bands", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
Length_HLB = input(14, minval=1)
PercentShift = input(1, minval = 0.01, step = 0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posHLB = HLB(Length_HLB, PercentShift)
pos = iff(posReversal123 == 1 and posHLB == 1 , 1,
iff(posReversal123 == -1 and posHLB == -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 )