프랙탈 브레이크업 전략

저자:차오장, 날짜: 2023-12-19 15:32:57
태그:

img

전반적인 설명

이것은 가격 프랙탈을 기반으로 트렌드를 판단하는 트렌드를 따르는 긴 라인 추적 전략입니다. 최신 프랙탈 포인트의 돌파구에 따라 포지션을 열기로 결정합니다. 동시에 마지막 N 프랙탈 포인트의 평균 가격을 계산하여 트렌드 방향을 판단하고 트렌드가 변경되면 포지션을 닫습니다.

원칙

  1. 가격의 프랙탈 포인트를 계산합니다. 프랙탈 포인트는 전날과 다음 이틀의 최고 가격보다 높은 오늘날의 가장 높은 가격으로 정의됩니다.

  2. 마지막 프랙탈 포인트의 가격을 저항으로 기록하세요.

  3. 닫기 가격이 마지막 프랙탈 포인트를 넘으면 저항이 깨지고 긴 포지션이 설정된 것으로 간주됩니다.

  4. 트렌드를 결정하기 위해 마지막 N 프랙탈 포인트의 평균 가격을 계산합니다. 평균 가격이 상승하면 상승 추세이고 떨어지면 하락 추세입니다.

  5. 만약 평균 프랙탈 포인트 가격이 긴 포지션 중에 하락하면 포지션을 닫습니다.

이점 분석

이 프랙탈 기반 트렌드 판단 전략의 가장 큰 장점은 시장 소음을 효과적으로 필터하고 장기적인 트렌드 방향을 결정할 수 있다는 것입니다. 간단한 이동 평균선과 다른 지표와 비교하면 갑작스러운 비정상적인 변동에 더 강한 저항력을 가지고 있습니다.

또한, 이 전략의 포지션 개설 및 폐쇄 기준은 매우 명확합니다. 이는 빈번한 거래를 피합니다. 또한 장기 보유에 특히 적합합니다.

위험 분석

이 전략의 가장 큰 위험은 프랙탈 포인트 자체의 확률적 성격에 있다. 프랙탈은 가격이 확실히 역전될지 완전히 예측할 수 없다. 즉, 잘못된 판단의 확률은 여전히 존재한다. 잘못된 판단이 발생하면 손실의 위험에 직면하게 된다.

또한, 프랙탈 포인트를 판단하는 기간은 길고 고 주파수 거래에 적응할 수 없습니다. 단기 거래를 추구하는 경우이 전략이 적합하지 않을 수 있습니다.

최적화 방향

프랙탈 점의 잘못된 판단의 가능성을 고려하면 다음과 같은 방법으로 최적화 할 수 있습니다.

  1. 볼링거 밴드, 이동 평균 등과 같은 다른 지표와 결합하여 프랙탈 포인트에만 기반한 잘못된 판단을 피하십시오.

  2. 프랙탈 포인트의 매개 변수를 조정하여 프랙탈 포인트 판단을 최적화합니다.

  3. 손실이 어느 정도 증가할 때 손실을 막기 위한 스톱 로스 전략을 추가합니다.

요약

프랙탈 브레이크아웃 전략은 전반적으로 장기적인 트렌드를 판단하는 데 매우 적합하며 장기 투자자들에 의해 사용하기에 매우 적합합니다. 우리가 적절한 매개 변수를 적절하게 조정하고 판단의 정확성을 보장하는 전제에서 다른 필터링 지표를 추가하는 한, 우리는이 전략을 크게 최적화하고 양적 의사 결정의 중요한 부분으로 만들 수 있습니다.


/*backtest
start: 2023-11-18 00:00:00
end: 2023-12-18 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("Fractal Breakout Strategy (by ChartArt)", shorttitle="CA_-_Fractal_Breakout_Strat", overlay=true)

// ChartArt's Fractal Breakout Strategy
//
// Version 1.0
// Idea by ChartArt on April 24, 2016.
//
// This long only strategy determines the last fractal top
// and enters a trade when the price breaks above the last
// fractal top. The strategy also calculates the average
// price of the last 2 (or 3) fractal tops to get the trend.
//
// The strategy exits the long trade when the average of the
// fractal tops is falling (when the trend is lower highs).
// And the user can manually set a delay of this exit.
//
// In addition the fractals tops can be colored in blue
// and a line can be drawn based on the fractal tops.
// This fractal top line is colored by the fractal trend.
//
// List of my work: 
// https://www.tradingview.com/u/ChartArt/
// 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  
// 
// 


// input

n_time = input(title='Always exit each trade after this amount of bars later (Most important strategy setting)', defval=3)
price = input(hl2,title='Price type to determine the last fractal top and the fractal breakout, the default is (high+low)/2')


// fractal calculation

fractal_top = high[2] > high[3] and high[2] > high[4] and high[2] > high[1] and high[2] > high[0]
fractal_price = valuewhen(fractal_top, price, 1)
use_longer_average = input(true,title='Use Fractal price average of the last 3 fractals instead of the last 2 fractals?')
fractal_average = use_longer_average?(fractal_price[1] + fractal_price[2] + fractal_price[3] ) / 3 : (fractal_price[1] + fractal_price[2]) / 2
fractal_trend = fractal_average[0] > fractal_average[1]
no_repainting = input(true,title='Use the price of the last bar to prevent repainting?')
fractal_breakout = no_repainting?price[1] > fractal_price[0]:price[0] > fractal_price[0]


// highlight fractal tops

show_highlight = input(true,title='Highlight fractal tops in blue and color all other bars in gray?')
highlight = fractal_top?blue:silver
barcolor(show_highlight?highlight:na,offset=-2)
show_fractal_top_line = input(true,title='Draw a colored line based on the fractal tops?')
fractal_top_line = change(fractal_top) != 0 ? price : na
fractal_top_line_color = change(fractal_price) > 0 and fractal_breakout == true ? green : change(fractal_price) < 0 and fractal_breakout == false ? red : blue
plot(show_fractal_top_line?fractal_top_line:na,offset=-2,color=fractal_top_line_color,linewidth=4)


// strategy

trade_entry = fractal_trend and fractal_breakout
trade_exit = fractal_trend[n_time] and fractal_trend == false 
 
if (trade_entry)
    strategy.entry('Long', strategy.long)
 
if (trade_exit)
    strategy.close('Long')

더 많은