TradingView
vitelot
9 jun 2018 18:22

Currency Strength Meter (by vitelot) 

U.S. Dollar/Japanese YenFXCM

Beskrivning

This script estimates the relative strength of forex major currencies.
It works in any timeframe with no input required.
The only parameter is used to smooth the curves and can be set to 1 to have the original, but noisy, signals.

Comments are welcome, and please push the like button if you find it useful.

Cheers.


PS Curious that this kind of indicator is not yet on tradingview, at least I could not find anything similar. Do you know any?
Kommentarer
Jasur
Hi! Thanks for the great indicator.
I wonder if you could add currency labels on the right side of every currency line?
That would be very helpful.
Thank you!
mnayalfx
how do you enable the label for each currency. does not seem to work as default
kasika62
A great piece of code! Thank you so much!
Wish I could get access to this code and try to play with it a bit! Buy awesome job!
vitelot
@kasika62, thank you!
I don't remember why I set it as private, I was probably playing around with settings.
Anyway, here it is, enjoy :)

//@version=4
study("Currency Strength Meter (by vitelot)", shorttitle="CSM")
//len = input(200, title="Length")
len = 200
smt = input(5, title="Smoothing EMA period", minval=1)

usd = security("DXY", timeframe.period, close)

myStoch(x) =>
200 * (x - lowest(x, len)) / (highest(x, len) - lowest(x, len)) - 100
Calc_inv(sec) =>
base = security(sec, timeframe.period, close) / usd
myStoch(base)
Calc_dir(sec) =>
base = usd / security(sec, timeframe.period, close)
myStoch(base)

sigEur = ema(Calc_inv("EURUSD"), smt)
sigGbp = ema(Calc_inv("GBPUSD"), smt)
sigAud = ema(Calc_inv("AUDUSD"), smt)
sigNzd = ema(Calc_inv("NZDUSD"), smt)
sigJpy = ema(Calc_dir("USDJPY"), smt)
sigCad = ema(Calc_dir("USDCAD"), smt)
sigChf = ema(Calc_dir("USDCHF"), smt)

sigUsd = ema(myStoch(usd), smt)

plot(sigUsd, title="USD", color=#ffffff, linewidth=4)
plot(sigEur, title="EUR", color=#00ffff, linewidth=3)
plot(sigGbp, title="GBP", color=#ff0000, linewidth=3)
plot(sigJpy, title="JPY", color=#ffff00, linewidth=3)
plot(sigCad, title="CAD", color=#ff00ff, linewidth=3)
plot(sigAud, title="AUD", color=#007fff, linewidth=2)
plot(sigNzd, title="NZD", color=#ff7f00, linewidth=2)
plot(sigChf, title="CHF", color=#ff007f, linewidth=2)
kasika62
@vitelot, Thank you so much for responding and sharing the code! I really do appreciate. Stay blessed!
I did try to run the code but it gives me an error on line 10 as follows,

Add to Chart operation failed, reason: line 10: Mismatched input '200' expecting 'end of line without the line continuation'.

Could you possibly advise what I can do to solve this? Thank you so much!
vitelot
@kasika62, you need to indent these lines because they are in their respective functions:

200 * (x - lowest(x, len)) / (highest(x, len) - lowest(x, len)) - 100

base = security(sec, timeframe.period, close) / USD
myStoch(base)

base = usd / security(sec, timeframe.period, close)
myStoch(base)

Copying and pasting the code broke the indentation.
KasikaBoss
@vitelot, Thank you so much! That helped!
Yonatan_Zagron
@vitelot,
Hi! great work man!

I'm also trying to add coding to make custom signals and facing the same issue,
Can you maybe open the script so we can copy it without this issue?

Many thanks!
vitelot
@Yonatan_Zagron, Hi, I posted it in a comment above ...
Yonatan_Zagron
@vitelot,
I saw that, but didn't manage to make it work
Mer