
この戦略は,異常な上昇のK線を識別して,現在の市場に突発的な一方的な動きがあるかどうかを判断する.異常な上昇のK線を識別すると,このK線の高点の近くで買取停止命令を設定し,以前のK線の低点の近くで止損命令を設定し,高レバレッジのリスクコントロールを形成する.戦略は,止損ラインをリアルタイムで監視し,価格が止損ラインを下に突破した場合,単一の損失を直ちに撤回する.
この策略は,K線が形成される異常な上昇を判断し,close>openとhighlow[1]のK線において,現在の周期異常上昇状況があると考える.このとき,長い単一の入場信号が設定され,入場価格は現在のK線の最高価格の近くにある.同時に,上方のK線の最低価格の近くにあるというストップ・ロスの価格が設定され,高レバレッジのリスクコントロールモデルが形成される.継続的に価格を監視することで,ストップ・ロスの線を突破した状況を実現する.
この戦略の最大の利点は,市場の短線異常突発的な状況を捕捉することができ,超高周波取引を実現することである.同時に,より大きな止損幅を設定することにより,高いレバレッジを使用してリスク制御取引を行うことができ,それによってより大きな利益を得ることができる.さらに,戦略は,止損ラインを自動的に監視することを実現し,価格が下向きに止損ラインを破るとき,取引リスクを迅速に止めて効果的に制御することができる.
この戦略の主なリスクは,異常上昇判断が不正確であり,市場における突発的な動きを効果的に捕捉することができないことであり,取引信号の誤判の可能性が高いことにある.さらに,止損位置の設定は,取引リスクと収益にも大きな影響を与える.止まりがあまりにも緩やかであれば,取引損失のリスクが増加し,止まりがあまりにも狭い場合は,動きの利益を効果的に追跡することができないかもしれない.大量にリターンで止損位置を最適化する必要があります.
この戦略は以下の点で最適化できます.
異常上昇判断基準は,より多くの指標や深度学習モデルによる補助判断を導入し,戦略取引信号判断の正確性を向上させることができます.
ストップ・ローズ・ポジション設定は,取引リスクと利益のレベルをバランスさせるのに最適なストップ・ローズ・ポジションを見つけるために,大量の統計的および最適化分析を行うことができます.
取引量フィルター,区間突破検証などの高周波取引風力制御の導入により,監禁の可能性を回避できます.
戦略の入場基準は調整可能であり,異常上昇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 //