跳转到内容

TradingView Alert 消息模板

{
"action": "BUY",
"symbol": "BTCUSDT",
"amount_usd": 200
}
字段类型必需说明
actionenumBUY / SELL / CLOSE
symbolstringBinance 合约 symbol,如 BTCUSDT
amount_usdnumberone-of以美元计价的仓位大小
qtynumberone-of以 base asset 计价的数量(和 Binance quantity 一致)
pricenumberlimit 必需限价价格(不传=市价)
reduce_onlybool可选只减仓;action=CLOSE 时隐含
position_sideenum可选双向模式:LONG / SHORT

amount_usdqty 二选一;都不传 = 用组合默认仓位大小。

//@version=5
strategy("panshi demo", overlay=true)
fast = ta.sma(close, 20)
slow = ta.sma(close, 50)
msg_long = '{"action":"BUY", "symbol":"BTCUSDT","amount_usd":200}'
msg_flat = '{"action":"CLOSE", "symbol":"BTCUSDT"}'
if ta.crossover(fast, slow)
strategy.entry("L", strategy.long, alert_message=msg_long)
if ta.crossunder(fast, slow)
strategy.close("L", alert_message=msg_flat)
alertcondition(
ta.crossover(fast, slow) or ta.crossunder(fast, slow),
"panshi-sim",
""
)

TradingView Alert 的 Message 栏填 {{strategy.order.alert_message}},Pine 拼好的 JSON 就会原样发到 webhook。

{"action":"CLOSE","symbol":"BTCUSDT"}

可选附 reduce_only=true 明示。

单个组合一个 webhook_token。若要一个 Alert 打给多个组合,建议:

  • 在 panshi 端用 跟单 功能:主组合接 webhook,下游组合自动镜像;或
  • TV 高级套餐下用多 webhook 同时发多个 URL