Indicator for Think or Swim based on Rob Smith's The STRAT

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I tried to update the Radar TFC labels to include the same color scheme as the Strat Numbers study but haven't been able to get it to work. Any advice?


Code:
Declare upper;
 
input Time_Frame = aggregationPeriod.DAY;

#Scenarios by Pelonsax

def H = high(period = Time_Frame);
def L = low(period = Time_Frame);
def C = close(period = Time_Frame);
def O = open(period = Time_Frame);

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];

AddLabel(yes, if Time_Frame == aggregationPeriod.YEAR then "Y"
    else
    if Time_Frame == aggregationPeriod.QUARTER then "Q"
    else
    if Time_Frame == aggregationPeriod.MONTH then "M"
    else
    if Time_Frame == aggregationPeriod.WEEK then "W"
    else
    if Time_Frame == aggregationPeriod.FOUR_DAYS then "4D"
    else
    if Time_Frame == aggregationPeriod.THREE_DAYS then "3D"
    else
    if Time_Frame == aggregationPeriod.TWO_DAYS then "2D"
    else
    if Time_Frame == aggregationPeriod.DAY then "D"
    else
    if Time_Frame == aggregationPeriod.FOUR_HOURS then "4H"
    else
    if Time_Frame == aggregationPeriod.TWO_HOURS then "2H"
    else
    if Time_Frame == aggregationPeriod.HOUR then "60m"
    else
    if Time_Frame == aggregationPeriod.THIRTY_MIN then "30m"
    else
    if Time_Frame == aggregationPeriod.TWENTY_MIN then "20m"
    else
    if Time_Frame == aggregationPeriod.FIFTEEN_MIN then "15m"
    else
    if Time_Frame == aggregationPeriod.TEN_MIN then "10m"
    else
    if Time_Frame == aggregationPeriod.FIVE_MIN then "5m"
    else
    if Time_Frame == aggregationPeriod.FOUR_MIN then "4m"
    else
    if Time_Frame  == aggregationPeriod.THREE_MIN then "3m"
    else
    if Time_Frame == aggregationPeriod.TWO_MIN then "2m"
    else
    if Time_Frame  == aggregationPeriod.MIN then "1m"
    else "",
if insidebar then color.yellow else if outsiderbar then color.magenta else if twoup then color.green else if twodown color.red else color.white);
 
Sorry guys, i honestly haven't had much free time on my hands, which is why I've been AWOL. No clue when or if I'll be able to adress these issues. If anyone who knows how to code would like to weigh in and offer some help it would be most welcome. Thank you all for understanding.
 
Sorry guys, i honestly haven't had much free time on my hands, which is why I've been AWOL. No clue when or if I'll be able to adress these issues. If anyone who knows how to code would like to weigh in and offer some help it would be most welcome. Thank you all for understanding.
No sweat Pelonsax - You've done a ton already.
 
@Pelonsax, I have been skulking around this site for awhile and never really saw the need to register as most of the questions are asked by other people on this forum but I saw it necessary to register just so I could thank you.

I'm new to trading in general and as everyone knows it can be disorientating trying to figure out strategies, grail-indicators (I know, no such thing), etc.

There are 2 things that I feel are important for me which is price action and following the trend. The strat kind of calls to me for these 2 reasons. I don't know if it's something that I'm going to actually implement but at the very least it's helping me in understanding price action and categorizing moves.

What you have done for the indicators is really amazing. On top of that, you have provided it for free. On top of that, you have created videos explaining everything. These indicators provide more value than any paid indicator that I have come across.

Really you are the man and I can't thank you enough for all of the work that you have done for this.
 
@Pelonsax, I have been skulking around this site for awhile and never really saw the need to register as most of the questions are asked by other people on this forum but I saw it necessary to register just so I could thank you.

I'm new to trading in general and as everyone knows it can be disorientating trying to figure out strategies, grail-indicators (I know, no such thing), etc.

There are 2 things that I feel are important for me which is price action and following the trend. The strat kind of calls to me for these 2 reasons. I don't know if it's something that I'm going to actually implement but at the very least it's helping me in understanding price action and categorizing moves.

