# (1) Trend Signal -- UP or DN
# The short-term trend is based upon the 8 period moving average in accordance with "The Market Maker's Edge". If the current stock price is above the 8MA, then the trend is up and UP will be displayed in green. If the current stock price is below the 8MA, then the trend is down and DN will be displayed in red.
# (2) Net Signal -- NS
# The net change in stock price. If the current price is greater than yesterday's closing price, then NS will be displayed in green. If the current price is less than yesterday's close, then NS will be displayed in red.
# (3) Open Signal -- OS
# The dominant direction of today's movement. If the current price is greater than today's opening price, then OS will be displayed in green. If the current price is less than today's opening price, then OS will be displayed in red.
# (4) High / Low Signal -- H/L
# This shows daily momentum by determining whether the stock is trading above or below yesterday's high or low price. If the current price is above yesterday's high, then H/L will be displayed in green. If the current price is below yesterday's low, then H/L will be displayed in red. If the current price is between yesterday's high and low, then H/L will be displayed in gray.
# (5) Out of Bounds
# This only displays when the stock is outside of the bollinger bands. For example, in the second image above, it may be seen that NFLX is $1.82 outside of the top bollinger band on the 55 min chart and $1.43 outside of the top bollinger band on the 34 min chart. The price will be displayed in white.
# This code may be applied to any chart Daily and below. For me, I like to have all the indicators in agreement across the 55, 34, 21, and 13. It is nice if the 233 and Daily agree, but is not necessary for me.
#The Edge
#Robert Payne
#Plot 8 period moving average
plot MA8 = Average(close, 8);
MA8.SetDefaultColor(Color.YELLOW);
MA8.SetLineWeight(2);
#Trend Signal
def TrendUp = if close > MA8 then 1 else Double.NaN;
def TrendDn = if close < MA8 then 1 else Double.NaN;
AddLabel(TrendUp, "UP", Color.GREEN);
AddLabel(TrendDn, "DN", Color.RED);
#Net Signal
def NSup = if close - close(period = "day" )[1] > 0 then 1 else Double.NaN;
def NSdn = if close - close(period = "day" )[1] <= 0 then 1 else Double.NaN;
AddLabel(NSup, "NS", Color.GREEN);
AddLabel(NSdn, "NS", Color.RED);
#Open Signal
def OSup = if close - open(period = "day" ) > 0 then 1 else Double.NaN;
def OSdn = if close - open(period = "day" ) < 0 then 1 else Double.NaN;
AddLabel(OSup, "OS", Color.GREEN);
AddLabel(OSdn, "OS", Color.RED);
#High / Low Signal
def Higher = if close > high(period = "day" )[1] then 1 else Double.NaN;
def Lower = if close < low(period = "day" )[1] then 1 else Double.NaN;
def Neutral = if close <= high(period="day" )[1] and close >= low(period="day" )[1] then 1 else Double.NaN;
AddLabel(Higher, "H/L", Color.GREEN);
AddLabel(Lower, "H/L", Color.RED);
AddLabel(Neutral, "H/L", Color.GRAY);
#Out of Bounds
def sDev = StDev(close, 21);
def MidLine = Average(close, 21);
def UpperBand = MidLine + 2 * sDev;
def LowerBand = MidLine - 2 * sDev;
def CloseAbove = if close > UpperBand then 1 else Double.NaN;
def CloseBelow = if close < LowerBand then 1 else Double.NaN;
AddLabel(CloseAbove, round(close - UpperBand,2), Color.WHITE);
AddLabel(CloseBelow, round(close - LowerBand,2), Color.WHITE);