Test Tradingview strategy alert

After server setup is done, this guide shows how to test you can receive strategy alert from Tradingview and execute order

  1. On the Tradingview website, select BINANCE:BTCPERP(or whatever ticker your want) and set the time interval to 1 minute.

2. Open "Pine Editor" tab and paste the following script after deleting shown original script. Then click "Add to chart"

//@version=5
strategy("My test strategy")

_TestPeriod() =>
    time >= timenow - 10000000 ? true : false
    
if _TestPeriod()
    if (bar_index % 2 == 0)
        strategy.entry("My Long Entry Id", strategy.long)
    else
        strategy.entry("My Short Entry Id", strategy.short)

3. Click Alert button

4. At Create alert popup, Set “Webhook URL” and “Message” and click “Create”

Webhook URL: HTTPS endpoint URL got in Running on local PC or Run on cloud service

Message: paste the following code

dYdX v3:

{
"exchange": "dydx",
"strategy":"testStrategy",
"market":"BTC_USD",
"size":"0.001",
"reverse":false,
"order":"{{strategy.order.action}}",
"position":"{{strategy.market_position}}",
"price":"{{strategy.order.price}}"
}

dYdX v4:

{
"exchange": "dydxv4",
"strategy":"testStrategy",
"market":"BTC_USD",
"size":"0.0001",
"reverse":false,
"order":"{{strategy.order.action}}",
"position":"{{strategy.market_position}}",
"price":"{{strategy.order.price}}"
}

Perpetual Protocol:

{
"exchange": "perpetual",
"strategy":"testStrategy",
"market":"BTC_USD",
"size":"0.001",
"reverse":false,
"order":"{{strategy.order.action}}",
"position":"{{strategy.market_position}}",
"price":"{{strategy.order.price}}"
}

GMX:

{
"exchange": "gmx",
"strategy":"testStrategy",
"market":"BTC_USD",
"sizeUsd":"3",
"reverse":false,
"order":"{{strategy.order.action}}",
"position":"{{strategy.market_position}}",
"price":"{{strategy.order.price}}"
}

This alert is triggered every minute and creates a buy/sell order alternately.

You can check if an order is executed on the exchange you selected after the first alert is triggered.

Last updated