# fsk_market_sentiment - Show over all market sentiments
# 02-01-2023 - fskhan - Created
# Show 4 Key ETFs/Indexes and an aggregate of 24 key stocks, sectors and indexes to determine
# overall market sentiment.
# this to help determine "SellPut" or "Sellput" signals from fsk_HighLowRangeToday should be considered.
# When label MSR (Market SentimentZoneOscillator Record) is RED and less than 50%
# then general trend is Down, so consider "Sell Call"
# When label MSR (Market SentimentZoneOscillator Record) is GREEN and MORE than 50%
# then General Trend is UP, so consider "Sell PUT"
#
declare once_per_bar;
input Symbol_1 = "$VOLD";
input Symbol_2 = "$ADD";
input Symbol_3 = "UNH";
input Symbol_4 = "JPM";
input Symbol_5 = "SVXY";
input Symbol_6 = "SPY";
input Symbol_7 = "UDN";
input Symbol_8 = "TSLA";
input Symbol_9 = "INTC";
input Symbol_10 = "NVDA";
input Symbol_11 = "AAPL";
input Symbol_12 = "AMZN";
input Symbol_13 = "XLF";
input Symbol_14 = "XLE";
input Symbol_15 = "XLK";
input Symbol_16 = "XLP";
input Symbol_17 = "IYT";
input Symbol_18 = "BRK/B";
input Symbol_19 = "MSFT";
input Symbol_20 = "MGAM";
input Symbol_21 = "F";
input Symbol_22 = "SNAP";
input Symbol_23 = "AMD";
input Symbol_24 = "XOM";
input Symbol_25 = "GS";
input Symbol_26 = "META";
def ztotal = 26;
def zct_0 = 0;
script zUpDown {
input zsymbol = "";
input zCount = 0;
input zinverse = double.Nan;
def Length = 0;
def aggr = AggregationPeriod.DAY;
def todayopen = (open(zsymbol, period = aggr));
def curclose = (close(zsymbol, period = aggr));
plot rUpdown =
if IsNan(zinverse)
then
if (curclose[0]) > (todayopen[Length]) then yes else no
else
if (curclose[0]) < (todayopen[Length]) then yes else no ;
plot rCount = if IsNan(zinverse)
then
if (curclose[0]) > (todayopen[Length]) then zCount + 1 else zCount + 0
else
if (curclose[0]) < (todayopen[Length]) then zCount + 1 else zCount + 0 ;
# plot rcount = zinverse * zrCount;
} # end zUpDown
# count of up downs
#def zct_yc = zUpDown("spy", zct_0).yc ;
#def zct_to = zUpDown("spy", zct_0).to ;
#AddLabel(yes, zct_yc , Color.GREEN );
#AddLabel(yes, zct_to , Color.GREEN );
def zct_1 = zUpDown(Symbol_1, zct_0).rCount ;
def zct_2 = zUpDown(Symbol_2, zct_1).rCount ;
#def t1 = zUpDown(Symbol_2, zct_0).topen;
#addlabel(yes, t1 , Color.GREEN );
#def t2 = zUpDown(Symbol_2, zct_0).tclose;
#addlabel(yes, t2 , Color.GREEN );
def zct_3 = zUpDown(Symbol_3 , zct_2 ).rCount ;
# $PCSP is reverse
def zct_4 = zUpDown(Symbol_4 , zct_3 ).rCount ;
def zct_5 = zUpDown(Symbol_5 , zct_4 ).rCount ;
def zct_6 = zUpDown(Symbol_6 , zct_5 ).rCount ;
def zct_7 = zUpDown(Symbol_7 , zct_6 ).rCount ;
def zct_8 = zUpDown(Symbol_8 , zct_7 ).rCount ;
def zct_9 = zUpDown(Symbol_9 , zct_8 ).rCount ;
def zct_10 = zUpDown(Symbol_10 , zct_9 ).rCount ;
def zct_11 = zUpDown(Symbol_11 , zct_10).rCount ;
def zct_12 = zUpDown(Symbol_12 , zct_11).rCount ;
def zct_13 = zUpDown(Symbol_13 , zct_12).rCount ;
def zct_14 = zUpDown(Symbol_14 , zct_13).rCount ;
def zct_15 = zUpDown(Symbol_15 , zct_14).rCount ;
def zct_16 = zUpDown(Symbol_16 , zct_15).rCount ;
def zct_17 = zUpDown(Symbol_17 , zct_16).rCount ;
def zct_18 = zUpDown(Symbol_18 , zct_17).rCount ;
def zct_19 = zUpDown(Symbol_19 , zct_18).rCount ;
def zct_20 = zUpDown(Symbol_20 , zct_19).rCount ;
def zct_21 = zUpDown(Symbol_21 , zct_20).rCount ;
def zct_22 = zUpDown(Symbol_22 , zct_21).rCount ;
def zct_23 = zUpDown(Symbol_23 , zct_22).rCount ;
def zct_24 = zUpDown(Symbol_24 , zct_23).rCount ;
def zct_25 = zUpDown(Symbol_25 , zct_24).rCount ;
def zct_26 = zUpDown(Symbol_25 , zct_25).rCount ;
def zct_zct = zct_26;
#AddLabel(yes, zct_yc , Color.GREEN );
# Updown
def ste_1 = zUpDown(Symbol_1, zct_0).rUpdown ;
def ste_2 = zUpDown(Symbol_2, zct_1).rUpdown ;
def ste_3 = zUpDown(Symbol_3 , zct_2 ).rUpdown ;
def ste_4 = zUpDown(Symbol_4 , zct_3, 1 ).rUpdown ;
AddLabel(!IsNaN(zct_1 ), Symbol_1 , if ste_1 and close(Symbol_1 , period = AggregationPeriod.DAY) > (open(Symbol_1 , period = AggregationPeriod.DAY)) then Color.GREEN else Color.RED );
AddLabel(!IsNaN(zct_2 ), Symbol_2 , if ste_2 and (close(Symbol_2 , period = AggregationPeriod.DAY)) > (open(Symbol_2 , period = AggregationPeriod.DAY)) then Color.GREEN else Color.RED );
#AddLabel(!IsNaN(zct_2 ), Symbol_3 , if ste_3 and close(Symbol_3 , period = AggregationPeriod.DAY) > (open(Symbol_3 , period = AggregationPeriod.DAY)) then Color.GREEN else Color.RED );
#AddLabel(!IsNaN(zct_2 ), Symbol_4 , if ste_4 and close(Symbol_4 , period = AggregationPeriod.DAY) > (open(Symbol_4 , period = AggregationPeriod.DAY)) then Color.GREEN else Color.RED );
def zpct = Round(100 * (zct_zct / ztotal), 2) ;
AddLabel(yes, "MSR: " + Round(100 * (zct_zct / ztotal), 2) + "% (" + zct_zct + "/" + ztotal + ")" , if zpct > 68 then Color.LIGHT_GREEN else if zpct < 60 then Color.PINK else Color.YELLOW);
#EOF