Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 367
SMJ Avatar asked Feb 17 '18 09:02

SMJ


People also ask

How do I get the Tradeview charting library?

The Charting Library is free, but its code is in the private repository on GitHub. Make sure that you have access to this repository: https://github.com/tradingview/charting_library/.

Can you publish TradingView charts?

You can share your charts in different ways on TradingView. You can publish an idea, you can make and share a snapshot as a picture, you can click the icon to share your chart in chat. Another, less known feature is sharing your chart easily while keeping the interactivity and allowing your setup to be easily copied.


2 Answers

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.

like image 125
SMJ Avatar answered Oct 14 '22 15:10

SMJ


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>

I hope this helps

Regards

like image 40
Issac Peña Avatar answered Oct 14 '22 15:10

Issac Peña