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)