作者: リン・ハーンチャオチャン開催日:2024年1月25日 15:56:41
タグ:

img

##戦略論理

  1. 傾向の方向を判断するためにDMIインジケーターを使用します.
    • DMI は 3 つの線で構成されています. +DI は上昇傾向を示し, -DI は下落傾向を示し,ADX は傾向の強さを判断します.
    • +DI>-DIは上昇傾向で,ロング; -DI>+DIは下落傾向で,ショート
  2. RSI インディケーターを使用して,過剰購入と過剰販売を判断します.
    • RSI は,過買いまたは過売りを決定するために,期間中の平均的利益と損失を比較します.
  3. DMI を組み合わせてトレンド方向とRSI を組み合わせると,過剰購入/過剰売却は市場のリズムをよりよく把握できます.
    • DMIが上昇傾向を示し,RSIが過剰に売れた場合,長期にわたって良いタイミングです
    • DMIがダウントレンドを示し,RSIが過剰に買い上げられた場合,ショートに適したタイミングです
  4. 利益をロックするために移動ストップ損失を設定します

##メリット分析 この傾向は比較的成熟し,安定しており,次の強みを持つ戦略に従っている.

  1. トレンドと過剰購入/過剰販売を組み合わせると,範囲限定市場での頻繁な取引が避けられます
  2. 人気指標DMIとRSIは,パラメータの調整が簡単で,徹底的な実用的な検証が可能です
  3. ストップロスは利益を固定し,ストップロスは一定程度回避する.
  4. 明確で簡単なルール 実行が簡単

##リスク分析 また,注意すべきリスクもあります.

  1. DMI と RSI は 簡単 に 偽信号 を 生み出し,不必要な 損失 を 引き起こし ます
  2. 効率的にシューズ市場をフィルタリングできず 罠にかかったりします
  3. トレンドが逆転すると,トレンドをフォローする人はすぐに離脱しない.

##最適化の方向性 戦略は以下の側面で最適化できます.

  1. 波動性フィルターを追加して,乱れやすい市場を避ける
  2. 偽のブレイクを避けるためにキャンドルスタイクパターンを組み合わせる
  3. DMI と RSI パラメータのダイナミック最適化


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-24 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © YingYangJPN

//@version=5
strategy("DMI and RSI Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// DMI indikatörünü tanımlayalım
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
len = input.int(14, minval=1, title="DI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
trailing_stop_loss_factor = input.float(0.50, "Trailing Stop Loss Factor", step = 0.01)

// RSI indikatörünü tanımlayalım
rsiLength = input.int(14, minval=1, title="RSI Length")
rsiSource = input(close, title="RSI Source")
rsiOverbought = input.int(70, title="RSI Overbought Level")
rsiOversold = input.int(30, title="RSI Oversold Level")
rsiValue = ta.rsi(rsiSource, rsiLength)

// Uzun pozisyon açma koşullarını tanımlayalım
longCondition1 = rsiValue < rsiOversold // RSI oversold seviyesinin altındaysa
longCondition2 = adx > 20 // ADX 20'den büyükse
longCondition3 = minus > plus

// Kısa pozisyon açma koşullarını tanımlayalım
shortCondition1 = rsiValue > rsiOverbought // RSI overbought seviyesinin üstündeyse
shortCondition2 = adx > 20 // ADX 20'den büyükse
shortCondition3 = plus > minus

// Uzun pozisyon açalım
if longCondition1 and longCondition2 and longCondition3
    strategy.entry("Long", strategy.long)
    

// Kısa pozisyon açalım
if shortCondition1 and shortCondition2 and shortCondition3
    strategy.entry("Short", strategy.short)
    
// Trailing Stop Loss
longTrailingStopLoss = strategy.position_avg_price * (1 - trailing_stop_loss_factor / 100)
shortTrailingStopLoss = strategy.position_avg_price * (1 + trailing_stop_loss_factor / 100)
if strategy.position_size > 0 
    strategy.exit("Exit Long", "Long", stop  = longTrailingStopLoss)
if strategy.position_size < 0 
    strategy.exit("Exit Short", "Short", stop = shortTrailingStopLoss)

// DMI ve RSI indikatörlerini grafiğe çizelim
plot(adx, color=#F50057, title="ADX")
plot(plus, color=#2962FF, title="+DI")
plot(minus, color=#FF6D00, title="-DI")
plot(rsiValue, color=#9C27B0, title="RSI")
hline(rsiOverbought, title="RSI Overbought Level", color=#E91E63, linestyle=hline.style_dashed)
hline(rsiOversold, title="RSI Oversold Level", color=#4CAF50, linestyle=hline.style_dashed)



もっと