
Chiến lược này là một chiến lược kết hợp trung bình di chuyển ngược xu hướng kép. Nó kết hợp chiến lược 123 reversal và chiến lược trung bình Bill Williams, sử dụng tín hiệu của cả hai chiến lược để kết hợp để có được tín hiệu giao dịch chính xác hơn.
Chiến lược này bao gồm hai phần:
123 Chiến lược đảo ngược: Khi giá đóng cửa cao hơn giá đóng cửa ngày trước hai ngày liên tiếp và đường K chậm dưới 50 ngày thứ 9; Khi giá đóng cửa thấp hơn giá đóng cửa ngày trước hai ngày liên tiếp và đường K nhanh hơn 50 ngày thứ 9;
Chiến lược đường trung bình Bill Williams: tính trung bình chuyển động giá trị 13, 8 và 5 ngày, làm nhiều khi đi qua đường trung bình chuyển động ngắn hạn trên đường trung bình chuyển động dài hạn; làm trơ khi đi qua đường trung bình chuyển động dài hạn dưới đường trung bình chuyển động ngắn hạn.
Cuối cùng, một tín hiệu giao dịch thực tế sẽ được tạo ra nếu hai chiến lược đồng nhất về hướng tín hiệu, và không giao dịch nếu hai chiến lược không đồng nhất.
Chiến lược này kết hợp với phán đoán xu hướng kép, có thể làm giảm tín hiệu giả và cải thiện độ chính xác của tín hiệu. Ngoài ra, việc thêm trung bình di chuyển cũng có thể lọc ra một số tiếng ồn.
Chiến lược này có những rủi ro sau:
Có thể giảm rủi ro bằng cách điều chỉnh các tham số trung bình di chuyển hoặc tối ưu hóa logic xuất nhập cảnh.
Chiến lược này có thể được tối ưu hóa theo các khía cạnh sau:
Chiến lược này tích hợp định giá xu hướng kép với chỉ số trung bình di chuyển, có thể lọc hiệu quả các tín hiệu tiếng ồn, cải thiện độ chính xác của quyết định giao dịch. Tuy nhiên, cũng có một số rủi ro, cần phải liên tục kiểm tra và tối ưu hóa logic nhập cảnh để có thể ổn định lợi nhuận trong thực tế.
/*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 )