Market label trend

nitrous

Member
VIP
I’m looking for the following labels to show up on the chart :

Spy
Nasdaq
Qqq
Vix

The labels should turn green if the that particular sector is trending up and red if trending down, during market hours.

Wasn’t able to find the labels in this forum for what I want.

TIA.
 

Pensar

Well-known member
VIP
@nitrous Here's something I've had for a bit. The Nasdaq and QQQ are the same - unless you mean the Nasdaq Composite?
Code:
# Market Labels
# Pensar

input symbol_1 = "SPY";
input symbol_2 = "QQQ";
input symbol_3 = "IWM";
input symbol_4 = "VIX";

def c1 = close("SPY", AggregationPeriod.DAY);
def c2 = close("QQQ", AggregationPeriod.DAY);
def c3 = close("IWM", AggregationPeriod.DAY);
def c4 = close("VIX", AggregationPeriod.DAY);

def a1 = (c1 - c1[1]) / c1[1];
def a2 = (c2 - c2[1]) / c2[1];
def a3 = (c3 - c3[1]) / c3[1];
def a4 = (c4 - c4[1]) / c4[1];

AddLabel(1, "SPY: " + AsPercent(a1),
         if a1 > 0 then CreateColor(0, 204, 75)
         else if a1 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "QQQ: " + AsPercent(a2),
         if a2 > 0 then CreateColor(0, 204, 75)
         else if a2 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "IWM: " + AsPercent(a3),
         if a3 > 0 then CreateColor(0, 204, 75)
         else if a3 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "VIX: " + AsPercent(a4),
         if a4 > 0 then CreateColor(0, 204, 75)
         else if a4 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

# end code
 

nitrous

Member
VIP
@nitrous Here's something I've had for a bit. The Nasdaq and QQQ are the same - unless you mean the Nasdaq Composite?
Code:
# Market Labels
# Pensar

input symbol_1 = "SPY";
input symbol_2 = "QQQ";
input symbol_3 = "IWM";
input symbol_4 = "VIX";

def c1 = close("SPY", AggregationPeriod.DAY);
def c2 = close("QQQ", AggregationPeriod.DAY);
def c3 = close("IWM", AggregationPeriod.DAY);
def c4 = close("VIX", AggregationPeriod.DAY);

def a1 = (c1 - c1[1]) / c1[1];
def a2 = (c2 - c2[1]) / c2[1];
def a3 = (c3 - c3[1]) / c3[1];
def a4 = (c4 - c4[1]) / c4[1];

AddLabel(1, "SPY: " + AsPercent(a1),
         if a1 > 0 then CreateColor(0, 204, 75)
         else if a1 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "QQQ: " + AsPercent(a2),
         if a2 > 0 then CreateColor(0, 204, 75)
         else if a2 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "IWM: " + AsPercent(a3),
         if a3 > 0 then CreateColor(0, 204, 75)
         else if a3 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

AddLabel(1, "VIX: " + AsPercent(a4),
         if a4 > 0 then CreateColor(0, 204, 75)
         else if a4 == 0 then Color.LIGHT_GRAY
         else CreateColor(250, 90, 0));

# end code
Thanks.
What’s nasdaq composite?
 
Top