What you have done for the indicators is really amazing. On top of that, you have provided it for free. On top of that, you have created videos explaining everything. These indicators provide more value than any paid indicator that I have come across.

Really you are the man and I can't thank you enough for all of the work that you have done for this.
Thank you very much for your kindness. That is very encouraging to me.
 
I know I can start studies at the beginning of RTH (like TPO Profile) however I am not sure how to do that with code for a watchlist column. Well, I'm actually not sure how to mash the defined code so that my script takes into account when I want it to start. Any pointers you can give will get you virtual high 5's from me.


Code:
#

#------------------------------
#THIS IS THE CODE IM TRYING TO MASH INTO THE STUDY BELOW.  I'M NOT HOW TO LINK THE STUDY BACK TO THIS CODE.  I DONT EVEN KNOW IF I 'FRANKENSTEINED' THE CODE PROPERLY FOR IT TO WORK.

input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
def multiplier = 1;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = Floor(seconds / 3600 + day_number * 24);
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = Floor(day_number / 7);
case MONTH:
    period = Floor(month - First(month));
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
}


def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = count < count[1] + period - period[1];


profile RTHStartProfile = TimeProfile("startNewProfile" = cond);
#------------------------------------


#ORIGINAL STUDY
#------------------------------------
def H = high;
def L = low;
def O = open;
def C = close;
#------------------------------------
# DEFINE SCENARIOS
#------------------------------------
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 insidebarup  = insidebar and O < C;
def twoup  = H > H[1] and L >= L[1];
def outsidebarup  = outsidebar and O < C;
def insidebardown  = insidebar and O > C;
def twodown  = H <= H[1] and L < L[1];
def outsidebardown  = outsidebar and O > C;
#Hammers and Shooters

input showArrows = yes;
input x = 5; #bars amount

# Calculate the length of the candle's wicks
def UpperWick = high - Max(open, close);
def LowerWick = Min(open, close) - low;

# Calculate the length of the candle's body
def CandleBody = bodyheight();
def range = High - low;
def cond = range == highest(range,x);

# Compare the wicks to the body to ensure that one wick is 1.25x longer than the body
# also compare the other wick to ensure that it is a "small" wick
plot Hammer = (lowerWick / CandleBody >= 1.25) and (upperWick / CandleBody <= 1);
plot ShootingStar = (upperWick / CandleBody >= 1.25) and (lowerWick / CandleBody <= 1);

# -------------------------
# ACTIONABLE SIGNALS
# -------------------------

def ASInsideUp = insidebar[1] and C >= (H[1] – L[1]) *.70 + L[1];

def ASTwoDownTwoUp = twodown[1] and C >= (H[1] – L[1]) *.70 + L[1];

def ASOutsidebarDownTwoUp = outsidebardown[1] and C >= (H[1] – L[1]) *.70 + L[1];

plot ActionableUp = ASInsideUp or ASTwoDownTwoUp or ASOutsidebarDownTwoUp;


def bardiff = (h[2]-h[1])*.33;
def top = bardiff + h[1];
def valid = h < top;
def overtop = h>top and h<h[2];
def positive= bardiff>0;
def good = valid and positive;
def over = overtop and positive;





#------------------------------------
# LABEL SECTION
#------------------------------------
AddLabel(yes,

if
ASInsideUp then "AS-1" else if
ASTwoDownTwoUp then "2d-2u" else if
ASOutsidebarDownTwoUp then "3d-2u" else if
!ActionableUp and hammer and insidebarup then "H-1" else if
!ActionableUp and shootingStar and insidebardown then "S-1" else if
!ActionableUp and shootingstar and insidebarup then "S-1" else if
!ActionableUp and hammer and insidebardown then "H-1" else if
!ActionableUp and hammer and twoup then "H-2U" else if
!ActionableUp and hammer and twodown then "H-2D" else if
!ActionableUp and shootingstar and twoup then "S-2U" else if
!ActionableUp and shootingstar and twodown then "S-2D" else if
!ActionableUp and twoup then “2U” else if twodown then “2D” else if
!ActionableUp and insidebarup then “1" else if
!ActionableUp and insidebardown then “1” else if
!ActionableUp and outsidebarup then “3” else if
!ActionableUp and outsidebardown then “3” else if
!ActionableUp and insidebar and !insidebarup and !insidebardown then "1" else if
!ActionableUp and outsidebar and !outsidebarup and !outsidebardown then "3"
else "", color.black);



