가격 돌파 및 회귀를 기반으로 한 모멘텀 단기 거래 전략


생성 날짜: 2023-11-13 16:50:45 마지막으로 수정됨: 2023-11-13 16:50:45
복사: 2 클릭수: 665
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

가격 돌파 및 회귀를 기반으로 한 모멘텀 단기 거래 전략

개요

이 전략은 가격 돌파와 평균 회귀의 조합을 기반으로 여러 지표를 사용하여 확인 및 필터링을 수행하여 추세를 판단하고 추적합니다. 이 전략은 단선 및 중선 거래에 적합하며, 엄격한 입시 및 퇴출 메커니즘을 통해 작은 이익을 잠금합니다.

전략 원칙

  1. HMA 평균선을 기준선으로 사용하여 가격 트렌드 방향을 판단한다. 평균선보다 높은 가격은 부진이며, 평균선보다 낮은 가격은 하락이다.

  2. SSL 통로는 확인 지표로서 통로의 방향과 가격 관계에 의해 트렌드를 확인한다.

  3. TDFI는 양능력 지표로 판단력을 측정한다. 특정 수준에 도달할 때만 입학한다.

  4. RVI 지표는 탈퇴 지표로서, RVI 선 모양이 변하면, 트렌드가 끝났다고 판단하고, 포지션에서 탈퇴한다.

  5. ATR 지표는 스톱 로즈와 스톱 보드를 계산한다.

  6. 입시 조건: 가격은 기준선을 뚫고, SSL 통로의 방향은 가격과 일치하고, TDFI는 절벽을 달성한다.

  7. 출구 조건: RVI 지표선 형태 변경, 또는 가격 재침입 기준선 및 SSL 통로

우위 분석

  1. 여러 지표의 조합을 사용하여 판단하면 가짜 돌파구를 효과적으로 필터링 할 수 있습니다.

  2. 엄격한 입력 조건과 Exit 중지, 단 한번의 중지 제어할 수 있습니다.

  3. 가격 동향을 최대한 활용하여 추가 수익을 얻습니다.

  4. 지표 매개 변수를 최적화 할 수 있는 공간이 넓고, 다른 제품과 주기별로 조정할 수 있다.

위험 분석

  1. 이 트렌드 전환을 판단할 수 없는 상황에서는, 과잉이 계속 상승/하락할 위험이 있다.

  2. 단기 운영, 과도한 거래의 위험.

  3. 스톱피스 설정에는 주관적인 영향이 있으며, 너무 느슨하거나 너무 단단할 수 있다.

  4. 잘못된 매개 변수 설정으로 거래가 빈번하거나 부족할 수 있습니다.

최적화 방향

  1. 트렌드 판단 지표를 추가하여 트렌드 방향 판단의 정확성을 보장합니다.

  2. 역전 신호 지표가 추가되어 과중 추격/추격의 확률을 낮춘다.

  3. ATR 트레일링 스톱을 ATR 트레일링 스톱으로 조정하여 더 역동적인 스톱을 고려하십시오.

  4. 다양한 평선 시스템을 테스트하여 파라미터를 최적화하는 방향을 찾습니다.

  5. 지표 파라미터를 최적화하여 특정 거래 품종에 대한 파라미터 조정.

요약하다

이 전략은 다중 지표 확인을 통해 거래 신호의 정밀화를 실현한다. 엄격한 스톱 로즈 메커니즘은 단일 손실을 제어한다. 이 전략은 기술 분석 작업에 익숙한 사람들을 위해 적합하며, 매개 변수를 조정하여 다른 시장 주기에 적응할 수 있다. 전체적으로 이 전략은 긍정적 인 효과와 수익을 가지고 있지만, 트렌드 판단 오류와 과도한 거래의 위험을 예방하는 데 주의가 필요합니다.

