8

I'm trying to add "Advanced Real Time chart" widget from tradinview. I'm able to add indicator Exponential moving average and Simple moving average. But it takes default 9 days length. I want to change that.

I tried as below but it does not work. Could somebody please help. Thanks a lot in advance.

widget = new TradingView.widget(
    {
        "width": 1200,
        "height": 700,
        "symbol": "NSE:DRREDDY",
        "interval": "D",
        "timezone": "Asia/Kolkata",
        "theme": "Dark",
        "style": "1",
        "locale": "in",
        "toolbar_bg": "#f1f3f6",
        "enable_publishing": false,
        "hide_side_toolbar": false,
        "allow_symbol_change": true,
        "details": true,
        "studies_overrides": {
            "moving average exponential.length": 20
        },
        "studies": [
            "MAExp@tv-basicstudies"
        ],

        "container_id": "tradingview_f6d89"
    }
  • Welcome to SO. Please provide the full widget code, not only the *settings* and results vs expected output. Please remember that SO is not a code-writing service. – not2qubit Oct 09 '18 at 05:51

2 Answers2

7

Here's the way to do it :

"studies": [
   {
     "id": "MAExp@tv-basicstudies",
     "version": 60,
     "inputs": {
       "length": 20
     }
   },
   ...
klem0810
  • 71
  • 1
  • 2
  • Not quite sure why - but this doesn't work when I am trying to edit the widget – EricZ Apr 25 '21 at 11:26
  • Thanks @Clément Letellier, do you know if it's possible to change the color too? Is there any documentation? – OlivierLarue May 07 '21 at 11:09
  • 1
    where can we find the documentation to customize/override the default properties of indicators? – S.Serpooshan Jun 11 '21 at 14:52
  • Thanks to @clément-letellier. Do you know, what does the line `"version": 60` mean? - I've removed the line and could not find any difference, so is the line needed? Would be also interested in a documentation. – Peter Jan 14 '22 at 18:27
0

The code above takes EMA 20 ticks back on the current time frame (TF), so if you want days, you need to set TF to days and change this value to 9 (or equivalently, set TF to hours and set EMA to 24*9).

not2qubit
  • 14,531
  • 8
  • 95
  • 135