
Chiến lược đảo ngược chéo MACD thời gian đa chu kỳ bằng cách tính toán các chỉ số MACD trong các chu kỳ khác nhau, xác định các tín hiệu có thể đảo ngược giá, sử dụng phương pháp theo dõi xu hướng dừng lỗ, theo đuổi hiệu quả sử dụng vốn cao hơn.
Chiến lược này đồng thời tính toán đường trung bình di chuyển SMA 3 chu kỳ và 10 chu kỳ, xây dựng đường chậm và nhanh, sau đó tính toán MACD và đường tín hiệu. Khi đường nhanh và đường tín hiệu xảy ra trên hoặc xuống, giá đạt đến điểm mấu chốt, có thể có sự đảo ngược. Ngoài ra, chiến lược này cũng kết hợp với phán đoán tình trạng đa luồng của khối lượng giao dịch, chỉ số RSI, v.v., để xác định độ tin cậy của tín hiệu đảo ngược.
Cụ thể, chiến lược này đánh giá sự đảo ngược giá theo các phương pháp sau:
Khi tín hiệu đảo ngược có độ tin cậy cao, chiến lược sử dụng phương thức dừng lỗ theo xu hướng để tìm kiếm thu nhập cao hơn.
Chiến lược này có một số lợi thế:
Chiến lược này cũng có một số rủi ro:
Bạn có thể giảm thiểu rủi ro bằng cách:
Chiến lược này có thể được tối ưu hóa hơn nữa trong các lĩnh vực như:
Chiến lược đảo ngược chéo MACD không có chu kỳ nhiều thời gian, tổng hợp các thông tin về nhiều chiều như giá cả, khối lượng giao dịch và chỉ số biến động, xác định thời gian quay trở lại bằng cách phán đoán nhiều chỉ số, dừng lỗ kịp thời sau khi có lợi nhuận đầy đủ, có thể thu được lợi nhuận tốt hơn trong trường hợp đảo ngược. Chiến lược này có khả năng được cải tiến hơn nữa thông qua học máy và tối ưu hóa vị trí quan trọng để giảm tần suất giao dịch và rủi ro, tăng không gian kiếm lợi nhuận.
/*backtest
start: 2023-02-11 00:00:00
end: 2024-02-17 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("3 10.0 Oscillator Profile Flagging", shorttitle="3 10.0 Oscillator Profile Flagging", overlay=false)
signalBiasValue = input(title="Signal Bias", defval=0.26)
macdBiasValue = input(title="MACD Bias", defval=0.8)
shortLookBack = input( title="Short LookBack", defval=3)
longLookBack = input( title="Long LookBack", defval=10.0)
takeProfit = input( title="Take Profit", defval=0.8)
stopLoss = input( title="Stop Loss", defval=0.75)
fast_ma = ta.sma(close, 3)
slow_ma = ta.sma(close, 10)
macd = fast_ma - slow_ma
signal = ta.sma(macd, 16)
hline(0, "Zero Line", color = color.black)
buyVolume = volume*((close-low)/(high-low))
sellVolume = volume*((high-close)/(high-low))
buyVolSlope = buyVolume - buyVolume[1]
sellVolSlope = sellVolume - sellVolume[1]
signalSlope = ( signal - signal[1] )
macdSlope = ( macd - macd[1] )
plot(macd, color=color.blue, title="Total Volume")
plot(signal, color=color.orange, title="Total Volume")
intrabarRange = high - low
rsi = ta.rsi(close, 14)
rsiSlope = rsi - rsi[1]
getRSISlopeChange(lookBack) =>
j = 0
for i = 0 to lookBack
if ( rsi[i] - rsi[ i + 1 ] ) > -5
j += 1
j
getBuyerVolBias(lookBack) =>
j = 0
for i = 1 to lookBack
if buyVolume[i] > sellVolume[i]
j += 1
j
getSellerVolBias(lookBack) =>
j = 0
for i = 1 to lookBack
if sellVolume[i] > buyVolume[i]
j += 1
j
getVolBias(lookBack) =>
float b = 0.0
float s = 0.0
for i = 1 to lookBack
b += buyVolume[i]
s += sellVolume[i]
b > s
getSignalBuyerBias(lookBack) =>
j = 0
for i = 1 to lookBack
if signal[i] > signalBiasValue
j += 1
j
getSignalSellerBias(lookBack) =>
j = 0
for i = 1 to lookBack
if signal[i] < ( 0.0 - signalBiasValue )
j += 1
j
getSignalNoBias(lookBack) =>
j = 0
for i = 1 to lookBack
if signal[i] < signalBiasValue and signal[i] > ( 0.0 - signalBiasValue )
j += 1
j
getPriceRising(lookBack) =>
j = 0
for i = 1 to lookBack
if close[i] > close[i + 1]
j += 1
j
getPriceFalling(lookBack) =>
j = 0
for i = 1 to lookBack
if close[i] < close[i + 1]
j += 1
j
getRangeNarrowing(lookBack) =>
j = 0
for i = 1 to lookBack
if intrabarRange[i] < intrabarRange[i + 1]
j+= 1
j
getRangeBroadening(lookBack) =>
j = 0
for i = 1 to lookBack
if intrabarRange[i] > intrabarRange[i + 1]
j+= 1
j
bool isNegativeSignalReversal = signalSlope < 0.0 and signalSlope[1] > 0.0
bool isNegativeMacdReversal = macdSlope < 0.0 and macdSlope[1] > 0.0
bool isPositiveSignalReversal = signalSlope > 0.0 and signalSlope[1] < 0.0
bool isPositiveMacdReversal = macdSlope > 0.0 and macdSlope[1] < 0.0
bool hasBearInversion = signalSlope > 0.0 and macdSlope < 0.0
bool hasBullInversion = signalSlope < 0.0 and macdSlope > 0.0
bool hasSignalBias = math.abs(signal) >= signalBiasValue
bool hasNoSignalBias = signal < signalBiasValue and signal > ( 0.0 - signalBiasValue )
bool hasSignalBuyerBias = hasSignalBias and signal > 0.0
bool hasSignalSellerBias = hasSignalBias and signal < 0.0
bool hasPositiveMACDBias = macd > macdBiasValue
bool hasNegativeMACDBias = macd < ( 0.0 - macdBiasValue )
bool hasBullAntiPattern = ta.crossunder(macd, signal)
bool hasBearAntiPattern = ta.crossover(macd, signal)
bool hasSignificantBuyerVolBias = buyVolume > ( sellVolume * 1.5 )
bool hasSignificantSellerVolBias = sellVolume > ( buyVolume * 1.5 )
// 393.60 Profit 52.26% 15m
if ( hasBullInversion and rsiSlope > 1.5 and volume > 300000.0 )
strategy.entry("15C1", strategy.long, qty=10.0)
strategy.exit("TPS", "15C1", limit=strategy.position_avg_price + takeProfit, stop=strategy.position_avg_price - stopLoss)
// 356.10 Profit 51,45% 15m
if ( getVolBias(shortLookBack) == false and rsiSlope > 3.0 and signalSlope > 0)
strategy.entry("15C2", strategy.long, qty=10.0)
strategy.exit("TPS", "15C2", limit=strategy.position_avg_price + takeProfit, stop=strategy.position_avg_price - stopLoss)
// 124 Profit 52% 15m
if ( rsiSlope < -11.25 and macdSlope < 0.0 and signalSlope < 0.0)
strategy.entry("15P1", strategy.short, qty=10.0)
strategy.exit("TPS", "15P1", limit=strategy.position_avg_price - takeProfit, stop=strategy.position_avg_price + stopLoss)
// 455.40 Profit 49% 15m
if ( math.abs(math.abs(macd) - math.abs(signal)) < .1 and buyVolume > sellVolume and hasBullInversion)
strategy.entry("15P2", strategy.short, qty=10.0)
strategy.exit("TPS", "15P2", limit=strategy.position_avg_price - takeProfit, stop=strategy.position_avg_price + stopLoss)