
이 전략은 RSI, MACD, OBV, CCI, CMF, MFI, VWMACD 등 여러 가지 기술 지표와 결합하여 자동화된 주식 수량 거래를 구현하는 다중 요소 수량 거래 전략이다. 이 전략은 수량화 다중 공백 요소 선택 시 전략이라고 한다.
이 전략의 핵심 논리는 여러 기술 지표의 형태에 따라 판단하고, 여러 지표가 동시에 구매 신호를 발산할 때 구매 작업을 수행하는 것이다.
구체적으로, 전략의 RSI, MACD, OBV, CCI, CMF, MFI, VWMACD 이러한 지표는 하향 추세가 나타나지만 지표 값 자체가 하락하지 않은 형태가 있는지 검출합니다. 이러한 상황이 발생하면 상승세를 반전시킬 수 있습니다.
또한, 전략에는 거래량 이상으로 판단하는 논리도 도입되었다. 가격이 변동하지만 거래량이 눈에 띄게 커지지 않은 경우, 가짜 돌파구가 발생할 가능성이 높으며, 이때도 구매 신호가 발송된다.
종합적으로, 이 전략은 여러 기술 지표의 역전 신호를 관찰하고 거래량의 비정상적인 판단을 결합하여 의사 결정의 정확성을 향상시킵니다. 이는 양적 거래 전략의 성공에 핵심입니다.
이 전략에는 다음과 같은 장점이 있습니다.
7개의 일반적인 기술 지표의 신호를 결합한 다인자 모델은 거래 의사 결정의 정확성을 향상시킵니다.
교차량 역전 신호를 도입하여 가짜 돌파구 속임수를 피하고, 무효 신호를 필터링한다.
하락상태를 판단하여 주가가 상승하는 시점을 미리 파악한다.
자동화 거래는 인적 개입이 필요없고 운영 비용을 크게 줄입니다.
전략 논리는 명확하고 간단하며, 이해하기, 수정 및 최적화하기 쉽습니다.
이 전략에는 몇 가지 위험도 있습니다.
여러 요소가 부적절하게 결합되어 충돌하는 거래 신호가 발생할 수 있습니다. 각 요소의 매개 변수를 조정하여 최적의 구성을 찾기 위해 테스트해야합니다.
반전 거래 자체에는 위험이 있으며, 다시 반전될 가능성이 있다. 위험을 제어하기 위해 스톱로스를 설정할 수 있다.
VOLUME 지표는 유동성이 낮은 일부 주식에 대해 효과가 좋지 않을 수 있으며, VOLUME 무게를 줄이거나 그 부분을 제외 할 수 있습니다.
회전시 데이터 적합 효과는 좋고, 실기시 성능은 저하될 수 있다. 테스트를 위해 더 많은 실기 데이터를 축적해야 한다.
이 전략은 다음의 몇 가지 측면에서 더 개선될 수 있습니다.
몇 가지 기술 지표를 추가하거나 줄여서 최적의 구성된 다중 인자 모델을 찾습니다.
다른 주식 유형에 대해 다른 매개 변수 또는 무게를 설정하여 전략을 더 타깃화하십시오.
다이내믹 스톱로스를 설정하고, 스톱을 움직여 수익을 고정하고, 위험을 조절한다.
산업, 개념 등의 정보를 결합하여 특정 부문에서 주식 거래를 선택하십시오.
기계 학습 알고리즘에 참여하여 전략의 매개 변수를 자동으로 최적화합니다.
이 전략overall은 매우 잠재적인 양적 거래 전략이다. 이 전략은 여러 가지 기술 지표 신호를 결합하여, 양적 역효율 판단을 보조하여, 주식 역전 기회를 효과적으로 발견하고, 자동화 거래 할 수 있다. 매개 변수 최적화 및 위험 통제가 자리 잡은 후, 더 나은 수익을 얻을 수 있을 것으로 기대된다. 이 전략은 아이디어는 새롭고, 더 많은 연구와 응용에 가치가 있다.
/*backtest
start: 2023-01-18 00:00:00
end: 2024-01-24 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mkose81
//@version=5
strategy("MK future stopsuz 40 alım (Sadece Long)", overlay=true, max_bars_back=4000,use_bar_magnifier= true,pyramiding=40)
// RSI Hesaplama
rsi = ta.rsi(close, 14)
float botRSI = na
botRSI := ta.pivotlow(5, 5)
botcRSI = 0
botcRSI := botRSI ? 5 : nz(botcRSI[1]) + 1
newbotRSI = ta.pivotlow(5, 0)
emptylRSI = true
if not na(newbotRSI) and newbotRSI < low[botcRSI]
diffRSI = (newbotRSI - low[botcRSI]) / botcRSI
llineRSI = newbotRSI - diffRSI
for x = 1 to botcRSI - 1 by 1
if close[x] < llineRSI
emptylRSI := false
break
llineRSI -= diffRSI
emptylRSI
// Pozitif Uyumsuzluk Alım Sinyali - RSI
alRSI = 0
if emptylRSI and not na(newbotRSI)
if rsi[botcRSI] < rsi
alRSI := 1
// MACD Hesaplama
[macd, signal, _] = ta.macd(close, 21, 55, 8)
float botMACD = na
botMACD := ta.pivotlow(5, 5)
botcMACD = 0
botcMACD := botMACD ? 5 : nz(botcMACD[1]) + 1
newbotMACD = ta.pivotlow(5, 0)
emptylMACD = true
if not na(newbotMACD) and newbotMACD < low[botcMACD]
diffMACD = (newbotMACD - low[botcMACD]) / botcMACD
llineMACD = newbotMACD - diffMACD
for x = 1 to botcMACD - 1 by 1
if close[x] < llineMACD
emptylMACD := false
break
llineMACD -= diffMACD
emptylMACD
// Pozitif Uyumsuzluk Alım Sinyali - MACD
alMACD = 0
if emptylMACD and not na(newbotMACD)
if macd[botcMACD] < macd
alMACD := 1
// OBV Hesaplama ve Uyumsuzluk Tespiti
obv = ta.cum(ta.change(close) > 0 ? volume : ta.change(close) < 0 ? -volume : 0)
float botOBV = na
botOBV := ta.pivotlow(5, 5)
botcOBV = 0
botcOBV := botOBV ? 5 : nz(botcOBV[1]) + 1
newbotOBV = ta.pivotlow(5, 0)
emptylOBV = true
if not na(newbotOBV) and newbotOBV < obv[botcOBV]
diffOBV = (newbotOBV - obv[botcOBV]) / botcOBV
llineOBV = newbotOBV - diffOBV
for x = 1 to botcOBV - 1 by 1
if obv[x] < llineOBV
emptylOBV := false
break
llineOBV -= diffOBV
emptylOBV
// Pozitif Uyumsuzluk Alım Sinyali - OBV
alOBV = 0
if emptylOBV and not na(newbotOBV)
if obv[botcOBV] < obv
alOBV := 1
// CCI Hesaplama ve Uyumsuzluk Tespiti
cci = ta.cci(close, 20)
float botCCI = na
botCCI := ta.pivotlow(5, 5)
botcCCI = 0
botcCCI := botCCI ? 5 : nz(botcCCI[1]) + 1
newbotCCI = ta.pivotlow(5, 0)
emptylCCI = true
if not na(newbotCCI) and newbotCCI < cci[botcCCI]
diffCCI = (newbotCCI - cci[botcCCI]) / botcCCI
llineCCI = newbotCCI - diffCCI
for x = 1 to botcCCI - 1 by 1
if cci[x] < llineCCI
emptylCCI := false
break
llineCCI -= diffCCI
emptylCCI
// Pozitif Uyumsuzluk Alım Sinyali - CCI
alCCI = 0
if emptylCCI and not na(newbotCCI)
if cci[botcCCI] < cci
alCCI := 1
// CMF Hesaplama
length = 20
mfm = ((close - low) - (high - close)) / (high - low)
mfv = mfm * volume
cmf = ta.sma(mfv, length) / ta.sma(volume, length)
float botCMF = na
botCMF := ta.pivotlow(5, 5)
botcCMF = 0
botcCMF := botCMF ? 5 : nz(botcCMF[1]) + 1
newbotCMF = ta.pivotlow(5, 0)
emptylCMF = true
if not na(newbotCMF) and newbotCMF < cmf[botcCMF]
diffCMF = (newbotCMF - cmf[botcCMF]) / botcCMF
llineCMF = newbotCMF - diffCMF
for x = 1 to botcCMF - 1 by 1
if cmf[x] < llineCMF
emptylCMF := false
break
llineCMF -= diffCMF
emptylCMF
// Pozitif Uyumsuzluk Alım Sinyali - CMF
alCMF = 0
if emptylCMF and not na(newbotCMF)
if cmf[botcCMF] < cmf
alCMF := 1
// MFI Hesaplama
lengthMFI = 14
mfi = ta.mfi(close, lengthMFI)
float botMFI = na
botMFI := ta.pivotlow(mfi, 5, 5)
botcMFI = 0
botcMFI := botMFI ? 5 : nz(botcMFI[1]) + 1
newbotMFI = ta.pivotlow(mfi, 5, 0)
emptylMFI = true
if not na(newbotMFI) and newbotMFI < mfi[botcMFI]
diffMFI = (newbotMFI - mfi[botcMFI]) / botcMFI
llineMFI = newbotMFI - diffMFI
for x = 1 to botcMFI - 1 by 1
if mfi[x] < llineMFI
emptylMFI := false
break
llineMFI -= diffMFI
emptylMFI
// Pozitif Uyumsuzluk Alım Sinyali - MFI
alMFI = 0
if emptylMFI and not na(newbotMFI)
if mfi[botcMFI] < mfi
alMFI := 1
// VWMACD Hesaplama
fastLength = 12
slowLength = 26
signalSmoothing = 9
vwmacd = ta.ema(close, fastLength) - ta.ema(close, slowLength)
signalLine = ta.ema(vwmacd, signalSmoothing)
histogram = vwmacd - signalLine
// VWMACD Uyumsuzluk Tespiti
float botVWMACD = na
botVWMACD := ta.pivotlow(histogram, 5, 5)
botcVWMACD = 0
botcVWMACD := botVWMACD ? 5 : nz(botcVWMACD[1]) + 1
newbotVWMACD = ta.pivotlow(histogram, 5, 0)
emptylVWMACD = true
if not na(newbotVWMACD) and newbotVWMACD < histogram[botcVWMACD]
diffVWMACD = (newbotVWMACD - histogram[botcVWMACD]) / botcVWMACD
llineVWMACD = newbotVWMACD - diffVWMACD
for x = 1 to botcVWMACD - 1 by 1
if histogram[x] < llineVWMACD
emptylVWMACD := false
break
llineVWMACD -= diffVWMACD
emptylVWMACD
// Pozitif Uyumsuzluk Alım Sinyali - VWMACD
alVWMACD = 0
if emptylVWMACD and not na(newbotVWMACD)
if histogram[botcVWMACD] < histogram
alVWMACD := 1
//Dipci indikator
lengthd= 130
coef = 0.2
vcoef = 2.5
signalLength = 5
smoothVFI = false
ma(x, y) =>
smoothVFI ? ta.sma(x, y) : x
typical = hlc3
inter = math.log(typical) - math.log(typical[1])
vinter = ta.stdev(inter, 30)
cutoff = coef * vinter * close
vave = ta.sma(volume, lengthd)[1]
vmax = vave * vcoef
vc = volume < vmax ? volume : vmax //min( volume, vmax )
mf = typical - typical[1]
iff_4 = mf < -cutoff ? -vc : 0
vcp = mf > cutoff ? vc : iff_4
vfi = ma(math.sum(vcp, lengthd) / vave, 3)
vfima = ta.ema(vfi, signalLength)
d = vfi - vfima
// Kullanıcı girdileri
volatilityThreshold = input.float(1.005, title="Volume Percentage Threshold")
pinThreshold = input.float(1.005, title="Deep Percentage Threshold")
// Hesaplamalar
volatilityPercentage = (high - low) / open
pinPercentage = close > open ? (high - close) / open : (close - low) / open
// Volatilite koşulu ve VFI ile filtreleme
voldip = volatilityPercentage >= volatilityThreshold or pinPercentage >= pinThreshold
volCondition = voldip and vfi< 0 // VFI değeri 0'dan küçükse volCondition aktif olacak
threeCommasEntryComment = input.string(title="3Commas Entry Comment", defval="")
threeCommasExitComment = input.string(title="3Commas Exit Comment", defval="")
takeProfitPerc = input.float(1, title="Take Profit Percentage (%)") / 100
fallPerc = input.float(5, title="Percentage for Additional Buy (%)") / 100
// Değişkenlerin tanımlanması
var float lastBuyPrice = na
var float tpPrice = na
var int lastTpBar = na
// Alım koşulları
longCondition = alRSI or alMACD or alOBV or alCCI or alCMF or alMFI or alVWMACD or volCondition
// Son alım fiyatını saklamak için değişken
// İlk alım stratejisi
if (longCondition and strategy.position_size == 0)
strategy.entry("Long", strategy.long, comment=threeCommasEntryComment)
lastBuyPrice := open
// İkinci ve sonraki alım koşulları (son alım fiyatının belirlenen yüzde altında)
if (open < lastBuyPrice * (1 - fallPerc) and strategy.position_size > 0)
strategy.entry("Long Add", strategy.long, comment=threeCommasEntryComment)
lastBuyPrice := open
// Kar alma fiyatını hesaplama ve strateji çıkışı
tp_price = strategy.position_avg_price * (1 + takeProfitPerc)
if strategy.position_size > 0
strategy.exit("Exit Long", "Long", limit=tp_price, comment=threeCommasExitComment)
strategy.exit("Exit Long Add", "Long Add", limit=tp_price, comment=threeCommasExitComment)
tpPrice := na // Pozisyon kapandığında TP çizgisini sıfırla
// Kar alma seviyesi çizgisi çizme
plot(strategy.position_size > 0 ? tp_price : na, color=color.green, title="Take Profit Line")