Loading TradingView Chart Widget with Dynamic Data (Dmx.parse)

How’s it going, guys?

I need some help implementing a “dynamic” TradingView widget.
I can’t for the life of me figure out how to pass in dynamic values as “symbol” for the widget below.

<!-- TradingView Widget BEGIN -->
<div class="tradingview-widget-container">
  <div id="tradingview_3ee77"></div>
  <div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/WETHVEGA/?exchange=SUSHISWAP" rel="noopener" target="_blank"><span class="blue-text">WETHVEGA 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": "100%",
  "height": 450,
  "symbol": "SUSHISWAP:WETHVEGA",
  "interval": "D",
  "timezone": "Etc/UTC",
  "theme": "light",
  "style": "1",
  "locale": "en",
  "toolbar_bg": "#f1f3f6",
  "enable_publishing": false,
  "hide_side_toolbar": false,
  "container_id": "tradingview_3ee77"
}
  );
  </script>
</div>
<!-- TradingView Widget END -->

I’ve tried “dmx.parse” to retrieve data from a variable (pair), but it comes up as “undefined.” I understand that it has something to do with the widget loading before the value in the variable, but I’m not quite sure how to go about it in this situation.

Thanks everyone.

Community Page
Last updated: