xarc
xarc

Reputation: 225

how to override the studies of the tradingview widget

I am trying to customize a trading view widget without success, I want to change the color of the RSI Indicator, and change the levels, this is the code:

new TradingView.widget({
        "container_id": "box" + i,
        "autosize": true,
        "symbol": chartTicker,
        "interval": intervalValue,
        "timezone": timezoneValue,
        "theme": theme,
        "style": "1",
        "locale": "en",
        "toolbar_bg": toolbarbg,
        "enable_publishing": false,
        // "hide_legend": true,
        "hide_top_toolbar": false,
        "hide_side_toolbar": false,
        "save_image": false,
        "allow_symbol_change": allowsymbolchange,
        "show_popup_button": false,
        "withdateranges": withdateranges,
        "details": details,
        "hideideas": true,
        "disabled_features": ["use_localstorage_for_settings", create_volume_indicator_by_default"],
        "enabled_features": ["move_logo_to_main_pane", "hide_left_toolbar_by_default"],
        // "disabledDrawings": true,
        "studies_overrides": {
            "rsi.rsi.plot.color": "#2196f3",
            "rsi.level.0": 20,
            "rsi.level.1": 80
        },
        "studies": [
            "RSI@tv-basicstudies"
        ],
    });

Thanks in advance

Upvotes: 8

Views: 8426

Answers (4)

Hadi Moghaddar
Hadi Moghaddar

Reputation: 125

Use the following code to customize RSI oscillator.

 "studies_overrides": {
            "relative strength index.rsi.color": "#2196f3",
            "relative strength index.upper band.color": "#2100f5",
            "relative strength index.lower band.color": "#2100f5",

            "relative strength index.upper band.value": 80,
            "relative strength index.lower band.value": 20,

        },
        "studies": [
            "RSI@tv-basicstudies"
        ]

Upvotes: 3

Amir Rezvani
Amir Rezvani

Reputation: 1504

for example in tradingview constructor:


new Tradingview.widget({
    overrides: {
       "paneProperties.background": "#ffffff"
    },
    studies_overrides: {
       "volume.volume.color.0": "#00FFFF",
    }

})

Normally I would add more about the solution, but the library isn't open source and its licensing terms might prohibit reproducing any of its documentation.

Upvotes: 1

Nicolas Torres
Nicolas Torres

Reputation: 171

I have this code working just right. Perhaps you can use to find the error.`

 var studies = [

     {
       id: "IchimokuCloud@tv-basicstudies",
       version: 2.0
    
     },

    {
      id: "BB@tv-basicstudies",
      inputs: {
        length: 25
      },

    },
    {
      id: "MASimple@tv-basicstudies",
      inputs: {
        length: 200
      }

    },
    {
      id: "MASimple@tv-basicstudies",
      inputs: {
        length: 100
      }

    },
    {
      id: "MASimple@tv-basicstudies",
      inputs: {
        length: 50
      }

    },
    {
      id: "MASimple@tv-basicstudies",
      inputs: {
        length: 9
      }

    },
    {
      id: "RSI@tv-basicstudies",

    },
    {
      id: "RSI@tv-basicstudies",
      inputs: {
        length: 4

      }

    }
  ];


  var chart1 = new TradingView.widget(
    {
      autosize: true,
      symbol: "OANDA:EURUSD",
      interval: "3",
      timezone: "America/Bogota",
      theme: "dark",
      style: "1",
      locale: "en",

      hide_side_toolbar: true,
      hide_top_toolbar: false,
      enable_publishing: false,
      allow_symbol_change: true,
      details: false,

      hidevolume: true,

      studies: studies,
      container_id: "tradingview_1"
    }
  );

Hope it is useful.

Upvotes: 8

Nicolas Torres
Nicolas Torres

Reputation: 171

the correct way to do it is, like the example below

new TradingView.widget({
        "container_id": "box" + i,
        "autosize": true,
        "symbol": chartTicker,
        "interval": intervalValue,
        "timezone": timezoneValue,
        "theme": theme,
        "style": "1",
        "locale": "en",
        "toolbar_bg": toolbarbg,
        "enable_publishing": false,
        // "hide_legend": true,
        "hide_top_toolbar": false,
        "hide_side_toolbar": false,
        "save_image": false,
        "allow_symbol_change": allowsymbolchange,
        "show_popup_button": false,
        "withdateranges": withdateranges,
        "details": details,
        "hideideas": true,
        "disabled_features": ["use_localstorage_for_settings", create_volume_indicator_by_default"],
        "enabled_features": ["move_logo_to_main_pane", "hide_left_toolbar_by_default"],
        // "disabledDrawings": true,
        "studies": [
                    {
                      id: "RSI@tv-basicstudies",
                      inputs: {
                       length: 4
                      }
                    }
        ]
    });

You can set inputs of any indicator like this, but I do not know how to change default styles of the indicators. Maybe you know.

Upvotes: 4

Related Questions