Topics like health, travel, finance, home, living, education and careers | Media Search Home

How to calculate a TradingView indicator on another indicator?

When we plot an indicator on the chart, we typically have that indicator run on price data. But did you know a TradingView indicator can also calculate on another indicator? Let"s find out how.

IN THIS ARTICLE:

  • Exploring TradingView"s ‘apply indicator on’ feature
  • Three ways to apply a TradingView indicator to another
    • Approach 1) Apply a TradingView indicator with the ‘+’ icon
    • Approach 2) Right-click an indicator plot and choose ‘apply indicator on …’
    • Approach 3) Configure the indicator to calculate on with input options
  • Remove an indicator and TradingView indicators that calculate on it
  • Summary
# Exploring TradingView"s ‘apply indicator on’ feature

Most of the calculations that an indicator does are based on the chart"s instrument, like fetching the closing prices or volume readings. But an indicator can also take the values that another indicator outputted as its input.

That is possible with TradingView"s ‘apply indicator on indicator’ feature. Now instead of running scripts on only price data, they can run on other indicators too. This opens up a lot of possibilities. With this feature we can, for instance, easily calculate the MACD on EMA prices. Or determine adaptive overbought and oversold areas by adding the MACD to the RSI.

With the ‘apply indicator on indicator’ feature all it takes are a few mouse clicks – not a single line of code is needed. There are a few requirements, though:

  • The other indicator (that we want to apply our indicator on) has to run on the same chart. We cannot apply an indicator to a script that doesn"t run on the chart.
  • Not all indicators support this feature (TradingView Blog, 2016). Unfortunately, I couldn"t find the indicator requirements documented somewhere. So we"ll have to test and see which indicators work with the ‘apply indicator on indicator’ feature.
  • The other indicator (on which we want to apply our indicator) has to plot the values we"re interested in. We can only apply an indicator to data plotted by another indicator (with the plot() function). We don"t get access to other indicator output or values inside that indicator.
  • And that plotted value (that we want to run our indicator on) has to be created by an indicator. At the time of writing we cannot apply an indicator to a strategy plot. And a strategy can calculate based on an indicator plot. Nor can a strategy script run on a plot made by another strategy. So TradingView"s ‘apply indicator on indicator’ feature only works with indicator scripts.

Now let"s see how we apply one indicator to another in TradingView.

# Three ways to apply a TradingView indicator to another

There are three ways to make an indicator calculate based on another indicator (TradingView Blog, 2016): the ‘+’ button, the ‘Apply indicator on …’ right-click option, and with the indicator"s input options. Let"s take a closer look at each approach.

# Approach 1) Apply a TradingView indicator with the ‘+’ icon

The first way to apply an indicator to another is with the ‘+’ button. We find that icon to the right of the indicator"s name on the chart:

Apply a TradingView indicator with Apply a TradingView indicator with

A click on that icon brings up a window. There we select which new indicator the existing indicator should calculate on.

There are several custom and built-in TradingView indicators in that window:

Indicator window to apply another TradingView indicatorIndicator window to apply another TradingView indicator

TradingView"s ‘apply indicator on indicator’ feature doesn"t work for all scripts (TradingView Blog, 2016). That"s why we won"t find all indicators in the ‘Apply Indicator on …’ window.

