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.
Frequently Asked Questions On TradingView
How do I put stop loss on TradingView?
To put a stop loss on TradingView, follow these simple steps:
1. Open TradingView and select the desired trading pair or asset you wish to trade.
2. Locate the "Order" panel usually found on the left-hand side of your screen. Click on it to expand the options.
3. Within the Order panel, find the section labeled "Stop Loss."
4. Set your desired stop loss level by either inputting a specific price or using percentage-based calculations relative to your entry point.
5. Specify whether you want this stop loss order to be executed as a "Market" order (executed immediately) or as a "Limit" order (executed only at a specified price).
6. Double-check that all other parameters such as quantity and leverage are set correctly before proceeding.
7. Once everything is in order, click on the appropriate button like "Sell/Short," depending on whether you're taking a long or short position, to place your stop loss order.
8. Confirm your decision by reviewing all details once more in the pop-up window that appears after clicking 'Sell/Short' button.
9. If everything looks correct, proceed with submitting your stop-loss order by clicking 'Confirm.'
10.Wait for confirmation from TradingView that your stop-loss order has been successfully placed and added to their system.
Remember: A well-placed stop loss can help limit potential losses and protect capital while trading volatile markets effectively; however, it is essential to constantly monitor market conditions and adjust stops accordingly if needed.
Is Pine Script easy?
Pine Script, a programming language designed for creating custom indicators and strategies on TradingView, can be both easy and challenging depending on your prior coding experience.
For those with some programming background, Pine Script offers a relatively gentle learning curve due to its simplified syntax and extensive documentation.
TradingView provides an online editor that enables real-time feedback as you write code, facilitating the learning process.
Please let us know if you have any questions on [email protected]