SMJ
SMJ

Reputation: 776

How to integrate trading view charting library in my website

Iam building a website for bitcoin exchange. I want to use trading view charting library I extracted it in my workspace. I want to know how to give my own datafeed. Which format should datafeed file be in (like php,js,json) ?

var _datafeed = new Datafeeds.UDFCompatibleDatafeed("http://localhost/workspace/charting");
    //var _datafeed = new Datafeeds.UDFCompatibleDatafeed("https://demo_feed.tradingview.com");

    TradingView.onready(function () {
        var widget = window.tvWidget = new TradingView.widget({
            debug: true, // uncomment this line to see Library errors and warnings in the console
            fullscreen: false,
            symbol: 'A',
            interval: 'D',
            timezone: "America/New_York",
            container_id: "tv_chart_container",
            locale: getParameterByName('lang') || "en",
            datafeed: _datafeed,
            library_path: "charting_library/",
        });
    });

In above code the charts are plotted with demo link. when I change it to my path, I get 'invalid symbol' error. Where do I specify config and symbol_info and what's their file format? Iam a total newbie. Please help .

Any suggestion to move in the right way is appreciated. I am STUCK!!

Screen shot of error message

Upvotes: 13

Views: 27227

Answers (3)

Issac Peña
Issac Peña

Reputation: 97

According with this page https://www.tradingview.com/widget/advanced-chart/ you do not need add any libraries, just to add the following references:

<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>

Two nested divs:

<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container" style="top:0px; left: 0px; height:50%; width:50%;">
   <div id="tradingview_99b08"></div>
</div>
<!-- TradingView Widget END -->


And set it with a script like this:

  <script type="text/javascript">
  new TradingView.widget(
  {
  "autosize": true,
  "symbol": "FX:EURUSD",
  "interval": "D",
  "timezone": "exchange",
  "theme": "Light",
  "style": "0",
  "locale": "en",
  "toolbar_bg": "#f1f3f6",
  "enable_publishing": false,
  "allow_symbol_change": true,
  "container_id": "tradingview_99b08"
}
  );
  </script>

Upvotes: 1

Charlie
Charlie

Reputation: 69

Try this one for node API, it is working well:

https://github.com/bergusman/tradingview-udf-binance-node

For front end you need tradingview's git repository access.

Upvotes: 1

SMJ
SMJ

Reputation: 776

You should write a php file and .htaccess in a folder within charting library. htaccess should rewrite all requests to that folder to that php file. Then in that php file echo results in UDF format.

UDF format and required api calls with sample result

UPDATE: Trading view charting library is a private repository. so you need to agree to their terms to get access the library and wiki pages on github.

Upvotes: 3

Related Questions