The Big Four Chart SetUp For ThinkOrSwim

Hey there, looking to get some help with this strategy and the conditional order tool system or the “condition wizard”. I’ve got some preset trades saved as templates that should fire off when the chart posts it’s buy or sell signal but something must be wrong because it isn’t happening.
 
Last edited:
Hiding the vertical lines by default and added arrows.

Code:
# The Big Four Indicator
# https://usethinkscript.com/threads/the-big-four-chart-setup.14711/
# v1.0 - GiantBull and TradingNumbers
# v1.1 - TradingNumbers - hiding vertical lines by ddefault and added arrows

# AK Trend

input aktrend_input1 = 3;
input aktrend_input2 = 8;
input aktrend_price = close;

def aktrend_fastmaa = MovAvgExponential(aktrend_price, aktrend_input1);
def aktrend_fastmab = MovAvgExponential(aktrend_price, aktrend_input2);
def aktrend_bspread = (aktrend_fastmaa - aktrend_fastmab) * 1.001;

def cond1_UP = if aktrend_bspread > 0 then 1 else 0;
def cond1_DN = if aktrend_bspread <= 0 then -1 else 0;

# ZSCORE

input zscore_price = close;
input zscore_length = 20;
input zscore_ZavgLength = 20;

def zscore_oneSD = StDev(zscore_price, zscore_length);
def zscore_avgClose = SimpleMovingAvg(zscore_price, zscore_length);
def zscore_ofoneSD = zscore_oneSD * zscore_price[1];
def zscore_Zscorevalue = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZv = Average(zscore_Zscorevalue, 20);
def zscore_Zscore = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZscore = Average(zscore_Zscorevalue, zscore_ZavgLength);

def cond2_UP = if zscore_Zscore > 0 then 1 else 0;
def cond2_DN = if zscore_Zscore <= 0 then -1 else 0;

# Ehlers

input ehlers_length = 34;

def ehlers_price = (high + low) / 2;
def ehlers_coeff = ehlers_length * ehlers_price * ehlers_price - 2 * ehlers_price * Sum(ehlers_price, ehlers_length)[1] + Sum(ehlers_price * ehlers_price, ehlers_length)[1];
def ehlers_Ehlers = Sum(ehlers_coeff * ehlers_price, ehlers_length) / Sum(ehlers_coeff, ehlers_length);

def cond3_UP = if close > ehlers_Ehlers then 1 else 0;
def cond3_DN = if close <= ehlers_Ehlers then -1 else 0;

# Anchored Momentum

input amom_src = close;
input amom_MomentumPeriod = 10;
input amom_SignalPeriod = 8;
input amom_SmoothMomentum = no;
input amom_SmoothingPeriod = 7;

def amom_p = 2 * amom_MomentumPeriod + 1;
def amom_t_amom = if amom_SmoothMomentum == yes then ExpAverage(amom_src, amom_SmoothingPeriod) else amom_src;
def amom_amom = 100 * ( (amom_t_amom / ( Average(amom_src, amom_p)) - 1));
def amom_amoms = Average(amom_amom, amom_SignalPeriod);


def cond4_UP = if amom_amom > 0 then 1 else 0;
def cond4_DN = if amom_amom <= 0 then -1 else 0;

# Strategy

input Strategy_Confirmation_Factor = 3;
input Strategy_ColoredCandlesOn = yes;
input Strategy_VerticalLinesOn = no;

def cond_UP = cond1_UP + cond2_UP + cond3_UP + cond4_UP;
def cond_DN = cond1_DN + cond2_DN + cond3_DN + cond4_DN;

def direction = if cond_UP >= Strategy_Confirmation_Factor then 1 else if cond_DN <= -Strategy_Confirmation_Factor then -1 else direction[1];

plot signal_up = direction == 1 and direction[1] < 1;
signal_up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal_up.SetDefaultColor(Color.WHITE);
signal_up.Hide();
signal_up.HideBubble();
signal_up.HideTitle();

plot signal_dn = direction == -1 and direction[1] > -1;
signal_dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signal_dn.SetDefaultColor(Color.WHITE);
signal_dn.Hide();
signal_dn.HideBubble();
signal_dn.HideTitle();

AssignPriceColor(if Strategy_ColoredCandlesOn then if direction == 1 then Color.LIGHT_GREEN else if direction == -1 then Color.RED else Color.GRAY else Color.CURRENT);

AddVerticalLine(Strategy_VerticalLinesOn and signal_up, "Buy", Color.LIGHT_GREEN);
AddVerticalLine(Strategy_VerticalLinesOn and signal_dn, "Sell", Color.RED);

Alert(signal_up, "Buy", Alert.BAR, Sound.DING);
Alert(signal_dn, "Sell", Alert.BAR, Sound.DING);
How would you place an exit trade arrow if there's an open position going into the close? Day Trading /ES futures.
 
Added Vix Alert 4 to the BIG4 watchlist column

View attachment 19059

http://tos.mx/I1aG5E5

Code:
#Big_5 WL (Vix Alert4 added)
#added Blst off - triple exhaustion - vix alert4 to the big 4 - HODL

#######################################
##  Create Labels
#######################################
def showtitle = no;
def showlabels = yes;
def AutoAgg = yes;
def AutoAgg2 = yes;
# Williams Vix Fix Formula
def pd = 22;
def bbl = 20;
def mult = 2.0;
def lb = 50;
def ph = 0.85;
def pl = 1.01;

# Downtrend Criteria

input ltLB = 40;
input mtLB = 14;
input str = 3;

def wvf = ((highest(close, pd) - low) / (highest(close, pd))) * 100;
def sDev = mult * stdev(wvf, bbl);
def midLine = SimpleMovingAvg(wvf, bbl);
def lowerBand = midLine - sDev;
def upperBand = midLine + sDev;
def rangeHigh = (highest(wvf, lb)) * ph;

#  Filtered Bar Criteria

def upRange = low > low[1] and close > high[1];
def upRange_Aggr = close > close[1] and close > open[1];

#  Filtered Criteria

def filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and(wvf<upperBand and wvf<rangeHigh));
def filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]);

# Alerts Criteria


def alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr;

def Buy_133 = if alert4 and alert4[1] then 1 else 0;
def hide133 = if buy_133 and buy_133[1] then 0 else 1;

def Buy_13 = if buy_133 and hide133 then 1 else 0;
input trig = 20;
input paintbar = yes;

def val = AbsValue(close - open);
def range = high - low;
def blastOffVal = (val / range) * 100;
def trigger = trig;
#def alert1 = blastOffVal < trig;
def col = blastOffVal < trig;

plot value = if col then 1 else 0;


def ag_skip = no;
def ag_skip2 = no;
def ag_skip_lbl = no;

def agperiod1 = GetAggregationPeriod();
       
input timeframe = aggregationperiod.DAY;

input length = 10;
input length2 = 20;

def Vol = volume(period = timeframe);
def at_High = high(period = timeframe);
def at_Open = open(period = timeframe);
def at_Close = close(period = timeframe);
def at_Low = low(period = timeframe);
def Vol1 = volume(period = timeframe);
def at_High1 = high(period = timeframe);
def at_Open1 = open(period = timeframe);
def at_Close1 = close(period = timeframe);
def at_Low1 = low(period = timeframe);

# Buy_Volume forumla is volume * (close_price minus low_price) / (High_price minus low_price)
def Buy_Volume = RoundUp(Vol * (at_Close - at_Low) / (at_High - at_Low));
def Buy_percent = RoundUp((Buy_Volume / Vol) * 100);
#Buy_percent.SetPaintingStrategy(PaintingStrategy.LINE);
#Buy_percent.SetLineWeight(1);
#Buy_percent.SetDefaultColor(Color.GREEN);

#Sell_Volume forumla is  volume * (High_price minus Close_price) / (High_price minus Low_price)
def Sell_Volume = RoundDown(Vol1 * (at_High1 - at_Close1) / (at_High1 - at_Low1));
def Sell_percent = RoundUp((Sell_Volume / Vol1) * 100);
#input price = close;
input length_BB = 10;
input length_BB2 = 20;
plot avg = ExpAverage(close(period = agperiod1), length_BB);
#plot avg = ExpAverage((price), length);
def height = avg - avg[length];
avg.SetStyle(Curve.SHORT_DASH);
avg.SetLineWeight(1);

AddLabel(showtitle, " Big_6: ", Color.Light_gray);

# AK Trend

def aktrend_input1 = 3;
def aktrend_input2 = 8;
def aktrend_price = close;

def aktrend_fastmaa = MovAvgExponential(aktrend_price, aktrend_input1);
def aktrend_fastmab = MovAvgExponential(aktrend_price, aktrend_input2);
def aktrend_bspread = (aktrend_fastmaa - aktrend_fastmab) * 1.001;

def cond1_UP = if aktrend_bspread > 0 then 1 else 0;
def cond1_DN = if aktrend_bspread <= 0 then -1 else 0;

# ZSCORE

def zscore_price = close;
def zscore_length = 20;
def zscore_ZavgLength = 20;

def zscore_oneSD = StDev(zscore_price, zscore_length);
def zscore_avgClose = SimpleMovingAvg(zscore_price, zscore_length);
def zscore_ofoneSD = zscore_oneSD * zscore_price[1];
def zscore_Zscorevalue = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZv = Average(zscore_Zscorevalue, 20);
def zscore_Zscore = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZscore = Average(zscore_Zscorevalue, zscore_ZavgLength);

def cond2_UP = if zscore_Zscore > 0 then 1 else 0;
def cond2_DN = if zscore_Zscore <= 0 then -1 else 0;

# Ehlers

def ehlers_length = 34;

def ehlers_price = (high + low) / 2;
def ehlers_coeff = ehlers_length * ehlers_price * ehlers_price - 2 * ehlers_price * Sum(ehlers_price, ehlers_length)[1] + Sum(ehlers_price * ehlers_price, ehlers_length)[1];
def ehlers_Ehlers = Sum(ehlers_coeff * ehlers_price, ehlers_length) / Sum(ehlers_coeff, ehlers_length);

def cond3_UP = if close > ehlers_Ehlers then 1 else 0;
def cond3_DN = if close <= ehlers_Ehlers then -1 else 0;

# Anchored Momentum

def amom_src = close;
def amom_MomentumPeriod = 10;
def amom_SignalPeriod = 8;
def amom_SmoothMomentum = no;
def amom_SmoothingPeriod = 7;

def amom_p = 2 * amom_MomentumPeriod + 1;
def amom_t_amom = if amom_SmoothMomentum == yes then ExpAverage(amom_src, amom_SmoothingPeriod) else amom_src;
def amom_amom = 100 * ( (amom_t_amom / ( Average(amom_src, amom_p)) - 1));
def amom_amoms = Average(amom_amom, amom_SignalPeriod);


def cond4_UP = if amom_amom > 0 then 1 else 0;
def cond4_DN = if amom_amom <= 0 then -1 else 0;

# TMO

def tmo_length = 30; #def 14
def tmo_calcLength = 6; #def 5
def tmo_smoothLength = 6; #def 3

def tmo_data = fold i = 0 to tmo_length with s do s + (if close > GetValue(open, i) then 1 else if close < GetValue(open, i) then - 1 else 0);
def tmo_EMA5 = ExpAverage(tmo_data, tmo_calcLength);
def tmo_Main = ExpAverage(tmo_EMA5, tmo_smoothLength);
def tmo_Signal = ExpAverage(tmo_Main, tmo_smoothLength);
def tmo_color = if tmo_Main > tmo_Signal then 1 else -1;

def cond5_UP = if tmo_Main <= 0 then 1 else 0;
def cond5_DN = if tmo_Main >= 0 then -1 else 0;

# Strategy

input Strategy_Confirmation_Factor = 4;
input Strategy_FilterWithTMO = no;
input Strategy_FilterWithTMO_arrows = yes;
input Strategy_ColoredCandlesOn = yes;
input Strategy_VerticalLinesOn = no;
input Strategy_HoldTrend = no;

def cond_UP = cond1_UP + cond2_UP + cond3_UP + cond4_UP;
def cond_DN = cond1_DN + cond2_DN + cond3_DN + cond4_DN;

def direction = if cond_UP >= Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO or cond5_UP) then 1
                else if cond_DN <= -Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO or cond5_DN) then -1
                else if !Strategy_HoldTrend and direction[1] == 1 and cond_UP < Strategy_Confirmation_Factor and cond_DN > -Strategy_Confirmation_Factor then 0
                else if !Strategy_HoldTrend and direction[1] == -1 and cond_DN > -Strategy_Confirmation_Factor and cond_UP < Strategy_Confirmation_Factor then 0
                else direction[1];

def direction2 = if cond_UP >= Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO_arrows or cond5_UP) then 1
                else if cond_DN <= -Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO_arrows or cond5_DN) then -1
                else if !Strategy_HoldTrend and direction2[1] == 1 and cond_UP < Strategy_Confirmation_Factor and cond_DN > -Strategy_Confirmation_Factor then 0
                else if !Strategy_HoldTrend and direction2[1] == -1 and cond_DN > -Strategy_Confirmation_Factor and cond_UP < Strategy_Confirmation_Factor then 0
                else direction2[1];

