적응형 불윙클 지표 롱-숏 전략


생성 날짜: 2024-01-04 16:09:30 마지막으로 수정됨: 2024-01-04 16:09:30
복사: 0 클릭수: 651
avatar of ChaoZhang ChaoZhang
1
집중하다
1621
수행원

적응형 불윙클 지표 롱-숏 전략

개요 (Overview)

이 전략은 부빈코 지표에 기반하여 시장 추세를 자동으로 인식하고 포지션을 설정합니다. 부빈코 지표, 이동 평균 및 수평지원선과 같은 기술 지표를 통합하여 자동으로 브레이크 신호를 인식하고 포지션을 설정합니다.

전략 원칙 (Strategy Principle)

이 전략의 핵심 지표는 부빈코 지표이며, 다른 거래일 종점 가격의 상수차 값을 계산하여 시장의 추세와 중요한 지원/저항 수준을 판단한다. 지표가 특정 수평선을 통과할 때 더 많이 하고, 아래로 넘어갈 때 공백한다.

또한, 이 전략은 21일, 55일 등 여러 개의 이동 평균으로 구성된 EMA 안전띠를 통합한다. 이러한 일률의 순서 관계에 따라 현재는 다목적 시장, 공목적 시장 또는 종합 시장으로 판단하고, 그에 따라 공백 또는 다수 작업을 제한한다.

부빈코 지표는 거래 신호를 식별하고, 이동 평균은 시장 단계를 판단합니다. 이 둘을 결합하여 부적절한 포지션 구축을 피할 수 있습니다.

장점 분석 (Advantage Analysis)

이 전략의 가장 큰 장점은 시장의 다중 하위 경향을 자동으로 식별 할 수 있다는 것입니다. 부빈코 지표는 두 시간 동안의 가격 차원에 매우 민감하여 중요한 지원 저항을 신속하게 파악 할 수 있습니다. 동시에, 이동 평균의 순서는 현재 상황을 효과적으로 판단 할 수 있습니다.

이러한 빠른 지표와 트렌드 지표의 결합은 전략이 구매 및 판매 지점을 신속하게 파악하고 부적절한 구매를 방지 할 수있게합니다. 이것은 전략의 가장 큰 장점입니다.

리스크 분석

이 전략의 위험은 크게 두 가지 측면에서 발생한다. 하나는 부빈코 지표 자체가 가격 변화에 매우 민감하기 때문에 불필요한 거래 신호를 많이 생성할 수 있다는 것이다. 둘째는 이동 평균이 수평으로 이동할 때 혼란을 일으켜 포지션이 혼란에 빠지게 한다는 것이다.

첫 번째 위험에는 부빈코 지표의 매개 변수를 적절하게 조정하여 지표 계산 주기를 늘리고 불필요한 거래를 줄일 수 있습니다. 두 번째 위험에는 이동 평균을 더 추가하여 추세를 더 정확하게 판단 할 수 있습니다.

최적화 방향 (Optimization Directions)

이 전략의 주요 최적화 방향은 매개 변수 조정과 필터 조건의 증가이다.

부빈코 지표에 대해, 다른 주기적 변수를 시도하여 최적의 변수 조합을 찾을 수 있습니다. 이동 평균에 대해, 더 많은 평균선을 추가하여 더 완전한 경향 판단 시스템을 형성 할 수 있습니다. 또한 변동률 지표, 거래량 지표와 같은 필터 조건을 추가하여 거짓 신호를 줄일 수 있습니다.

이 전략의 안정성과 수익성을 더욱 높일 수 있는 방법은, 조건과 변수들을 통합적으로 조정하는 것이다.

요약

이 적응형 부빈코도 공중 전략은 빠른 지표와 트렌드 지표를 성공적으로 결합하여 시장의 중요한 지점을 자동으로 식별하고 올바른 위치를 설정할 수 있습니다. 그것의 장점은 빠른 위치와 부적절한 위치 구축을 방지하는 능력입니다. 다음 단계는 매개 변수 및 조건을 통해 최적화하여 전략의 안정성과 수익 수준을 더욱 향상시킬 수 있습니다.

