Automation



In this page, you will learn about how automation can be achieved with the StratBuilder.



Disclaimer: We are not responsible for any losses or gains that are achieved with our product. The user is responsible for their own decisions. The information on this page is purely for education.


Automation is very simple with all versions of the StratBuilder.
First, find a strategy you would like to automate and hook up your exchange/broker to a site that allows automation through TradingView alerts. This will cost a subscription fee to the platform.

Some examples are:
 Alertatron  - Recommended for Crypto trading. Supports Binance, Bybit, Bitget, OKX, phemex, and Bitmex.
 3commas  - Crypto trading. Supports 16 different crypto exchanges:  https://3commas.io/exchanges 
 Pineconnector  - Recommended for Metatrader 4/5. Forex, stocks, and futures trading.
Many more 
1. Connect your trading exchange/broker/account to your preferred automation platform. The automation platform will have directions on how to do this.

2. Create a strategy on the StratBuilder that you want to automate.

3. Input the messages you want to occur during entry, exit, take-profit, and stop-loss in the settings of the StratBuilder:
This example is automating a BTC strategy using Alertatron. I set the take-profit and stop-loss price in the entry command so I don’t need to input any commands for when the TP or SL get hit.


3.Hover over the ‘StratBuilder’ name on the chart and click on the icon with the three dots at the very right



4. Click ‘Add alert on StratBuilder…’



5. In the ‘Message’ box, input this exactly:
{{strategy.order.alert_message}}



6. Give it any title you want, then click on the ‘Notifications’ tab



7. Turn on the ‘Webhook URL’ option, and input the webhook URL given to you by the automation platform.


8. Click ‘Create’ in the bottom right. And that’s it, now your strategy is automated!



So when do the specific alert messages fire off?


Alert Message for Entry’ - The alert for this message will be triggered when a trade is entered.


Alert Message for Exit’ - The alert for this message will be triggered when the script exits a trade upon closure (not off a take-profit or stop-loss).


Alert Message when TP is hit’ - The alert for this message will be triggered when the script exits a trade by hitting the take-profit.


Alert Message when SL is hit’ - The alert for this message will be triggered when the script exits a trade by hitting the stop-loss.

In the ‘StratBuilder (2-Side)’ version, there’s input for all of these for both longs and shorts, separately. So longs have their own 4 alert message inputs, and shorts have a separate 4 alert message inputs in the same indicator.



Helpful Tips:


In your automation commands, you can refer to the stop-loss price as:
{{plot_0}}

You can refer to the take-profit price as:
{{plot_1}}

There’s also an ‘Order Size’ input at the very bottom of the indicator. The number you input there will be divided by the price of the asset. This was mainly added for crypto trading. The 'Order Size' can be referred to in your automation command as:
{{plot_2}}



Example Entry Command for Alertatron (works for both longs and shorts):

This will enter on a market order with the dollar amount that you specify in the ‘Order Size’ input at the bottom of the StratBuilder’s settings. It also sets the take-profit and stop-loss for the strategy.

apiName(BTCUSDT) {market(side=buy, amount={{plot_2}}); stopOrder(offset=@{{plot_0}}, reduceOnly=true, position=0, tag=stop); limit(offset=@{{plot_1}}, reduceOnly=true, position=0, tag=limit_exit); } #bot


Example Exit Command for Alertatron (works for both longs and shorts):
This will exit the trade and cancel all existing orders.

apiName(BTCUSDT) {cancel(which=all); market(position=0, reduceOnly=true); } #bot