RicardoSantos

[RS]The Great Dollar Basket V1

UPDATE:
fixed the string for gold and silver was using NZDUSD string.
changed oil and gas instruments to support intraday values.
added option to smooth the series.
added option to show/hide groups of series.
開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?
study(title='[RS]The Great Dollar Basket V1', overlay=false)
yyyy = input(title='Year:', type=integer, defval=2015)
mm = input(title='Month:', type=integer, defval=08, minval=1, maxval=12)
dd = input(title='Day:', type=integer, defval=01, minval=1, maxval=31)
src = input(title='Source:', type=source, defval=close)
smooth = input(title='Signal Smoothing:', type=integer, defval=1)
SHOW_XXXUSD = input(title='Show XXXUSD instruments:', type=bool, defval=true)
SHOW_USDXXX = input(title='Show USDXXX instruments:', type=bool, defval=true)
SHOW_METAL = input(title='Show Metal instruments:', type=bool, defval=true)
SHOW_OIL = input(title='Show Oil and Gas instruments:', type=bool, defval=true)
SHOW_INDEX = input(title='Show Index instruments:', type=bool, defval=true)

f_get_percentual_src(_yyyy, _mm, _dd, _srctype)=>
    //--> remove data prior to date.
    _src = year < _yyyy or (year <= _yyyy and month < _mm) or (year <= _yyyy and month <= _mm and dayofmonth < _dd)  ? na : _srctype
    _basis_ad = valuewhen( na(_src[1]), _src, 0)
    _return = (_src/_basis_ad)*100

mod_src = smooth <= 1 ? src : ema(src, smooth)
eurusd = not SHOW_XXXUSD ? na : security('EURUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
gbpusd = not SHOW_XXXUSD ? na : security('GBPUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
audusd = not SHOW_XXXUSD ? na : security('AUDUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
nzdusd = not SHOW_XXXUSD ? na : security('NZDUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
usdjpy = not SHOW_USDXXX ? na : security('USDJPY', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
usdcad = not SHOW_USDXXX ? na : security('USDCAD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
usdcnh = not SHOW_USDXXX ? na : security('USDCNH', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
usdchf = not SHOW_USDXXX ? na : security('USDCHF', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
usdrub = not SHOW_USDXXX ? na : security('USDRUB', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
xauusd = not SHOW_METAL ? na : security('XAUUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
xagusd = not SHOW_METAL ? na : security('XAGUSD', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
oilusd = not SHOW_OIL ? na : security('USOIL', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
gasusd = not SHOW_OIL ? na : security('NGAS', period, f_get_percentual_src(yyyy, mm, dd, mod_src))
dxy = not SHOW_INDEX ? na : security('DXY', 'D', f_get_percentual_src(yyyy, mm, dd, mod_src))
usd = not SHOW_INDEX ? na : security('USDOLLAR', period, f_get_percentual_src(yyyy, mm, dd, mod_src))

plot(title='EURUSD', series=eurusd, color=blue)
plot(title='GBPUSD', series=gbpusd, color=aqua)
plot(title='AUDUSD', series=audusd, color=teal)
plot(title='NZDUSD', series=nzdusd, color=navy)
plot(title='USDJPY', series=usdjpy, color=orange)
plot(title='USDCAD', series=usdcad, color=olive)
plot(title='USDCNH', series=usdcnh, color=purple)
plot(title='USDCHF', series=usdchf, color=fuchsia)
plot(title='USDRUB', series=usdrub, color=lime)
plot(title='XAUUSD', series=xauusd, color=yellow)
plot(title='XAGUSD', series=xagusd, color=silver)
plot(title='OIL', series=oilusd, color=black)
plot(title='GAS', series=gasusd, color=gray)
plot(title='DXY', series=dxy, color=maroon)
plot(title='USDOLLAR', series=usd, color=red)

hline(title='100', price=100, color=black)