
この戦略は,価格分類理論に基づくトレンド追跡取引システムで,市場内のトップ・ボトム分類構造を識別し,固定ポイントのトリガー条件とストップセットを組み合わせて,取引を自動化します.戦略の核心は,ボトムタイプの上部に複数の単一のエントリーポイントを設定し,トップタイプ下部に空の単一のエントリーポイントを設定し,対応するストップポイントの位置を配合してリスク管理を行います.
戦略の核心的な論理には以下の重要なステップが含まれています.
この戦略は,型化理論と動量突破思想を組み合わせて,完全な取引システムを構築している.戦略の優点は,その客観性と自動化の高い程度にあるが,市場環境への適応性の問題もある.ダイナミックなパラメータ調整と市場環境の識別などの最適化措置を追加することによって,戦略の安定性と収益性をさらに向上させることができる.実物取引では,投資家は,自身のリスク承受能力と資金規模に応じてパラメータ設定を調整することをお勧めする.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-09 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Fractal Buy/Sell Strategy with 107 Pips Target", overlay=true)
// 输入参数
trigger_pips = input.int(107, title="Entry Distance (Pips)") // 入场点距离底分型或顶分型的距离
take_profit_pips = input.int(107, title="Take Profit (Pips)") // 止盈点数
pip_value = syminfo.mintick * 10 // 点值(每点等于多少价格单位)
// 计算分型
is_bottom_fractal = low[1] < low[2] and low[1] < low[0] // 判断是否为底分型
is_top_fractal = high[1] > high[2] and high[1] > high[0] // 判断是否为顶分型
// 存储分型位置
var float last_bottom_fractal = na
var float last_top_fractal = na
// 更新分型值
if is_bottom_fractal
last_bottom_fractal := low[1]
if is_top_fractal
last_top_fractal := high[1]
// 计算开盘价格
bottom_trigger_price = na(last_bottom_fractal) ? na : last_bottom_fractal + trigger_pips * pip_value
top_trigger_price = na(last_top_fractal) ? na : last_top_fractal - trigger_pips * pip_value
// 交易逻辑:底分型多单和顶分型空单
if not na(last_bottom_fractal)
if close <= bottom_trigger_price
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=bottom_trigger_price + take_profit_pips * pip_value)
if not na(last_top_fractal)
if close >= top_trigger_price
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=top_trigger_price - take_profit_pips * pip_value)
// 绘制分型和触发价格
plotshape(series=is_bottom_fractal, style=shape.triangleup, location=location.belowbar, color=color.green, title="Bottom Fractal")
plotshape(series=is_top_fractal, style=shape.triangledown, location=location.abovebar, color=color.red, title="Top Fractal")
plot(bottom_trigger_price, title="Buy Trigger", color=color.green, linewidth=1)
plot(top_trigger_price, title="Sell Trigger", color=color.red, linewidth=1)