멀티 타임프레임 수익 전략

저자:차오장, 날짜: 2023-10-30 12:02:43
태그:

img

전반적인 설명

이 전략은 여러 시간 프레임에서 수익을 관리하는 것을 구현하는 것을 목표로합니다. 이 전략은 더 정확하고 효과적인 수익 관리를 달성하기 위해 더 높은 시간 프레임에 기반한 수익을 차지하는 비율과 주요 가격 수준을 모두 사용합니다.

전략 논리

이 전략은 웨이브 트렌드 지표가 넘어가면 먼저 장차가 됩니다.

이윤관리를 위해, 전략은 이윤관리의 두 가지 유형을 사용합니다.

  1. 영업이익 비율: 입시 가격의 특정 비율을 기준으로 여러 개의 영업이익 가격을 설정합니다.

  2. 멀티 타임프레임 수익: 일일 및 4시간 차트에서 이동 평균을 그리고 그 가격을 수익 가격으로 사용하십시오.

이윤을 차지하는 비율을 위해, 전략은 다른 비율로 수익을 취하는 가격을 설정합니다. 가격이 각 수익을 취하는 가격을 달성하면 설정된 비율에 따라 부분 포지션을 닫습니다.

멀티 타임프레임 취득을 위해 전략은 일일 및 4시간 차트 모두에 100MA와 200MA를 그려냅니다. 가격이 이러한 이동 평균에 도달하면 포지션을 닫습니다.

또한, 스톱 로스 가격이 설정됩니다. 가격이 스톱 로스 가격 이하일 때, 모든 포지션은 종료됩니다.

전체 전략은 더 포괄적이고 정교한 영업이익 관리를 달성하기 위해 수익을 차지하는 비율과 다중 시간 프레임을 결합합니다.

장점

  • 고정된 비율을 기준으로 조기 또는 불충분한 수익을 피하기 위해 수익을 차지하는 비율을 채택합니다.

  • 다중 시간 프레임 분석을 활용하여 더 정확한 수익 가격을 더 나은 수준으로 설정합니다.

  • 여러 계층의 취득은 부분적으로 포지션을 닫을 수 있고 위험을 줄일 수 있습니다.

  • 스톱 로스 가격을 설정하면 하향 리스크를 효과적으로 제어할 수 있습니다.

  • 이윤을 차지하는 비율과 이윤을 취하는 다중 기간을 결합하면 이윤을 취하는 것이 더 포괄적이고 정화됩니다.

위험 분석

  • 수익률은 매개 변수 설정에 의존합니다. 부적절한 설정은 일찍 또는 늦게 수익을 얻을 수 있습니다.

  • 멀티 타임프레임 분석은 이동 평균에 의존하고 있습니다.

  • 부적절한 스톱 손실 배치로 인해 불필요한 스톱 손실이 발생할 수 있습니다.

  • 매개 변수들을 최적화해서 이윤을 차지하는 비율과 이윤을 취하는 여러 기간을 가장 잘 맞추어야 합니다.

최적화 방향

  • 더 많은 이동 평균을 테스트하여 가장 최적의 것을 찾으십시오.

  • 모델 예측 방법을 시도하여 주요 가격 수준을 예측하여 수익 가격을 취하십시오.

  • 기대 수익률, 후속 수익률 등과 같은 더 많은 수익률 규칙을 도입하여 수익률을 더 포괄적으로 만들 수 있습니다.

  • 테스트 최적의 비율은 다른 보유 기간에 수익 매개 변수를 취합니다.

  • 더 나은 전반적인 리스크 보상 비율을 위해 백테스팅을 통해 수익 매개 변수를 최적화합니다.

요약

이 전략은 수익을 취하는 비율과 다중 시간 프레임을 결합하여 유연하고 정확한 수익을 관리하는 것을 실현합니다. 전략은 더 나은 수익 가격 선택과 더 포괄적인 수익을 취하는 등의 장점을 가지고 있습니다. 또한 매개 변수 설정 및 스톱 손실 배치와 같은 문제가 있습니다. 수익을 취하는 매개 변수를 최적화하여 후속 개선이 가능하며, 더 많은 수익을 취하는 규칙을 추가하여 수익을 취하는 시스템을 더 견고하게 만듭니다.


