真っ た カメ 岩 カメ の よう に 堅く 策定 する

作者: リン・ハーンチャオチャン開催日:2024年2月18日14時34分40秒
タグ:

img

概要

ロックタートルストラテジーは,ブレイディタートルストラテジーのルールに従う定量的な取引戦略である. ポジションに入るために価格ブレイクアウトを使用し,退出のためにストップを追跡することを停止する. 真の変動に基づいてポジションサイズを計算し,取引毎の損失を厳格に制御する. 戦略は長期間の安定性があり,安定した岩石のように引き下げに対する強い耐性がある.

原則

入国規則

ストアファスト・ア・ロック・タートル戦略は,ブレイクアウトを入力します.具体的には,指定されたバックバック期間の最高高値と最低低値を計算します.価格が最高高値を超えると,ロングになります.価格が最低低値を下回ると,ショートになります.

例えば,エントリー期間を20バーに設定すると,戦略は過去20バーの最高値と最低値を引き出す.現在のバーの終了が過去20バーの最高値を超えると,戦略は,最高値を超えるブレイクを準備するために,その接近価格でロングストップオーダーを置く.

退場規則

ストップを追跡するストップで終了します.指定された出口期間の最高高と最低低を動的に計算し,出口チャネルを決定するためにそれらを使用します.

ロングを保持すると,価格が出口チャネルの最低値を下回ると,ポジションは停止します.また,ショートポジションでは逆です.

さらに,ストップ・ロスは真の変動に基づいてストップ・ロスのレベルを計算し,最終ストップとして機能します.価格が出口チャネルの上にとどまる限り,ストップ・ロスは追跡と調整を続け,ストップが不必要なストップのためにあまりにも緊密になく,リスク制御のためにあまりにも緩やかでない適切な距離に設定されていることを確認します.

位置 サイズ

ロックタートルストラテジーのように安定したストラテジーは,真の変動に基づいてポジションをサイズします.特に,最初にエントリー価格に近い潜在的な損失パーセントを推定し,その後,期待されるリスクパラメータからポジションサイズを逆計算します.これは取引毎の最大損失を効果的に制御します.

利点分析

安定した運用

ストイデストア・ア・ロック・タートル戦略は,任意の変更なしにエントリーと出口に関するクラシックなタートル取引規則を厳格に遵守します. これにより,一時的な判断力低下によるシステム障害なく,長期にわたって安定して実行できます.

引き下げ抵抗力

ブレイクアウトに入ることで,この戦略は過大評価されたエントリを効果的に回避し,システム損失の確率を軽減します.そしてストップを追跡するストップで退出することで,取引ごとに最大損失が制御され,大きな引き下げにつながる連続した損失を大幅に防ぐことができます.

リスクの控えめ

戦略は真の波動性に基づいて サイズを設定することで 取引毎の最大損失を 許容範囲内で厳格に制御し ストップ距離を追跡することで リスクを効果的に抑えるために 時間をかけて損失を削減できます

リスク分析

破損リスク

価格が低勢でブレイクした場合,誤ったエントリー損失を引き起こす偽信号であることが判明する可能性があります. 非効率なブレイクノイズを避けるために,参数がより多くのエントリー確認ルールで調整する必要があります.

パラメータ最適化リスク

市場体制が急激に変化した場合,エントリー/エグジット期間のような静的戦略パラメータは無効になり得ます.これらのパラメータは適応するために再評価と再最適化が必要です.

テクニカルインジケーターの不具合リスク

価格ブレイクフラグのような指標は,トレンドや変動が大きく変化すると失敗する可能性があります.戦略の信頼性を向上させるために,より多くの技術が統合する必要があります.

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

トレンドフィルターを追加

MA,MACDのような一般的なトレンドインジケーターは追加できます.反トレンドのウィップソウを避けるために,上向きでのみロング,下向きでのみショートします.

時間枠の概要

高いタイムフレームの指標,例えば日間MAレベルは,より低いタイムフレームの信号を補完するために,全体的な方向性を確認するのに役立ちます.

ダイナミックパラメータ調整

機械学習は 変化する市場動態に 効果を維持するために 最新のデータに基づいて 戦略パラメータを自動的に継続的に更新できます

概要

ロックタートルストラテジーのように堅固である. クラシックなタートルストラテジーの方法論を厳格に遵守し,厳格なリスク制御でブレイクアウトエントリーとストップアウトを追跡する. これにより,強い引き下げ回復力を持つ長期間の安定したオペレーションが可能になる. 偽ブレイクアウト,パラメータ失敗などのリスクにもかかわらず,トレンドフィルター,タイムフレームシンセシス,ダイナミックチューニングなどの追加により効果的に緩和され,戦略の安定性が著しく向上する. 全体的に,信頼して保持する価値のある優れた堅牢な戦略である.


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

