Hi All,
I am trying to create a custom watchlist column with below conditions
1) Close is > 5 Minute ORB High + Close is above 21 EMA + 100 EMA > 200 EMA + SPY 100 EMA > SPY 200 EMA == If all conditions are met then display "Calls"
2) Close is < 5 Minute ORB Low + Close is under 21 EMA + 100 EMA < 200 EMA + SPY 100 EMA < SPY 200 EMA == If all conditions are met then display "Puts"
Below is the script. All the conditions work except SPY 100 EMA > SPY 200 EMA and SPY 100 EMA < SPY 200 EMA. Could you please help me understand what I am missing here. Thanks in advance and let me know if you have any questions.
# 5M ORB + Stock Trend + SPY Trend
def OpenRangeMinutes = 5;
def MarketOpenTime = 0930;
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def OpenRangeTime = if SecondsFromTime(MarketOpenTime) < 60 * OpenRangeMinutes then 1 else 0;
def ORHigh = if FirstMinute then high else if OpenRangeTime and high > ORHigh[1] then high else ORHigh[1];
def ORLow = if FirstMinute then low else if OpenRangeTime and low < ORLow[1] then low else ORLow[1];
def OpenRangeHigh = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORHigh else Double.NaN;
def OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;
def dailyRange = high(period = "day" )[1] - low(period = "day" )[1];
def range = Average(dailyRange, 10);
plot status = if close > OpenRangeHigh then 1 else if close < OpenRangeLow then 0 else -1; status.AssignValueColor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);
#EMA Stack of stock
def EMA21 = MovAvgExponential("length" = 21)."AvgExp";
def EMA100 = MovAvgExponential("length" = 100)."AvgExp";
def EMA200 = MovAvgExponential("length" = 200)."AvgExp";
def EMABullStack = EMA100 >= EMA200;
def EMABearStack = EMA100 < EMA200;
#EMA Stack of SPY
input marketIndex = "SPY";
def SPYEMA100 = ExpAverage(close(marketIndex), 100);
def SPYEMA200 = ExpAverage(close(marketIndex), 200);
def SPYEMABullStack = SPYEMA100 >= SPYEMA200;
def SPYEMABearStack = SPYEMA100 < SPYEMA200;
AddLabel(1, if close > ORhigh and close > EMA21 and EMA100 > EMA200 and SPYEMABullStack
then "Calls"
else if ORlow > close and EMA21 > close and EMA200 > EMA100 and SPYEMABearStack
then "Puts"
else "Listen to Songs",
if close > ORhigh and close > EMA21 and EMA100 > EMA200 and SPYEMABullStack
then color.BLACK
else if ORlow > close and EMA21 > close and EMA200 > EMA100 and SPYEMABearStack
then color.BLACK
else color.BLACK);
I am trying to create a custom watchlist column with below conditions
1) Close is > 5 Minute ORB High + Close is above 21 EMA + 100 EMA > 200 EMA + SPY 100 EMA > SPY 200 EMA == If all conditions are met then display "Calls"
2) Close is < 5 Minute ORB Low + Close is under 21 EMA + 100 EMA < 200 EMA + SPY 100 EMA < SPY 200 EMA == If all conditions are met then display "Puts"
Below is the script. All the conditions work except SPY 100 EMA > SPY 200 EMA and SPY 100 EMA < SPY 200 EMA. Could you please help me understand what I am missing here. Thanks in advance and let me know if you have any questions.
# 5M ORB + Stock Trend + SPY Trend
def OpenRangeMinutes = 5;
def MarketOpenTime = 0930;
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def FirstMinute = if SecondsFromTime(MarketOpenTime) < 60 then 1 else 0;
def OpenRangeTime = if SecondsFromTime(MarketOpenTime) < 60 * OpenRangeMinutes then 1 else 0;
def ORHigh = if FirstMinute then high else if OpenRangeTime and high > ORHigh[1] then high else ORHigh[1];
def ORLow = if FirstMinute then low else if OpenRangeTime and low < ORLow[1] then low else ORLow[1];
def OpenRangeHigh = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORHigh else Double.NaN;
def OpenRangeLow = if ShowTodayOnly and !Today then Double.NaN else if !OpenRangeTime then ORLow else Double.NaN;
def dailyRange = high(period = "day" )[1] - low(period = "day" )[1];
def range = Average(dailyRange, 10);
plot status = if close > OpenRangeHigh then 1 else if close < OpenRangeLow then 0 else -1; status.AssignValueColor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);
AssignBackgroundCOlor(if status == 1 then Color.Dark_Green else if status == 0 then Color.Dark_Red else Color.Dark_Orange);
#EMA Stack of stock
def EMA21 = MovAvgExponential("length" = 21)."AvgExp";
def EMA100 = MovAvgExponential("length" = 100)."AvgExp";
def EMA200 = MovAvgExponential("length" = 200)."AvgExp";
def EMABullStack = EMA100 >= EMA200;
def EMABearStack = EMA100 < EMA200;
#EMA Stack of SPY
input marketIndex = "SPY";
def SPYEMA100 = ExpAverage(close(marketIndex), 100);
def SPYEMA200 = ExpAverage(close(marketIndex), 200);
def SPYEMABullStack = SPYEMA100 >= SPYEMA200;
def SPYEMABearStack = SPYEMA100 < SPYEMA200;
AddLabel(1, if close > ORhigh and close > EMA21 and EMA100 > EMA200 and SPYEMABullStack
then "Calls"
else if ORlow > close and EMA21 > close and EMA200 > EMA100 and SPYEMABearStack
then "Puts"
else "Listen to Songs",
if close > ORhigh and close > EMA21 and EMA100 > EMA200 and SPYEMABullStack
then color.BLACK
else if ORlow > close and EMA21 > close and EMA200 > EMA100 and SPYEMABearStack
then color.BLACK
else color.BLACK);