#strat_jackson2
#https://usethinkscript.com/threads/randy-jackson-bullish-bearish-scan.20756/
#Randy Jackson Bullish/Bearish Scan
#cashfolder78 Apr 2, 2025
#1
# I am currently learning "the strat" and searched around to see if anyone may have created a tos scan for "Randy Jackson Bullish/Bearish yet.
# Attached is a img of what I am looking to create a scan for.
# my interpretation of the rules, from pic
# bull
#.. bar1 , green 2
#.. bar2 , green 2. high > bar1 high. low > bar1 low. high is target
#.. bar3 , red 2. high < bar2 high. low < bar2 low. high is entry. close ?
#.. bar4 , green 2. bar4 high > bar3 high. low > bar3 low.
# make up a loss exit rule
# bar4 close < bar3 low
# no , if bar4 high < bar3 high * x% , then sell (approx midpoint of bar3)
# redo to mirror bull
# bear
#.. bar1 , red 2
#.. bar2 , red 2. low < bar1 low. high < bar1 high. low is target
#.. bar3 , green 2. high > bar high. low > bar2 low. low is entry
#.. bar4 , red 2. low < bar3 low. high < bar3 high
# make up a loss exit rule
# bar4 close > bar3 high
# no , if bar4 low > bar3 low * x% , then sell (approx midpoint of bar3)
def na = double.nan;
def bn = barnumber();
#------------------------------
# https://usethinkscript.com/threads/indicator-for-think-or-swim-based-on-rob-smiths-the-strat.3312/
# Indicator for Think or Swim based on Rob Smith's The STRAT
# Pelonsax Aug 1, 2020
#------------------------------
# S T R A T N U M B E R S
# A study by Ramon DV. aka Pelonsax
#------------------------------
def H = high;
def L = low;
def C = close;
def O = open;
def insidebar = (H < H[1] and L > L[1]) or (H == H[1] and L > L[1]) or (H < H[1] and L == L[1]) or (H == H[1] and L == L[1]);
def outsidebar = H > H[1] and L < L[1];
def twoup = H > H[1] and L >= L[1];
def twodown = H <= H[1] and L < L[1];
#-----------------------------
# STRAT NUMBERS
#-----------------------------
input Show_Strat_Numbers = yes;
input Show_Twos = yes;
plot barType = if Show_Strat_Numbers and insidebar then 1
else if Show_Strat_Numbers and outsidebar then 3
else Double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(color.WHITE);
plot barTypeDN = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twodown then 2 else Double.NaN;
barTypeDN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barTypeDN.AssignValueColor(color.DOWNTICK);
plot barTypeUP = if Show_Strat_Numbers and !insidebar and !outsidebar and Show_Twos and twoup then 2 else Double.NaN;
barTypeUP.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
barTypeUP.AssignValueColor(color.UPTICK);
#---------------------------
def bdn = if !insidebar and !outsidebar and twodown then 2 else 0;
def bup = if !insidebar and !outsidebar and twoup then 2 else 0;
# bull
#.. bar1 , green 2
#.. bar2 , green 2. high > bar1 high. low > bar1 low. high is target
#.. bar3 , red 2. high < bar2 high. low < bar2 low. high is entry. close ?
#.. bar4 , green 2. bar4 high > bar3 high. low > bar3 low.
# make up a loss exit rule
# bar4 close < bar3 low
#def bull1 = (barTypeUP == 2 and barTypeUP[-1] == 2 and barTypeDN[-2] == 2 and barTypeUP[-3] == 2)
def bull1 = (bup == 2 and bup[-1] == 2 and bdn[-2] == 2 and bup[-3] == 2)
and high[-1] > high and low[-1] > low
and high[-2] < high[-1] and low[-2] < low[-1]
and high[-3] > high[-2] and low[-3] > low[-2];
#addverticalline(bull1, "bull 1", color.green);
plot zup = if bull1 then low*0.9999 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.cyan);
zup.setlineweight(3);
zup.hidebubble();
#-----------------------
# cloud levels
def big = 99999;
def upcldtop;
if bn == 1 then {
upcldtop = 0;
} else if bull1 then {
upcldtop = fold a = 0 to 3
with b
do max(b,getvalue(high,-a));
} else if bull1[1] or bull1[2] or bull1[3] then {
upcldtop = upcldtop[1];
} else {
upcldtop = 0;
}
def upcldbot;
if bn == 1 then {
upcldbot = 0;
} else if bull1 then {
upcldbot = fold e = 0 to 3
with f = big
do min(f,getvalue(low,-e));
} else if bull1[1] or bull1[2] or bull1[3] then {
upcldbot = upcldbot[1];
} else {
upcldbot = 0;
}
def cut = if upcldtop > 0 then upcldtop else na;
def cub = if upcldbot > 0 then upcldbot else na;
addcloud(cut,cub,color.light_green);
#--------------------
def uptarget = if bn == 1 then 0
else if !bull1[1] and !bull1[0] and close[1] > uptarget[1] then 0
else if bull1[1] then high
else uptarget[1];
plot zuptgt = if uptarget > 0 then uptarget else na;
zuptgt.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zuptgt.SetDefaultColor(Color.green);
zuptgt.setlineweight(2);
zuptgt.hidebubble();
def uploss = if bn == 1 then 0
else if uptarget == 0 then 0
else if close[1] < uploss[1] then 0
else if bull1[2] then low
else uploss[1];
plot zuploss = if uploss > 0 then uploss else na;
zuploss.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zuploss.SetDefaultColor(Color.red);
zuploss.setlineweight(2);
zuploss.hidebubble();
def upentry = if bn == 1 then 0
else if uptarget == 0 then 0
else if bull1[2] then high
else upentry[1];
plot zupen = if upentry > 0 then upentry else na;
zupen.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
zupen.SetDefaultColor(Color.blue);
zupen.setlineweight(2);
zupen.hidebubble();
addchartbubble(0, low*0.997,
#bull1[2] + " B2\n" +
bull1[0] + " B\n" +
bup + "\n" +
bdn + "\n" +
upentry + " En"
, (if bull1 then color.yellow else color.gray), no);
#