Golferdave
New member
I have a code for the squeeze with an arrow green for long and red for short. How can I create a watchlist or scan to show up with a stock show the arrow? Hope that makes sense
Code:
#Momentum Indicator
input length = 13;
input AvgMomentumLength = 13;
input price = close;
input AverageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;
assert(length > 0, "'length' must be positive: " + length);
def Momentum = price - price[length];
plot AvgMomentum = movavgExponential(Momentum, AvgMomentumLength);
def bullishMomentum = AvgMomentum > 0;
def bearishMomentum = AvgMomentum < 0;
AvgMomentum.SetPaintingStrategy(paintingstrategy.LINE);
AvgMomentum.SetLineWeight(3);
AvgMomentum.AssignValueColor(if bullishmomentum then color.blue else if bearishMomentum then color.red else color.black);
# Squeeze Checklist Signals
def EMA8 = movavgExponential(close,8);
def EMA21 = movavgExponential(close,21);
def bullishStack = EMA8 > EMA21;
def bearishStack = EMA8 < EMA21;
#RSI
def RSIlength = 14;
def RSIover_Bought = 70;
def RSIover_Sold = 30;
def RSIprice = close;
def RSIaverageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(RSIaverageType, RSIprice - RSIprice[1], RSIlength);
def TotChgAvg = MovingAverage(RSIaverageType, AbsValue(RSIprice - RSIprice[1]), RSIlength);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def RSIOverSold = RSIover_Sold;
def RSIOverBought = RSIover_Bought;
def RSIUpSignal = if RSI crosses above RSIOverSold then RSIOverSold else Double.NaN;
def RSIDownSignal = if RSI crosses below RSIOverBought then RSIOverBought else Double.NaN;
def RSImidline = 50;
def bullishRSI = RSI >= 50;
def bearishRSI = RSI < 50;
#Stochastics
def over_bought = 80;
def over_sold = 20;
def KPeriod = 14;
def DPeriod = 3;
def priceH = high;
def priceL = low;
def priceC = close;
def slowing_period = 3;
def averageTypeStoch = AverageType.SIMPLE;
def lowest_k = Lowest(priceL, KPeriod);
def c1 = priceC - lowest_k;
def c2 = Highest(priceH, KPeriod) - lowest_k;
def FastK = if c2 != 0 then c1 / c2 * 100 else 0;
def FullK = MovingAverage(averageTypeStoch, FastK, slowing_period);
def FullD = MovingAverage(averageTypeStoch, FullK, DPeriod);
def OverBought = over_bought;
def OverSold = over_sold;
def MidLine = 50;
def upK = FullK crosses above OverSold;
def upD = FullD crosses above OverSold;
def downK = FullK crosses below OverBought;
def downD = FullD crosses below OverBought;
def bullishStoch = FullK > FullD;
def bearishStoch = FullK < FullD;
# SqueezeHistogram
def squeezehistogram = TTM_Squeeze(close, 20, 1.5, 2.0, 1.0).Histogram;
def squeezehistogramUP = squeezehistogram > squeezehistogram[1] and squeezehistogram[1] > squeezehistogram[2];
def squeezehistogramDOWN = squeezehistogram < squeezehistogram[1] and squeezehistogram[1] < squeezehistogram[2];
# Squeeze Signal
def normalSqueeze = if TTM_Squeeze(close, 20, 1.5, 2.0, 1.0).SqueezeAlert == 0 then 1 else 0;
def aggroSqueeze = if TTM_Squeeze(close, 20, 2.0, 2.0, 1.0).SqueezeAlert == 0 then 1 else 0;
plot squeezeSignal = normalSqueeze or aggroSqueeze;
squeezeSignal.setPaintingStrategy(paintingStrategy.POINTS);
squeezeSignal.setLineWeight(3);
squeezeSignal.AssignValueColor(if normalSqueeze then color.yellow else if aggroSqueeze then color.yellow else color.dark_gray);
def BullishSignal = squeezeSignal and bullishstack and bullishRSI and bullishStoch and squeezehistogramUP;
def BearishSignal = squeezeSignal and bearishstack and bearishRSI and bearishStoch and squeezehistogramDOWN;
plot BullishSignal2 = if bullishsignal and !bullishsignal[1] then avgmomentum else double.nan;
plot BearishSignal2 = if bearishsignal and !bearishsignal[1] then avgmomentum else double.nan;
BullishSignal2.SetpaintingStrategy(PaintingStrategy.ARROW_UP);
BearishSignal2.SetpaintingStrategy(PaintingStrategy.ARROW_DOWN);
BullishSignal2.SetLineWeight(2);
BearishSignal2.SetlineWeight(2);
BullishSignal2.SetdefaultColor(color.green);
BearishSignal2.SetdefaultColor(color.red);
# End Code
Last edited by a moderator: