内部幅ストップ損失に基づくモメントブレイク戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月23日 14:14:58
タグ:

img

概要

この戦略は,波動性の急上昇を伴う一方的な市場があるかどうかを判断するために,異常な上昇するKラインを特定します.異常な上昇するKラインが特定された場合,そのKラインの高値に近い利潤制限オーダーを設定し,前回のKラインの低値に近いストップロスを設定し,高いレバレッジリスク制御を持つロングポジションを形成します.この戦略は,ストップロスのラインを継続的に監視し,価格がストップロスの線を下に突破した場合,すぐにストップロスのオーダーをキャンセルします.

戦略原則

この戦略は主に異常上昇するKラインの形成を判断する.閉じる>オープンと高<高[1]および低>低[1]のKラインが表示されると,現在の異常上昇市場が存在すると考えられる.ロングエントリー信号が生成され,エントリー価格は現在のKラインの最高価格に近い.ストップ損失価格も以前のKラインの最低価格に近い位置に設定され,高いレバレッジリスク制御モデルを形成する.リスク制御は,ストップ損失ラインの価格ブレイクを継続的に監視することによって達成される.

利点分析

この戦略の最大の利点は,超高周波の取引を達成するために,短期間の市場波動性を捕捉することができることです.同時に,より大きなストップ損失範囲を設定することで,より大きなリターンを得るため,リスク制御された取引のために高いレバレッジを使用できます.また,この戦略はストップ損失ラインの自動モニタリングを実現します.価格がストップ損失ラインを下向きに突破すると,迅速にストップ損失を停止して取引リスクを効果的に制御することができます.

リスク分析

この戦略の主なリスクは,異常な急上昇の判断が不正確であり,市場の波動性を効果的に把握できず,取引シグナルを誤判する可能性が高くなることにある.また,ストップ損失ポジションの設定は,取引リスクとリターンにも大きな影響を与えます.ストップ損失が緩すぎると,取引損失リスクが増加します.ストップ損失が狭すぎると,市場での利益を効果的に追跡できない可能性があります.ストップ損失ポジションを最適化するために,大量のバックテストが必要です.

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

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

  1. 異常な急上昇を判断する基準は,戦略における取引信号判断の正確性を向上させる判断を支援するためのより多くの指標やディープラーニングモデルを導入することができます.

  2. ストップ・ロスのポジションの設定は,取引リスクとリターンレベルをバランスさせるためのより良いストップ・ロスのポジションを見つけるために,多くの統計分析と最適化分析を受けることができます.

  3. 高頻度取引のリスク管理メカニズムが導入され,取引量のフィルタリング,範囲の突破の検証などにより,罠にかかった可能性が回避される.

  4. 戦略のエントリー基準は調整可能で,異常な上昇するK線に限定する必要はない.より多くの指標とモデルを組み合わせて判断を行い,複数の検証メカニズムを形成することができます.

概要

この戦略は,短期間のブレイクアウト戦略に属する典型的な高周波取引戦略である.超高周波取引を達成するために,市場の動きの波動性を捕捉する.同時に,ストップ損失リスク制御と高レバレッジメカニズムを使用してリスクを制御する.この戦略には最適化のための大きな余地があり,複数の角度から調整および最適化することができます.最終目標は,リスクを制御しながら超高周波取引からより高い収益を得ることです.


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

// LOVE JOY PEACE PATIENCE KINDNESS GOODNESS FAITHFULNESS GENTLENESS SELF-CONTROL 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JoshuaMcGowan
// I needed to test/verify the functionality for canceling an open limit order in a strategy and also work thru the pieces needed to set the position sizing so each loss is a set amount. 
// This is not meant to be dropped into a chart but rather gives the code/logic in order to use in your own script w/alerts or strategy. Hope it helps. 
 
//@version=4
strategy("Strategy Test - Cancel Limit Order and Position Sizing", overlay=true, precision=4)
 
/////////////////
// Backtest Period Selection
 
testStartYear = input(2020, "Backtest Start Year",minval=1980)
testStartMonth = input(2, "Backtest Start Month",minval=1,maxval=12)
testStartDay = input(1, "Backtest Start Day",minval=1,maxval=31)
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
 