전략 소스 코드
/*backtest
start: 2023-12-27 00:00:00
end: 2024-01-03 00:00:00
period: 1m
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/
// © boftei

//@version=5

strategy("Boftei's Strategy", overlay=false, pyramiding=1, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, margin_long = 100, margin_short = 100, slippage=0, commission_type=strategy.commission.percent, commission_value = 0, initial_capital = 40, precision = 6)
strat_dir_input = input.string("all", "strategy direction", options=["long", "short", "all"])
strat_dir_value = strat_dir_input == "long" ? strategy.direction.long : strat_dir_input == "short" ? strategy.direction.short : strategy.direction.all
strategy.risk.allow_entry_in(strat_dir_value)
//////////////////////////////////////////////////////////////////////
//DATA
testStartYear = input(2005, "Backtest Start Year")
testStartMonth = input(7, "Backtest Start Month")
testStartDay = input(16, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
//Stop date if you want to use a specific range of dates
testStopYear = input(2030, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)


testPeriod() =>
    time >= testPeriodStart and time <= testPeriodStop ? true : false
//////////////////////////////////////////////////////////////////////
sell = input.float(0.0065, "sell level")
buy = input.float(0, "buy level")
long1 = input.float(-0.493, "long retry - too low")
long2 = input.float(2, "long close up")
long3 = input.float(-1.5, "long close down")
short1 = input.float(1.26, "short retry - too high")
short2 = input.float(-5, "dead - close the short")
///< botvenko script
nn = input(60, "Histogram Period")
float x = 0
float z = 0
float k = 0



y = math.log(close[0]) - math.log(close[nn])
if y>0
    x := y
else
    k := y
//---------------------------------------------
        
plot(y > 0 ? x: 0, color = color.green, linewidth = 4)
plot(y <= 0 ? k: 0, color = color.maroon, linewidth = 4)
plot(y, color = color.yellow, linewidth = 1)

co = ta.crossover(y, buy)
cu = ta.crossunder(y, sell)
retry_long = ta.crossunder(y, long1)
deadline_long_up = ta.crossover(y, long2)
deadline_long_down = ta.crossunder(y, long3)
retry_short = ta.crossover(y, short1)
deadline_short = ta.crossunder(y, short2)


hline(buy, title='buy', color=color.green, linestyle=hline.style_dotted, linewidth=2)
hline(0, title='zero', color=color.white, linestyle=hline.style_dotted, linewidth=1)
hline(sell, title='sell', color=color.red, linestyle=hline.style_dotted, linewidth=2)
hline(long1, title='long retry', color=color.blue, linestyle=hline.style_dotted, linewidth=2)
hline(long2, title='overbought', color=color.teal, linestyle=hline.style_dotted, linewidth=2)
hline(long3, title='oversold', color=color.maroon, linestyle=hline.style_dotted, linewidth=2)
hline(short1, title='short retry', color=color.purple, linestyle=hline.style_dotted, linewidth=2)
hline(short2, title='too low to short - an asset may die', color=color.navy, linestyle=hline.style_dotted, linewidth=2)


////////////////////////////////////////////////////////////EMAprotectionBLOCK
ema_21 = ta.ema(close, 21)
ema_55 = ta.ema(close, 55)
ema_89 = ta.ema(close, 89)
ema_144 = ta.ema(close, 144)
//ema_233 = ta.ema(close, 233)
// ema_377 = ta.ema(close, 377)

long_st = ema_21>ema_55 and ema_55>ema_89 and ema_89>ema_144 //and ema_144>ema_233 and ema_233>ema_377
short_st = ema_21<ema_55 and ema_55<ema_89 and ema_89<ema_144 //and ema_144<ema_233 and ema_233<ema_377 

g_v = long_st == true?3:0
r_v = short_st == true?-2:0
y_v = long_st != true and short_st != true?2:0

plot(math.log(ema_21), color = color.new(#ffaf5e, 50))
plot(math.log(ema_55), color = color.new(#b9ff5e, 50))
plot(math.log(ema_89), color = color.new(#5eff81, 50))
plot(math.log(ema_144), color = color.new(#5effe4, 50))
//plot(math.log(ema_233), color = color.new(#5e9fff, 50))
//plot(math.log(ema_377), color = color.new(#af5eff, 50))

plot(long_st == true?3:0, color = color.new(color.green, 65), linewidth = 5)
plot(short_st == true?-2:0, color = color.new(color.red, 65), linewidth = 5)
plot(long_st != true and short_st != true?2:0, color = color.new(color.yellow, 65), linewidth = 5)
////////////////////////////////////////////////////////////EMAprotectionBLOCK




if (co and testPeriod() and (g_v == 3 or y_v == 2))
    strategy.close("OH BRO", comment = "EXIT-SHORT")
    strategy.close("OH DUDE", comment = "EXIT-SHORT")
	strategy.entry("OH DAMN", strategy.long, comment="ENTER-LONG 'co'")
if (retry_long and testPeriod() and (g_v == 3 or y_v == 2))
    strategy.close("OH DAMN", comment = "EXIT-LONG")
    strategy.entry("OH BRUH", strategy.long, comment="ENTER-LONG 'retry_long'")
	
if (cu and testPeriod() and (r_v == -2 or y_v == 2))
    strategy.close("OH DAMN", comment = "EXIT-LONG")
    strategy.close("OH BRUH", comment = "EXIT-LONG")
	strategy.entry("OH BRO", strategy.short, comment="ENTER-SHORT 'cu'")
if (retry_short and testPeriod() and (r_v == -2 or y_v == 2))
    strategy.close("OH BRO", comment = "EXIT-SHORT")
    strategy.entry("OH DUDE", strategy.short, comment="ENTER-SHORT 'retry_short'")
	
    
if (deadline_long_up and testPeriod() or r_v == -2 and testPeriod())
    strategy.close("OH DAMN", comment = "EXIT-LONG 'deadline_long_up'")
if (deadline_long_down and testPeriod())
    strategy.close("OH DAMN", comment = "EXIT-LONG 'deadline_long_down'")
if (deadline_short and testPeriod() or g_v == 3 and testPeriod())
    strategy.close("OH BRO", comment = "EXIT-SHORT 'deadline_short'")
    // (you can use strategy.close_all(comment = "close all entries") here)