DanielManahan
Member
the Watchlist Column for SMA doesn't allow the user to select the number of lookback bars on the daily time frame
suppose we want to have a column return a 0 (N/A), 1 (bearish), or 2 (bullish) based on the close of the current candle in relation to crossing the 200 day simple moving average. a stock is bullish if above the 200 day and bearish if below
I need to correct the following code. this isn't working and only returning a 2. it should return all three numbers. I get an error on half of the stocks in a watchlist NAN
can someone please help me fix this script?
declare lower;
def lookback = 200;
def sma = SimpleMovingAvg();
def bull = close() crosses above sma;
def bear = close() crosses below sma;
def bull_lookback = highest(bull, lookback);
def bear_lookback = highest(bear, lookback);
plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
suppose we want to have a column return a 0 (N/A), 1 (bearish), or 2 (bullish) based on the close of the current candle in relation to crossing the 200 day simple moving average. a stock is bullish if above the 200 day and bearish if below
I need to correct the following code. this isn't working and only returning a 2. it should return all three numbers. I get an error on half of the stocks in a watchlist NAN
can someone please help me fix this script?
declare lower;
def lookback = 200;
def sma = SimpleMovingAvg();
def bull = close() crosses above sma;
def bear = close() crosses below sma;
def bull_lookback = highest(bull, lookback);
def bear_lookback = highest(bear, lookback);
plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;