GVZ:CGI and $DXY. But, their market hours are different than /GC, resulting in NaN values when applied to /CG's chart, and therefore further messing up the averages from the looks of it. The two indices print on different price scales too, so, as it stands now, it's going to be all separated and scrunched. This is going to be a real mess one way or the other. You should probably take a look at it before I get any deeper into it.$DXYhow can i code a U.S. Dollar Index (DXY) lower label that changes color accordingly to dxy while I lookup different stocks
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
input showGVZ = yes;
input showDXY = yes;
def gvz = if showGVZ then close("GVZ") else Double.NaN;
def dxy = if showDXY then close("DXY") else Double.NaN;
def gvzMA = Average(gvz, 10);
def dxyMA = Average(dxy, 10);
plot GoldVol = gvz;
GoldVol.SetDefaultColor(Color.WHITE);
GoldVol.SetLineWeight(2);
plot Dollar = dxy;
Dollar.SetDefaultColor(Color.GREEN);
Dollar.SetLineWeight(2);
def gvzFalling = gvz < gvzMA;
def dxyFalling = dxy < dxyMA;
AddCloud(if gvzFalling and dxyFalling then gvz else Double.NaN, gvzMA, Color.DARK_GREEN, Color.BLACK);
AddCloud(if gvzFalling and !dxyFalling then gvz else Double.NaN, gvzMA, Color.DARK_ORANGE, Color.BLACK);
AddCloud(if !gvzFalling and dxyFalling then gvz else Double.NaN, gvzMA, Color.DARK_RED, Color.BLACK);
AddCloud(if !gvzFalling and !dxyFalling then gvz else Double.NaN, gvzMA, Color.GRAY, Color.BLACK);
AddLabel(yes, "GVZ: " + Round(gvz, 2) + (if gvzFalling then " ↓" else " ↑"), if gvzFalling then Color.GREEN else Color.RED);
AddLabel(yes, "DXY: " + Round(dxy, 2) + (if dxyFalling then " ↓" else " ↑"), if dxyFalling then Color.GREEN else Color.RED);
AddLabel(yes,
if gvzFalling and dxyFalling then "Condition: Calm Bullish"
else if !gvzFalling and !dxyFalling then "Condition: Risk-Off / Bearish"
else "Condition: Mixed",
Color.YELLOW);
Alert(gvzFalling and dxyFalling, "GVZ↓ and DXY↓ — Calm Bullish Setup!", Alert.BAR, Sound.Ring);
GVZ:CGI and $DXY. But, their market hours are different than /GC, resulting in NaN values when applied to /CG's chart, and therefore further messing up the averages from the looks of it. The two indices print on different price scales too, so, as it stands now, it's going to be all separated and scrunched. This is going to be a real mess one way or the other. You should probably take a look at it before I get any deeper into it.Thank you for that. I am now able to see lines plotted for GVZ and DXY but it is separated. What other options do we have available?Try it withGVZ:CGIand$DXY. But, their market hours are different than /GC, resulting in NaN values when applied to /CG's chart, and therefore further messing up the averages from the looks of it. The two indices print on different price scales too, so, as it stands now, it's going to be all separated and scrunched. This is going to be a real mess one way or the other. You should probably take a look at it before I get any deeper into it.
declare lower;
input showGVZ = yes;
input showDXY = yes;
def gvz = if showGVZ and !IsNaN(close("GVZ:CGI")) then close("GVZ:CGI") else Double.NaN;
def dxy = if showDXY and !IsNaN(close("$DXY")) then close("$DXY") else Double.NaN;
def gvzMA = Average(gvz, 10);
def dxyMA = Average(dxy, 10);
plot GoldVol = gvz;
GoldVol.SetDefaultColor(Color.WHITE);
GoldVol.SetLineWeight(2);
plot Dollar = dxy;
Dollar.SetDefaultColor(Color.GREEN);
Dollar.SetLineWeight(2);
def gvzFalling = gvz < gvzMA;
def dxyFalling = dxy < dxyMA;
AddLabel(yes, "GVZ: " + Round(gvz, 2) + (if gvzFalling then " ↓" else " ↑"), if gvzFalling then Color.GREEN else Color.RED);
AddLabel(yes, "DXY: " + Round(dxy, 2) + (if dxyFalling then " ↓" else " ↑"), if dxyFalling then Color.GREEN else Color.RED);
AddLabel(yes,
if gvzFalling and dxyFalling then "Condition: Calm Bullish"
else if !gvzFalling and !dxyFalling then "Condition: Risk-Off / Bearish"
else "Condition: Mixed",
Color.YELLOW);
Alert(gvzFalling and dxyFalling, "GVZ↓ and DXY↓ — Calm Bullish Setup!", Alert.BAR, Sound.Ring);
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.