TradingView tem os melhores charts. Pine Script é linguagem pra criar indicadores e alertas neles. Combinar TradingView (sinal) + OpenClaw (decisão+execução) é setup popular. Este guia cobre.
Arquitetura
TradingView (Pine Script alerta)
↓ webhook HTTPS
Servidor HTTP do OpenClaw
↓ skill call
Exchange/Broker (executa ordem)
Pré-requisitos
- TradingView assinatura Essential ou superior (webhooks)
- OpenClaw rodando em VPS com IP público
- HTTPS configurado (Caddy ou nginx + Let's Encrypt)
- Skill de exchange já configurada
Passo 1 — Webhook endpoint no OpenClaw
openclaw skill install @openclaw/skill-webhook
Config:
# ~/.openclaw/config.yml
webhook:
port: 8443
path: "/tv-alert"
secret: "${TV_WEBHOOK_SECRET}" # validado em headers
rate_limit: "20/min"
Passo 2 — Reverse proxy HTTPS
Caddy (mais simples):
# /etc/caddy/Caddyfile
tv-webhook.seudominio.com {
reverse_proxy localhost:8443
}
Caddy auto-renova certificate Let's Encrypt.
Passo 3 — Pine Script alerta
//@version=5
strategy("EMA Cross", overlay=true)
ema_fast = ta.ema(close, 20)
ema_slow = ta.ema(close, 50)
if ta.crossover(ema_fast, ema_slow)
strategy.entry("Long", strategy.long, alert_message='{"action":"buy","symbol":"BTCUSDT","secret":"YOUR_SECRET"}')
if ta.crossunder(ema_fast, ema_slow)
strategy.close("Long", alert_message='{"action":"close","symbol":"BTCUSDT","secret":"YOUR_SECRET"}')
Passo 4 — Configurar alert no TradingView
- Adicione script ao chart
- Create Alert (sino no topo)
- Condition: "EMA Cross" → "Any alert() function call"
- Webhook URL:
https://tv-webhook.seudominio.com/tv-alert - Message:
{{strategy.order.alert_message}} - Save
Passo 5 — Validação do payload no OpenClaw
Skill recebe webhook e valida:
- Secret matches?
- Symbol whitelisted?
- Action válida (buy/sell/close)?
- Rate limit OK?
- Risk checks (saldo, max ordens abertas)?
Só depois executa.
Segurança crítica
- Secret obrigatório no payload — TradingView IPs não são white-listáveis confiavelmente
- HTTPS sempre — HTTP expose secret
- Rate limit — webhook bug pode disparar tempestade
- Whitelist de symbols/actions — não execute payload arbitrário
- Risk checks antes de qualquer ordem
Testing
- Test webhook manualmente:
curl -X POST https://... -d '{"action":"buy","secret":"..."}' - Verifique logs no OpenClaw — alert recebido?
- Trigger alert manual no TradingView (Alert → Test alert)
- Confirme execução em conta demo
- Operar em conta demo por 1-2 semanas antes de live
Veja também: TradingView setup completo. 🦞