//@version=3
strategy("Real Turtle", shorttitle = "Real Turtle", overlay=true, pyramiding=1, default_qty_type= strategy.percent_of_equity,calc_on_order_fills=false, slippage=25,commission_type=strategy.commission.percent,commission_value=0.075)
//////////////////////////////////////////////////////////////////////
// Testing Start dates
testStartYear = input(2016, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
//Stop date if you want to use a specific range of dates
testStopYear = input(2030, "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
// Use if using a specific date range
testPeriodBackground = input(title="Color Background?", type=bool, defval=false)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

testPeriod() => true
// Component Code Stop
//////////////////////////////////////////////////////////////////////

//How many candles we want to determine our position entry
enterTrade = input(20, minval=1, title="Entry Channel Length")
//How many candles we want ot determine our position exit
exitTrade = input(10, minval=1, title="Exit Channel Length")

//True Range EMA Length
trLength = input(13, minval=1, title="True Range Length")
//Go all in on every trade
allIn = input(false, title="Use whole position on every trade")
dRisk = input(2, "Use Desired Risk %")
//How much of emaTR to use for TS offset
multiEmaTR = input(2, "Desired multiple of ema Tr (N)")
//absolute value (highest high of of this many candles - lowest high of this many candles) . This is used if we want to change our timeframe to a higher timeframe otherwise just works like grabbing high o r low of a candle
//True range is calculated as just high - low. Technically this should be a little more complicated but with 24/7 nature of crypto markets high-low is fine.
trueRange = max(high - low, max(high - close[1], close[1] - low))
//Creates an EMA of the true range by our custom length
emaTR = ema(trueRange, trLength)
//Highest high of how many candles back we want to look as specified in entry channel for long
longEntry = highest(enterTrade)
//loweest low of how many candles back we want to look as specified in exit channel for long
exitLong = lowest(exitTrade)
//lowest low of how many candles back want to look as specified in entry channel for short
shortEntry = lowest(enterTrade)
//lowest low of how many candles back want to look as specified in exit channel for short
exitShort = highest(exitTrade)
//plots the longEntry as a green line
plot(longEntry[1], title="Long Entry",color=green)
//plots the short entry as a purple line
plot(shortEntry[1], title="Short Entry",color=purple)

howFar = barssince(strategy.position_size == 0)
actualLExit = strategy.position_size > 0 ? strategy.position_avg_price - (emaTR[howFar] * multiEmaTR) : longEntry - (emaTR * multiEmaTR)
actualLExit2 = actualLExit > exitLong ? actualLExit : exitLong
actualSExit = strategy.position_size < 0 ? strategy.position_avg_price + (emaTR[howFar] * multiEmaTR) : shortEntry + (emaTR * multiEmaTR)
actualSExit2 = actualSExit < exitShort ? actualSExit : exitShort

//plots the long exit as a red line
plot(actualLExit2[1], title="Long Exit",color=red)
//plots the short exit as a blue line
plot(actualSExit2[1], title="Short Exit",color=yellow)


//Stop loss in ticks
SLLong =(emaTR * multiEmaTR)/ syminfo.mintick
SLShort = (emaTR * multiEmaTR)/ syminfo.mintick


//Calculate our potential loss as a whole percentage number. Example 1 instead of 0.01 for 1% loss. We have to convert back from ticks to whole value, then divided by close
PLLong = ((SLLong * syminfo.mintick) * 100) / longEntry
PLShort = ((SLShort * syminfo.mintick) * 100) / shortEntry
//Calculate our risk by taking our desired risk / potential loss. Then multiple by our equity to get position size. we divide by close because we are using percentage size of equity for quantity in this script as not actual size.
//we then floor the value. which is just to say we round down so instead of say 201.54 we would just input 201 as TV only supports whole integers for quantity.
qtyLong = floor(((dRisk / PLLong) * strategy.equity) /longEntry )
qtyShort = floor(((dRisk / PLShort) * strategy.equity) /shortEntry )
qtyLong2 = allIn ? 100 : qtyLong
qtyShort2 = allIn ? 100 : qtyShort
//Only open long or short positions if we are inside the test period specified earlier
if testPeriod()
    //Open a stop market order at our long entry price and keep it there at the quantity specified. This order is updated/changed on each new candlestick until a position is opened
    strategy.entry("long", strategy.long, stop = longEntry, qty = qtyLong2) 
    //sets up or stop loss order by price specified in our actualLExit2 variable
    strategy.exit("Stoploss-Long", "long", stop=actualLExit2)
    
     //Open a stop market order at our short entry price and keep it there at the quantity specified. This order is updated/changed on each new candlestick until a position is opened
    strategy.entry("short", strategy.short, stop = shortEntry, qty = qtyShort2)
    //sets up or stop loss order by price specified in our actualLExit2 variable
    strategy.exit("Stoploss-Short", "short", stop=actualSExit2)



もっと