バランスラインPSARインジケーター取引戦略


作成日: 2023-09-12 15:16:17 最終変更日: 2023-09-12 15:16:17
コピー: 1 クリック数: 915
1
フォロー
1617
フォロワー

この戦略は,均衡線グラフとPSAR指標を組み合わせて,トレンド判断を行い,取引シグナルを生成する.この戦略は,均衡線の静音化特性を利用し,PSAR指標とトレンド反転点を組み合わせて,中長線のトレンドを捕捉する.

戦略の原則:

  1. 均衡線の開値,閉値,最高値,最低値を計算する.

  2. 均衡線実体色によって判断する多頭と空頭傾向.

  3. PSAR指標を計算し,上から下へ,あるいは下から上へと突破すると,トレンドの逆転を決定する.

  4. 均衡線が多頭であれば,PSARは下へ突破して多行する.均衡線が空頭であれば,PSARは上へ突破して空行する.

  5. PSARは新高新低と加速因子に応じて自律的に調整する.

この戦略の利点は

  1. バランスラインフィルターノイズ,PSAR捕捉反転. 組み合わせにより精度が向上する.

  2. PSARパラメータは市場変化に対応する.

  3. ルールが明確で操作が簡単で,パラメータの最適化に便利である.

この戦略のリスクは

  1. 均衡線とPSARの両方で遅滞があり,最適な入場点を逃す可能性がある.

  2. 震動傾向下では,PSARは誤信号を発生させる可能性が高い.

  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)