この戦略は,一定の期間における変動率を計算することで,買いと売却のタイミングを決定する.これは,短期的な価格変動の機会を捕まえるトレーダーに役立つ.
この戦略は以下の指標に基づいています.
具体的には
具体的には,
オーダーの規模は,総権益のパーセントで設定され (デフォルトは96%),レバレッジ効果を提供できます.
この戦略の利点は以下の通りです.
総じて,この戦略は,価格変動率,SMA指数などのツールを十分に活用し,波動的な状況で優れたパフォーマンスを得ることができます.
この戦略には以下のリスクもあります.
変動率とSMAパラメータの設定が不適切である場合,取引シグナルが誤りまたは誤りになる可能性があります.異なる市場に対応してパラメータを調整する必要があります.
オーダーサイズが大会を超えてリスクを増大させる。テスト段階でオーダー割合を最適化することが推奨。
追跡ストップは震動の状況で早期にストップすることがあります. ストップ幅の調整を検討することができます.
策略 transactionsstabは,トレンド判断とストップ・ローズ・マネジメントのリスクを組み合わせて行われやすい.
データを復元する 適合リスク 戦略の強さを異なる市場で複数の実験で検証する
これらのリスクに対して,パラメータ最適化,注文調整,ストップダスト戦略最適化,実地検証などの手段によってリスク管理を行うことができる.
この戦略は,以下の点で最適化できます.
波動率や取引量などの他の技術指標の判断を加え,信号の正確性を向上させる.
取引回数を最適化し,取引頻度を低下させることで,取引の影響を軽減する.
突破策と組み合わせて,重要な価格位近くで突破取引シグナルを設定する.
機械学習によるパラメータ設定の自動最適化.
複数の市場で長期間,戦略の強さをテストし,適応性を向上させる.
株や外貨などの異なる品種の特性を考慮し,特定のパラメータの組み合わせを設定します.
リアルタイムの結果に基づいて,戦略信号とリスク管理方法を繰り返し最適化します.
この戦略は,変動率とSMA指標を判断して,ショートライン価格変動の中で取引機会を探します.それは急速な動向を捕捉するのに有利ですが,リスク管理にも注意する必要があります.パラメータ最適化,注文調整,止損戦略の改善,およびリポートの検証により,戦略の安定性と適応性を継続的に向上させることができます.この戦略は,量化取引のための参考テンプレートを提供します.しかし,実際の適用では,市場の特徴に応じて調整と最適化が必要です.
/*backtest
start: 2022-09-21 00:00:00
end: 2023-09-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=4
// Author: Sonny Parlin (highschool dropout)
// Best if run on 5m timeframe
strategy(shorttitle="ROC+Strategy", title="Rate of Change Strategy",
overlay=true, currency=currency.USD,
initial_capital=10000)
// Inputs and variables
ss = input(14, minval=10, maxval=50, title="SMA Fast (days)")
ff = input(100, minval=55, maxval=200, title="SMA Slow (days)")
ref = input(30, minval=20, maxval=50, title="SMA Reference (days)")
lowOffset = input(0.023, "ROC Low (%)", minval=0, step=0.01)
highOffset = input(0.047, "ROC High (%)", minval=0, step=0.01)
orderStake = input(0.96, "Order Stake (%)", minval=0, step=0.01)
lookback = input(12, "Lookback Candles", minval=1, step=1)
// SMA
smaFast = sma(close, ss)
smaSlow = sma(close, ff)
smaRef = sma(close, ref)
ROC = (max(close[lookback],close) - min(close[lookback],close)) / max(close[lookback],close)
// Set up SMA plot but don't show by default
plot(smaFast, "smaFast", color=#00ff00, display = 0)
plot(smaSlow, "smaSlow", color=#ff0000, display = 0)
plot(smaRef, "smaRef", color=#ffffff, display = 0)
// The buy stratey:
// Guard that the low is under our SMA Reference line
// Guard that the rate of change over the lookback period is greater than our
// ROC lowOffset %, default is 0.023. (low < smaRef) and (ROC > lowOffset)
// SMA fast is on the rise and SMA slow is falling and they are very likely
// to cross. (rising(smaFast,1)) and (falling(smaSlow, 1))
enterLong = (low < smaRef) and (ROC > lowOffset) and (rising(smaFast,1)) and (falling(smaSlow,1))
// The sell Strategy:
// Guard that close is higher than our SMA reference line and that the rate of
// change over the lookback period is greater than our highOffset %, default
// is 0.047. (close > smaRef) and (ROC > highOffset)
// Guard that close has risen by 3 candles in a row (rising(close,3))
// Guard that we currently have profit (strategy.openprofit > 0)
// Guard that SMA fast is higher than smaSlow (smaFast > smaSlow)
// If it keeps going up past our close position the trailing stoploss will kick in!
enterShort = (close > smaRef) and (ROC > highOffset) and (rising(close,3)) and (strategy.openprofit > 0) and (smaFast > smaSlow)
// Order size is based on total equity
// Example 1:
// startingEquity = 2000
// close = 47434.93
// orderStake = 0.45
// (2,000 × orderStake) / close = orderSize = 0.0189733599 = approx $900
// Example 2:
// startingEquity = 2000
// close = 1.272
// orderStake = 0.45
// (startingEquity × orderStake) / close = orderSize = 707.5471698113 = approx $900
orderSize = (strategy.equity * orderStake) / close
// Trailing Stoploss
// I'm using 2.62 as my default value, play with this for different results.
longTrailPerc = input(title="Trailing Stoploss (%)",
type=input.float, minval=0.0, step=0.1, defval=3.62) * 0.01
longStopPrice = 0.0
longStopPrice := if (strategy.position_size > 0)
stopValue = close * (1 - longTrailPerc)
max(stopValue, longStopPrice[1])
else
0
if (enterLong)
strategy.entry("Open Long Position", strategy.long, orderSize, when=strategy.position_size <= 0)
if (enterShort)
strategy.exit(id="Close Long Position", stop=longStopPrice)
//plot(strategy.equity)