
Đây là một chiến lược giao dịch tổng hợp dựa trên 7 chỉ số giao dịch khác nhau. Chiến lược này xây dựng một hệ thống giao dịch toàn diện bằng cách tích hợp nhiều chỉ số giao dịch như OBV, đường A / D, CMF, MFI, VWAP, dao động giao dịch và RSI giao dịch.
Chiến lược này sử dụng phương pháp xác thực đa chỉ số, bao gồm:
Khi có hơn 4 chỉ số đồng thời đưa ra tín hiệu thống nhất, chiến lược cho rằng thị trường có cơ hội có xu hướng mạnh hơn, do đó giao dịch.
Đây là một chiến lược giao dịch tổng hợp dựa trên nhiều chỉ số khối lượng giao dịch để nâng cao độ chính xác của giao dịch thông qua phân tích thị trường đa chiều. Chiến lược có nền tảng lý thuyết và giá trị thực tế mạnh mẽ, nhưng cần tối ưu hóa tham số và quản lý rủi ro phù hợp với tình hình thị trường trong ứng dụng thực tế.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Combined Volume Indicators Strategy", overlay=true)
// تنظیمات
lengthRSI = 14
lengthMFI = 14
lengthCMF = 20
fastLength = 5
slowLength = 10
// محاسبه OBV
obv = ta.cum(close > close[1] ? volume : close < close[1] ? -volume : 0)
// محاسبه A/D بهصورت دستی
var float ad = na
ad := na(ad[1]) ? 0 : ad[1] + ((close - low) - (high - close)) / (high - low) * volume
// محاسبه CMF (Chaikin Money Flow)
moneyFlowMultiplier = ((close - low) - (high - close)) / (high - low)
moneyFlowVolume = moneyFlowMultiplier * volume
cmf = ta.sma(moneyFlowVolume, lengthCMF) / ta.sma(volume, lengthCMF)
// محاسبه MFI بهصورت دستی
typicalPrice = (high + low + close) / 3
moneyFlow = typicalPrice * volume
// محاسبه جریان پول مثبت و منفی
positiveFlow = 0.0
negativeFlow = 0.0
for i = 0 to lengthMFI - 1
positiveFlow := positiveFlow + (close[i] > close[i + 1] ? moneyFlow[i] : 0)
negativeFlow := negativeFlow + (close[i] < close[i + 1] ? moneyFlow[i] : 0)
mfi = 100 - (100 / (1 + (positiveFlow / negativeFlow)))
// محاسبه VWAP
vwap = ta.vwap(close)
// محاسبه Volume Oscillator
fastVolMA = ta.sma(volume, fastLength)
slowVolMA = ta.sma(volume, slowLength)
volumeOscillator = fastVolMA - slowVolMA
// محاسبه VRSI (Volume RSI)
vrsi = ta.rsi(volume, lengthRSI)
// شمارش اندیکاتورهای سیگنال خرید
buySignals = 0
buySignals := buySignals + (obv > obv[1] ? 1 : 0)
buySignals := buySignals + (ad > ad[1] ? 1 : 0)
buySignals := buySignals + (cmf > 0 ? 1 : 0)
buySignals := buySignals + (mfi < 40 ? 1 : 0)
buySignals := buySignals + (close < vwap ? 1 : 0)
buySignals := buySignals + (volumeOscillator > 0 ? 1 : 0)
buySignals := buySignals + (vrsi < 40 ? 1 : 0)
// شمارش اندیکاتورهای سیگنال فروش
sellSignals = 0
sellSignals := sellSignals + (obv < obv[1] ? 1 : 0)
sellSignals := sellSignals + (ad < ad[1] ? 1 : 0)
sellSignals := sellSignals + (cmf < 0 ? 1 : 0)
sellSignals := sellSignals + (mfi > 60 ? 1 : 0)
sellSignals := sellSignals + (close > vwap ? 1 : 0)
sellSignals := sellSignals + (volumeOscillator < 0 ? 1 : 0)
sellSignals := sellSignals + (vrsi > 60 ? 1 : 0)
// شرایط سیگنال خرید: اگر بیش از 4 اندیکاتور سیگنال خرید دهند
buyCondition = (buySignals > 4)
// شرایط سیگنال فروش: اگر بیش از 4 اندیکاتور سیگنال فروش دهند
sellCondition = (sellSignals > 4)
// ورود به معامله خرید
if (buyCondition)
strategy.entry("Buy", strategy.long)
// خروج از معامله فروش
if (sellCondition)
strategy.close("Buy")
// رسم سیگنالهای خرید و فروش بر روی چارت
plotshape(buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")