Advertisement
zmnkh

chart_library demo

Nov 2nd, 2017
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4.  
  5. <title>TradingView Charting Library demo</title>
  6.  
  7. <!-- Fix for iOS Safari zooming bug -->
  8. <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
  9. <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  10.  
  11. <script type="text/javascript" src="//code.jquery.com/jquery-1.11.2.min.js"></script>
  12. <script type="text/javascript" src="charting_library.js"></script>
  13. <script type="text/javascript" src="datafeed/udf/datafeed.js"></script>
  14.  
  15. <script type="text/javascript">
  16.  
  17. function getParameterByName(name) {
  18. name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  19. var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  20. results = regex.exec(location.search);
  21. return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
  22. }
  23.  
  24. TradingView.onready(function()
  25. {
  26. var widget = window.widget = new TradingView.widget({
  27. fullscreen: true,
  28. symbol: 'AA',
  29. interval: 'D',
  30. container_id: "tv_chart_container",
  31. // BEWARE: no trailing slash is expected in feed URL
  32. datafeed: new Datafeeds.UDFCompatibleDatafeed("http://demo_feed.tradingview.com"),
  33. locale: getParameterByName('lang') || "en",
  34. // Regression Trend-related functionality is not implemented yet, so it's hidden for a while
  35. drawings_access: { type: 'black', tools: [ { name: "Regression Trend" } ] },
  36. disabled_features: ["use_localstorage_for_settings"],
  37. enabled_features: ["study_templates"],
  38. charts_storage_url: 'http://saveload.tradingview.com',
  39. charts_storage_api_version: "1.1",
  40. client_id: 'tradingview.com',
  41. user_id: 'public_user_id'
  42.  
  43. });
  44.  
  45. // ********** REPRODUCTION CODE STARTS HERE **********
  46. var savedState = null;
  47. setTimeout(function() {
  48. console.log("Saving state...");
  49. widget.save(function(data) {
  50. savedState = data
  51. console.log("Got state:", savedState);
  52.  
  53. setTimeout(function() {
  54. console.log("Setting symbol to NLY...")
  55. widget.setSymbol('NLY', 5);
  56.  
  57. setTimeout(function() {
  58. console.log("Loading saved state...")
  59. widget.load(savedState);
  60.  
  61. setTimeout(function() {
  62. console.log("Setting symbol to NLY...")
  63. widget.setSymbol('NLY', 5);
  64. console.log("Automated actions complete. Note that the chart remained on AA.")
  65. }, 5000);
  66. }, 5000);
  67. }, 5000);
  68. });
  69. }, 5000);
  70. // ********** REPRODUCTION CODE ENDS HERE **********
  71. });
  72.  
  73. </script>
  74.  
  75. </head>
  76.  
  77. <body style="margin:0px;">
  78. <div id="tv_chart_container"></div>
  79. </body>
  80.  
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement