
이 전략은 이중 트렌드 반전 이동 평균 조합 전략이다. 123 반전 전략과 빌 윌리엄스 평균 전략을 결합하여 두 전략의 신호를 조합하여 더 정확한 거래 신호를 얻는다.
이 전략은 두 부분으로 구성되어 있습니다.
123 역전 전략: 종결 가격이 2일 연속으로 전날의 종결 가격보다 높고, 9일 느린 K선이 50보다 낮으면 더 많이 한다. 종결 가격이 2일 연속으로 전날의 종결 가격보다 낮고, 9일 빠른 K선이 50보다 높으면 더 많이 한다.
빌 윌리엄스 평균 전략: 13일, 8일, 5일의 중도 이동 평균을 계산하여, 단기 이동 평균 위에 중기 이동 평균을 통과할 때 더 많이 하고, 단기 이동 평균 아래에 중기 장기 이동 평균을 통과할 때 적어진다.
마지막으로, 두 가지 전략의 신호 방향이 일치하면 실제 거래 신호가 발생하고, 일치하지 않으면 거래하지 않습니다.
이 전략은 이중 트렌드 판단과 결합하여 잘못된 신호를 줄이고 신호의 정확성을 향상시킬 수 있다. 또한, 이동 평균의 추가는 일부 잡음을 필터링 할 수 있다.
이 전략에는 다음과 같은 위험들이 있습니다.
이동 평균 변수를 조정하거나 입출력 논리를 최적화하여 위험을 줄일 수 있다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
이 전략은 이중 트렌드 판단과 이동 평균 지표를 통합하여 노이즈 신호를 효과적으로 필터링하여 거래 의사 결정의 정확성을 향상시킬 수 있습니다. 그러나 특정 위험이 있지만, 실전에서 수익을 안정화하기 위해 입문 출퇴근 논리를 지속적으로 테스트하고 최적화해야합니다.
/*backtest
start: 2023-10-28 00:00:00
end: 2023-11-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 18/06/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
// This indicator calculates 3 Moving Averages for default values of
// 13, 8 and 5 days, with displacement 8, 5 and 3 days: Median Price (High+Low/2).
// The most popular method of interpreting a moving average is to compare
// the relationship between a moving average of the security's price with
// the security's price itself (or between several moving averages).
//
// 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
BillWilliamsAverages(LLength, MLength,SLength, LOffset,MOffset, SOffset ) =>
xLSma = sma(hl2, LLength)[LOffset]
xMSma = sma(hl2, MLength)[MOffset]
xSSma = sma(hl2, SLength)[SOffset]
pos = 0
pos := iff(close < xSSma and xSSma < xMSma and xMSma < xLSma, -1,
iff(close > xSSma and xSSma > xMSma and xMSma > xLSma, 1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal & Bill Williams Averages. 3Lines", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LLength = input(13, minval=1)
MLength = input(8,minval=1)
SLength = input(5,minval=1)
LOffset = input(8,minval=1)
MOffset = input(5,minval=1)
SOffset = input(3,minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBillWilliamsAverages = BillWilliamsAverages(LLength, MLength,SLength, LOffset, MOffset, SOffset)
pos = iff(posReversal123 == 1 and posBillWilliamsAverages == 1 , 1,
iff(posReversal123 == -1 and posBillWilliamsAverages == -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 )