누적 단계 식별자 및 거래 전략

저자:차오장, 날짜: 2024-02-20 11:29:57
태그:

img

전반적인 설명

이 전략은 이동 평균, 부피 지표 및 가격 동력 지표를 결합하여 축적 단계로 진입하는 주식의 시기를 식별하기 위해 정량 규칙의 집합을 설계합니다. 이 단계에서 주식은 일반적으로 가격 통합 및 저장 상태에 있으며 낮은 가격의 좋은 기회를 제공합니다.

전략 원칙

이 전략은 가격 트렌드를 결정하기 위해 50일, 90일 및 200일 간단한 이동 평균을 사용합니다. 가격 200일 라인을 넘으면 구매 신호가 생성됩니다. 이것은 주요 하락 추세의 불확실성을 필터링합니다.

주요 트렌드를 판단하는 것 외에도 전략은 트렌드를 확인하기 위해 단기 이동 평균의 순서를 판단합니다. 구체적으로 50일 라인이 90일 라인의 위에 있는지 판단합니다.

이동 평균이 주요 및 단기 트렌드를 확인한다는 근거에서 전략은 축적 특성을 판단하기 위해 PVT 볼륨 지표와 MACD 지표를 결합합니다. PVT가 상향으로 깨지고 MACD 라인이 신호 라인보다 높고 볼륨이 확장 될 때만 구매 신호가 생성됩니다.

장점

이동 평균만을 사용하는 것과 비교하여, 이 전략은 또한 양의 특성을 확인하고 동향을 확인합니다. 이것은 축적 단계에 들어가는 재고의 시기를 더 정확하게 결정할 수 있습니다. 따라서 더 나은 입시 가격을 보장합니다.

여러 시간 프레임을 분석함으로써 이 전략은 중장기 트렌드 판단과 단기 특징 판단을 결합하여 시간 프레임을 일치시킵니다. 이는 단일 시간 프레임을 잘못 판단하는 불확실성을 줄일 수 있습니다.

위험 과 해결책

이 전략은 주로 이동 평균 판단에 의존합니다. 가격이 격렬하게 변동하면 이동 평균 판단이 실패합니다. 이 시점에서 포지션 크기를 줄이거나 스톱 로스 출출을 유발해야합니다.

또한 축적 단계에서 잘못된 판단이 가능하며 따라서 역행 기회를 놓칠 수 있습니다. 이것은 판단을 확인하기 위해 더 많은 특징 지표를 관찰해야합니다.

최적화 아이디어

머신 러닝 알고리즘은 특징을 추출하고 모델 트레이닝을 통해 축적 단계에 대한 자동 판단을 달성함으로써 이 전략에 도입될 수 있다. 이것은 수동적으로 임계치를 설정하는 데의 한계를 줄일 수 있다.

또한 이 전략은 다른 시장 환경에서 자동으로 매개 변수를 전환하는 브레이크포인트 기능을 시도하여 전략을 더욱 견고하게 만들 수 있습니다.

요약

요약하자면, 이 전략은 일반적으로 주식 축적 단계의 특성을 판단하기 위해 가격과 양을 일치시키는 아이디어를 채택합니다. 주요 방향을 확인하면서 단기 축적 기회를 파고갑니다. 매개 변수 최적화와 기계 학습을 도입함으로써 전략 성능의 추가 개선이 여전히 가능합니다.


/*backtest
start: 2023-02-13 00:00:00
end: 2024-02-19 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © stocktechbot

//@version=5
strategy("Accumulate", overlay = true)
lookback = input(defval = 21, title = 'Lookback')
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
//SMA Tredline
out = ta.sma(close, 200)
outf = ta.sma(close, 50)
outn = ta.sma(close, 90)
outt = ta.sma(close, 21)
//sma plot
plot(out, color=color.blue, title="MA200", offset=offset)
plot(outf, color=color.maroon, title="MA50", offset=offset)
plot(outn, color=color.orange, title="MA90", offset=offset)
plot(outt, color=color.olive, title="MA21", offset=offset)

//MarketCap Calculation
//MarketCap = 0.0
//TSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ", ignore_invalid_symbol = true)


//if str.tostring(TSO) != 'na'
//    if ta.barssince(TSO != TSO[1] and TSO > TSO[1])==0
//        MarketCap := TSO * close
//       
//    if barstate.islast and MarketCap == 0
//        runtime.error("No MarketCap is provided by the data vendor.")
//    
//momlen = 100
//msrc = MarketCap
//mom = msrc - msrc[momlen]
//plotmom = if (mom > mom[1])
//    true
//else
//   false

//OBV with sma on macd
obv = ta.cum(math.sign(ta.change(close)) * volume)
smoothingLength = 5
smoothingLine = ta.sma(obv,5)
[macdLine, signalLine, histLine] = ta.macd(ta.pvt, 12, 26, 9)
sellvolhigh = macdLine < signalLine
buyvolhigh = macdLine > signalLine
//Buy Signal
mafentry =ta.sma(close, 50) > ta.sma(close, 90)
//matentry = ta.sma(close, 21) > ta.sma(close, 50)
matwohun = close > ta.sma(close, 200)
higheshigh = ta.rising(high, 2)
higheslow = ta.rising(low, 2 )
twohunraise = ta.rising(out, 2)
//highvol =  ta.crossover(volume, ta.sma(volume, lookback))
highvol = ta.rising(volume,2)
fourlow = ta.lowest(close, lookback)
fourhig = ta.highest(close, lookback)
change =  (((fourhig - fourlow) / fourlow) * 100) <= 30
green = close > open
allup = false
lineabove = ta.cross(close, ta.sma(close, input(defval = 21, title = 'Entry Line')))
if matwohun and mafentry and higheshigh and twohunraise and buyvolhigh
//if higheshigh and higheslow and highvol
    allup := true

plotshape(allup, style=shape.arrowup,location=location.belowbar, color=color.green, title = "Buy Signal")

barsSinceLastEntry() =>
    strategy.opentrades > 0 ? bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) : na
    
//Sell Signal
mafexit =ta.sma(close, 50) < ta.sma(close, 90)
matexit = ta.sma(close, 21) < ta.sma(close, 50)
matwohund = close < ta.sma(close, 200)
linebreak = ta.sma(close, input(defval = 21, title = 'Exit Line')) > close
lowesthigh = ta.falling(high, 3)
lowestlow = ta.falling(low, 2 )
twohunfall = ta.falling(out, 3)
twentyfall = ta.falling(outt, 2)
highvole =  ta.crossover(volume, ta.sma(volume, 5))
//fourlow = ta.lowest(close, lookback)
//fourhig = ta.highest(close, lookback)
changed =  (((fourhig - close) / close) * 100) >= 10
red = close < open
atr = ta.atr(14)
//atrsmalen = int(bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) )
atrsmalen = barsSinceLastEntry()
atrsma = false
atrlen = 5
if str.tostring(atrsmalen) != 'NaN' and atrsmalen > 0
    atrlen := atrsmalen

    
atrsma := atr > ta.sma(atr,50)


alldwn = false
if sellvolhigh and lowestlow and (close < close[1] and close < open)
//if higheshigh and higheslow and highvol
    alldwn := true

plotshape(alldwn, style=shape.arrowdown,location=location.abovebar, color=color.red, title = "Sell Signal")


longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (allup)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (alldwn)
    strategy.entry("My Short Entry Id", strategy.short)


더 많은