Created
July 10, 2025 06:59
-
-
Save wuuconix/fafb95d77d417a6309b63a1e055f5121 to your computer and use it in GitHub Desktop.
event
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("10分钟高胜率顺势突破策略", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10) | |
// === 参数 === | |
length_bb = input.int(20, title="布林带周期") | |
mult = input.float(2.0, title="布林带倍数") | |
ma_length = input.int(50, title="均线周期") | |
use_trend_filter = input.bool(true, title="是否使用均线趋势过滤") | |
sl_pct = input.float(1.0, title="止损(%)", step=0.1)/100 | |
tp_pct = input.float(2.0, title="止盈(%)", step=0.1)/100 | |
// === 指标计算 === | |
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) | |
// === 过滤条件 === | |
trend_up = close > ma | |
trend_down = close < ma | |
// === 多单条件 === | |
long_cond = close > upper and (not use_trend_filter or trend_up) | |
if (long_cond) | |
strategy.entry("Long", strategy.long) | |
strategy.exit("TP/SL Long", from_entry="Long", stop=close * (1 - sl_pct), limit=close * (1 + tp_pct)) | |
// === 空单条件 === | |
short_cond = close < lower and (not use_trend_filter or trend_down) | |
if (short_cond) | |
strategy.entry("Short", strategy.short) | |
strategy.exit("TP/SL Short", from_entry="Short", stop=close * (1 + sl_pct), limit=close * (1 - tp_pct)) | |
// === 绘制 === | |
plot(basis, color=color.orange) | |
plot(upper, color=color.green) | |
plot(lower, color=color.red) | |
plot(ma, color=color.blue) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to calculate win rate: