The below guide will show you how you can integrate your tradingview with Tradetron.
- API token: This is a unique token that you can now generate for your strategy. The token is bound to one strategy template and cannot be used elsewhere.
- Tradingview account: Please note that alerts with webhook can only be set from a paid trading view subscription.
- A basic strategy
- Basic understanding of Tradetron workflow: Although, there is much to know about Tradetron, however, the below points are enough to start your first very basic strategy integration.
- A condition builder is a place where all your conditions should be in comparison with something, which means, each condition should return either True or false
- Once an entry is taken, the entry block will again execute only after the exit block is triggered.
- You will have to figure out how to send API calls for each instrument if your pine script is working on a list of instruments.
- Basic understanding of the API calls made by tradingview and how it is handled by Tradetron.
From tradingview, we send keys(variable names) and its value(variable values) from alerts via webhook, these webhooks send an HTTP post request to Tradetron.
When Tradetron gets these values from tradingview, it matches these values in its condition builder and triggers any positions defined in the Position builder.
Open the tradingview and select the instrument. In our example, we have selected Crude Oil Futures.
Set your indicators. In our example, we have selected SMA 2 and SMA 5.
Select Alerts and click create Alert
Create your condition. In our Example, i am setting an alert when SMA2 cross SMA 5 from bottom to the top
Let us first generate a token for your strategy.
- Go to “MY STRATEGIES” Page in your Tradetron account
- Click the three dots on the strategy and select API OAUTH Token
3. This will open the menu
4. Select Link and click Proceed, this generates the token and release control of Tradetron
5. The Part outlined in red is your token.
6. You can go back to the same menu to unlink the API control
Note: Every time you unlink and relink a strategy, you will get a new API code. Just to illustrate this point I have unlinked and relinked the strategy which generated a new key.
Now go back to tradingview and select Webhook URL in the same menu and insert https://api.tradetron.tech/api in the below text box.
Now comes the sending api request part. The variables and values are send in a JSON format and always in a pair. In this strategy when this alert triggers, i want trading view to send a variable and value to Trading view signifying a Long signal and Short Exit Signal
I will create one more alert with opposite condition, i.e when SMA 5 crosses up SMA 2 signifying my short position and my Long Exit
Notice that my variables are different but my auth token is the same.
Note: the key: value start from key, key1, key2, key3...
And my values also start from value, value1, value2, vlaue3...
This order should not be changed else the api call will not trigger
Go to Tradetron & create your strategy
In Set 1, i will define my condition as below
- The first condition is when i want the trades to start.
- The Get Run-time keyword is used to fetch the value of the the variable “Crude_long” and check if its value is equal to 1
- Position detail in only to ensure that at any given time, only one side position is open
I will define my position builder as below
I will select FX in Qty formula and add Get Runtime keyword with variable name Crude_long_lots in it
I will define my set 1 exit as below
Now when Tradingview triggers the first alert it will send value 1 for Crude_long and 100 for Crude_long_lots
The first variable gets compared in set no 1 and a position will be taken
Now when the second alert gets triggered, it will send value 1 for Crude_short and 100 for Crude_short_lots
This will trigger an Exit for set no 1 and Entry for Set no 2.
You can check your Variable from Runtime Data
And that concludes the guide.
Please let us know if you have any questions on email@example.com