Pivot Point と Slope をベースにしたリアルタイムトレンドライン取引

作者: リン・ハーンチャオチャン開催日:2024年4月26日15時34分28秒
タグ:ATRADXマルチ

img

概要

この戦略は,ピボットポイント (PivotHighとPivotLow) を使用して価格のスイング・ハイ&ローを特定し,これらのポイントに基づいて上下トレンドラインを描く.トレンドラインの傾斜は,ATR (平均真差),標準偏差,または線形回帰などの方法を使用して計算され,その後傾斜因数で調整される.価格がトレンドラインを突破すると,戦略は購入または販売信号を生成する.

戦略原則

  1. ta.pivothigh ((() と ta.pivotlow ((() の関数を使用して,特定の回顧期間にわたってスイング・ハイ (ph) とスイング・ロー (pl) を検出します.
  2. 選択した計算方法 (ATR,標準偏差,または線形回帰) に基づいて傾向線の傾きを計算し,傾き因数 (mult) で掛けることで調整する.
  3. 傾き値とピボット値を使用して,上向きトレンドライン (上) と下向きトレンドライン (下向き) の現在の値を計算します.
  4. 現在の終了価格がトレンドラインを突破したかどうかを決定する.終了価格が上昇トレンドラインを超えている場合,上向きブレイクシグナルが生成される.終了価格がダウントレンドラインを下回っている場合,下向きブレイクシグナルが生成される.
  5. グラフのトレンドラインを図に描き,線を拡張するオプションを用意します
  6. ブレイクシグナルに基づく取引: 上向きブレイクでロング,下向きブレイクでショート.

戦略 の 利点

  1. この戦略は,価格の行動 (ピボットポイントとトレンドライン) の客観的な事実に基づいて取引信号を生成し,一定程度の信頼性と安定性を提供します.
  2. トレンドラインの傾きは,市場の変動に基づいて動的に調整され,異なる市場状況に適応できます.
  3. ユーザは,傾き計算方法とパラメータ設定を柔軟に選択して戦略のパフォーマンスを最適化できます.
  4. この戦略は,異なるユーザーのニーズを満たすために,リアルタイムと遅延信号モードの両方を提供しています.
  5. 内蔵されたアラート機能は,ユーザーが取引機会を間に合うようにすることができます.

戦略リスク

  1. 市場が不安定で 傾向が明確でない場合 戦略は頻繁に誤った信号を生成し 収益性が低下する可能性があります
  2. 戦略のパフォーマンスはパラメータ設定に依存する.不適切なパラメータは,戦略の失敗または過剰な取引を引き起こす可能性があります.
  3. 遅延信号モードでは,バックテストがあるため,実際の取引結果は過去のテスト結果と異なる可能性があります.

戦略の最適化方向

  1. トレンドラインのブレイクシグナルを確認し,シグナル品質を改善するために,取引量や波動性などのより多くの技術指標や価格行動特性を導入する.
  2. 偽信号を減らすために,トレンドラインブレイクの期間と規模などの要因を考慮して取引信号をフィルターします.
  3. ポジション管理とリスク管理を最適化し,トレンド強度や波動性に基づいてポジションサイズを動的に調整し,合理的なストップ・ロストとテイク・プロフィートのレベルを設定する.
  4. マシンラーニングや最適化アルゴリズムを使用してパラメータを最適化して,最適なパラメータの組み合わせを見つけます.

概要

この戦略は,ピボットポイントとトレンドライン傾斜を活用してリアルタイムトレンドライン取引システムを構築する.トレンドラインブレイクイベントをキャプチャすることで,戦略はトレンド形成の初期段階で取引することができます.この戦略には一定の利点がありますが,不安定な市場でリスクを知っておいて,より多くの情報,シグナルフィルタリングの最適化,ポジション管理,および他の方法によって戦略の強度と収益性をさらに高めることが必要です.


/*backtest
start: 2023-04-20 00:00:00
end: 2024-04-25 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy(" only Ajay ", overlay=true)

//------------------------------------------------------------------------------
//Settings
//------------------------------------------------------------------------------{
length = input.int(14, 'Swing Detection Lookback')
mult = input.float(1., 'Slope', minval = 0, step = .1)
calcMethod = input.string('Atr', 'Slope Calculation Method', options = ['Atr','Stdev','Linreg'])
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the past. Disable backpainting to see real time information returned by the indicator.')

//Style
upCss = input.color(color.teal, 'Up Trendline Color', group = 'Style')
dnCss = input.color(color.red, 'Down Trendline Color', group = 'Style')
showExt = input(true, 'Show Extended Lines')

//------------------------------------------------------------------------------}
//Calculations
//------------------------------------------------------------------------------{
var upper = 0.
var lower = 0.
var slope_ph = 0.
var slope_pl = 0.

var offset = backpaint ? length : 0

n = bar_index
src = close

ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)

//Slope Calculation Method
slope = switch calcMethod
    'Atr'    => ta.atr(length) / length * mult
    'Stdev'  => ta.stdev(src,length) / length * mult
    'Linreg' => math.abs(ta.sma(src * n, length) - ta.sma(src, length) * ta.sma(n, length)) / ta.variance(n, length) / 2 * mult

//Get slopes and calculate trendlines
slope_ph := ph ? slope : slope_ph
slope_pl := pl ? slope : slope_pl

upper := ph ? ph : upper - slope_ph
lower := pl ? pl : lower + slope_pl

var upos = 0
var dnos = 0
upos := ph ? 0 : close > upper - slope_ph * length ? 1 : upos
dnos := pl ? 0 : close < lower + slope_pl * length ? 1 : dnos

//------------------------------------------------------------------------------}
//Extended Lines
//------------------------------------------------------------------------------{
// var uptl  = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend = extend.right)
// var dntl  = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend = extend.right)

// if ph and showExt
//     uptl.set_xy1(n-offset, backpaint ? ph : upper - slope_ph * length)
//     uptl.set_xy2(n-offset+1, backpaint ? ph - slope : upper - slope_ph * (length+1))

// if pl and showExt
//     dntl.set_xy1(n-offset, backpaint ? pl : lower + slope_pl * length)
//     dntl.set_xy2(n-offset+1, backpaint ? pl + slope : lower + slope_pl * (length+1))

//------------------------------------------------------------------------------}
//Plots
//------------------------------------------------------------------------------{
plot(backpaint ? upper : upper - slope_ph * length, 'Upper', color = ph ? na : upCss, offset = -offset)
plot(backpaint ? lower : lower + slope_pl * length, 'Lower', color = pl ? na : dnCss, offset = -offset)

//Breakouts
upBreakout = upos > upos[1]
dnBreakout = dnos > dnos[1]

if (upBreakout)
    strategy.entry("Up Breakout", strategy.long)

if (dnBreakout)
    strategy.entry("Down Breakout", strategy.short)

//------------------------------------------------------------------------------}
//Alerts
//------------------------------------------------------------------------------{
alertcondition(upos > upos[1], 'Upward Breakout', 'Price broke the down-trendline upward')
alertcondition(dnos > dnos[1], 'Downward Breakout', 'Price broke the up-trendline downward')

//------------------------------------------------------------------------------}


関連性

もっと