def signal_up = direction2 == 1 and direction2[1] < 1;


def signal_dn = direction2 == -1 and direction2[1] > -1;

def up = direction == 1;
def down= direction == -1;
def none = !up and !down;
def alert4_1 = alert4 within 8 bars;

addlabel(yes,
if  alert4_1  and none then " Alert 4 "
else if signal_up and alert4_1 and up then " Alert 4 | 👍 "
else if signal_dn and  alert4_1  and down then " Alert 4 | 👎 "
else if signal_up and  alert4_1  then " Alert 4 | 👍 "
else if signal_dn and  alert4_1  then " Alert 4 | 👎 "
else if up and Alert4_1 then " Alert 4 "
else if down and Alert4_1 then " Alert 4 "
else if signal_up then "👍"
else if signal_dn then "👎"
else "  ", color.white);

Assignbackgroundcolor(
 if up and Alert4_1 then Color.dark_green
else if up then Color.dark_GREEN
else if down and alert4_1 then Color.dark_red
else if down then Color.dark_RED
else color.gray);
Hey, I am getting an error uploading it to TOS, any clue?
 
Hey, I am getting an error uploading it to TOS, any clue?
Unfortunately, you did not provide enough information to say where you went astray.

If you were attempting to cut & paste, please explain which step in these instructions, you encountered the problem:
https://usethinkscript.com/threads/how-to-import-existing-thinkscript-code-on-thinkorswim.10/

If you are attempting to import a link, please explain which step in the following instructions, you encountered the problem:
https://usethinkscript.com/threads/...ed-item-error-in-thinkorswim.5098/#post-57930
 
Last edited:
Thanks MerryDay, I could able to see the WL as single column, and i see the attachment has many columns, not sure if i have to add each section of the strategy as different columns, please advise.
1707260054518.png
 
Newest Version v1.5
Here is the latest update. Also added labels.

View attachment 17857
Code:
# The Big Four Indicator
# https://usethinkscript.com/threads/the-big-four-chart-setup.14711/
# v1.0 - GiantBull and TradingNumbers
# v1.1 - TradingNumbers - hiding vertical lines by ddefault and added arrows
# v1.2 - TradingNumbers - added TMO
# v1.3 - TradingNumbers - hold trend input added
# v1.4 - TradingNumbers - simplified options, added filter with TMO, and set conditions per GianBull parameters
# v1.5 - TradingNumbers - removed TMO color filter percentChg GiantBull, added labels

# Info Labels

input showLabels = yes;
AddLabel(showLabels, " The Big Four v1.5 ", Color.WHITE);

# AK Trend

def aktrend_input1 = 3;
def aktrend_input2 = 8;
def aktrend_price = close;

def aktrend_fastmaa = MovAvgExponential(aktrend_price, aktrend_input1);
def aktrend_fastmab = MovAvgExponential(aktrend_price, aktrend_input2);
def aktrend_bspread = (aktrend_fastmaa - aktrend_fastmab) * 1.001;

def cond1_UP = if aktrend_bspread > 0 then 1 else 0;
def cond1_DN = if aktrend_bspread <= 0 then -1 else 0;

# ZSCORE

def zscore_price = close;
def zscore_length = 20;
def zscore_ZavgLength = 20;

def zscore_oneSD = StDev(zscore_price, zscore_length);
def zscore_avgClose = SimpleMovingAvg(zscore_price, zscore_length);
def zscore_ofoneSD = zscore_oneSD * zscore_price[1];
def zscore_Zscorevalue = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZv = Average(zscore_Zscorevalue, 20);
def zscore_Zscore = ((zscore_price - zscore_avgClose) / zscore_oneSD);
def zscore_avgZscore = Average(zscore_Zscorevalue, zscore_ZavgLength);

def cond2_UP = if zscore_Zscore > 0 then 1 else 0;
def cond2_DN = if zscore_Zscore <= 0 then -1 else 0;

# Ehlers

def ehlers_length = 34;

