How it work
We are excited to announce the release of our latest feature - Webhook signal trading!
Now, you can trigger your ALGOGENE strategies based on TradingView alerts! This means a new world of possibilities such as:
- various indicators in TradingView can now be used to automate your trading without coding
- you can create multiple signals on TradingView and execute on a single broker account that is connected on ALGOGENE
- a single alert from TradingView can be executed to multiple broker accounts connected on ALGOGENE
- distribute your real-time signals to ALGOGENE marketplace to showcase your trading performance and attract investment
This article goes through the steps to apply ALGOGENE webhook on your TradingView account. The overall workflow is summarized in this diagram.
What is Webhook?
A Webhook lets you send a POST request to a specific URL when an alert is triggered. This feature can be enabled when creating or editing an alert on TradingView (or other third party platform). Add the URL given by ALGOGENE, it allows you to link TradingView signals to any brokers/exchanges supported by ALGOGENE such as Interactive Brokers, Binance, etc. TradingView will send a request as soon as an alert is triggered, with the request body containing the alert message. If the alert is activated, TradingView will send the request to ALGOGENE which will then automatically create a trade on your connected broker accounts.
How to Use Webhook Signal Trading?
Using Webhook Signal Trading is as simple as 3 steps:
- Run a strategy on TradingView (or other third party platform)
- Create a webhook on ALGOGENE
- Activate the webhook on TradingView to start receiving signals
Prerequisite
Please take note of the following before starting Webhook signal trading with TradingView (or other third party platforms)
- The webhooks feature may not be available for free users. For TradingView, you need to subscribe for Pro/Pro+/Premium plan to enable webhooks.
- Keep your webhook URL confidential and avoid sharing it with others to prevent receiving fake incoming signals and unauthorized orders
- All third party (eg. TradingView) alerts are sent based on your own settings, and you should be responsible to test it completely before using it in a real account
- There may be risks of signal loss or delay, as the triggering of signals relies on a third-party platform.
How to create Webhook on ALGOGENE?
- Login ALGOGENE Portal, go to [Settings]
- Go to [Live Demo] or [Real Trade] depending on whether you want to connect the signal to a paper or real trading account
- Mouse hover to your subaccount, then click "Webhook Setup"
- Click to "Set" webhook key
- For better account security, you can also white-list the IP that our system will accept the signal messages sent from
- Copy this webhook key
How to activate Webhook on TradingView?
- Login TradingView, then go to "Chart" (https://www.tradingview.com/chart/)
- Create your strategy on TradingView. Here we use "MA Cross" as an example.
- Click "Indicators"
- Search and add "MA Cross" strategy
- Click "Alert"
- Go to [Settings], paste the following in message
- Go to [Notifications], enable webhook URL and input
- Click "Create"
1234567 | { "instrument": "{{ticker}}", "price": "{{close}}", "ordertype": "LMT", "buysell": "{{strategy.order.action}}", "volume": "{{strategy.order.contracts}}"} |
Reference: https://www.tradingview.com/support/solutions/43000529348-about-webhooks/
Message Specification
Here is all available attributes that can be included in TradingView message.
Attribute | Description | Optional | Example |
---|---|---|---|
instrument | the trading instrument. Make sure the instument name aligns with ALGOGENE's symbols https://algogene.com/community/post/48 | No | BTCUSD |
buysell |
| No | BUY |
volume | the order quantity, unit in number of shares | No | 100 |
ordertype |
| No | LMT |
price |
| Yes | 15000 |
timeinforce | For limit/stop order, specify the maximum number of seconds to wait before auto-cancelling the order if not filled | Yes | 86400 |
takeProfitLevel | the take profit level after the order has been opened | Yes | 20000 |
stopLossLevel | the stop loss level after the order has been opened | Yes | 10000 |
holdtime | the holding time (in seconds) if the order has been opened | Yes | 86400 |
openclose | 'open' to open a new order, 'close' to close an outstanding order. If not speciified, assume to be 'open' | Yes | open |
orderRef | your reference message attached to this order. for openclose='close', it will close all outstanding trades with this reference | Yes | test |
Demo Video
This new feature unlocks a world of opportunities. Start automating your trading journey with Webhook Signal today!
Can I connect TradingView with my MT5?
Original Posted by - b'Henry Tsai': Can I connect TradingView with my MT5?
Currently it supports receiving signals from TradingView, then execute on MT5.
Hi, how to implement a round order strategy?
eg. open a long position, then close it later
from your example, what to add the open/close condition in tradingview?
{ "instrument": "{{ticker}}", "price": "{{close}}", "ordertype": "LMT", "buysell": "{{strategy.order.action}}", "volume": "{{strategy.order.contracts}}"}
Original Posted by - b'\xe5\xb0\x8f\xe9\x9c\xb8\xe7\x8e\x8b': Hi, how to implement a round order strategy?eg. open a long position, then close it later
from your example, what to add the open/close condition in tradingview?
{ "instrument": "{{ticker}}", "price": "{{close}}", "ordertype": "LMT", "buysell": "{{strategy.order.action}}", "volume": "{{strategy.order.contracts}}"}
According to TradingView (https://www.tradingview.com/support/solutions/43000481368-strategy-alerts/), strategy alert currently doesn't provide information about open/close and transaction number. As a workaround, you can put those information in pine script's comment.
For example, we have 2 strategies in TradingView using '123' and '124' to distinguish them. For entry order, we put 'open' in the comment; while putting 'close' for exit order.
1 2 3 4 5 6 7 8 910111213 | // pine scriptif entryCondition1 strategy.entry("buy", strategy.long, qty=10, comment="open 123")if entryCondition2 strategy.entry("sell", strategy.short, qty=20, comment="open 124")if exitCondition1 strategy.exit("sell", strategy.short, qty=10, comment="close 123")if exitCondition2 strategy.exit("buy", strategy.long, qty=10, comment="close 124") |
Then copy this to TradingView's alert setting.
12345678 | { "instrument": "{{ticker}}", "price": "{{close}}", "ordertype": "LMT", "buysell": "{{strategy.order.action}}", "volume": "{{strategy.order.contracts}}", "comment": "{{strategy.order.comment}}"} |
Original Posted by - b'admin':According to TradingView (https://www.tradingview.com/support/solutions/43000481368-strategy-alerts/), strategy alert currently doesn't provide information about open/close and transaction number. As a workaround, you can put those information in pine script's comment.
For example, we have 2 strategies in TradingView using '123' and '124' to distinguish them. For entry order, we put 'open' in the comment; while putting 'close' for exit order.
1 2 3 4 5 6 7 8 910111213 // pine scriptif entryCondition1 strategy.entry("buy", strategy.long, qty=10, comment="open 123")if entryCondition2 strategy.entry("sell", strategy.short, qty=20, comment="open 124")if exitCondition1 strategy.exit("sell", strategy.short, qty=10, comment="close 123")if exitCondition2 strategy.exit("buy", strategy.long, qty=10, comment="close 124")Then copy this to TradingView's alert setting.
12345678 { "instrument": "{{ticker}}", "price": "{{close}}", "ordertype": "LMT", "buysell": "{{strategy.order.action}}", "volume": "{{strategy.order.contracts}}", "comment": "{{strategy.order.comment}}"}
Hello What of{{strategy.position_size}} how can I use this placeholder in algogene?
Original Posted by - b'user': Hello What of{{strategy.position_size}} how can I use this placeholder in algogene?
"{{strategy.position_size}}" is currently not supported on our system. It needs to specify the details (eg. buy/sell direction, volume, order type, etc) for each trade instruction.
You can refer to below RSI example. It will close all outstanding trades when there is new signal.
//@version=5strategy("RSI Strategy", shorttitle="RSI Strategy", overlay=true)// INPUT VARIABLEStrade_qty = 1 RSIlength = input(14,title="RSI Period Length") RSIoverSold = 30RSIoverBought = 70price = close// RSI Strategyvrsi = ta.rsi(price, RSIlength)BUY = ta.crossover(vrsi, RSIoverSold)SELL = ta.crossunder(vrsi, RSIoverBought)if (not na(vrsi)) if (BUY) if (strategy.position_size<0) strategy.close("RSI_S", comment="[{'orderRef':'RSI_S','openclose':'close'},{'orderRef':'RSI_S','openclose':'cancel'}]") strategy.entry("RSI_L", strategy.long, qty=trade_qty, comment="{'orderRef':'RSI_L','openclose':'open','ordertype':'MKT','volume':"+str.tostring(trade_qty)+",'price':"+str.tostring(price)+"}" ) if (SELL) if (strategy.position_size>0) strategy.close("RSI_L", comment="[{'orderRef':'RSI_L','openclose':'close'},{'orderRef':'RSI_L','openclose':'cancel'}]") strategy.entry("RSI_S", strategy.short, qty=trade_qty, comment="{'orderRef':'RSI_S','openclose':'open','ordertype':'STOP','volume':"+str.tostring(trade_qty)+",'price':"+str.tostring(price)+"}")
- 1