block-quote On this pagechevron-down
GitBook Assistant Ask chevron-down Custom Strategies 24. Connecting Your Strategy to Perpbot Once you’re happy with a backtested strategy:
Make sure it uses clear alert messages :
"long" for opening longs.
"short" for opening shorts.
"close" for closing positions.
Then in TradingView:
Click the Alarm/Alert icon on your chart.
Select the corresponding strategy you saved as condition (e.g. Perpbot Strategy 1 ). Make sure to do this on the time frame you wish to automate on.
Set Interval as the time interval you want to trade on
Set expiration to Open Ended (only available for Premium Tradinview subscription). Otherwise, set to the expiration you like and update it every month.
In “Message" , paste exactly the JSON Perpbot expects shown below. Notice they are all the same for all actions as {{strategy.order.alert_message}} is used.
Open Long
Copy {
" action " : " {{strategy.order.alert_message}} " ,
" symbol " : " BTCUSDT " ,
" leverage " : 20 ,
" quantity " : " 25% " ,
" sl " : " 1% " ,
" tp " : " 5% " ,
" secret " : " YOUR_STRATEGY_PASSWORD "
} Open Short
Close Position
Key points:
action: {{strategy.order.alert_message}} is one of "long", "short", or "close" (case-insensitive).
symbol: Aster futures symbol (e.g. BTCUSDT, ETHUSDT).
leverage: integer leverage (1–125) for non-close orders.
quantity:
"25%" = use 25% of account (based on available balance & leverage).
"$100" = roughly $100 of notional (depending on your leverage/mode).
secret: must match the password you set for the strategy; otherwise Perpbot rejects the alert.
sl: set a stop loss for trades. A % would compute the SL at % from entry price. A set number would put SL at that set price.
tp: set a take profit for trades. A % would compute the TP at % from entry price. A set number would put TP at that set price.
Paste your Perpbot strategy webhook URL shown in Perpbot when you select your strategy:
https://webhook.perpbot.io/yourToken
Important: You should only automate a strategy after you’ve:
Backtested it over a decent sample size.
Checked drawdown is tolerable.
Appropriate safety measures.
PLEASE NOTE: YOU CAN ONLY HAVE 1 LONG OR SHORT ACTIVE AT ONE TIME PER STRATEGY.
Last updated 3 months ago