SSL 채널 지표를 기반으로 한 추세 추종 전략


생성 날짜: 2023-11-27 16:42:34 마지막으로 수정됨: 2023-11-27 16:42:34
복사: 0 클릭수: 1449
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

SSL 채널 지표를 기반으로 한 추세 추종 전략

개요

이 전략은 SSL 통로 지표에 기반한 트렌드 추적 전략이다. 이 전략은 안정적인 자금 성장을 위해 수익을 잠금하기 위해 스톱로스 및 스톱 관리와 결합한다.

전략 원칙

코드의 주요 논리는 SSL 상단 및 하단 궤도의 골든 크로스 (Golden Cross) 를 사용하여 트렌드 방향을 판단하는 것이다. 구체적으로 SSL 상단 궤도가 SSL 하단 궤도를 하단 방향으로 돌파할 때, 더 많이 하고, SSL 하단 궤도가 SSL 상단 궤도를 상단 방향에서 하단 방향으로 돌파할 때, 공백하게 한다.

포지션에 진입한 후, 전략은 ATR 지표를 계수로 곱하여 스톱로스 및 스톱 프라이즈를 설정한다. 예를 들어, 스톱로스 프라이즈는 가격으로 ATR * 1.5을 빼고, 스톱 프라이즈는 가격으로 ATR * 1을 더한다. 이것은 단위 손실을 효과적으로 제어하고 수익을 잠금화할 수 있다.

SSL 통로가 포크할 때, 평지한다. 이렇게하면 트렌드의 전환점을 추적할 수 있고, 적시에 손실을 막는다.

우위 분석

  1. SSL 통로를 사용하여 트렌드 방향을 판단하는 정확도
  2. 정지 및 차단 설정이 합리적이고, 위험을 효과적으로 제어할 수 있습니다.
  3. 동향 전환점을 추적하는 시간적 상쇄

위험 분석

  1. 트렌드 트레이딩은 과도한 트레이딩으로 이어집니다.
  2. SSL 통로 판단 실패의 확률이 존재합니다.
  3. ATR을 최적화해야 합니다.

그 해결책은 다음과 같습니다.

  1. 적당히 조정된 포지션 주기
  2. 다른 지표와 함께 확인
  3. 다른 ATR 계수의 조합을 테스트합니다.

최적화 방향

  1. ATR 변수를 최적화하여 최적의 변수 조합을 찾습니다.
  2. 다른 지표 필터링 및 확인 신호를 추가합니다.
  3. 다른 시장에 따라 조정된 포지션 주기
  4. 제휴 전략의 최적화

요약하다

이 전략은 전체적으로 명확하고, SSL 통로로 추세를 판단하고, 합리적인 스톱을 설정한다. 그러나, 더 많은 테스트와 최적화가 필요하며, 다른 지표와 함께 가짜 신호를 필터링하여 최적의 파라미터 조합을 찾는다. 동시에, 다른 시장에 따라 파라미터를 조정하여 전략을 더 탄력하게 만든다.

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

//@version=3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Designed per No Nonsense Forex VP rules
//For testing your individual indicators before the full system
//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 from 1 x confirmation
// - Exit conditions
//// - Exit on confirmation flip 

///////////////////////////////////////////////////
//Trades entries
///////////////////////////////////////////////////
// - First entry L1 or S1 with standard SL and TP

///////////////////////////////////////////////////
//Included Indicators and settings
///////////////////////////////////////////////////
// - Confirmtion = SSL 10

///////////////////////////////////////////////////
//Credits
// Strategy causecelebre https://www.tradingview.com/u/causecelebre/
// SSL Channel ErwinBeckers https://www.tradingview.com/u/ErwinBeckers/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Change log
//First release. Testing of indicators
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

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

//Price
price = close

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

slMultiplier = input(1.5, "SL")
tpMultiplier = input(1, "TP")

atrlength = input(title="ATR Length", defval=14, minval=1)
atrsmoothing = input(title="Smoothing", defval="SMA", options=["RMA", "SMA", "EMA", "WMA"])

ma_function(source, atrlength) => 
    if atrsmoothing == "RMA"
        rma(source, atrlength)
    else
        if atrsmoothing == "SMA"
            sma(source, atrlength)
        else
            if atrsmoothing == "EMA"
                ema(source, atrlength)
            else
                wma(source, atrlength)

//plot(ma_function(tr(true), atrlength), title = "ATR", color=#991515, transp=0)

atr = ma_function(tr(true), atrlength)

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

ssllen=input(title="SSL Length 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

plot(sslDown, "SSL Down", linewidth=1, color=red)
plot(sslUp, "SSL Up", linewidth=1, color=lime)

///////////////////////////////////////////////////
//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)

//Signals based on signal position
trendLong = c_Up > c_Down ? 1 : 0
trendShort = c_Down > c_Up ? 1 : 0

confirmLong = c_Long
confirmShort = c_Short

plotshape(trendLong, color = green, style=shape.triangleup, location=location.bottom)
plotshape(trendShort, color = red, style=shape.triangledown, location=location.bottom)


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//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.order("L1", strategy.long, when = confirmLong)
    strategy.close("L1", when = confirmShort)
    strategy.exit("L Limit Exit", "L1", stop = long_sl, limit = long_tp)

    
    //Short entries with standard 1.5 ATR for SL, 1 ATR for TP
    short_sl = price + (atr * slMultiplier)
    short_tp = price - (atr * tpMultiplier)
    strategy.order("S1", strategy.short, when = confirmShort)
    strategy.close("S1", when = confirmLong)
    strategy.exit("S Limit Exit", "S1", stop = short_sl, limit = short_tp)


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//End
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////