testStopYear = input(2020, "Backtest Stop Year",minval=1980)
testStopMonth = input(12, "Backtest Stop Month",minval=1,maxval=12)
testStopDay = input(31, "Backtest Stop Day",minval=1,maxval=31)
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
 
testPeriod() => time >= true
 
//////////////
// Inside Bar
bull_inside_bar = close>open and high<high[1] and low>low[1]

// Set Levels
bull_inside_bar_sl = valuewhen(bull_inside_bar, low[1], 0) - (1*syminfo.mintick)
bull_breakout_price = valuewhen(bull_inside_bar, high, 0) + (1*syminfo.mintick)
entry_buy   = high
inside_bar_dist = entry_buy - bull_inside_bar_sl
inside_bar_be = entry_buy + (inside_bar_dist * 1)
inside_bar_tgt = entry_buy + (inside_bar_dist * 2)

///////////////////
// Position Sizing 
//////////////////
// For each trade setup that fires in this scenario we want to set our total loss amount in USD, so every trade that loses is lets say $1 and the 2:1 target would be $2 in this example. 
// The math logic for this take the risk amount and divide by the stop percentage, take that number and divide by leverage amount chosen. Stop percentage is a variable below if questions on that. 
//
// Taken from @JoshuaMorris (shout out to the UK peeps) position sizing google doc so thank you sir. 
// Would be used if risking based on percentage of a portfolio. Leaving code snippets here in case that's the direction someone wants to go. 
// xbt_price = security("BITMEX:XBTUSD", "D", close)
// account_size_xbt = input(1, "Account Size (XBT)", type=input.float)
// account_size_usd = (account_size_xbt * xbt_price)
// percentage_risk = input(0.01, "Personal Risk Percent - Default is 1%", type=input.float)
// personal_risk = (account_size_usd * percentage_risk)
// position_size_usd = (personal_risk) / risk_percent
// leverage_req = position_size_usd / account_size_usd

// Will want to hard code leverage as 1x, 5x, 10x etc and dont need it to automagically be set as is above. If you're doing 100x you are gnarly haha. 
leverage_amount = input(title="Leverage Amount Desired", type=input.integer, defval=10, options=[1, 2, 3, 5, 10, 25, 50, 100])
risk_amount = input(title="Risk Total Per Trade in USD", type=input.integer, defval=1, minval=1, step=1)

// Reminder this is for Longs. Math needs to be changed a bit for Shorts. This is the information using the long/short tool would give us if doing manually. 
stop_percent = inside_bar_dist / (entry_buy)
pos_size_no_lev = risk_amount / stop_percent
pos_size_with_lev = pos_size_no_lev / leverage_amount 

//////////////
// Strategy Section

if testPeriod()
    strategy.entry(id="Long", long=true, qty=1, limit=9320.00, when=bull_inside_bar)
    strategy.cancel(id="Long", when = low < 9310)
// as a test swap the price to be above the limit or below to see the cancel in play.
 
//////////////
// Plot Section
plotchar(bull_inside_bar, title="bull_inside_bar", char="🐂", location=location.belowbar, offset=-0, color=color.green, transp=25)
plot(bull_inside_bar_sl, title="bull_inside_bar_sl", transp=100)
plot(entry_buy, title="entry_buy", transp=100)
plot(inside_bar_dist, title="inside_bar_dist", transp=100)
plot(stop_percent, title="stop_percent", transp=100)
plot(pos_size_no_lev, title="pos_size_no_lev", transp=100)
plot(pos_size_with_lev, title="pos_size_with_lev", transp=100)

// Hidden Plots // For Data Window Eyes Only // 
// plot(longCondition==true?1:0, title="Long Condition", transp=100)
// plot(xbt_price, title="XBT Price", transp=100)
// plot(account_size_usd, title="Account Size USD", transp=100)
// plot(risk_percent, title="risk_percent", transp=100)
// plot(position_size_usd, title="position_size_usd", transp=100)
// plot(leverage_req, title="leverage_req", transp=100)

// END //

もっと