deperp

How to automate TradingView Alerts strategies on Dex

Education
PYTH:BTCUSD   Bitcoin
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
npm install
Run command
npm run start 

4. Add environment variables in the .env file.Required Variables:
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: 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:

{
 "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.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.