전략 소스 코드
/*backtest
start: 2022-11-06 00:00:00
end: 2023-11-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Designed per No Nonsense Forex VP rules
//Made to be as modular as possible, so we can swap the indicators in and out.
//Originated from causecelebre
//Tried to put in as much VP rules as possible

///////////////////////////////////////////////////
//Rules Implemented:
///////////////////////////////////////////////////
// - SL 1.5 x ATR
// - TP 1 x ATR
//
// - Entry conditions
//// - Entry within 1 candles of baseline + 1 x confirmation + volume
//// - Entry only if baseline is < 1 x ATR
// - Exit conditions
//// - Exit on exit indicator or when baseline or confirmation flip 

///////////////////////////////////////////////////
//Trades entries
///////////////////////////////////////////////////
// - First entry L1 or S1 with standard SL and TP
// - Second entry L2 or S2 with standard SL and exit upon the exit conditions

///////////////////////////////////////////////////
//Included Indicators and settings
///////////////////////////////////////////////////
// - Baseline = HMA 20
// - Confirmtion = SSL 10
// - Volume = TDFI 4
// - Exit = RVI 4

///////////////////////////////////////////////////
//Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// TDFI causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

strategy(title="NNFX Strategy | jh", overlay = true )

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  **** Set the main stuff  ****
///////////////////////////////////////////////////

//Price
price = close

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ATR stuff
///////////////////////////////////////////////////

atrLength = input(14, "ATR Length")
slMultiplier = input(1.5, "SL")
tpMultiplier = input(1, "TP")
atr = atr(atrLength)

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  **** Baseline ****
///////////////////////////////////////////////////

///////////////////////////////////////////////////
//HMA 20
///////////////////////////////////////////////////

hmaslowlength = input(20, minval=1)
src = input(close, title="Source")
slowhullma = wma(2*wma(src, hmaslowlength/2)-wma(src, hmaslowlength), round(sqrt(hmaslowlength)))
plot(slowhullma, title = "baseline", color = yellow, linewidth=2, transp=0)

///////////////////////////////////////////////////
// Base Signals
///////////////////////////////////////////////////

///////////////////////////////////////////////////
baseline = slowhullma

//Signals based on crossover
//baseShort = crossover(baseLine, price)
//baseLong = crossover(price, baseLine)

//Signals based on signal position
b_Short = baseline > price ? 1 : 0
l_Long = baseline < price ? 1 : 0

baseShort = b_Short
baseLong = l_Long

///////////////////////////////////////////////////
//ATR Check
///////////////////////////////////////////////////

distBasefromPrice = abs(baseline - price)
atrCheck = distBasefromPrice <= atr ? 1 : 0

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  **** Confirmation ****
///////////////////////////////////////////////////

///////////////////////////////////////////////////
//SSL Channel
///////////////////////////////////////////////////

sslLen=input(title="SSL Period", defval=10)
smaHigh=sma(high, sslLen)
smaLow=sma(low, sslLen)
Hlv = na
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp   = Hlv < 0 ? smaLow : smaHigh

///////////////////////////////////////////////////
//Confirm Signals
///////////////////////////////////////////////////

c_Up = sslUp
c_Down = sslDown

//Signals based on crossover
c_Long = crossover(c_Up, c_Down)
c_Short = crossover(c_Down, c_Up)

confirmLong = c_Long
confirmShort = c_Short

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  **** Volume Indicator Start ****
///////////////////////////////////////////////////

///////////////////////////////////////////////////
//TDFI
///////////////////////////////////////////////////

lookback = input(4, title = "TDFI Lookback") 
filterHigh = input(0.05, title = "Filter High") 
filterLow = input(-0.05, title = "Filter Low") 

mma = ema(price * 1000, lookback)
smma = ema(mma, lookback)

impetmma = mma - mma[1]
impetsmma= smma - smma[1]
divma = abs(mma - smma)
averimpet = (impetmma + impetsmma) / 2

number = averimpet
pow = 3
result = na

for i = 1 to pow - 1
    if i == 1
        result := number
    result := result * number

tdf = divma * result
ntdf = tdf / highest(abs(tdf), lookback * 3)

///////////////////////////////////////////////////
//Volume Signals
///////////////////////////////////////////////////
v_Long = ntdf > filterHigh ? 1 : 0
v_Short = filterLow > ntdf ? 1 : 0

volumeLong = v_Long
volumeShort = v_Short

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// **** Exit Indicator ****
///////////////////////////////////////////////////

///////////////////////////////////////////////////
//RVI 4
///////////////////////////////////////////////////

rgvlen = input(4, title="RVI Length", minval=1)
rvi = sum(swma(close-open), rgvlen)/sum(swma(high-low),rgvlen)
sig = swma(rvi)

///////////////////////////////////////////////////
//Exit Signals
///////////////////////////////////////////////////
e_Short = crossover(rvi, sig)
e_Long = crossover(sig, rvi)

exitOutofShort = e_Short
exitOutofLong = e_Long

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// **************************** Logic to handle NNFX rules ****************************
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Checking for base and confirmation indication with 1 candle difference
baseandConfirmLong = ((baseLong[0] and confirmLong[0]) or (baseLong[1] and confirmLong[0]) or (baseLong[1] and confirmLong[1]) or (baseLong[0] and confirmLong[1])) ? 1 : 0
baseandConfirmShort = ((baseShort[0] and confirmShort[0]) or (baseShort[1] and confirmShort[0]) or (baseShort[1] and confirmShort[1]) or (baseShort[0] and confirmShort[1])) ? 1 : 0

//Combining with volume with 1 candle difference
enterLong = ((baseandConfirmLong[0] and volumeLong[0]) or (baseandConfirmLong[1] and volumeLong[0]) or (baseandConfirmLong[1] and volumeLong[1]) or (baseandConfirmLong[0] and volumeLong[1])) ? 1 : 0
enterShort = ((baseandConfirmShort[0] and volumeShort[0]) or (baseandConfirmShort[1] and volumeShort[0]) or (baseandConfirmShort[1] and volumeShort[1]) or (baseandConfirmShort[0] and volumeShort[1])) ? 1 : 0

//Exit on base or confirmation flip over
baseandConfirmFliptoShort = ((baseShort[0] or confirmShort[0]) or (baseShort[1] or confirmShort[0]) or (baseShort[1] or confirmShort[1]) or (baseShort[0] or confirmShort[1])) ? 1 : 0
baseandConfirmFliptoLong = ((baseLong[0] or confirmLong[0]) or (baseLong[1] or confirmLong[0]) or (baseLong[1] or confirmLong[1]) or (baseLong[0] or confirmLong[1])) ? 1 : 0

//Exit on base and confirmation flip or exit indicator 
exitLong = exitOutofLong or baseandConfirmFliptoShort ? 1 : 0 
exitShort = exitOutofShort or baseandConfirmFliptoLong ? 1 : 0 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Entries and Exits
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (year>2009)

    //Long entries with standard 1.5 ATR for SL, 1 ATR for TP
    long_sl = price - atr * slMultiplier
    long_tp = price + atr * tpMultiplier
    strategy.entry("L1", strategy.long, when = enterLong and atrCheck)
    strategy.exit("L1 SL Exit", "L1", stop = long_sl, limit = long_tp)
    strategy.close("L1", when = exitLong)
    
    //Long entries with no TP
    strategy.entry("L2", strategy.long, when = enterLong and atrCheck)
    strategy.exit("L2 SL Exit", "L2", stop = long_sl)
    strategy.close("L2", when = exitLong)

    //Short entries with standard 1.5 ATR for SL, 1 ATR for TP
    short_sl = price + atr * slMultiplier
    short_tp = price - atr * tpMultiplier
    strategy.entry("S1", strategy.short, when = enterShort and atrCheck)
    strategy.exit("S1 SL Exit", "Short1", stop = short_sl, limit = short_tp)
    strategy.close("S1", when = exitShort)
    
    //Short entries with no TP
    strategy.entry("S2", strategy.short, when = enterShort and atrCheck)
    strategy.exit("S2 Exit", stop = short_sl)
    strategy.close("S2", when = exitShort)
    
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////