롱과 숏 듀얼 트랙을 기반으로 한 추적 이익 실현 전략


생성 날짜: 2024-01-15 14:56:03 마지막으로 수정됨: 2024-01-15 14:56:03
복사: 1 클릭수: 626
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

롱과 숏 듀얼 트랙을 기반으로 한 추적 이익 실현 전략

Myo_LS_D 양적 정책

개요

Myo_LS_D 양적 전략은 다중 공백 이중 궤도에 기반한 추적 중지 전략이다. 이 전략은 평균선, 가격 돌파, 리스크 수익률 등 여러 지표를 종합적으로 활용하여 거래 신호를 구성한다. 추세를 정확하게 판단하는 전제 하에 높은 승률과 수익률을 달성한다.

전략 원칙

이 전략은 주로 트렌드 판단 모듈, 다중 모듈, 공백 모듈, 추적 중지 모듈 등으로 구성된다.

  1. 트렌드 판단 모듈은 donchain 통로를 사용하여 전체적인 트렌드 방향을 판단한다. 더 많은 진입은 상승 추세에 있다는 전제이며, 하락 추세에 있는 것은 다가가야 한다.

  2. 다중 모듈은 새로운 고점, 낮은 점, 긴 선 평균선 위치와 같은 요소를 고려한다. 공백 모듈은 새로운 고점, 낮은 점, 짧은 선 평균선 위치와 같은 요소를 고려한다. 이것은 위 또는 아래로 중요한 가격 지점을 돌파 할 때 상장을 보장한다.

  3. 스톱트랙 모듈은 두 개의 다른 기간의 SMA 평균선을 사용하여 가격 변화를 실시간으로 추적한다. 가격이 평균선 아래로 떨어질 때 평점 포지션을 중지한다. 이러한 실시간 추적은 트렌드에서 수익을 최대화 할 수 있다.

  4. 스톱 손실 설정은 스톱 손실을 확대하여 스톱 손실 지점이 지원 지점에서 멀리 떨어져 있고 흔들림이 발생하지 않도록합니다.

우위 분석

이 전략의 가장 큰 장점은 다공간 분리 창고 건설, 추적 정지 전략이다. 구체적으로 다음과 같이 나타난다:

  1. 다중 공간 분리는 일방적인 추세에서 수익을 얻을 수 있는 기회를 극대화할 수 있습니다.

  2. 트래킹 스톱은 실시간 조정으로 더 높은 수익률을 얻을 수 있다. 전통적인 스톱 방식에 비해 수익률이 크게 향상된다.

  3. 스톱로스를 확장하면 흔들림의 가능성을 줄이고 손실의 위험을 줄일 수 있다.

위험과 해결

이 전략의 주요 위험은 다음과 같습니다.

  1. 트렌드 판단에 오류가 발생하면 역동성 포지션 손실이 발생할 수 있다. Donchain 파라미터를 적절히 조정하거나 다른 지표 판단을 추가하여 최적화 할 수 있다.

  2. 추적 스톱은 너무 급진적이며, 조기 스톱은 지속 가능한 수익을 얻지 못할 수 있습니다. 스톱 평균선 간격을 적절히 확장하여 최적화 할 수 있습니다.

  3. 스포드 범위가 너무 작아 지진 발생 가능성을 높일 수 있다. 스포드 범위를 적절히 확장하여 위험을 줄일 수 있다.

최적화 방향

이 전략은 다음의 몇 가지 측면에서 개선될 수 있습니다.

  1. 트렌드 판단 모듈을 최적화하여 판단 정확도를 높인다. MACD와 같은 더 많은 지표와 결합하여 실현할 수 있다.

  2. 트래킹 스톱 방식을 조정하여 수익 공간을 더욱 확장하십시오. 예를 들어, 스톱 라인을 비율로 이동 할 수 있습니다.

  3. 스포드 범위를 넓히거나 스포드를 축소하는 것을 고려하여 진동 확률을 더 낮출 수 있습니다.

  4. 다양한 품종의 파라미터가 다르기 때문에 최적의 파라미터 조합을 얻기 위해 훈련할 수 있다. 전략적 수익을 더욱 향상시킬 수 있다.

요약하다

Myo_LS_D 전략은 전반적으로 비교적 성숙하고 안정적인 다공간 추적 중지 전략이다. 장점은 분명하고, 위험은 조절할 수 있으며, 장기간 사용하기에 가치가 있는 수치화 계획 중 하나이다. 미래에는 추가적인 최적화를 통해 수익 성능이 지속적으로 향상되어 더욱 우수한 수치화 전략이 될 수 있다.