/*backtest
start: 2023-10-22 00:00:00
end: 2023-10-29 00:00:00
period: 5m
basePeriod: 1m
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/
// © TrendCrypto2022
//@version=5
// strategy("Take profit Multi timeframe", overlay=true, margin_long=100, margin_short=100)
takepercent  = input.bool(title="Take profit %", defval=true ,group="Set up take profit")
takemtf  = input.bool(title="Take profit Multi timeframe", defval=false ,group="Set up take profit")

//Paste your strategy at here. This is example strategy. I use WaveTrend indicator

//WaveTrend indicator
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
oblv1 = input(60, "Over Bought Lv 1")
oblv2 = input(53, "Over Bought Lv 2")
oslv1 = input(-60, "Over Sold Lv 1")
oslv2 = input(-53, "Over Sold Lv 2")
 
ap = hlc3 
esa = ta.ema(ap, n1)
d = ta.ema(math.abs(ap - esa), n1)
ci = (ap - esa) / (0.015 * d)
tci = ta.ema(ci, n2)
 
wt1 = tci
wt2 = ta.sma(wt1,4)

//Strategy
buy = ta.crossover(wt1, wt2) and wt1 < -40
if (buy)
    strategy.entry("Long", strategy.long)


//Resistant in time D and 4H
ema_len1 = input.int(title='Ema1', defval=100, group='Take profit Mtf')
ema_len2 = input.int(title='Ema2', defval=200, group='Take profit Mtf')
src = input.source(title='Source', defval=close, group='Take profit Mtf')
tf1 = input.timeframe(title='Time frame 1', defval='240', group='Take profit Mtf')
tf2 = input.timeframe(title='Time frame 2', defval='D', group='Take profit Mtf')
htf_ma1 = ta.ema(src, ema_len1)
htf_ma2 = ta.ema(src, ema_len2)
ema1 = request.security(syminfo.tickerid, tf1, htf_ma1)
ema2 = request.security(syminfo.tickerid, tf1, htf_ma2)
ema3 = request.security(syminfo.tickerid, tf2, htf_ma1)
ema4 = request.security(syminfo.tickerid, tf2, htf_ma2)

//Plot
plotema1 = plot(ema1, color=color.new(color.silver, 0), style=plot.style_line, linewidth=1, offset=0, title='Ema100 4h', display=display.none)
plotema2 = plot(ema2, color=color.new(color.silver, 0), style=plot.style_line, linewidth=1, offset=0, title='Ema200 4h', display=display.none)
plotema3 = plot(ema3, color=color.new(color.orange, 20), style=plot.style_line, linewidth=1, offset=0, title='Ema100 D', display=display.none)
plotema4 = plot(ema4, color=color.new(color.orange, 20), style=plot.style_line, linewidth=1, offset=0, title='Ema200 D', display=display.none)

//Label take profit multitime frame
var label labelema1 = na
label.delete(labelema1)
labelema1 := label.new(x=time + 120, y=ema1, text='\n*****Ema100 4H: ' + str.tostring(math.round(ema1,4)) + '', color=color.new(#000000, 100), textcolor =  color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)

var label labelema2 = na
label.delete(labelema2)
labelema2 := label.new(x=time + 120, y=ema2, text='\n*****Ema200 4H: ' + str.tostring(math.round(ema2,4)) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)

var label labelema3 = na
label.delete(labelema3)
labelema3 := label.new(x=time + 120, y=ema3, text='\n*****Ema100 1D: ' + str.tostring(math.round(ema3,4)) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)

var label labelema4 = na
label.delete(labelema4)
labelema4 := label.new(x=time + 120, y=ema4, text='\n*****Ema200 1D: ' + str.tostring(math.round(ema4,4)) + '', color=color.new(#000000, 100), textcolor = color.yellow, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)

//Set up take profit %
percent(pcnt) =>
    strategy.position_size != 0 ? math.round(pcnt / 100 * strategy.position_avg_price / syminfo.mintick) : float(na)
TP1=input.float(3, title="TP1 %", step=0.1, group="Take profit %")
TP2=input.float(5, title="TP2 %", step=1, group="Take profit %")
TP3=input.float(6, title="TP3 %", step=1, group="Take profit %")
TP4=input.float(8, title="TP4 %", step=1, group="Take profit %")

SL=input.float(5, title="Stop Loss %", step=1, group="Take profit %")
qty1=input.float(5, title="% Close At TP1", step=1, group="Take profit %")
qty2=input.float(5, title="% Close At TP2", step=1, group="Take profit %")
qty3=input.float(5, title="% Close At TP3", step=1, group="Take profit %")
qty4=input.float(5, title="% Close At TP4", step=1, group="Take profit %")
lossPnt_L = percent(SL)

//Set up take profit multi timeframe
a = array.from((ema1), (ema2), (ema3), (ema4))
tpmtf1 = array.min(a)
tpmtf2 = array.min(a, 2)
tpmtf3 = array.min(a, 3)
tpmtf4 = array.min(a, 4)
//Set up exit
long_sl_level = strategy.position_avg_price - lossPnt_L*syminfo.mintick
if takepercent == true
    strategy.exit("TP1%", "Long", qty_percent = qty1, profit = percent(TP1), loss = lossPnt_L)
    strategy.exit("TP2%", "Long", qty_percent = qty2, profit = percent(TP2), loss = lossPnt_L)
    strategy.exit("TP3%", "Long", qty_percent = qty3, profit = percent(TP3), loss = lossPnt_L)
    strategy.exit("TP4%", "Long", qty_percent = qty4, profit = percent(TP3), loss = lossPnt_L)
    strategy.close_all(when= ta.crossunder(wt1, wt2) and wt1 > 0, comment="Close All")


if takemtf == true and array.max(a, 1) > strategy.position_avg_price
    strategy.exit("TP1Mtf", "Long", qty_percent = qty1, limit = tpmtf1, stop = long_sl_level)
    strategy.exit("TP2Mtf", "Long", qty_percent = qty2, limit = tpmtf2, stop = long_sl_level)
    strategy.exit("TP3Mtf", "Long", qty_percent = qty3, limit = tpmtf3, stop = long_sl_level)
    strategy.close_all(when= ta.crossunder(wt1, wt2) and wt1 > 0, comment="Close All")

// Plot TP & SL
long_tp1_level = strategy.position_avg_price + percent(TP1)*syminfo.mintick
long_tp2_level = strategy.position_avg_price + percent(TP2)*syminfo.mintick
long_tp3_level = strategy.position_avg_price + percent(TP3)*syminfo.mintick
long_tp4_level = strategy.position_avg_price + percent(TP4)*syminfo.mintick

plot(strategy.position_size > 0 ? long_sl_level : na, color=color.red, style=plot.style_linebr, title="SL Long")

plot(strategy.position_size > 0 ? long_tp1_level : na, color=color.lime, style=plot.style_linebr, title="Long TP1%")
plot(strategy.position_size > 0 ? long_tp2_level : na, color=color.lime, style=plot.style_linebr, title="Long TP2%")
plot(strategy.position_size > 0 ? long_tp3_level : na, color=color.lime, style=plot.style_linebr, title="Long TP3%")
plot(strategy.position_size > 0 ? long_tp4_level : na, color=color.lime, style=plot.style_linebr, title="Long TP4%")

plot(strategy.position_size > 0 ? tpmtf1 : na, color=color.orange, style=plot.style_linebr, title="Long TP1Mtf", display = display.none)
plot(strategy.position_size > 0 ? tpmtf2 : na, color=color.orange, style=plot.style_linebr, title="Long TP2Mtf", display = display.none)
plot(strategy.position_size > 0 ? tpmtf3 : na, color=color.orange, style=plot.style_linebr, title="Long TP3Mtf", display = display.none)

//Label TP
if strategy.position_size > 0
    var label labellongtp1 = na
    label.delete(labellongtp1)
    labellongtp1 := label.new(x=time + 120, y=long_tp1_level, text='\nTP1: ' + str.tostring(math.round(long_tp1_level,2)) + '', color=color.new(#000000, 100), textcolor = color.lime, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
     
    var label labellongtp2 = na
    label.delete(labellongtp2)
    labellongtp2 := label.new(x=time + 120, y=long_tp2_level, text='\nTP2: ' + str.tostring(math.round(long_tp2_level,2)) + '', color=color.new(#000000, 100), textcolor = color.lime, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
     
    var label labellongtp3 = na
    label.delete(labellongtp3)
    labellongtp3 := label.new(x=time + 120, y=long_tp3_level, text='\nTP3: ' + str.tostring(math.round(long_tp3_level,2)) + '', color=color.new(#000000, 100), textcolor = color.lime, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
        
    var label labellongtp4 = na
    label.delete(labellongtp4)
    labellongtp4 := label.new(x=time + 120, y=long_tp4_level, text='\nTP4: ' + str.tostring(math.round(long_tp4_level,2)) + '', color=color.new(#000000, 100), textcolor = color.lime, size=size.small, style=label.style_label_left, xloc=xloc.bar_time, yloc=yloc.price)
    
    

더 많은