Automating trading from a TradingView Pine Script strategy
With OctoBot, you can listen to TradingView Pine Script strategies signals to automate your trades.
Create strategy alert
To send alerts from a strategy, use the alert_message
parameter from Pine Script strategy functions which can create orders.
- Define the content of your alert before any
strategy.entry
,strategy.exit
orstrategy.close
call:- example:
messageBuy = "EXCHANGE=binance\nSYMBOL=SOLUSDT\nVOLUME=100a%\nSIGNAL=BUY"
Note: when defining your alert, don’t forget to add
\n
at the end of each value. This simulates a return to the next line to comply with to the OctoBot alert format. - example:
- In the strategy section, add
alert_message = messageBuy
to your strategyentry
,exit
orclose
calls:- example:
strategy.entry("Buy", strategy.long, comment = "Buy Signal Triggered", alert_message = messageBuy)
- example:
- When creating a new alert (right-click on the strategy / add new alert) make sure that you:
- Select the name of your strategy as the condition
- Name the alert (the name can be whatever you want)
- Replace ALL the message content with exactly
{{strategy.order.alert_message}}
- Et voilà ! This alert will automatically notify your OctoBot each time your strategy executes
entry
,exit
orclose
calls.
Tips:
- For multi-coin, simply edit the strategy and modify the SYMBOL entry in the messageBuy definition. You can thus vary the parameters according to the assets.
- It can be easier to define multiple messages such as
messageBuy
,messageBuyWithATakeProfit
,messageSell
or evenmessageCancel
and use the appropriate message later on (with thealert_message
parameter) when callingentry
,exit
orclose
.
Special thanks to @KidCharlemagne for creating the basis of this guide !
Alert format
Learn more about how to create your TradingView alerts on the TradingView alert format guide.
TradingView setup
Wondering how to make your OctoBot listen to TradingView signals ? Check out our TradingView integration guide.