我正在使用Tradigview Chart Widget来显示数据。 我找不到在图表上绘制线条(或其他东西)的方法,并保存图纸以便在页面重新加载时显示它们。
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_6fd01"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"width": 980,
"height": 610,
"symbol": "NASDAQ:AAPL",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "Light",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"container_id": "tradingview_6fd01"
});
</script>
</div>
<!-- TradingView Widget END -->
答案 0 :(得分:4)
对于任何想要使用小部件但不依赖于TradingView实时数据的人,都可以使用tradingview charting library。它是免费的,但您必须请求访问github存储库。
以下是绘制形状的简单示例:
var order = widget.chart().createOrderLine()
.setText("Buy Line")
.setLineLength(3)
.setLineStyle(0)
.setQuantity("221.235 USDT")
order.setPrice(160);
在github仓库中有很多例子,所以您不会迷路。但是您必须创建自己的数据Feed,或者至少建立与所需数据提供商/市场的Websocket连接。
我希望这可以帮助面临相同问题的每个人。
答案 1 :(得分:2)
答案 2 :(得分:0)
你需要这样的东西:
<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
<div id="tradingview_f1133"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NASDAQ-AAPL/" rel="noopener" target="_blank"><span class="blue-text">AAPL Chart</span></a> by TradingView</div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
new TradingView.widget(
{
"width": 980,
"height": 610,
"symbol": "NASDAQ:AAPL",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "dark",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"hide_side_toolbar": false,
"allow_symbol_change": true,
"container_id": "tradingview_f1133"
}
);
</script>
</div>
<!-- TradingView Widget END -->
该网站有一个页面可以配置和查看嵌入代码 https://www.tradingview.com/widget/advanced-chart/ 见上页并找到确切的配置