KDJ ゴールデンクロス ロングエントリー戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-01 10:28:12
タグ:

img

概要

KDJゴールデンクロスロングエントリー戦略は,KDJ指標に基づいた定量的な取引戦略である.この戦略は主に,KDJ指標のJラインとDラインの黄色のクロスを利用して買い信号を生成し,JラインがDラインを超えるとロングする.この戦略は比較的シンプルで,実施が容易で,定量的な取引の初心者にとって適している.

戦略の論理

この戦略で使用される主な技術指標は,KDJ指標である.KDJ指標は,K線,D線,J線で構成される.

K = (現在の閉店 - 過去N日間の最低値) ÷ (過去N日間の最高値 - 過去N日間の最低値) x 100;

D = K の M 日移動平均値

J=3K−2D

KDJ指標の規則によると,J線がD線を横切ると価格が上昇し,ロングポジションが取れる.J線がD線を下回ると価格が下がり,ショートポジションが取れる.

この戦略は,上記のルールを活用し,J線がD線の上を横切ると,つまり金色の十字が形成され,ロングに行くときに買い信号を生成する.出口信号は,Jがロングポジションを閉じるために100を超えると発生する.

利点

  1. KDJ指標を使用して,価格上昇と下落の動きを組み込むエントリータイミングを決定し,より信頼性があります.

  2. この戦略には 分かりやすく 実行しやすい シンプルな信号ルールがあり 初心者にも適しています

  3. リスクを効果的にコントロールするために ストップ・プロフィートとストップ・ロスを採用しました

  4. パラメータの最適化と柔軟な実装のための大きな余地

リスク

  1. KDJインジケーターは誤った信号を生成し 損失を招く傾向があります

  2. 購入後の短期的な市場調整は,ストップロスの脱出を誘発し,主要なトレンドを見逃す可能性があります.

  3. パラメータの設定が正しくない場合,オーバートレードや不明確な信号が発生する可能性があります.

  4. トランザクションコストが全体的な収益性への影響を考慮する必要がある.

主なリスク管理方法:パラメータを適切に最適化し,インデックスを改善するために追跡し,ストップロスの範囲を適切に拡大する.

オプティマイゼーションの方向性

  1. KDJのパラメータを最適化して 最適なパラメータの組み合わせを見つけます

  2. 偽信号を避けるためにフィルタリング条件を追加します.フィルタリングのために他の指標や形式を組み合わせることができます.

  3. 市場の種類 (牛市場または熊市場) に基づいて異なるパラメータ設定を選択できます.

  4. ストップ・ロスの出口の可能性を減らすため,ストップ・ロスの範囲を適切に拡大できる.

  5. トレーディング・ボリュームと他の指標を組み合わせて分析することで 罠にはまりません

概要

KDJゴールデンクロスロングエントリー戦略は,比較的シンプルで,全体的に実践的で,初心者にとって開始し,実装するのが簡単です.この戦略には,特定の取引の利点がありますが,いくつかのリスクもあります.戦略の価値を完全に実現するために,標的型最適化が必要です.全体として,この戦略は重要な研究と適用に値します.


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

//  ## !<------------------ Script --------------------------> 
//@version=5
strategy('KDJ NVDA', shorttitle='KDJ')

ilong = input(9, title='period')
isig = input(3, title='signal')

bcwsma(s, l, m) =>
    _bcwsma = float(na)
    _s = s
    _l = l
    _m = m
    _bcwsma := (_m * _s + (_l - _m) * nz(_bcwsma[1])) / _l
    _bcwsma

// profit strategy add
profit_m = input.float(1.20,"Profit Margin",minval=1.0,maxval=1.99,step=0.05)
stop_m = input.float(0.98,"Stop Loss Margin",minval=0.0,maxval=1,step=0.05)

// Make input options that configure backtest date range
startDate = input.int(title="Start Date", defval=1, minval=1,maxval=31)
startMonth = input.int(title="Start Month", defval=1,minval=1,maxval=12)
startYear = input.int(title="Start Year", defval=2023,minval=2018,maxval=2024)
endDate = input.int(title="End Date", defval=1, minval=1,maxval=31)
endMonth = input.int(title="End Month", defval=1,minval=1,maxval=12)
endYear = input.int(title="End Year", defval=2024,minval=2018,maxval=2099)

// intialization of variables
// Look if the close time of the current bar
// falls inside the date range
inDateRange = (time >= timestamp(syminfo.timezone, startYear,startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))

c = close
h = ta.highest(high, ilong)
l = ta.lowest(low, ilong)
RSV = 100 * ((c - l) / (h - l))
pK = bcwsma(RSV, isig, 1)
pD = bcwsma(pK, isig, 1)
pJ = 3 * pK - 2 * pD
KDJ = math.avg(pD, pJ, pK)

go_long= ta.crossunder(pD,pJ)


if (inDateRange and go_long)
    strategy.entry("S",strategy.long,comment="C")
	// strategy.exit("S", limit=c*profit_m, stop=c*stop_m, comment="SL/SP")
	
if (inDateRange and pJ > 100)
	strategy.close("S", comment="TP")
	
// Plot options
// plot(pK, color= #1E88E5)
// plot(pD, color=#FF6F00)
// plot(ma, color=color.yellow)
// bgcolor(pJ>pD? color.green : color.red)

plot(pK, title='% K', color=color.new(color.orange, 0))
plot(pD, title='% D', color=color.new(color.lime, 0))
plot(pJ, title='% J', color=color.new(color.fuchsia, 0))
plot(KDJ, title='KDJ', color=color.new(color.white, 0))
// </PINE> </SCRIPT>
// ## This source code is subject to the terms of the ozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// ## !<------------------ End Script --------------------------> 


もっと