전략 소스 코드
/*backtest
start: 2023-12-15 00:00:00
end: 2024-01-14 00:00:00
period: 4h
basePeriod: 15m
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/
// © agresiynin

//@version=5
// ©Myo_Pionex
strategy(
 title                  =   "Myo_simple strategy_LS_D",
 shorttitle             =   "Myo_LS_D",
 overlay                =   true )


// var
lowest_price = ta.lowest(low, 200)
highest_price = ta.highest(high, 200)
min_800 = ta.lowest(low, 800)
max_800 = ta.highest(high, 800)
tp_target_L = min_800 + (max_800 - min_800) * math.rphi
tp_target_S = max_800 - (max_800 - min_800) * math.rphi
sl_length_L = input.int(100, "做多的止損長度", minval = 50, maxval = 300, step = 50)
sl_length_S = input.int(100, "做空的止損長度", minval = 50, maxval = 300, step = 50)
sl_L = lowest_price * (1 - 0.005)
sl_S = highest_price * (1 + 0.005)
rrr_L = tp_target_L - sl_L / sl_L
rrr_S = ta.lowest(low, 800) + ta.highest(high, 800) - ta.lowest(low, 800) * math.rphi / ta.highest(high, 200) + 0.005 * ta.highest(high, 200) - ta.lowest(low, 200) - 0.005 * ta.lowest(low, 200)
smalen1 = input.int(10, "做多追蹤止盈SMA長度1", options = [5, 10, 20, 40, 60, 80])
smalen2 = input.int(20, "做多追蹤止盈SMA長度2", options = [5, 10, 20, 40, 60, 80])
smalen1_S = input.int(5, "做空追蹤止盈SMA長度1", options = [5, 10, 20, 40, 60, 80])
smalen2_S = input.int(10, "做空追蹤止盈SMA長度2", options = [5, 10, 20, 40, 60, 80])
TrendLength_L = input.int(400, "做多趨勢線", options = [100, 200, 300, 400, 500])
TrendLength_S = input.int(300, "做空趨勢線", options = [100, 200, 300, 400, 500])
SMA1 = ta.sma(close, smalen1)
SMA2 = ta.sma(close, smalen2)
SMA1_S = ta.sma(close, smalen1_S)
SMA2_S = ta.sma(close, smalen2_S)
shortlength = input.int(20, "短期均價K線數量")
midlength = input.int(60, "中期均價K線數量")
longlength = input.int(120, "長期均價K線數量")
ShortAvg = math.sum(close, shortlength)/shortlength
MidAvg = math.sum(close, midlength)/midlength
LongAvg = math.sum(close, longlength)/longlength

// Trend
basePeriods = input.int(8, minval=1, title="趨勢基準線")
basePeriods_Short = input.int(26, "做空基準線")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
baseLine = donchian(basePeriods)
baseLine_Short = donchian(basePeriods_Short)
trend = request.security(syminfo.tickerid, "D", baseLine)
isUptrend = false
isDowntrend = false
baseLine_D = request.security(syminfo.tickerid, "D", baseLine)
plot(baseLine_D, color=#B71C1C, title="趨勢基準線")
if close[0] > baseLine_D
    isUptrend := true
if close[0] < baseLine_Short
    isDowntrend := true
// Long
// Condition
// entry
con_a = low > lowest_price ? 1 : 0
con_b = high > highest_price ? 1 : 0
con_c = close[0] > ta.sma(close, TrendLength_L) ? 1 : 0
con_d = isUptrend ? 1 : 0
con_e = rrr_L > 3 ? 1 : 0
con_a1 = close[0] > ShortAvg[shortlength] ? 1 : 0
con_b1 = close[0] > MidAvg[midlength] ? 1 : 0

// close
con_f = ta.crossunder(close, SMA1) and ta.crossunder(close, SMA2) ? 1 : 0
con_g = close < ta.lowest(low, sl_length_L)[1] * (1 - 0.005) ? 1 : 0

// exit
con_h = tp_target_L

// Main calculation
LongOpen = false
AddPosition_L = false

if con_a + con_b + con_c + con_e + con_a1 + con_b1 >= 4 and con_d >= 1
    LongOpen := true
// Short
// Condition
// entry
con_1 = high < highest_price ? 1 : 0
con_2 = low < lowest_price ? 1 : 0
con_3 = close[0] < ta.sma(close, TrendLength_S) ? 1 : 0
con_4 = isDowntrend ? 1 : 0
con_5 = rrr_S > 3 ? 1 : 0
con_11 = close[0] < ShortAvg[shortlength] ? 1 : 0
con_12 = close[0] < MidAvg[midlength] ? 1 : 0

// close
con_6 = ta.crossover(close, SMA1_S) and ta.crossover(close, SMA2_S) ? 1 : 0
con_7 = close > ta.highest(high, sl_length_S)[1] * (1 + 0.005) ? 1 : 0

// exit
con_8 = tp_target_S

// Main calculation
ShortOpen = false
AddPosition_S = false

if con_1 + con_2 + con_3 + con_4 + con_5 + con_11 + con_12 >= 5
    ShortOpen := true

//
// execute
//
strategy.initial_capital = 50000
if strategy.position_size == 0
    if LongOpen
        strategy.entry("Long Open" , strategy.long , comment= "Long Open " + str.tostring(close[0]), qty=strategy.initial_capital/close[0])

if strategy.position_size > 0
    if (con_f > 0 or con_g > 0 or ShortOpen) and close <= baseLine_D
        strategy.close_all(comment="Close Long " + str.tostring(close[0]))

if strategy.position_size == 0
    if ShortOpen
        strategy.entry("Short Open" , strategy.short , comment= "Short Open " + str.tostring(close[0]), qty=strategy.initial_capital/close[0])

if strategy.position_size < 0
    if (con_6 > 0 or con_7 > 0 or LongOpen) and close >= baseLine_D
        strategy.close_all(comment="Close Short " + str.tostring(close[0]))


plot(ta.sma(close, TrendLength_L), color=#e5c212, title="LTradeTrend")
plot(ta.sma(close, TrendLength_S), color=#1275e5, title="STradeTrend")
plot(SMA1, "SMA1", color = color.lime, linewidth = 2)
plot(SMA2, "SMA2", color = color.rgb(255, 0, 255), linewidth = 2)