Cloudflared with Custom Domain
This documentation outlines how to set up a Cloudflare Tunnel (cloudflared) with OpenAlgo to receive TradingView alerts securely on your local machine
1. Overview
A Cloudflare Tunnel creates a secure, outbound-only connection between your local OpenAlgo server and the Cloudflare network. This allows TradingView (which is on the public web) to send HTTP POST requests (Webhooks) to your local machine (localhost:5000) securely.
2. Installation
To follow the video tutorial, install cloudflared on your Windows machine using PowerShell:
Note: After installation, restart your terminal to ensure the command is recognized.
3. Configuration in OpenAlgo
Before starting the tunnel, you must tell OpenAlgo what its public address will be.
Open your OpenAlgo folder in VS Code.
Open the
.envfile.Locate the
HOST_SERVERvariable and update it with your intended domain:Save the file and start OpenAlgo:
python app.py(running on port 5000).
4. Setting Up the Tunnel (Two Options)
Option A: Custom Domain (Recommended for Production)
This keeps your Webhook URL permanent.
Login to Cloudflare:
A browser window will open. Select your domain to authorize.
Create the Tunnel:
This generates a JSON credentials file. Note the path provided in the terminal.
Configure
config.yml: In your OpenAlgo project, locate or create.cloudflared/config.ymland fill it:Route DNS:
Run the Tunnel:
Option B: Free Temporary Tunnel (Quick Testing)
If you don't own a domain, you can generate a random public URL.
Run the command:
Cloudflare will generate a URL like
https://random-words-generated.trycloudflare.com.Warning: Every time you restart this tunnel, the URL will change. You will have to update your TradingView Webhook URL and
.envfile accordingly.
5. Integrating with TradingView
Once the tunnel is "Active" in your terminal:
Get Webhook URL: Your URL will be
https://yourdomain.com/api/v1/placeorder.Generate Payload:
Go to OpenAlgo Local Dashboard -> Platforms -> TradingView.
Configure your symbol (e.g.,
SILVERMARFUT), action (BUY), and quantity.Click Generate JSON and Copy the code.
Create Alert in TradingView:
Set your Condition (e.g., Price Crossing).
Under Notifications, check Webhook URL and paste your tunnel URL.
Under Message, paste the JSON payload generated by OpenAlgo.
6. Verification & Performance
Order Book: When the alert triggers, check the Order Book tab in OpenAlgo to see the executed trade.
Latency Monitor: Go to Logs -> Latency Monitor.
Cloudflare Tunnels typically offer latency between 150ms – 300ms, which is faster than Ngrok or Pagekite in many regions.
Security: Because the tunnel is outbound-only, your local IP address remains hidden from the public internet.
7. Troubleshooting
404 Error: Ensure the
serviceURL inconfig.ymlmatches the port OpenAlgo is running on (default is5000).HTTPS Requirement: TradingView requires an
httpsURL. Ensure you use the Cloudflare provided link and not your local IP.Tunnel Fails to Start: Check if another instance of
cloudflaredis running in the background.
Last updated
Was this helpful?