
이 전략은 가격 분기 이론에 기반한 트렌드 추적 거래 시스템으로, 시장의 상위 하위 분기 구조를 식별하여 고정 점수의 트리거 조건과 정지 설정을 결합하여 거래를 자동화합니다. 전략의 핵심은 하위 분기 상단에 여러 개의 입시점을 설정하고, 상위 분기 하단에 빈 입시점을 설정하며, 그에 따른 정지 점수 설정을 통해 위험을 제어합니다.
이 전략의 핵심 논리는 다음과 같은 몇 가지 핵심 단계를 포함합니다.
이 전략은 분형 이론과 동력 돌파구 생각을 결합하여 완전한 거래 시스템을 구축한다. 전략의 장점은 객관성과 자동화 수준이 높지만 시장 환경 적응성에 대한 문제가 있다. 동적 매개 변수 조정 및 시장 환경 식별과 같은 최적화 조치를 추가함으로써 전략의 안정성과 수익성을 더욱 향상시킬 수 있다. 실물 거래에서는 투자자가 자신의 위험 용도와 자금 규모에 따라 매개 변수 설정을 조정하는 것이 좋습니다.
/*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)