-
Notifications
You must be signed in to change notification settings - Fork 36
Creating Custom Studies
Ruslan edited this page Jun 15, 2015
·
4 revisions
We use our Pine scripting language to create indicators for Charting Library. If you want to create a custom indicator you have to write it in Pine using TradingView site. Then contact us and we'll compile your Pine code to a code for Charting Library. Then use widget constructor's indicators_file_name parameter to show the library where to find your studies.
Here is an instruction for the case if you have some data which you want to show on the chart like an indicator and which cannot be computed from series data directly.
Plese follow these few steps:
- Contrive a new ticker for your data and set up your server to return valid SymbolInfo for this ticker.
- Also set up the server to return valid history data for this ticker.
- Write a simple script in Pine which will request this ticker's data (with
security()function) and render it with an appropriate style. - Send this script to us and we'll return the compiled version.
- Update your widget's initialization code to create this indicator when chart is ready.
Example
Assume you want to show user's equity curve on his charts. You will have to do the following:
- Create a name for the new ticker. Assume it will be
#EQUITYticker. You can use any name you can imagine. - Change your server's code to resolve this ticker as a valid symbol. Return the minimal valuable SymbolInfo for this case.
- Make the server to return valid history for this ticker. I.e., the server could ask your database for equity history and return this data just as you return the history for generic symbols (like, say,
AAPL). - Write a script in Pine. This could be something likeshown below. Send this script to us.
study("Equity", overlay = false)
s = security("#EQUITY", period, close)
plot(s, color=red)
- Plug the compiled indicator into your Charting Library with indicators_file_name option.
- Change your widget's intiialization code. Add something like this
widget = new TradingView.Widget(/* ... */);
widget.onChartReady(function() {
widget.createStudy('Equity', false, true);
});
#Wiki Content
- What is Charting Library
- Getting Started
- Package Content
- Running Your Charting Library
- Data Binding
- How To Connect My Data
- JS API
- UDF
- Symbology
- Trading Sessions
- Quotes
- Chart Customization
- Charts Customization 101
- Client-Side Customization 1. Widget Constructor 2. Widget Methods 3. Chart Methods 4. Featuresets
- Server-Side Customization
- Trading Platform
- Brief Intro
- Trading Controller
- Saving/Loading Charts
- Creating Custom Studies
- Best Practices
- Breaking changes in versions