Tradingview Pinescript library Tutorial
Please refer to the following video : How to use Pinetrader library
How to use Pinetrader TradingView library
The goal of the TradingView library is to generate the Order ticket by following all the required guidelines.
Inside of TradingView there is no support for creating JSON payloads, so creating the order ticket yourself will be quite a pain. You’ll need to play with string methods and functions.
Lukely we’ve automated this for you.
The main step to starting to use the TradingView library are as follow:
- Import the library
- Declare the Order Ticket
- Pass the Order Ticket in an alert function
Link to the Tradingview Library: Library
Importing the Library inside of Pinescript
The first step is to actually import the library we’ve created. Since Pinescript V5, you can now create and share libraries across the whole Tradingview community.
In order to import the library you can copy this line of code inside your Pinesript Code Editor:
import Pinetraderio/PineTraderOT/1 as [VARIABLE]
This will import the function: GenerateOT()
.
It will be accessible by using the keyword: [VARIABLE]
, this have any name you wish.
Creating the Order Tickets
Once imported you can now create the order ticket. The best way to go about this is to generate the order ticket for each type of trade you will take: Buy, Sell, Closing.
Here is how you might consider doing it:
var LongOT = [VARIABLE].GenerateOT(**Params)
var ShortOT = [VARIABLE].GenerateOT(**Params)
var CloseOT = [VARIABLE].GenerateOT(**Params)
Each **Params
represents the paramaters you can find here.
Sending the Order Ticket to Pinetrader
Last step is to actually send the Order Ticket generated by the GenerateOT()
function.
There are different way to achieve the same thing here, it will depend on your preferences and strategy requirements.
- Method 1: Copy exactly what the TradingView Strategy is showing
- Inside your Pinescript trading strategy, where you are invoking the
strategy.entry()
you will add a message like so:
- Inside your Pinescript trading strategy, where you are invoking the
// Entry Trades
strategy.entry(**Params, alert_message=LongOT)
strategy.entry(**Params, alert_message=ShortOT)
// Exit Trade
strategy.exit(**Params, alert_message=CloseOT)
- In your alert notification settings activate the webhook (if you are new to Tradingview,
grab our special 15$ rebate for new users)
- Set the message field to the following:
{{strategy.order.alert_message}}
- Method 2: More control over when the data is settings_notification
- Unlike the first method, this one will allow you to send data when you want. This can be added to a indicator or even a strategy.
- Using the
alert()
function built in Tradinview’s Pinescript. - In your notification panel, select the condition: alert() calls only.
- This will send the data you passed in your
alert()
.
Pinetrader library live exemple
Please refer to the following video : How to use Pinetrader library
How to use Pinetrader TradingView library
The goal of the TradingView library is to generate the Order ticket by following all the required guidelines.
Inside of TradingView there is no support for creating JSON payloads, so creating the order ticket yourself will be quite a pain. You’ll need to play with string methods and functions.
Luckily we’ve automated this for you.
The main step to starting to use the TradingView library are as follow:
- Import the library
- Declare the Order Ticket
- Pass the Order Ticket in an alert function
Link to the Tradingview Library: Library
Importing the Library inside of Pinescript
The first step is to actually import the library we’ve created. Since Pinescript V5, you can now create and share libraries across the whole Tradingview community.
In order to import the library you can copy this line of code inside your Pinesript Code Editor:
import Pinetraderio/PineTraderOT/1 as [VARIABLE]
This will import the function: GenerateOT()
.
It will be accessible by using the keyword: [VARIABLE]
, this have any name you wish.
Creating the Order Tickets
Once imported you can now create the order ticket. The best way to go about this is to generate the order ticket for each type of trade you will take: Buy, Sell, Closing.
Here is how you might consider doing it:
var LongOT = [VARIABLE].GenerateOT(**Params)
var ShortOT = [VARIABLE].GenerateOT(**Params)
var CloseOT = [VARIABLE].GenerateOT(**Params)
Each **Params
represents the paramaters you can find here.
Sending the Order Ticket to Pinetrader
Last step is to actually send the Order Ticket generated by the GenerateOT()
function.
There are different way to achieve the same thing here, it will depend on your preferences and strategy requirements.
- Method 1: Copy exactly what the TradingView Strategy is showing
- Inside your Pinescript trading strategy, where you are invoking the
strategy.entry()
you will add a message like so:
- Inside your Pinescript trading strategy, where you are invoking the
// Entry Trades
strategy.entry(**Params, alert_message=LongOT)
strategy.entry(**Params, alert_message=ShortOT)
// Exit Trade
strategy.exit(**Params, alert_message=CloseOT)
- In your alert notification settings activate the webhook (if you are new to Tradingview,
grab our special 15$ rebate for new users)
- Set the message field to the following:
{{strategy.order.alert_message}}
- Method 2: More control over when the data is settings_notification
- Unlike the first method, this one will allow you to send data when you want. This can be added to a indicator or even a strategy.
- Using the
alert()
function built in Tradinview’s Pinescript. - In your notification panel, select the condition: alert() calls only.
- This will send the data you passed in your
alert()
.
Pinetrader library live exemple
Please refer to the following video : How to use Pinetrader library
How to use Pinetrader TradingView library
The goal of the TradingView library is to generate the Order ticket by following all the required guidelines.
Inside of TradingView there is no support for creating JSON payloads, so creating the order ticket yourself will be quite a pain. You’ll need to play with string methods and functions.
Lukely we’ve automated this for you.
The main step to starting to use the TradingView library are as follow:
- Import the library
- Declare the Order Ticket
- Pass the Order Ticket in an alert function
Link to the Tradingview Library: Library
Importing the Library inside of Pinescript
The first step is to actually import the library we’ve created. Since Pinescript V5, you can now create and share libraries across the whole Tradingview community.
In order to import the library you can copy this line of code inside your Pinesript Code Editor:
import Pinetraderio/PineTraderOT/1 as [VARIABLE]
This will import the function: GenerateOT()
.
It will be accessible by using the keyword: [VARIABLE]
, this have any name you wish.
Creating the Order Tickets
Once imported you can now create the order ticket. The best way to go about this is to generate the order ticket for each type of trade you will take: Buy, Sell, Closing.
Here is how you might consider doing it:
var LongOT = [VARIABLE].GenerateOT(**Params)
var ShortOT = [VARIABLE].GenerateOT(**Params)
var CloseOT = [VARIABLE].GenerateOT(**Params)
Each **Params
represents the paramaters you can find here.
Sending the Order Ticket to Pinetrader
Last step is to actually send the Order Ticket generated by the GenerateOT()
function.
There are different way to achieve the same thing here, it will depend on your preferences and strategy requirements.
- Method 1: Copy exactly what the TradingView Strategy is showing
- Inside your Pinescript trading strategy, where you are invoking the
strategy.entry()
you will add a message like so:
- Inside your Pinescript trading strategy, where you are invoking the
// Entry Trades
strategy.entry(**Params, alert_message=LongOT)
strategy.entry(**Params, alert_message=ShortOT)
// Exit Trade
strategy.exit(**Params, alert_message=CloseOT)
- In your alert notification settings activate the webhook (if you are new to Tradingview,
grab our special 15$ rebate for new users)
- Set the message field to the following:
{{strategy.order.alert_message}}
- Method 2: More control over when the data is settings_notification
- Unlike the first method, this one will allow you to send data when you want. This can be added to a indicator or even a strategy.
- Using the
alert()
function built in Tradinview’s Pinescript. - In your notification panel, select the condition: alert() calls only.
- This will send the data you passed in your
alert()
.