(I couldn"t find a resource for which indicators work and which ones don"t. Neither did I find what requirements TradingView"s ‘apply indicator on indicator’ feature has. So we have to try and see what works for now.)

Say we select the standard ‘Bollinger Bands’ indicator from the ‘Apply Indicator on …’ window. In that case TradingView adds a new instance of the Bollinger bands indicator to the chart.

But instead of the Bollinger bands calculating on closing prices, they now run based on the EMA indicator. That"s because we press the ‘+’ button of the EMA indicator, and then choose the Bollinger bands script.

On the chart we can also see that Bollinger bands calculate based on EMA prices. That"s because ‘EMA’ is listed with the indicator"s other input options:

Calculating the Bollinger bands based on the EMA in TradingViewCalculating the Bollinger bands based on the EMA in TradingView# Approach 2) Right-click an indicator plot and choose ‘apply indicator on …’

The second way to apply an indicator to another is similar to the first: this one also adds a new indicator to the chart.

For this second approach we first find a plot on the current chart that we want to use as the input for another indicator. Then we right-click that plot and choose ‘Apply Indicator on …":

Right-click a TradingView indicator plotRight-click a TradingView indicator plot

This opens another window where we can choose which indicator should calculate based on those plotted values. In this example, we choose an indicator to calculate based on the 8-bar RSI plot:

Choosing a TradingView indicator to apply another onChoosing a TradingView indicator to apply another on

At this time TradingView"s ‘apply indicator on indicator’ feature doesn"t work with all scripts (TradingView Blog, 2016), which explains why you won"t find all standard and custom indicators in the ‘Apply Indicator on …’ window.

Let"s apply an EMA to our plotted RSI values. For that we choose ‘Exponential Moving Average’ from the list of indicator scripts. That adds a moving average that runs on RSI values to the chart:

Calculating a moving average on TradingView RSI valuesCalculating a moving average on TradingView RSI values

In the parentheses after the indicator name we can see it indeed uses the RSI plot line as an input value. (See orange arrow in above image.)

# Approach 3) Configure the indicator to calculate on with input options

Both the ‘+’ button and the right-click approach add a new indicator to the chart. But what if we already got the two indicators we want to use on our chart?

In that case we simply configure the indicator that should calculate on values plotted by the other indicator. For that click on the gear icon that appears to the right of the indicator name that should calculate on the other indicator.

In this case, we want to run the Keltner Channel on the 9-bar SMA. So we click on the gear icon that appears right to the Keltner Channel:

Configuring the options of a TradingView indicator on the chartConfiguring the options of a TradingView indicator on the chart

This brings up a window with the different input options for the Keltner Channel indicator. There, in the ‘Source’ pull-down menu, we can select which data to compute on.

The name of the input that specifies which data the script uses differs with each indicator. Here that option is named ‘Source’, but if we code our own script we can use any name we want. What doesn"t change amongst multiple indicators, however, is the pull-down menu. So always look for a pull-down menu that has the ‘close’, ‘high’, ‘low’, and ‘open’ options in it.

When we expand that ‘Source’ menu in the Keltner Channel settings, we see that the moving average plot is also listed there:

Configuring the TradingView Keltner Channel to run on a moving averageConfiguring the TradingView Keltner Channel to run on a moving average

After we choose the plot name from the other indicator, we confirm the indicator"s settings. Now the Keltner Channel calculates based on the moving average. We can confirm that because ‘MA’ now appears in the list of input settings of the Keltner Channel:

Plotting the TradingView Keltner Channel on a moving averagePlotting the TradingView Keltner Channel on a moving average

To make the ‘apply indicator’ feature work with custom TradingView indicators, we need to add a so-called ‘source’ input option to our indicator code. See coding an input option for TradingView"s ‘apply indicator on indicator’ feature for more.

# Remove an indicator and TradingView indicators that calculate on it

When an indicator bases its calculations on values that another indicator plotted, both need to be kept on the chart. Since they"re tied together, we can"t simply remove one and keep the other.

If we attempt to remove an indicator that another script calculates on, TradingView warns us and asks for confirmation:

Confirm removal of a TradingView indicator that another indicator runs onConfirm removal of a TradingView indicator that another indicator runs on

When we confirm this removal action, TradingView removes the indicator that selected to remove. But it also removes any indicators based on that indicator script.

If you want to keep those other indicators on the chart, you"ll first need to configure them so they don"t calculate anymore on the indicator you plan to remove. See the steps in the third step above for how to use the indicator"s input options for that.

# Summary

With TradingView"s ‘apply indicator on indicator’ feature we calculate an indicator based on values plotted by another indicator. This makes it possible to quickly test ideas and experiment without having to write code.

The ‘apply indicator’ feature has a couple of requirements. The other indicator (that we want to run our indicator on) has to be on the same chart. And that indicator needs to output values with a plot – we cannot apply an indicator on other output or values. Not all indicators support the ‘apply indicator’ feature. And we cannot apply an indicator to a strategy, a strategy to an indicator, or a strategy to a strategy.

There are three ways to apply an indicator on another. The first is with the ‘+’ button that shows to the right of the indicator"s name. We can also right-click an indicator plot and choose ‘Apply Indicator on …". These two approaches will add a new indicator to the chart, though. If the indicators are already on the chart, we use the third approach: configure which indicator plot an indicator calculates on through its input options.

References

TradingView Blog (2016, June 14). New feature – apply an indicator to another indicator. Retrieved on August 14, 2018, from https://blog.tradingview.com/en/new-feature-8211-apply-an-indicator-to-another-indicator-1844/

Published August 23, 2018.
# Related TradingView tutorials
  • How to enable or disable TradingView"s dark theme?

    TradingView has a ‘Light’ and a ‘Dark’ theme that affect the appearance of the entire platform. Let"s see how we use night view mode and light mode.

  • Overview: all TradingView keyboard shortcuts

    With TradingView"s shortcuts we can productively work with charts, drawings, Watchlist and screener windows, and scripts in TradingView"s Pine Editor.

  • How to set a TradingView chart to the instrument"s ‘Exchange’ time zone?

    In this TradingView recipe we discuss what the ‘Exchange’ time zone option is, how to set it, and its importance when scripts to our chart.

« All TradingView platform articles


Email: contact@about.com.vn - Phone: 818.333.007 - Website: Media Search Home
Copyright © 2007 - Noos. All rights reserved