Home Community Webhook Exchange Join Community
// Webhook ยท Panduan Lengkap

Webhook Trading Automation

Konsep, cara pakai, dan integrasi untuk semua platform trading

โ—ˆ Dashboard Preview

Live Testnet Long Short
Total Balance
$00,000.00
Available $0,000.00
Unrealized PnL
+$000.00
+0.00% today
Win Rate
00.0%
000 trades
Daily PnL
-$000.00
0 open positions
SymbolSideSizeEntryPnL
BTCUSDTLong0.00000,000.0+$000.00
ETHUSDTShort0.000,000.0-$00.00
SOLUSDTLong00.0000.00+$000.00

๐Ÿ“ก Apa itu Webhook?

Webhook adalah metode komunikasi real-time antar aplikasi yang bekerja dengan prinsip "push" โ€” bukan "pull" (polling).

Ketika suatu event terjadi di aplikasi A (misal: sinyal trading muncul), aplikasi A akan mengirim HTTP POST request ke URL yang sudah ditentukan di aplikasi B. Aplikasi B kemudian memproses data tersebut dan menjalankan aksi yang sudah diprogram.

1

Event terjadi
Contoh: sinyal BUY dari strategi trading muncul

2

Kirim HTTP POST
Ke URL endpoint yang sudah ditentukan (misal: /api/webhook)

3

Validasi & Proses
Bot memverifikasi signature/secret, lalu memproses order

4

Eksekusi
Order dikirim ke exchange (Binance, dll) dan hasilnya dicatat

๐Ÿ’ฐ Crypto Flow
๐Ÿ“Š TradingView Pine Script ๐Ÿ Python / Custom Script
โ†’ ๐Ÿ“ฆ JSON Payload (HTTP POST) โ†’ ๐Ÿค– Webhook Bot โ†’
๐Ÿฆ Binance ๐Ÿฆ Bybit ๐Ÿฆ OKX
๐Ÿ’ฑ Forex Flow
๐Ÿ“Š TradingView Alert ๐Ÿ Python / Custom Script
โ†’ ๐Ÿ“ฆ JSON Payload (HTTP POST) โ†’ ๐Ÿค– Webhook Bot โ†’ ๐Ÿ“ˆ MT4 / MT5 โ†’
๐Ÿฆ XM ๐Ÿฆ IC Markets ๐Ÿฆ Exness

๐ŸŒ Tidak Hanya Kripto

Meskipun contoh di dokumentasi menggunakan crypto futures, konsep webhook ini universal dan bisa diterapkan untuk berbagai instrumen trading:

๐Ÿ’ฐ
Crypto
BTC, ETH, SOL, dll
๐Ÿ’ฑ
Forex
EUR/USD, GBP/JPY, dll
๐Ÿช™
Commodities
Gold, Oil, Silver
๐Ÿ“Š
Indices
S&P500, NASDAQ, Nikkei

๐Ÿ“ก Sumber Sinyal (Tidak Hanya TradingView)

Webhook bot bisa menerima sinyal dari berbagai sumber. Yang penting adalah payload (format data) sesuai dengan yang diharapkan oleh bot.

๐Ÿ“Š TradingView
Pine Script alerts dengan webhook URL
๐Ÿค– MQL5 / MT5
Expert Advisor dengan fungsi WebRequest()
๐Ÿ Python Script
Custom bot dengan requests.post()
โšก 3Commas / DCA
Platform trading automation

๐Ÿš€ Cara Pakai Webhook

1. Dapatkan Endpoint & Secret

Setelah deploy bot, buka halaman Settings. Di sana akan ada:

// Webhook Configuration
Webhook URL : https://your-bot.com/api/v1/webhook
Webhook Secret : sk_live_8f7a3b9c2e1d...

โš ๏ธ Jangan bagikan Secret ke siapapun. Secret ini berfungsi sebagai API key untuk mengotentikasi bahwa request benar-benar berasal dari sumber yang sah.

2. Format Payload

Kirimkan data dalam format JSON dengan field-field berikut:

{
  "secret": "sk_live_8f7a3b9c2e1d...",   // wajib: webhook secret
  "symbol": "BTCUSDT",               // wajib: pasangan trading
  "side": "BUY",                    // wajib: BUY atau SELL
  "posSide": "LONG",                // LONG atau SHORT (untuk futures)
  "type": "MARKET",                // MARKET, LIMIT, STOP_MARKET, dll
  "amount": "0.001",               // quantity (wajib untuk market order)
  "leverage": "10",                // optional: leverage yang dipakai
  "price": "64210.50",             // optional: untuk limit/stop order
  "strategy": "EMA CROSS",          // optional: nama strategi
  "signalId": "{{strategy.order.id}}" // optional: idempotency key
}

3. Contoh Integrasi

๐Ÿ“Š TradingView (Pine Script)
alert(
  "BUY signal for "  + syminfo.ticker,
  title = "Webhook Signal",
  message = '{"secret":"sk_live_...","symbol":"' + syminfo.ticker +
    '","side":"BUY","positionSide":"LONG","type":"MARKET","amount":"0.001"}'
)
๐Ÿค– MQL5 (MetaTrader 5)
string data = "{\"secret\":\"sk_live_...\",\"symbol\":\"EURUSD\",\"side\":\"BUY\",\"type\":\"MARKET\",\"amount\":\"0.01\"}";
char postData[];
StringToCharArray(data, postData);
WebRequest("POST", "https://your-bot.com/api/webhook", headers, postData, result);
๐Ÿ Python (Custom Script)
import requests
import json

payload = {
    "secret": "sk_live_...",
    "symbol": "XAUUSD",   # Gold / Forex
    "side": "SELL",
    "order_type": "MARKET",
    "amount": "0.5"
}

requests.post("https://your-bot.com/api/webhook", json=payload)

โš™๏ธ Proses di Balik Layar

Ketika webhook menerima request, bot menjalankan serangkaian validasi dan proses:

๐Ÿ”
Validasi Secret
Constant-time comparison untuk mencegah timing attack
๐Ÿ›ก๏ธ
Rate Limiting
Maksimal 30 request per IP per menit
โฑ๏ธ
Cooldown & Dedup
Cooldown 3 detik per symbol + dedup hash 60 detik
๐Ÿ“ก
Sync Time Binance
Sinkronisasi waktu server untuk mencegah error recvWindow
๐Ÿ”„
Retry with Backoff
Retry 3x untuk error 5xx / network transient
๐Ÿ’พ
Logging & Storage
Semua request dan trade dicatat di PostgreSQL

โœ… Keuntungan Pakai Webhook

โšก
Real-time
Eksekusi dalam milidetik, tanpa jeda polling
๐Ÿ”—
Universal
Bisa dari TradingView, MT5, Python, dll
๐Ÿ›ก๏ธ
Secure
Validasi secret, rate limit, dedup, encryption
๐Ÿ“Š
Auditable
Semua aktivitas tercatat di database

Siap mulai otomatisasi?

Deploy bot, atur webhook, dan hubungkan dengan strategi trading favoritmu.