示例策略报告:日线趋势回调Sample report: daily trend pullback

这是我们交付给客户的报告格式。策略本身只是演示用的例子,不是推荐。报告刻意不包含收益数字,因为它要证明的是“系统按规则工作”。

This is the report format clients receive. The strategy is a teaching example, not a recommendation. The report deliberately leaves out returns, because its job is to prove the system follows the rules.

本页所有数字均为演示数据,用于展示报告结构,不代表任何真实账户或收益。
All figures on this page are demonstration data that show the report's structure. They do not represent any real account or return.

1. 规则说明书1. Rule specification

品种:SPY;周期:日线;只做多;美股常规交易时段。

Instrument: SPY. Timeframe: daily. Long only. US regular trading hours.

ID规则Rule
R1趋势过滤:收盘价高于 50 日简单均线Trend filter: close above the 50-day simple average
R2入场:R1 成立,且 RSI(2) 低于 10,K 线收盘后买入Entry: R1 holds and RSI(2) is below 10; buy after the bar closes
R3出场:收盘价高于 5 日简单均线,卖出全部Exit: close above the 5-day simple average; sell all
R4止损:入场价减 2 倍 ATR(14)Stop: entry price minus 2 × ATR(14)
R5仓位:每笔固定 100 股,同时最多持有一笔Size: fixed 100 shares, at most one open position
R6风控:每日最多 2 笔订单;系统未连接时拒绝信号并通知Limits: at most 2 orders a day; reject and alert while disconnected

2. Pine Script 实现2. Pine Script implementation

每条规则在代码注释中都有对应编号。

Each rule ID appears in the code comments.

//@version=6
strategy("Plan2Fill demo: trend pullback", overlay = true,
     default_qty_type = strategy.fixed, default_qty_value = 100,
     commission_type = strategy.commission.cash_per_order, commission_value = 1,
     slippage = 2, pyramiding = 0)

maLen   = input.int(50,    "R1 trend average")
rsiLen  = input.int(2,     "R2 RSI length")
rsiBuy  = input.float(10,  "R2 RSI entry level")
exitLen = input.int(5,     "R3 exit average")
atrLen  = input.int(14,    "R4 ATR length")
atrMult = input.float(2.0, "R4 ATR multiple")
qty     = input.int(100,   "R5 shares")

trendOk = close > ta.sma(close, maLen)                        // R1
entry   = trendOk and ta.rsi(close, rsiLen) < rsiBuy          // R2
exitSig = close > ta.sma(close, exitLen)                      // R3
atr     = ta.atr(atrLen)

// Unique signal ID: symbol + side + bar time
msg(side) =>
    id = syminfo.ticker + "-" + side + "-" + str.tostring(time)
    '{"strategy":"p2f-pullback","id":"' + id + '","symbol":"' + syminfo.ticker +
     '","side":"' + side + '","qty":' + str.tostring(qty) + '}'

var float stopPrice = na
flat = strategy.position_size == 0

if barstate.isconfirmed and flat and entry
    stopPrice := close - atrMult * atr                          // R4
    strategy.entry("L", strategy.long, qty = qty, comment = "R2",
         alert_message = msg("buy"))

if strategy.position_size > 0
    strategy.exit("Stop", "L", stop = stopPrice, comment = "R4",
         alert_message = msg("sell"))
    if barstate.isconfirmed and exitSig
        strategy.close("L", comment = "R3", alert_message = msg("sell"))

plot(ta.sma(close, maLen), "R1 trend average", color = color.gray)
plot(strategy.position_size > 0 ? stopPrice : na, "R4 stop",
     color = color.orange, style = plot.style_linebr)

3. 警报格式3. Alert format

TradingView 警报的消息内容填写 {{strategy.order.alert_message}},服务器收到的是这样的 JSON:

The TradingView alert message is set to {{strategy.order.alert_message}}, so the server receives JSON like this:

{"strategy":"p2f-pullback","id":"SPY-buy-1761868800000","symbol":"SPY","side":"buy","qty":100}

服务器按 id 去重:同一个编号第二次到达时直接丢弃并记录日志。

The server de-duplicates on id: a second arrival of the same ID is dropped and logged.

4. 回测追溯(节选)4. Backtest tracing (excerpt)

每笔交易都能对应到触发它的规则,并由人工对照图表复核。

Each trade maps to the rule that triggered it and is checked by hand against the chart.

日期Date动作Action触发规则Rule人工复核Hand check
2026-03-09买入BuyR1 + R2一致Match
2026-03-12卖出SellR3一致Match
2026-04-02买入BuyR1 + R2一致Match
2026-04-07卖出SellR4一致Match

5. 模拟盘对账(两周汇总)5. Paper reconciliation (two-week summary)

项目Item结果Result验收标准Criterion
收到的警报Alerts received9—
有对应订单或拒单原因Matched to an order or a logged rejection9 / 9100%
方向、品种、数量一致Side, symbol and quantity match9 / 9100%
最长延迟(警报到券商确认)Longest delay, alert to broker ack3.4 s< 60 s
重复下单Duplicate orders00

6. 异常演练6. Failure drills

演练Drill系统反应System response结果Result
同一信号发送两次Same signal sent twice第二次按编号丢弃并记录Second copy dropped by ID and logged通过Pass
券商会话断开Broker session dropped暂停接单,手机收到带登录链接的通知Orders paused, phone alert with a login link通过Pass
断开期间收到信号Signal during disconnect拒绝并在对账表标红,恢复后不补单Rejected and flagged, not replayed later通过Pass
超过每日订单上限Daily order limit exceeded拒绝下单并通知Order refused, alert sent通过Pass

7. 已知限制7. Known limits

  • TradingView 的 webhook 偶尔可能发送失败,对账表会标出缺失的信号,由你决定是否手动处理。
  • 券商会话需要定期重新登录,届时你会收到手机通知。
  • 回测使用日线数据,止损在实盘中的成交价可能与回测不同。
  • 本系统只保证按规则执行,不保证盈利。
  • TradingView webhooks can occasionally fail to send. The reconciliation sheet flags missing signals and you decide how to handle them.
  • The broker session needs periodic re-login, and you get a phone alert when it does.
  • The backtest uses daily bars, so live stop fills may differ from the backtest.
  • The system guarantees rule-faithful execution, not profit.