
Chiến lược này tạo ra tín hiệu giao dịch bằng cách kết hợp chỉ số kỹ thuật cổ điển CCI và chỉ số kép VCI, MCI được phát triển độc lập. Đây là một chiến lược giao dịch định lượng điển hình. Nó tạo ra tín hiệu giao dịch bằng cách xác định xu hướng thay đổi của khối lượng và giá, đánh giá hướng và cường độ giao dịch chính của thị trường hiện tại. Nó có thể được áp dụng rộng rãi cho các công cụ tài chính như tiền kỹ thuật số, ngoại hối và cổ phiếu.
Chiến lược này tạo ra tín hiệu giao dịch thông qua so sánh chỉ số hai cc, xem xét nhiều yếu tố như giá cả và khối lượng giao dịch, đánh giá sức mạnh mua và bán của thị trường, là một chiến lược giao dịch định lượng điển hình và thực tế. Tuy nhiên, vẫn cần được sử dụng kết hợp với các công cụ phụ trợ khác để có thể sử dụng tối đa hiệu quả của chiến lược.
/*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
strategy("MCI and VCI - Modified CCI Formulas")
test = cci(ohlc4, 13)
test1 = cci(ohlc4, 20)
obv(src) => cum(change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume)
mDisc = input(0, title="Mode Discrepency")
mDiv = input(0.015, title="Interval")
mean(_src, _length)=>
_return = sum(_src, _length) / _length
median(_src, _length)=>
_return = _src
for _i = 0 to _length
_return := _return == 0 ? _src : (_return + _src[_i]) / 2
_return
len = input(20, title="Standard (Average) Length")
mmm = input(20, title="Lookback length")
srcV = obv(input(ohlc4))
srcP = input(close)
x = sma(srcV, len)
MDV2 = abs(stdev(median(x, len), mmm))
MDV3 = abs(stdev(mean(x, len), mmm))
AMDV = (MDV2+MDV3)/2
pt1v = (srcV-ema(srcV, len))/ AMDV
pt2v = 1/mDiv
VCI=pt1v*pt2v
y = ema(srcP, len)
MDP2 = abs(stdev(median(y, len), mmm))
MDP3 = abs(stdev(mean(y, len), mmm))
AMDA = (MDP2 + MDP3)/2
pt1p = 1/mDiv
pt2p = (srcP-ema(srcP, len))/ AMDA
MCI = pt1p * pt2p
plot(VCI, color=yellow, title="VCI", style="Histogram")
plot(MCI, color=white, title="MCI")
plot(500, style=line)
plot(0, style=line, linewidth=2)
plot(-500, style=line)
long = crossover(MCI, 0) and VCI > MCI[2]
short = crossunder(MCI, 0) and VCI < MCI[2]
//Time Control
//Set date and time
FromMonth = input(defval = 9, title = "From Month", minval = 1, maxval = 12)
FromDay = input(defval = 13, title = "From Day", minval = 1, maxval = 31)
FromYear = input(defval = 2018, title = "From Year", minval = 2017)
ToMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12)
ToDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)
ToYear = input(defval = 9999, title = "To Year", minval = 2017)
// === FUNCTION EXAMPLE ===
start = timestamp(FromYear, FromMonth, FromDay, 00, 00) // backtest start window
finish = timestamp(ToYear, ToMonth, ToDay, 23, 59) // backtest finish window
window() => time >= start and time <= finish ? true : false // create function "within window of time"
direction = input(0, title = "Strategy Direction", minval=-1, maxval=1)
strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))
if (long)
strategy.entry("Long", strategy.long, when=window(), limit=ohlc4, oca_name="BollingerBands", comment="BBandLE")
else
strategy.cancel(id="Long")
if (short)
strategy.entry("Short", strategy.short, when=window(), limit=ohlc4, oca_name="BollingerBands", comment="BBandSE")
else
strategy.cancel(id="Short")