最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to integrate trading view charting library in my website - Stack Overflow

programmeradmin3浏览0评论

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("");

    TradingView.onready(function () {
        var widget = window.tvWidget = new TradingView.widget({
            debug: true, // unment 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

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.");

    TradingView.onready(function () {
        var widget = window.tvWidget = new TradingView.widget({
            debug: true, // unment 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

Share Improve this question edited Feb 17, 2018 at 21:19 Alex 9,2658 gold badges42 silver badges88 bronze badges asked Feb 17, 2018 at 9:36 SMJSMJ 7762 gold badges9 silver badges25 bronze badges 1
  • 7 Please tell me how to improve my question when you downvote – SMJ Commented Feb 17, 2018 at 9:44
Add a ment  | 

3 Answers 3

Reset to default 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.

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

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

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

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

<script type="text/javascript" src="https://s3.tradingview./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>
发布评论

评论列表(0)

  1. 暂无评论