밸런스 라인 PSAR 지표 거래 전략


생성 날짜: 2023-09-12 15:16:17 마지막으로 수정됨: 2023-09-12 15:16:17
복사: 1 클릭수: 915
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 평형선 그래프와 PSAR 지표를 사용하여 트렌드 판단과 거래 신호를 생성합니다. 이 전략은 평형선 소음 감기의 특성을 사용하여, PSAR 지표와 함께 트렌드 역점을 판단하여 중장선 트렌드를 포착합니다.

전략적 원칙:

  1. 평형선의 개시 가격, 폐쇄 가격, 최고 가격, 최저 가격을 계산한다.

  2. 평형선 개체 색에 따라 다중 머리 및 공허 머리 경향을 판단한다.

  3. PSAR 지표를 계산하여, 상향 하향 또는 하향 상향으로 돌파 할 때, 트렌드 반전을 결정합니다.

  4. 평형선이 다단일 때, PSAR는 아래로 돌파하여 더 많은 일을 한다. 평형선이 공백일 때, PSAR는 위쪽으로 돌파하여 공백을 한다.

  5. PSAR는 새로운 고고 낮은 그리고 가속 인자에 따라 적응 조정한다.

이 전략의 장점:

  1. 평형선 필터 소음, PSAR 캡처 반전. 조합은 정확도를 높인다.

  2. PSAR 매개 변수는 시장 변화에 적응할 수 있다.

  3. 규칙이 명확하고, 쉽게 실행할 수 있고, 매개 변수 최적화를 돕는다.

이 전략의 위험은:

  1. 평형선과 PSAR 모두 지연 문제로 인해 최적의 입구 지점을 놓칠 수 있습니다.

  2. 이런 현상에서는 잘못된 신호가 발생하기 쉽다.

  3. 역전 거래의 위험을 감수하기 위해 엄격한 자금 관리가 필요합니다.

요약하자면, 이 전략은 평형선을 통해 큰 트렌드를 판단하고, PSAR은 특정 입문 시점을 식별하고, 트렌드 추적 작업을 수행한다. 미지수 문제와 가짜 반전의 위험은 경계해야 하지만, 최적화함으로써 장기적으로 안정적인 수익을 얻을 수 있다.

전략 소스 코드
/*backtest
start: 2023-08-12 00:00:00
end: 2023-09-11 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("QuantNomad - Heikin-Ashi PSAR Strategy", shorttitle = "HA-PSAR[QN]", overlay = false)

////////////
// INPUTS //

start      = input(0.02, title = "PSAR Start")
increment  = input(0.02, title = "PSAR Increment")
maximum    = input(0.2,  title = "PSAR Max")

start_year  = input(2018, 'Start Year',  input.integer)
start_month = input(1,    'Start Month', input.integer)
start_day   = input(1,    'Start Day',   input.integer)

end_year  = input(2100, 'End Year',  input.integer)
end_month = input(1,    'End Month', input.integer)
end_day   = input(1,    'End Day',   input.integer)

date_start = timestamp(start_year, start_month, start_day, 00, 00)
date_end   = timestamp(end_year,   end_month,   end_day,   00, 00)

// if time is in correct period
time_cond = time >= date_start and time <= date_end

// Calculation HA Values 
haopen  = 0.0
haclose = (open + high + low + close) / 4
haopen := na(haopen[1]) ? (open + close) / 2 : (haopen[1] + haclose[1]) / 2
hahigh  = max(high, max(haopen, haclose))
halow   = min(low,  min(haopen, haclose))

// HA colors
hacolor = haclose > haopen ? color.green : color.red

psar        = 0.0 // PSAR
af          = 0.0 // Acceleration Factor
trend_dir   = 0   // Current direction of PSAR
ep          = 0.0 // Extreme point
trend_bars  = 0

sar_long_to_short = trend_dir[1] == 1  and haclose <= psar[1] // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1] // PSAR switches from short to long

trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long

// Calculate trend direction
trend_dir    := barstate.isfirst[1] and haclose[1] > haopen[1] ? 1 : 
   barstate.isfirst[1] and haclose[1] <= haopen[1] ? -1 : 
   sar_long_to_short ? -1 : 
   sar_short_to_long ?  1 : nz(trend_dir[1])

trend_bars := sar_long_to_short ? -1 : 
              sar_short_to_long ?  1 : 
              trend_dir ==  1   ? nz(trend_bars[1]) + 1 : 
              trend_dir == -1   ? nz(trend_bars[1]) - 1 : 
              nz(trend_bars[1])

// Calculate  Acceleration Factor
af := trend_change ? start : 
   (trend_dir == 1 and hahigh > ep[1]) or  
   (trend_dir == -1 and low < ep[1]) ? 
   min(maximum, af[1] + increment) : 
   af[1]

// Calculate extreme point
ep := trend_change and trend_dir == 1 ? hahigh :  
   trend_change and trend_dir == -1 ? halow : 
   trend_dir == 1 ? max(ep[1], hahigh) : 
   min(ep[1], halow)

// Calculate PSAR
psar := barstate.isfirst[1] and haclose[1] > haopen[1] ? halow[1] : 
   barstate.isfirst[1] and haclose[1] <= haopen[1] ? hahigh[1] : 
   trend_change ? ep[1] :    
   trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep) 

plotcandle(haopen, hahigh, halow, haclose, title = "HA", color = hacolor)
plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red,  linewidth = 2)

// Strategy
strategy.entry("long",  true,  when = sar_short_to_long and time_cond)
strategy.entry("short", false, when = sar_long_to_short and time_cond)