11

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

Alex
  • 9,215
  • 8
  • 39
  • 82
SMJ
  • 716
  • 1
  • 9
  • 23

3 Answers3

3

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.

SMJ
  • 716
  • 1
  • 9
  • 23
  • then link that you have given, doesn't help me anymore, becuase I could not understand that, could you please give me any code leve examples to apply that. Thanks in advance – Thomson Ignesious Jun 12 '18 at 15:21
  • are you sure we have to register to access the instruction on using the charts ? – Afsanefda Sep 02 '19 at 10:53
  • @Afsanefda I had to register to access the library files from Github. Its always better to register to ask for help/ raise bugs on GitHub also. – SMJ Sep 04 '19 at 05:57
  • Unfortunately I live in their restrictions area (Iran) I asked for the repo invitation but they refused to grant me the access. Do you have the repo ? @SMJ – Afsanefda Sep 04 '19 at 06:14
1

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>
Dharman
  • 30,962
  • 25
  • 85
  • 135
Issac Peña
  • 97
  • 1
  • 5
  • 8
    The [TradingView Widget is different from the Charting Library](https://github.com/tradingview/charting_library/wiki/Frequently-Asked-Questions#other-questions) (link requires GitHub repo membership). The widget comes with data from TradingView but doesn't have (documented) methods. The OP is asking about Charting Library, which requires supplying a data feed. – Dan Dascalescu Jul 04 '18 at 07:28
1

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.

ahwayakchih
  • 2,101
  • 19
  • 24
Charlie
  • 69
  • 7