assignbackgroundColor(
if

ActionableUp and  good then color.yellow else if
ActionableUp and overtop then color.dark_ORANGE else if
ActionableUp and H>H[2] and close>open then color.green else if
ActionableUp and H>H[2] and close<open then color.red else if
#ActionableDown then color.yellow else if
hammer and !ActionableUp then color.white else if
shootingStar and !ActionableUp then color.white else if
twoup and !ActionableUp and close>open then color.green else if
twoup and !ActionableUp and close<open then color.red else if
twodown and !ActionableUp and close>open then color.green else if
twodown and !ActionableUp and close<open then color.red else if
outsidebarup and !ActionableUp  then color.green else if
insidebarup and !ActionableUp then color.green else if
outsidebardown and !ActionableUp then color.red else if
insidebardown and !ActionableUp then color.red else if
!insidebarup and
!insidebardown and
!ActionableUp and
insidebar then color.current else if
!outsidebardown and
!outsidebarup and
!ActionableUp and
outsidebar then color.current else color.current);
 
is your chart on a timeframe that supports the labels? If you‘re on a daily and expect to see intraday, it won’t work.
Thats not just my chart. Any TOS study will only work on the aggregation of the chart or higher, never lower
 
Thank you. I was able to do the 1 Bar Rev Strat and the Inside Bull Break. The 2 Bar Rev Strat scan is looking for a 1-2dn-2up and the Thinkscript Editor says "no such function:TwoDown at 1:1". I'm not quite sure what that means, but it won't let me change it to "TwoUp", since I'd be looking for a 1-2up-2dn @KCali Did you ever figure this out because I've Benn trying to scan that as well with the same error message?
 
You have to watch the video on how to make the scenarios scan first and save them as separate studies and then do the actionable signal scan the way I demonstrate in my video.
 
