CrossTrade Docs
CrossTrade.io
  • Welcome!
    • Set Up Guide
  • Getting Started
    • Installation
    • User Dashboard
      • XT Control Panel
      • Command Tester
      • Command Builder
    • Alert History
    • TradingView Alerts
      • Dynamic Variables
      • XT Alert Builder
      • Example Indicators
      • Example Strategies
    • VPS Connection Guide
  • Webhooks
    • Overview
    • Commands
      • Place Order
      • Flat Place Order
      • Close Position
      • Reverse
      • Reverse Position
      • Flatten Positions
      • Flatten Everything
      • Cancel Order
      • Cancel Orders
      • Cancel All Orders
      • Cancel Replace
      • Change Order
      • Close Strategy
    • Advanced Options
      • Multi-Account Placement
      • Flatten First
      • Require Market Position
      • Max Positions
      • Bracket Orders
      • Percentage and Tick Prices
      • Limit Order Timeouts
      • Trading Window
      • Bypass Trade Windows
      • Delay Timer
      • Rate-Limiting
      • Alert Commenting
      • Kill Switch
      • Notes
    • Examples & Use Cases
    • Troubleshooting
  • Account Manager
    • Overview
      • How It Works
      • Dashboard
      • Global Settings
      • Frequently Asked Questions (FAQ)
    • Monitors
      • Profit/Loss Thresholds
      • Minimum Profit Drawdown
      • Trailing Drawdown
      • Advanced Usage
    • Account Settings
      • Auto-Flattening
      • Trading Windows
    • Management Logs
  • NinjaTrader
    • ATM Strategies
      • Creating ATM Template
    • Optimizing NinjaTrader Performance
    • Enabling Multi-Provider Mode
  • CrossTrade API
    • Overview
    • Authentication
    • Rate Limiting
    • Webhook Trading
    • Accounts
      • GET Accounts Summary
      • GET Accounts
      • GET Account
    • Positions
      • GET Positions
      • GET Position
      • POST Close Position
      • POST Reverse
      • POST Reverse Position
      • POST Flatten Positions
      • POST Flatten Everything
    • Orders
      • GET Orders
      • GET Order
      • GET Order Status
      • POST Cancel Order
      • POST Cancel Orders
      • POST Cancel All Orders
      • POST Place Order
      • POST Flat Place Order
      • POST Replace Order
      • PUT Change Order
    • Strategies
      • GET Strategies
      • GET Strategy
      • POST Close Strategy
    • Executions
      • GET Executions
      • GET Execution
    • Quotes
      • GET Quote
  • Changelog
    • XT Versions
    • All Updates
  • Affiliate Program
    • Media Kit
  • Social Links
    • Discord
    • TradingView
    • YouTube
    • X (Twitter)
    • Instagram
    • Facebook
    • Reddit
    • Website
    • Blog
Powered by GitBook
On this page
  • Authentication
  • Code Example (Python)
  1. CrossTrade API

Webhook Trading

Send a webhook as if it came from TradingView or anywhere else.

Some traders enjoy the functionality available as part of the webhook system that they don't want to implement themselves, e.g., rate limiting.

It's easy to replicate these requests in your own code, with a few caveats to be aware of. To make webhooks easy for non-technical users, they are sent as plaintext messages from places like TradingView, not JSON. So when sending them in code, we need to ensure the Content-Type header is "text/plain", otherwise it will be rejected.

Functionally, there is no difference between the way these webhooks are sent and any other external webhook CrossTrade receives.

Authentication

Just like a regular external webhook, you do not need an "Authorization: Bearer <token>" header in your post request. Instead, your URL should match the custom Webhook URL provided with your account and your Secret Key should be contained inside the message body.

Code Example (Python)

import requests

# Webhook URL
url = "https://app.crosstrade.io/v1/send/abc123/abcdefghijklmnopqrstuvwxyz"

# Content must be sent as plain text
headers = {
    "Content-Type": "text/plain"
}

# Message payload text
data = '''
    key=my-secret-key;
    command=PLACE;
    account=Sim105;
    instrument=MES 03-25;
    action=BUY;
    qty=1;
    tif=DAY;
    order_type=MARKET;
'''

# Post it to CrossTrade!
try:
    response = requests.post(url, headers=headers, data=data)
    print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
    print(f"An error occurred: {e}")
PreviousRate LimitingNextAccounts

Last updated 2 months ago