def ehlers_price = (high + low) / 2;
def ehlers_coeff = ehlers_length * ehlers_price * ehlers_price - 2 * ehlers_price * Sum(ehlers_price, ehlers_length)[1] + Sum(ehlers_price * ehlers_price, ehlers_length)[1];
def ehlers_Ehlers = Sum(ehlers_coeff * ehlers_price, ehlers_length) / Sum(ehlers_coeff, ehlers_length);

def cond3_UP = if close > ehlers_Ehlers then 1 else 0;
def cond3_DN = if close <= ehlers_Ehlers then -1 else 0;

# Anchored Momentum

def amom_src = close;
def amom_MomentumPeriod = 10;
def amom_SignalPeriod = 8;
def amom_SmoothMomentum = no;
def amom_SmoothingPeriod = 7;

def amom_p = 2 * amom_MomentumPeriod + 1;
def amom_t_amom = if amom_SmoothMomentum == yes then ExpAverage(amom_src, amom_SmoothingPeriod) else amom_src;
def amom_amom = 100 * ( (amom_t_amom / ( Average(amom_src, amom_p)) - 1));
def amom_amoms = Average(amom_amom, amom_SignalPeriod);


def cond4_UP = if amom_amom > 0 then 1 else 0;
def cond4_DN = if amom_amom <= 0 then -1 else 0;

# TMO

def tmo_length = 30; #def 14
def tmo_calcLength = 6; #def 5
def tmo_smoothLength = 6; #def 3

def tmo_data = fold i = 0 to tmo_length with s do s + (if close > GetValue(open, i) then 1 else if close < GetValue(open, i) then - 1 else 0);
def tmo_EMA5 = ExpAverage(tmo_data, tmo_calcLength);
def tmo_Main = ExpAverage(tmo_EMA5, tmo_smoothLength);
def tmo_Signal = ExpAverage(tmo_Main, tmo_smoothLength);
def tmo_color = if tmo_Main > tmo_Signal then 1 else -1;

def cond5_UP = if tmo_Main <= 0 then 1 else 0;
def cond5_DN = if tmo_Main >= 0 then -1 else 0;

# Strategy

input Strategy_Confirmation_Factor = 4;
input Strategy_FilterWithTMO = no;
input Strategy_ColoredCandlesOn = yes;
input Strategy_VerticalLinesOn = no;
input Strategy_HoldTrend = yes;

def cond_UP = cond1_UP + cond2_UP + cond3_UP + cond4_UP;
def cond_DN = cond1_DN + cond2_DN + cond3_DN + cond4_DN;

def direction = if cond_UP >= Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO or cond5_UP) then 1
                else if cond_DN <= -Strategy_Confirmation_Factor and (!Strategy_FilterWithTMO or cond5_DN) then -1
                else if !Strategy_HoldTrend and direction[1] == 1 and cond_UP < Strategy_Confirmation_Factor and cond_DN > -Strategy_Confirmation_Factor then 0
                else if !Strategy_HoldTrend and direction[1] == -1 and cond_DN > -Strategy_Confirmation_Factor and cond_UP < Strategy_Confirmation_Factor then 0
                else direction[1];

plot signal_up = direction == 1 and direction[1] < 1;
signal_up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal_up.SetDefaultColor(Color.WHITE);
signal_up.Hide();
signal_up.HideBubble();
signal_up.HideTitle();

plot signal_dn = direction == -1 and direction[1] > -1;
signal_dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
signal_dn.SetDefaultColor(Color.WHITE);
signal_dn.Hide();
signal_dn.HideBubble();
signal_dn.HideTitle();

AssignPriceColor(if Strategy_ColoredCandlesOn then if direction == 1 then Color.LIGHT_GREEN else if direction == -1 then Color.RED else Color.GRAY else Color.CURRENT);

AddLabel(showLabels, if Strategy_ColoredCandlesOn then if direction == 1 then " Bullish " else if direction == -1 then " Bearish " else " Neutral " else " N/A ",
                     if Strategy_ColoredCandlesOn then if direction == 1 then Color.LIGHT_GREEN else if direction == -1 then Color.RED else Color.GRAY else Color.BLACK);

AddVerticalLine(Strategy_VerticalLinesOn and signal_up, "Buy", Color.LIGHT_GREEN);
AddVerticalLine(Strategy_VerticalLinesOn and signal_dn, "Sell", Color.RED);

Alert(signal_up[1], "Buy", Alert.BAR, Sound.DING);
Alert(signal_dn[1], "Sell", Alert.BAR, Sound.DING);
Has anyone ever tried this strategy for swing trades with success?
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
435 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