Has anyone had any real world luck with The Strat?
Yes. I have.
I'm a little confused at what is the optimal setup that people look for in terms of the numbered bars? Can someone please share their favs? @skychemist5 and if there is an easier way to simply setup buy/sell arrows on the chart instead of manually having to figure out the numbered candles? Thanks
optimal setup would be subjective (some people prefer trading off inside bars, other prefer looking for something coming back off the bottom (or top) of a broadening formation.

What I look for is something near the edge of the broadening formation while waiting for an indication that price is moving in the opposite direction.

As far as what you're looking for, the main idea is that you're hoping to catch the next 2-candle (or a 2 that becomes a 3).

The way I trade it is fairly simple:
I develop a thesis of whether I think something is going up or down, and then I set my entry, target, and stop. This is how I do it whether it's an option or a stock trade. (I tend to use conditional orders for option trades.)

For example: (using TSLA as an example, of wanting to trade a 2-2 Bearish Reversal
LDwlLsL.png


uD39yLX.png




So, you have to develop a thesis about where you think price will go. You have to "predict" what you think the pattern will be.
(You'd check your higher time frames, and draw broadening formations, and figure out which way you'd most likely think TSLA would go.)
If you thought TSLA was going down, then you'd enter short @ 730.44, and your profit target would be at 718.62. (Note: Some people like to go a penny beyond, and they'd be going short at 730.43). I don't go with a stop-loss that is bigger than half my target.

Basically, you'd be guessing that if price dropped all the way to 730.44, it might continue dropping until it got to 718.62.

(Caution: If trading theSTRAT don't use a vanilla LIMIT order, make sure to use a STOP order, or a STOP-LIMIT order, so that you can trigger the trade at the Price Level that you really want to enter. A vanilla LIMIT order might give you a more FAVORABLE price of entry, but it could potentially get you in the deal PRIOR TO your desired trigger point.)

If you're the type who wants to strictly enter off one side of the candle and stop-loss at the other side of the entry candle, then make sure you look for price contractions from inside bars (1s), or double-inside bars (1-1), or maybe find some small-magnitude directional bars (2s). Then, you can set a tighter stop-loss that way .


You can even just use conditional orders to enter the trade at certain levels.



Example: You're looking to trade a 2 up, 2 down reversal combo. You just look for the 2 up, and you're guessing at the 2-down is coming next. It's maybe an educated guess, because you're guessing based upon your time frame analysis, broadening formation, and where the overall trend of the market appears to be. If all of those points are in agreement for you, then you're more likely to be successful, but it's still a guess.

If you're looking for an "easy" way, you can get "actionable signals", yes, but the way ThinkOrSwim works, you need to have the chart loaded to get an alert that you could immediately act upon. (Either that, or you use an auto-trading platform.) For an example of getting actionable signals, you can look at "Alex's Options" on Youtube. He does his research the night before, but during the morning trading session, you can see charts loaded for getting alerts on high volume symbols (tighter spreads). He has videos posted on his channel, so that might help you with ideas.
Tried the strat but not for me, hope someone is able to make some real money with this. Like someone said too much hindsight. All the stuff I see and read out there is “after the fact”. I did learn a lot like using MTF analysis which I am able to take away and broadening formations happen everywhere.

Trading theSTRAT is just like trading any other strategy. You get a thesis, and you see if it plays out, or not.

By the time that last bar is forming, you're already too late (as you probably already observed.) You can see that last bar hitting the entry trigger live, but if you're not right on it (i.e.: using automation or monitoring the charts, you might enter too late, and you don't want to chase.

So, you're not trading the last bar, you're trading off that next-to-last bar, and you're "predicting" what that next bar will be (unless you're trading live and watching charts like a hawk or using automation)

See my TSLA example above in this post.

If you don't have a lot of time to trade during the day (like me) You could do your chart studies at night, pre-enter your entries, targets, and stops across multiple symbols, and then come back later to see how they did. If you can't stomach that, then just watch the charts live or leverage automation.

Hope this makes sense.
 
Yes. I have.

optimal setup would be subjective (some people prefer trading off inside bars, other prefer looking for something coming back off the bottom (or top) of a broadening formation.

What I look for is something near the edge of the broadening formation while waiting for an indication that price is moving in the opposite direction.

As far as what you're looking for, the main idea is that you're hoping to catch the next 2-candle (or a 2 that becomes a 3).

The way I trade it is fairly simple:
I develop a thesis of whether I think something is going up or down, and then I set my entry, target, and stop. This is how I do it whether it's an option or a stock trade. (I tend to use conditional orders for option trades.)

For example: (using TSLA as an example, of wanting to trade a 2-2 Bearish Reversal
LDwlLsL.png


uD39yLX.png




So, you have to develop a thesis about where you think price will go. You have to "predict" what you think the pattern will be.
(You'd check your higher time frames, and draw broadening formations, and figure out which way you'd most likely think TSLA would go.)
If you thought TSLA was going down, then you'd enter short @ 730.44, and your profit target would be at 718.62. (Note: Some people like to go a penny beyond, and they'd be going short at 730.43). I don't go with a stop-loss that is bigger than half my target.

Basically, you'd be guessing that if price dropped all the way to 730.44, it might continue dropping until it got to 718.62.

(Caution: If trading theSTRAT don't use a vanilla LIMIT order, make sure to use a STOP order, or a STOP-LIMIT order, so that you can trigger the trade at the Price Level that you really want to enter. A vanilla LIMIT order might give you a more FAVORABLE price of entry, but it could potentially get you in the deal PRIOR TO your desired trigger point.)

If you're the type who wants to strictly enter off one side of the candle and stop-loss at the other side of the entry candle, then make sure you look for price contractions from inside bars (1s), or double-inside bars (1-1), or maybe find some small-magnitude directional bars (2s). Then, you can set a tighter stop-loss that way .


You can even just use conditional orders to enter the trade at certain levels.



Example: You're looking to trade a 2 up, 2 down reversal combo. You just look for the 2 up, and you're guessing at the 2-down is coming next. It's maybe an educated guess, because you're guessing based upon your time frame analysis, broadening formation, and where the overall trend of the market appears to be. If all of those points are in agreement for you, then you're more likely to be successful, but it's still a guess.

If you're looking for an "easy" way, you can get "actionable signals", yes, but the way ThinkOrSwim works, you need to have the chart loaded to get an alert that you could immediately act upon. (Either that, or you use an auto-trading platform.) For an example of getting actionable signals, you can look at "Alex's Options" on Youtube. He does his research the night before, but during the morning trading session, you can see charts loaded for getting alerts on high volume symbols (tighter spreads). He has videos posted on his channel, so that might help you with ideas.


Trading theSTRAT is just like trading any other strategy. You get a thesis, and you see if it plays out, or not.

By the time that last bar is forming, you're already too late (as you probably already observed.) You can see that last bar hitting the entry trigger live, but if you're not right on it (i.e.: using automation or monitoring the charts, you might enter too late, and you don't want to chase.

So, you're not trading the last bar, you're trading off that next-to-last bar, and you're "predicting" what that next bar will be (unless you're trading live and watching charts like a hawk or using automation)

See my TSLA example above in this post.

If you don't have a lot of time to trade during the day (like me) You could do your chart studies at night, pre-enter your entries, targets, and stops across multiple symbols, and then come back later to see how they did. If you can't stomach that, then just watch the charts live or leverage automation.

Hope this makes sense.

Replying to my own post, TSLA didn't trigger the 2-2 Bearish reversal today, as it appears to have done a gap-fill instead. and gone in the opposite direction.

Note: The proposed trade would not have triggered, as it never hit the entry point on the daily. Like with any trade idea, you get your opinion (hopefully based on something you've tested) and you see what happens. In this case, it didn't happen.
MFBpUv1.png

Hope this makes sense!
 
Yes. I have.

optimal setup would be subjective (some people prefer trading off inside bars, other prefer looking for something coming back off the bottom (or top) of a broadening formation.

What I look for is something near the edge of the broadening formation while waiting for an indication that price is moving in the opposite direction.

As far as what you're looking for, the main idea is that you're hoping to catch the next 2-candle (or a 2 that becomes a 3).

The way I trade it is fairly simple:
I develop a thesis of whether I think something is going up or down, and then I set my entry, target, and stop. This is how I do it whether it's an option or a stock trade. (I tend to use conditional orders for option trades.)

For example: (using TSLA as an example, of wanting to trade a 2-2 Bearish Reversal
LDwlLsL.png


uD39yLX.png




So, you have to develop a thesis about where you think price will go. You have to "predict" what you think the pattern will be.
(You'd check your higher time frames, and draw broadening formations, and figure out which way you'd most likely think TSLA would go.)
If you thought TSLA was going down, then you'd enter short @ 730.44, and your profit target would be at 718.62. (Note: Some people like to go a penny beyond, and they'd be going short at 730.43). I don't go with a stop-loss that is bigger than half my target.

Basically, you'd be guessing that if price dropped all the way to 730.44, it might continue dropping until it got to 718.62.

(Caution: If trading theSTRAT don't use a vanilla LIMIT order, make sure to use a STOP order, or a STOP-LIMIT order, so that you can trigger the trade at the Price Level that you really want to enter. A vanilla LIMIT order might give you a more FAVORABLE price of entry, but it could potentially get you in the deal PRIOR TO your desired trigger point.)

If you're the type who wants to strictly enter off one side of the candle and stop-loss at the other side of the entry candle, then make sure you look for price contractions from inside bars (1s), or double-inside bars (1-1), or maybe find some small-magnitude directional bars (2s). Then, you can set a tighter stop-loss that way .


You can even just use conditional orders to enter the trade at certain levels.



Example: You're looking to trade a 2 up, 2 down reversal combo. You just look for the 2 up, and you're guessing at the 2-down is coming next. It's maybe an educated guess, because you're guessing based upon your time frame analysis, broadening formation, and where the overall trend of the market appears to be. If all of those points are in agreement for you, then you're more likely to be successful, but it's still a guess.

If you're looking for an "easy" way, you can get "actionable signals", yes, but the way ThinkOrSwim works, you need to have the chart loaded to get an alert that you could immediately act upon. (Either that, or you use an auto-trading platform.) For an example of getting actionable signals, you can look at "Alex's Options" on Youtube. He does his research the night before, but during the morning trading session, you can see charts loaded for getting alerts on high volume symbols (tighter spreads). He has videos posted on his channel, so that might help you with ideas.


Trading theSTRAT is just like trading any other strategy. You get a thesis, and you see if it plays out, or not.

By the time that last bar is forming, you're already too late (as you probably already observed.) You can see that last bar hitting the entry trigger live, but if you're not right on it (i.e.: using automation or monitoring the charts, you might enter too late, and you don't want to chase.

So, you're not trading the last bar, you're trading off that next-to-last bar, and you're "predicting" what that next bar will be (unless you're trading live and watching charts like a hawk or using automation)

See my TSLA example above in this post.

If you don't have a lot of time to trade during the day (like me) You could do your chart studies at night, pre-enter your entries, targets, and stops across multiple symbols, and then come back later to see how they did. If you can't stomach that, then just watch the charts live or leverage automation.

Hope this makes sense.
Thank you
 
Replying to my own post, TSLA didn't trigger the 2-2 Bearish reversal today, as it appears to have done a gap-fill instead. and gone in the opposite direction.

Note: The proposed trade would not have triggered, as it never hit the entry point on the daily. Like with any trade idea, you get your opinion (hopefully based on something you've tested) and you see what happens. In this case, it didn't happen.
MFBpUv1.png

Hope this makes sense!

have you tried a strat that sets up both long and short position triggers on both sides of these trades? curious if that has worked for you / anyone with The Strat.
 
If anyone who knows how to code would like to weigh in and offer some help it would be most welcome.
Just started messing around with this strat. I have no idea if I'll end up using it long term until I do some extensive testing, but I appreciate the time you've spent on the indicators and studies. As it's my nature, I can't help but want to jump in and make tweaks and improvements that will serve my own purposes when testing any given strategy or study.

Watching your 10 minute video, the very first thing that came to mind was I could combine the DanielBones label coloring into the exiting TFC study labels, and then make them conditionally hide not only based on the user's study setting, but also based on if the chart time frame selected supports the data required for that time frame to work (might help users not mistakenly belive they are seeing TFC for a time frame their chart doesn't have the required data for.

1) any reason I shouldn't do that?
2) would you like the finished code if I do combine them?
 
I found this script for adding a custom watchlist column and it works fine for 15m and 30m. But it is not displaying correctly for 1h, nor 4h. I am sure it has to do with the aggregation periods not starting at market open. How do I force them to aggregate at market open?
Ruby:
#------------------------------------
#
# M T F S T R A T
# W A T C H L I S T
# a Study by Ramon DV. aka Pelonsax
#
#------------------------------------
#------------------------------------
# S T R A T R E V E R S A L S
#
# A study by Ramon DV. aka Pelonsax
#
# Version 1.0 8/01/20
#
# Version 2.0 8/4/20 Corrected errors in logic for scenarios
# Version 2.1 8/15/20 Added Reversals
# 9/15/20 added two previous bars and reversals for WL
#------------------------------------
# COLUMNS
#------------------------------------
def H = high;
def L = low;
def O = open;
def C = close;
#------------------------------------
# DEFINE SCENARIOS
#------------------------------------
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 insidebarup = insidebar and O < C;
def twoup = H > H[1] and L >= L[1];
def outsidebarup = outsidebar and O < C;
def insidebardown = insidebar and O > C;
def twodown = H <= H[1] and L < L[1];
def outsidebardown = outsidebar and O > C;


def insidebar1 = (H[1] < H[2] and L[1] > L[2]) or (H[1] == H[2] and L[1] > L[2]) or (H[1] < H[2] and L[1] == L[2]) or (H[1] == H[2] and L[1] == L[2]);
def outsidebar1 = H[1] > H[2] and L[1] < L[2];

def insidebarup1 = insidebar1 and O[1] < C[1];
def twoup1 = H[1] > H[2] and L[1] >= L[2];
def outsidebarup1 = outsidebar1 and O[1] < C[1];
def insidebardown1 = insidebar1 and O[1] > C[1];
def twodown1 = H[1] <= H[2] and L[1] < L[2];
def outsidebardown1 = outsidebar1 and O[1] > C[1];


def insidebar2 = (H[2] < H[3] and L[2] > L[3]) or (H[2] == H[3] and L[2] > L[3]) or (H[2] < H[3] and L[2] == L[3]) or (H[2] == H[3] and L[2] == L[3]);
def outsidebar2 = H[2] > H[3] and L[2] < L[3];

def insidebarup2 = insidebar2 and O[2] < C[2];
def twoup2 = H[2] > H[3] and L[2] >= L[3];
def outsidebarup2 = outsidebar2 and O[2] < C[2];
def insidebardown2 = insidebar2 and O[2] > C[2];
def twodown2 = H[2] <= H[3] and L[2] < L[3];
def outsidebardown2 = outsidebar2 and O[2] > C[2];

#------------------------------------
# DEFINE REVERSALS (Basic four)
#------------------------------------

# Bullish
def TwoOneTwoBull = twoup and insidebar1 and twodown2;
def TwoTwoBull = twoup and twodown1;
def ThreeBull = outsidebarup and (twodown1 or insidebar1 or outsidebardown1);
def ThreeOneTwoBull = twoup and insidebar1 and outsidebardown2;

# Bearish
def TwoOneTwoBear = twodown and insidebar1 and twoup2;
def TwoTwoBear = twodown and twoup2;
def ThreeBear = outsidebardown and (twoup1 or insidebar1 or outsidebarup1);
def ThreeOneTwoBear = twodown and insidebar1 and outsidebarup2;

#------------------------------------
# LABEL SECTION
#------------------------------------
AddLabel(yes,

(if twoup2 then “2U” else if twodown2 then “2D” else if insidebarup2 then “1U" else if insidebardown2 then “1D” else if outsidebarup2 then “3U” else if outsidebardown2 then “3D” else if insidebar2 and !insidebarup2 and !insidebardown2 then "1" else if outsidebar2 and !outsidebarup2 and !outsidebardown2 then "3" else “”) + “-“ +

(if twoup1 then “2U” else if twodown1 then “2D” else if insidebarup1 then “1U" else if insidebardown1 then “1D” else if outsidebarup1 then “3U” else if outsidebardown1 then “3D” else if insidebar1 and !insidebarup1 and !insidebardown1 then "1" else if outsidebar1 and !outsidebarup1 and !outsidebardown1 then "3" else “”)+ ”-“ +

(if twoup then “[2U]” else if twodown then “[2D]” else if insidebarup then “[1U]” else if insidebardown then “[1D]” else if outsidebarup then “[3U]” else if outsidebardown then “[3D]” else if insidebar and !insidebarup and !insidebardown then “[1]” else if outsidebar and !outsidebarup and !outsidebardown then “[3]” else “”), color.black);

assignbackgroundColor(if TwoOneTwoBull or TwoTwoBull or ThreeBull or ThreeOneTwoBull then color.cyan else if TwoOneTwoBear or TwoTwoBear or ThreeBear or ThreeOneTwoBear then color.magenta else if

!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
twoup then color.green else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
twodown then color.red else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
outsidebarup then color.dark_green else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
insidebarup then color.light_green else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
outsidebardown then color.dark_red else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
insidebardown then color.orange else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
!insidebarup and
!insidebardown and
insidebar then color.white else if

!TwoOneTwoBull and
!TwoTwoBull and
!ThreeBull and
!ThreeOneTwoBull and
!TwoOneTwoBear and
!TwoTwoBear and
!ThreeBear and
!ThreeOneTwoBear and
!outsidebardown and
!outsidebarup and
outsidebar then color.white

else color.current);
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
434 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top