比特幣
教育

How to automate TradingView Alerts strategies on Dex

2 237
Easily receive and execute strategy alerts from TradingView. This tool enables automatic market order placements based on TradingView alerts and supports integration with third-party services via webhooks. It also provides the flexibility to run multiple strategies/markets simultaneously.

Source code: https://github.com/DePerp/Deperp-Self-Api

Conditions
A computing device (Cloud service, local PC) with a stable internet connection.
A TradingView Account with at least a Essential plan to enable Webhook notifications.
A blockchain wallet with private key (e.g., Metamask, Coinbase Wallet).
A trading account with collateral (USDT, USDC) already in the wallet and ETH for pay gas fees.
Approve the required (USDT,USDC) token in the interface https://app.deperp.com/

Features
Receive and execute market orders based on TradingView strategy alerts.
Place orders using webhooks from third-party services.
Supports multiple strategies/markets concurrently.
Security
Use of environment variables to safeguard sensitive information.
Implementation of a passphrase authentication between TradingView alerts and your web server.

Setup with Cloud Server
Self-API DePerp can be hosted on any cloud platform which supports Node.js.

1. Getting Started: Visit Render.com and either sign up or log in.

2. Create a New Web Service: Once logged in, click on "New Web Service".


3. Repository Setup: Enter the URL github.com/DePerp/Deperp-Self-Api into the search field and press Enter.


Note: You can also use a forked version of the original source code for setting up RPC found at
https://github.com/DePerp/Deperp-Self-Api/blob/main/src/config.ts.

4. Configure the Web Service:
‍Build command
Pine Script®
npm install

Run command
Pine Script®
npm run start


4. Add environment variables in the .env file.Required Variables:
Pine Script®
WALLET_PRIVATE_KEY= TYPE_NETWORK=mainnet

Replace the values with your specific details.

5. Initiate Deployment:

Start the deployment process.
Wait until the process completes.
The generated URL will be your webhook endpoint.


Setting Up Tradingview Strategy Alerts:
Strategy Selection:
Go to the TradingView website.
Choose a market and a strategy. Example: https://www.tradingview.com/script/vQSBf9rh-Wyckoff-Range-Strategy/
Add this to your terminal’s main indicator list.

It is recommended to use pairs in tradingview with the prefix BTCUSD

Creating Alerts:

When setting up an alert:

Set the “Webhook URL” to your cloud service’s endpoint.
The “Message” should be a JSON template, e.g.,

Example Message:

Pine Script®
{ "exchange": "deperp", "strategy": "test", "asset": "USDC", "market": "BTC-USD", "size": "200", //Position Size "leverage": "10", "reverse": true, "order": "{{strategy.order.action}}", "position": "{{strategy.market_position}}", "price": "{{strategy.order.price}}", "passphrase": "" }



As you indicated the message, now go to the notification section and add your server url to the webhook section


Click “Create” to activate the alert.

Operation

Once a strategy alert is triggered, the tool executes an order based on the settings.
Users can monitor and adjust strategies as needed.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。