ダイナミックなポジション構築戦略

作者: リン・ハーンチャオチャン開催日:2024年2月20日 (月) 14時30分
タグ:

img

概要

この戦略の主な考えは,リスクをコントロールし,低平均入場価格を得るため,牛市におけるシステム信号に基づいて動的にポジションを構築することです.

戦略の論理

この戦略は,まずスタート資本とDCAパーセントを設定する.各バーの閉じる時に,価格変化に基づいて調整されたパーセントを計算する.価格が上昇した場合,それはパーセントを下げる.価格が下がると,それはパーセントを増加させる.これはより低い価格でポジションに追加することを可能にする.その後,調整されたパーセントと残った資本に基づいてオーダーサイズを計算する.各バーの閉じる時に,スタート資本が使用されるまでポジションを構築するオーダーを配置する.

変動する価格アクション中にリスクを制御し,平均入場価格を下げることができます.一方,現在の入場状況を判断するために平均入場価格と中位価格を追跡します.

利点分析

この戦略には以下の利点があります.

  1. ポジションを動的にスケーリングし,リスクを制御するために,ディープでのアロケーションを増やし,ラリーでのアロケーションを減少させることができます.

  2. 中間価格よりも平均的な入場価格が低くなり 利益の可能性が高まります

  3. リスク・リターン比率を向上させるため 波動性のある高騰市場に適しています

  4. 初期資本とDCAパーセントを事前に設定することで,ポジションサイズのリスクを制御できます.

  5. 平均入場価格と中位価格の統計が提供され,入場品質を明確に判断できます.

リスク分析

リスクもあります:

  1. 市場が急落すると ポジションを拡大し 損失を大きく引き起こす ストップロスはリスクを制限します

  2. 価格が急激に上昇すると,スケーリングは減少し,ラリーの多くを逃す可能性があります.その後,他のLSI信号が必要になります.

  3. パラメータの設定が正しくないことも危険です.過剰なスタート資本と高いDCAパーセントは損失を拡大します.

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

戦略を最適化する方法:

  1. ストップ・ロスの論理を加えることで 高い売り上げの規模を 拡大しないようにします

  2. 動的にDCAパーセントを変動または他のメトリックに基づいて調整する.

  3. 価格を予測し,スケーリング決定を導くために機械学習モデルを組み込む.

  4. 他の指標を組み合わせて,市場構造の変化を特定し,出口点をスケーリングする.

  5. 口座値に基づいて動的にサイズオーダーに資本管理規則を追加します.

結論

これは非常に実用的な動的ポジションスケーリング戦略である.これは,設定可能なパラメータを通じてリスクを制限しながら,牛市で良い平均エントリを達成するために価格変動に基づいてポジションサイズを柔軟に調整する.他の指標またはモデルと組み合わせることで,パフォーマンスをさらに改善することができます.長期的利益を求める投資家に適しています.


/*backtest
start: 2024-01-20 00:00:00
end: 2024-02-19 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/
// © RWCS_LTD

//@version=5
strategy("DCA IN Calculator {RWCS}", overlay=true, pyramiding=999, default_qty_type=strategy.cash, initial_capital=10000, commission_value=0.02)

// User inputs
backtestStartDate = input(timestamp("1 Jan 2024"), 
     title="Start Date", group="Backtest Time Period",
     tooltip="This start date is in the time zone of the exchange " + 
     "where the chart's instrument trades. It doesn't use the time " + 
     "zone of the chart or of your computer.")
start_date = true
starting_capital = input.float(defval=5000, title="Starting Capital")
dca_allocation_percentage = input.int(defval=10, title="DCA Allocation Percentage")

// Calculate DCA allocation based on price change
price_change_percentage = ((close - close[1]) / close[1]) * 100
adjusted_allocation_percentage = close > close[1] ? dca_allocation_percentage - price_change_percentage : dca_allocation_percentage + price_change_percentage // If price action is negative, increase allocations
adjusted_allocation_percentage1 = dca_allocation_percentage - price_change_percentage // If price action is positive, reduce allocations

// Calculate order size based on adjusted allocation percentage
order_size = (adjusted_allocation_percentage / 100) * starting_capital

// Track remaining capital
var remaining_capital = starting_capital

// Long on the close of every bar
if true
    // Ensure the order size doesn't exceed remaining capital or adjusted allocation
    order_size := math.min(order_size, remaining_capital, adjusted_allocation_percentage / 100 * starting_capital)
    // Ensure order size is not negative
    order_size := math.max(order_size, 0)
    
    strategy.entry("DCA", strategy.long, qty = order_size)
    remaining_capital := remaining_capital - order_size

// Plot average entry price
var float total_entry_price = 0.0
var int total_signals = 0

if start_date
    total_entry_price := total_entry_price + close
    total_signals := total_signals + 1

avg_entry_price = total_entry_price / total_signals

// Calculate and plot median price
var float median_price = na

if start_date
    var float sum_prices = 0.0
    var int num_prices = 0
    
    for i = 0 to bar_index
        if (time[i] >= backtestStartDate)
            sum_prices := sum_prices + close[i]
            num_prices := num_prices + 1
    
    median_price := sum_prices / num_prices

// Reset variables at the start of each day
if (dayofweek != dayofweek[1])
    total_entry_price := 0.0
    total_signals := 0

//table colors
borders_col = color.new(color.black, 90)
top_row_col = color.new(color.gray, 90)
size = input.string(defval='Normal', options=['Tiny', 'Small', 'Normal', 'Large'], title='Table size', inline='design', group='Table Design')
table_size = size == 'Tiny' ? size.tiny : size == 'Small' ? size.small : size == 'Normal' ? size.normal : size == 'Large' ? size.large : na

var tablee = table.new(position=position.top_right, columns=2, rows=3, frame_color=borders_col, frame_width=4, border_color=borders_col, border_width=4)

table.cell(tablee, 0, 0, "Average Entry Price", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 0, str.tostring(avg_entry_price, '#.##'), text_color=color.white, text_size=table_size)
table.cell(tablee, 0, 1, "Median Price", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 1, str.tostring(median_price, '#.##'), text_color=color.white, text_size=table_size)
table.cell(tablee, 0, 2, "Remaining Capital", bgcolor=top_row_col, text_color=color.white, text_size=table_size)
table.cell(tablee, 1, 2, str.tostring(remaining_capital, '#.##'), text_color=color.white, text_size=table_size)



もっと