Tradingview: Currency strength indicator

When we place a trade in the Forex market we are stating our belief about two economies at the same time. In other words we are betting that one economy is, or will be, stronger than the other. Before placing a trade it would be useful to validate our belief by looking at the overall strength of both the currencies in the pair that we are going to trade. After all, if one currency in the pair is weak against all major currencies, it is likely to be weak in the pair you are trading. With this in mind, a currency strength indicator would be a useful tool for analysis. For the US dollar we could argue that it is not needed. We have the USDOLLAR index to gauge USD strength but what about other currencies?

Currency strength indicator

The currency strength indicator shall take up to 4 currency pairs and calculate the average percentage change compared to the daily time frame. It will then plot all pairs on the chart along with an aggregate line that indicates the overall strength. An option is provided to flag a currency as the counter currency so that the percentage change is inverted. Consider this example. I want to know the strength of the British pound. In most pairs the pound is the base currency except against the Euro. This means that when the EURGBP rises, it the pound is weakening and vice versa. Therefore to get an accurate reading, I need to flag the pound as the counter currency and invert the percentage change result.


Brief Commentary

If you are wondering why I have lookahead on and want to know more about it, I have a post which describes lookhead in more detail here: Tradingview: Understanding lookahead, historical and realtime data

In addition, using the security() function to get data from another timeframe or instrument is covered in more detail here: Tradingview: Create an Indicator

The rest of the code is just calculating the percentage change and overall strength of the currency. If you are interested in the maths behind calculating a percentage change, I can point you to this tutorial:

Before I move on, I think it is worth noting why I chose to use area style plotting and transparency for all plots except the “overall strength” line. I did this because I felt the indicator would become over crowded otherwise. Additionally, in my opinion, the “overall strength” line is the most important plot and I was concerned it could become masked or harder to read.

Adding another currency

Should you feel 4 currency pairs are not enough, you can easily add more. As you can see from the code, we have 6 basic steps:

  1. Select the currency pairs
  2. Get the daily close for those pairs
  3. Get the close prices for the current time frame
  4. Calculate the difference between the current close price and the yesterday’s close
  5. Average the differences between each
  6. Finally plot the results.

Therefore to add another currency pair to the indicator you can:

  • First, add new inputs from the pair. Be sure to create new variable names and default values. E.g sym5 below.

  • Second, Get the daily and current timeframe data for the pair. Again be careful to update the variable names and security() parameters

  • Third, Calculate the change and invert the value if the currency is the counter currency. If you see an error telling you that inst5_change is already declared, pay special attention to the “:=” operator. To update a variable that is already declared, you need to add a colon “:” in front of the equals operator.

  • Finally add the new pair to the overall strength calculation and plot it.

Indicator Screenshot

Default Settings

Usage Examples & Tips

Setup 2 indicators to compare strength

JPY stength beating GBP strength

The example above shows GBPJPY with a GBP currency strength indicator and a JPY currency strength indicator. Both currencies are trending stronger. However the JPY is showing more strength and that is then reflected in a drop in the GBPJPY.

Identify opposing trends

Next we have an example showing how opposing trends can accelerate price movements. In the example below, the GBP starts to trend stronger whilst at the same time the USD starts to trend weaker. This causes a steady increase in prices followed by a final pop up.

Large price jump from opposing trend

Setting up for JPY and verifying the output

Finally, here is a screenshot of how to set up the indicator to monitor Japanese Yen strength. In all cases the JPY is the counter currency to set this up, open the settings page for the indicator and fill it out with the JPY pairs you are interested in as follows. If you want to save your settings don’t forget to click the down arrow next to the defaults button and select “Save As Default“.

Setting up the currency strength indicator

For peace of mind, you may wish to verify the indicator. To do this simply add some currencies to your watchlist. Currencies added here will show the daily change percentage. It is the same time frame that the currency strength indicator uses.

Checking the indicator results

Find This Post Useful?

If this post saved you time and effort, please consider support the site! There are many ways to support us and some won’t even cost you a penny.