Created
July 24, 2025 02:13
-
-
Save wuuconix/728c7fa072bace4e8f33d5843c55b7d1 to your computer and use it in GitHub Desktop.
1分钟实体突破-精确计时版-动量过滤
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@version=5 | |
strategy("1分钟实体突破-精确计时版-动量过滤", overlay=true, process_orders_on_close=true) | |
adx_length = input.int(14, "ADX周期") | |
adx_threshold = input.int(20, "ADX阈值") | |
[_, _, adx] = ta.dmi(adx_length, adx_length) | |
adx_ok = adx > adx_threshold | |
// === 参数设置 === | |
length_bb = input.int(20, "布林带周期") | |
mult = input.float(2.0, "布林带倍数") | |
ma_length = input.int(50, "均线周期") | |
use_trend_filter = input.bool(true, "趋势过滤") | |
trade_duration = input.int(10, "持仓时间(分钟)", minval=1) | |
use_rsi_filter = input.bool(true, "启用RSI过滤") | |
rsi_length = input.int(14, "RSI周期") | |
rsi_long = input.int(55, "做多RSI阈值") | |
rsi_short = input.int(45, "做空RSI阈值") | |
use_macd_filter = input.bool(true, "启用MACD过滤") | |
// === 指标计算 === | |
basis = ta.sma(close, length_bb) | |
dev = mult * ta.stdev(close, length_bb) | |
upper = basis + dev | |
lower = basis - dev | |
ma = ta.sma(close, ma_length) | |
rsi = ta.rsi(close, rsi_length) | |
[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9) | |
// === 信号条件 === | |
body_break_upper = close > upper and open > upper[1] | |
body_break_lower = close < lower and open < lower[1] | |
trend_up = close > ma | |
trend_down = close < ma | |
rsi_long_ok = not use_rsi_filter or rsi > rsi_long | |
rsi_short_ok = not use_rsi_filter or rsi < rsi_short | |
macd_long_ok = not use_macd_filter or histLine > 0 | |
macd_short_ok = not use_macd_filter or histLine < 0 | |
// === 交易逻辑 === | |
// 用plotshape标记信号点位 | |
plotshape(body_break_upper and (not use_trend_filter or trend_up) and rsi_long_ok and macd_long_ok and adx_ok, title="↑突破", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small) | |
plotshape(body_break_lower and (not use_trend_filter or trend_down) and rsi_short_ok and macd_short_ok and adx_ok, title="↓突破", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) | |
// === 可视化 === | |
plot(basis, "中线", color=color.orange) | |
plot(upper, "上轨", color=color.green) | |
plot(lower, "下轨", color=color.red) | |
plot(ma, "均线", color=color.blue) | |
plot(rsi, "RSI", color=color.purple, linewidth=1, title="RSI") | |
hline(rsi_long, "RSI多阈值", color=color.green) | |
hline(rsi_short, "RSI空阈值", color=color.red) | |
plot(adx, "ADX", color=color.fuchsia, linewidth=1, title="ADX") | |
hline(adx_threshold, "ADX阈值", color=color.fuchsia) |
default.mp4
default.mp4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
统计胜率