MomoAlphaTrigger (Day to Year) quote for ThinkorSwim

wtf_dude

wtf_dude

Active member
No idea if anybody would want this. Built it a year or 2 ago. Yea, some of the letter coding is out of order (I'm not a big coding guy and have severe concentration issues)
Feel free to play around with it.

Add this to your quote screen. It will average the return of the week, month, quarter and year and confirm that it's positive,
Then add the day and the week's returns to add more recent weight and see if the number remains positive,
Then see checks to see if it's beating SPX by more than 25bps,
Then checks to see if the RSI is over 50

If all tests check out, it will give you a green go signal and count the number of days since the signal turned green. Vice versa the tests fail.
Simple, but has helped me a lot with a quick glance for market winners

Code:
# Ultimate MomoAlphaTrigger (Day to Year) by WTF_Dude
# This script identifies days passed since time frame composites are +, alpha is over 25bps, RSI over 50
# if days passed is less than or equal to 5 then we assign light green/red color
# if days passed is greater than or equal to 5 then we assign dark green/red color
# More weight on day and week. Averages week, month, quarter, year.
# Only makes sure the composite is positive. No threshold minimum >0

def price = close;
def f = ((close - close[1]) / close[1]) * 100;
def a = ((close - close[5]) / close[5]) * 100;
def b = ((close - close[21]) / close[21]) * 100;
def c = ((close - close[63]) / close[63]) * 100;
def d = ((close - close[252]) / close[252]) * 100;
def e = ((a + b + c + d) / 4);
def h = f + a + e;

def ALPHA = AlphaJensen(index = "SPX") ;
def RSI1 = RSI(14);

# Identify bars where returns are up
def MOMO1up = e > 0;
def MOMO2up = h > 0;
def ALPHAup = ALPHA>.25;
def RSIup=RSI1>50;

#identify bars for 4up or 4down
def FourUP = MOMO1up and MOMO2up and ALPHAup and RSIup;
def FourDN = !MOMO1up and !MOMO2up and !ALPHAup and !RSIup;
#counter code
def FourUP_Count  = CompoundValue(1, if FourUP != FourUP[1] then 1 else FourUP_Count[1] + 1, 0);
def FourDN_Count  = CompoundValue(1, if FourDN != FourDN[1] then -1 else FourDN_Count[1] + 1 * -1, 0);
def data = if FourUP then FourUP_Count  else if FourDN then FourDN_Count else Double.NaN;
#Assign Back Ground Color

# HINT: Change CreateColor(237,237,237) to Color.BLACK or to any other color that matches your background

AssignBackgroundColor(if FourUP then (if data <= 3 then Color.GREEN else Color.DARK_GREEN ) else if FourDN then (if data >= -3 then Color.RED else Color.DARK_RED) else Color.BLACK );

AddLabel(!IsNaN(data), data, if FourUP then (if data <= 3 then Color.BLACK else Color.WHITE) else if FourDN then (if data >= -3 then Color.WHITE else CreateColor(237, 237, 237)) else Color.BLACK);

AddLabel(IsNaN(data), " ", CreateColor(237, 237, 237));
 

Similar threads

Top