
平均回帰漸進開場戦略は,HedgerLabsが設計した高度な量化取引戦略スクリプトで,金融市場の平均回帰技術に焦点を当てている.この戦略は,体系的な方法を好み,価格の相対移動平均に基づいて漸進開場方法を強調するトレーダーを狙っている.
この戦略の核心は,シンプル・ムービング・アベアンス (SMA) である. すべての入場と出場取引は,ムービング・アベアンス (SMA) を中心に行われる. 取引者は,異なる取引スタイルと時間帯に適したMAの長さをカスタマイズすることができます.
この戦略の独特な点は,その漸進的な開設メカニズムにある.価格が移動平均から偏りがある一定のパーセントを超えると,この戦略は最初のポジションを起動する.その後,価格が移動平均から偏り続ける程度がますます大きくなるにつれて,この戦略は,トレーダーが定義する方法で漸進的にポジションを増加させる.この方法は,市場の変動が拡大したときにより高い利益を得ることができる.
この戦略はまた,ポジションを賢く管理する.価格が移動平均より低くなるときは多めにし,高くなるときは空白し,異なる市場条件に適応する.平仓ポイントは,価格が移動平均に触れたときに,潜在的な逆転点を捉え,最適な閉じるポジションを実現するために設定される.
起動するcalc_on_every_tickこの戦略は,市場状況を常に評価し,迅速な対応を可能にします.
平均回帰の漸進的な開設策には以下の利点がある.
この戦略にはいくつかのリスクがあります.
適切なエクジット最適化,トレンドの判断,または適切な開設幅の縮小により,上記のリスクを緩和することができます.
この戦略は以下の点で最適化できます.
平均回帰漸進開仓戦略は,平均回帰取引技術に焦点を当て,体系化された漸進開仓管理ポジションを採用し,異なる取引品種に適用できるカスタマイズ可能なパラメータを使用する.この戦略は波動的な市場で良好なパフォーマンスを発揮し,ショートライン操作を重視する量化トレーダーに適しています.
/*backtest
start: 2023-12-29 00:00:00
end: 2024-01-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Mean Reversion with Incremental Entry by HedgerLabs", overlay=true, calc_on_every_tick=true)
// Input for adjustable settings
maLength = input.int(30, title="MA Length", minval=1)
initialPercent = input.float(5, title="Initial Percent for First Order", minval=0.01, step=0.01)
percentStep = input.float(1, title="Percent Step for Additional Orders", minval=0.01, step=0.01)
// Calculating Moving Average
ma = ta.sma(close, maLength)
// Plotting the Moving Average
plot(ma, "Moving Average", color=color.blue)
var float lastBuyPrice = na
var float lastSellPrice = na
// Function to calculate absolute price percentage difference
pricePercentDiff(price1, price2) =>
diff = math.abs(price1 - price2) / price2 * 100
diff
// Initial Entry Condition Check Function
initialEntryCondition(price, ma, initialPercent) =>
pricePercentDiff(price, ma) >= initialPercent
// Enhanced Entry Logic for Buy and Sell
if (low < ma)
if (na(lastBuyPrice))
if (initialEntryCondition(low, ma, initialPercent))
strategy.entry("Buy", strategy.long)
lastBuyPrice := low
else
if (low < lastBuyPrice and pricePercentDiff(low, lastBuyPrice) >= percentStep)
strategy.entry("Buy", strategy.long)
lastBuyPrice := low
if (high > ma)
if (na(lastSellPrice))
if (initialEntryCondition(high, ma, initialPercent))
strategy.entry("Sell", strategy.short)
lastSellPrice := high
else
if (high > lastSellPrice and pricePercentDiff(high, lastSellPrice) >= percentStep)
strategy.entry("Sell", strategy.short)
lastSellPrice := high
// Exit Conditions - Close position if price touches the MA
if (close >= ma and strategy.position_size > 0)
strategy.close("Buy")
lastBuyPrice := na
if (close <= ma and strategy.position_size < 0)
strategy.close("Sell")
lastSellPrice := na
// Reset last order price when position is closed
if (strategy.position_size == 0)
lastBuyPrice := na
lastSellPrice := na