The below guide will show you how you can integrate your tradingview with Tradetron.

Prequisites:

  1. 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.
  2. Tradingview account: Please note that alerts with webhook can only be set from a paid trading view subscription.
  3. A basic strategy
  4. 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.
    1. 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
    2. Once an entry is taken, the entry block will again execute only after the exit block is triggered.
    3. 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.
  5. 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.

Step 1:

Open the tradingview and select the instrument. In our example, we have selected Crude Oil Futures.

Step 2:

Set your indicators. In our example, we have selected SMA 2 and SMA 5.

01


Step 3:

Select Alerts and click create Alert

02


Step 4:

Create your condition. In our example, i am setting an alert when SMA2 cross SMA 5 from bottom to the top

03


 

 

 

 

 

 

 

 Step 5:

Let us first generate a token for your strategy.

  1. Go to “MY STRATEGIES” Page in your Tradetron account
  2. Click the three dots on the strategy and select API OAUTH Token
04


 

   3. This will open the menu

05


 

  4.  Select Link and click Proceed, this generates the token and release control of Tradetron

06

5. The Part outlined in red is your token.

ab4ee4c7-4413-4110-993e-cf9b9b927d4a

        6.  You can go back to the same menu to unlink the API control

07




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.

08


 

 

 

 

 

 

 

 Step 6: 

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

09


 {"auth-token":"2d07b8c5-dcda-4ea9-972c-cc413d654846","key":"Crude_long","value":"1","key1":"Crude_long_lots","value1":"100","key2":"Crude_short","value2":"0"}
10


Step 7:

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

{"auth-token":"2d07b8c5-dcda-4ea9-972c-cc413d654846","key":"Crude_short","value":"1","key1":"Crude_short_lots","value1":"100","key2":"Crude_long","value2":"0"}
11


 

 

 

 

 

 

 

 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

Step 8:

Go to Tradetron & create your strategy

In Set 1, i will define my condition as below

12


  1. The first condition is when i want the trades to start.
  2. 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
  3. Position detail in only to ensure that at any given time, only one side position is open

 

Step 9:

I will define my position builder as below

13


I will select FX in Qty formula and add Get Runtime keyword with variable name Crude_long_lots in it

14



 

Step 10:

I will define my set 1 exit as below

15


 

Conclusion:

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

16


 

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.

18


You can check your Variable from Runtime Data

19


 

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.

Its syntax resembles JavaScript, making it more accessible to developers familiar with web development languages.

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]