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:
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:
Now let"s see how we apply one indicator to another in TradingView.
# Three ways to apply a TradingView indicator to anotherThere 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 ‘+’ iconThe 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:
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:
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:
# 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 …":
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:
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:
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 optionsBoth 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:
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:
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:
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.
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:
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.
# SummaryWith 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.
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/
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.
With TradingView"s shortcuts we can productively work with charts, drawings, Watchlist and screener windows, and scripts in TradingView"s Pine Editor.
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.