週末波動性取引戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月16日 10:53:01
タグ:

img

概要

この戦略は,金曜日の閉盘価格に基づいて長期と短期入場条件を設定し,土曜日と日曜日の開盤後に長期または短期を設定し,月曜日の開盤前にすべてのポジションを終了します.この戦略は,週末に金曜日の閉盘価格の周りの価格変動から利益を得ることを目的としています.

原則

  1. 基準価格として金曜日の閉店価格を記録する
  2. 土曜と日曜の営業日:
    • 金曜の閉店の105%以上なら ショート
    • 金曜の閉店の95%を下回るなら,ロング
  3. 利益は初期資本の3%に設定されています
  4. 月曜の営業前にすべてのポジションを閉じる

利点分析

  1. 市場リスクを減らすため,週末の取引量は低く,変動も低い.
  2. 明確な入国・退出規則は戦略の実行を簡素化する
  3. 短期取引で安定した小利益を追求する
  4. 短周期で高い資本回転

リスク分析

  1. 週末の価格変動は予想より小さく,ポジションを開くことができません.
  2. 過剰な変動がストップ損失を引き起こす可能性があります.
  3. 月曜日の重要なイベントは,価格ギャップを引き起こす可能性があります. 時間内に損失を止めることができない.

リスク対策

  1. エントリーの変動範囲を調整する
  2. 適切なストップ・ロスト・ポイントを設定する
  3. ポジションを早く閉め,週末は持たずに

最適化ガイドライン

  1. 異なる製品の特徴に基づいて入口限界値を調整する
  2. バックテスト結果に基づいて利益を取るルールを最適化
  3. 資本規模に基づいてレバレッジを選択する
  4. 移動平均値などの指標フィルターを時間エントリに追加する

概要

この短期取引戦略は,非常に明確な論理とリスク管理措置を持っています.適切なパラメータ調整と継続的なテストと最適化により,安定した投資収益を生むことができます.同時に,過剰な変動による週末の大損失のリスクは,適切なリスク管理を通じて管理する必要があります.


/*backtest
start: 2023-10-16 00:00:00
end: 2023-11-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//Copyright Boris Kozak 
strategy("XBT Weekend Trade Strategy", overlay=true, default_qty_type=strategy.percent_of_equity,initial_capital=20000)
leverage = input(1,"Leverage")
profitTakingPercentThreshold = input(0.03,"Profit Taking Percent Threshold")

//****Code used for setting up backtesting.****///
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(12, "Backtest Start Month")
testStartDay = input(10, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2025, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FFFF : na
bgcolor(testPeriodBackgroundColor, transp=50)

testPeriod() => true
    
//****END Code used for setting up backtesting.****///


//*** Main entry point is here***//
// Figure out how many days since the Friday close 
days_since_friday = if dayofweek == 6
    0
else 
    if dayofweek == 7
        1
    else
        if dayofweek == 1
            2
        else
            if dayofweek == 2
                3
            else
                if dayofweek == 3
                    4
                else
                    if dayofweek == 4
                        5
                    else
                        6
    
// Grab the Friday close price
fridaycloseprice = request.security(syminfo.tickerid,'D',close[days_since_friday])
plot(fridaycloseprice)
strategy.initial_capital = 50000
// Only perform backtesting during the window specified 
if testPeriod()
    // If we've reached out profit threshold, exit all positions 
    if ((strategy.openprofit/strategy.initial_capital) > profitTakingPercentThreshold)
        strategy.close_all()
    // Only execute this trade on saturday and sunday (UTC)
    if (dayofweek == 7.0 or dayofweek == 1.0)
        // Begin - Empty position (no active trades)
        if (strategy.position_size == 0)
            // If current close price > threshold, go short 
            if ((close>fridaycloseprice*1.045))
                strategy.entry("Short Entry", strategy.short, leverage)
            else
                // If current close price < threshold, go long
                if (close<(fridaycloseprice*0.955))
                    strategy.entry("Long Entry",strategy.long, leverage)
        // Begin - we already have a position
        if (abs(strategy.position_size) > 0)
            // We are short 
            if (strategy.position_size < 0)
                if ((close>strategy.position_avg_price*1.045))
                    // Add to the position
                    strategy.entry("Adding to Short Entry", strategy.short, leverage)
            else
                strategy.entry("Long Entry",strategy.long,leverage)
    // On Monday, if we have any open positions, close them 
    if (dayofweek==2.0)
        strategy.close_all()
 






もっと