Pullback Chart Setup For ThinkOrSwim

UpTwoBucks

EDUCATOR
Powerful Live Data Pull Back Indicator.

Important Notes: This script is very powerful if used correctly. Practice until you totally understand your entry and exits. Warning, this script does not give entry and exit signals. The arrows represent pull backs in price. It is up to you to determine entry and exit decisions. This script does include "possible entries" (green candles) to buy long or (Red Candles) to go short. In either case, these are not entry and exit signals. Each arrow represents either a pull back (Green Arrow) as the price is rising or a pull back short position (Red Arrow) as the price is falling. Best entries for a long position is on the front side of a run up, or the back side of a run up for a short position. This indicator relies on live data to perform its functions not past history.

I have also included a 3 scans that find these stocks that meet the requirements of this indicator. They are 1 minute, 5 minute and 15 minute and are listed below. Find the one that works best for you. Don't forget to change your chart time frame for whichever one you decide to use.

The Perfect Setup:

Long Position: A Green Arrow is Plotted, The buyers in the Volume Label is Green, The Volume Spike at the top of your screen is Green and the numbers are rising.

Short Position: A Red Arrow is Plotted, The Sellers in the Volume label is Red, The Volume Spike at the top of your screen is Red and the numbers are rising.

Explore Different Time Frames, 1 min, 5 Min, 15 min. Make sure to change the Scan time frame as well.

######

Pullback Indicator:

The pullback indicator aims to identify pullback conditions in the price movement.

The input parameters are:

"length" is set to 50.
"multiplier" is set to 1.5.
"emaLength" is set to 8.

Moving Average Calculation:

It calculates the simple moving average (SMA) of the closing price over the specified length (50).
The moving average is stored in the variable "ma" using the MovingAverage function.

Pullback Calculation:

The "pullbackValue" is determined by subtracting the product of the multiplier (1.5) and the average true range (ATR) from the moving average.
The ATR is calculated using the TrueRange function with high, low, and close prices as inputs.

Pullback Conditions:

The variable "isPullback" is set to true if the current closing price is less than the pullback value calculated earlier.

Green and Red Candle Conditions:

The variable "isFirstGreenCandle" is set to true if the following conditions are met:

The current closing price is not a pullback (isPullback is false).
The current closing price is greater than the open price.
The previous closing price (close[1]) is less than or equal to the previous open price (open[1]).
The current closing price is greater than the current exponential moving average (EMA) with a length of 8.

The variable "isFirstRedCandle" is set to true if the following conditions are met:

The current closing price is a pullback (isPullback is true).
The current closing price is less than the open price.
The previous closing price (close[1]) is greater than or equal to the previous open price (open[1]).

First Green and Red Candle After Condition:

The variables "isFirstGreenAfterRed" and "isFirstRedAfterGreen" are set to true if there is exactly one occurrence of a green or red candle after the respective opposite candle.
They use the Sum function with a length of 1 to count the occurrences of isFirstGreenCandle and isFirstRedCandle being true.

Plotting the Indicator:

The "PullbackIndicator" is plotted as a boolean arrow pointing up if isFirstGreenAfterRed is true.
The "PullbackRedIndicator" is plotted as a boolean arrow pointing down if isFirstRedAfterGreen is true.
The line weight is set to 2, and the default colors are green for the pullback indicator and red for the pullback red indicator.

******

This script also includes a volume spike label to help you determine if a spike in buying or selling volume is detected.

The given script represents a volume spike indicator that aims to identify significant changes in volume compared to the average volume.

Here's how it works:

Percentage Threshold:

The variable "spike_percentage_threshold" is set to 0.0. This represents the percentage threshold for determining whether a volume spike has occurred.

Relative Volume Calculation:

The relative volume for the current bar is calculated by dividing the current volume by the average volume over a specified period (50 bars).
The "rel_vol" variable stores the calculated relative volume.

Volume Change Percentage Calculation:

The percentage change in volume relative to the average volume is calculated by subtracting 1.0 from the relative volume and multiplying it by 100.
The "vol_change_pct" variable stores the calculated percentage change.

Volume Spike Condition:

The "is_spike" variable is set to true if the volume change percentage (vol_change_pct) is greater than or equal to the spike percentage threshold.

Label Value:

The "label_value" variable is defined as the percentage change in volume (vol_change_pct) if a volume spike is detected. Otherwise, it is set to NaN (not a number).

Bullish and Bearish Conditions:

The "is_bullish" variable is set to true if the current closing price is greater than the open price, indicating a bullish bar.
The "is_bearish" variable is set to true if the current closing price is less than the open price, indicating a bearish bar.

Adding Labels to the Watchlist:

The "AddLabel" function is used to add labels to the watchlist based on certain conditions.
The label value displayed depends on whether a volume spike is detected and the bar's bullish or bearish nature.
If there is a volume spike and the bar is bullish, the label will be the percentage change in volume followed by " - Bullish".
If there is a volume spike and the bar is bearish, the label will be the percentage change in volume followed by " - Bearish".
The label color is set to green for bullish spikes, light red for bearish spikes, and black for non-spike bars.

In summary, this volume spike indicator calculates the relative volume and the percentage change in volume compared to the average volume. It then determines if there is a volume spike based on a specified threshold. Labels are added to the watchlist indicating the percentage change and whether the spike is bullish or bearish.

*****

To Install: Copy link below, Click Setup Top right, Open Shared Item, "CTRL V" to paste, Preview, Import. Move it over to your chart if not there.

Updated V2 Pull Back Indicator: https://tos.mx/eZnhche

Custom Volume Label: https://tos.mx/4vIM0Zz

Bid Ask Spread: https://tos.mx/Hz4C0iC

My Desk Top: https://tos.mx/53WHide

1 Min Pull Back Scan: https://tos.mx/46zqVAF
5 Min Pull Back Scan; https://tos.mx/T4ujTnE
15 Min Pull Back Scan; https://tos.mx/MqYs0PN

Here is the code for the Pull Back Indicator. If you imported the code above, you don't do this step:

Code:
####Begin Code####

#Pull Back Arrows V2

# Green Arrow = Possible Buy
# Yellow Arrow = Possible Sell
# Red Arrow Possible Short


input length = 50;
input multiplier = 1.5;
input emaLength = 8;
input emaLengthSell = 20;

def ma = MovingAverage(AverageType.SIMPLE, close, length);
def pullbackValue = ma - multiplier * Average(TrueRange(high, close, low), length);
def isPullback = close < pullbackValue;

def ema = ExpAverage(close, emaLength);
def isFirstGreenCandle = !isPullback and close > open and close[1] <= open[1] and close > ema;
def isFirstRedCandle = isPullback and close < open and close[1] >= open[1];

def isFirstGreenAfterRed = Sum(isFirstGreenCandle, 1) == 1;
def isFirstRedAfterGreen = Sum(isFirstRedCandle, 1) == 1;

def priceCrossesBelowEMA = close crosses below ExpAverage(close, emaLengthSell);

plot PullbackIndicator = isFirstGreenAfterRed;
PullbackIndicator.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PullbackIndicator.SetLineWeight(2);
PullbackIndicator.SetDefaultColor(Color.GREEN);

plot PullbackRedIndicator = isFirstRedAfterGreen;
PullbackRedIndicator.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
PullbackRedIndicator.SetLineWeight(2);
PullbackRedIndicator.SetDefaultColor(Color.RED);


#Volume Spike

# Set the percentage threshold for the spike
def spike_percentage_threshold = 0.0;

# Calculate the relative volume for the current bar
def rel_vol = volume / Average(volume, 50);

# Calculate the percentage change in volume relative to the average volume
def vol_change_pct = (rel_vol - 1.0) * 100.0;

# Determine if the current bar has a volume spike
def is_spike = vol_change_pct >= spike_percentage_threshold;

# Define the label value as the percentage change in volume if it is a spike, otherwise NaN
def label_value = if is_spike then vol_change_pct else Double.NaN;

# Determine if the current bar is bullish or bearish based on the close price
def is_bullish = close > open;
def is_bearish = close < open;

plot arrowDown = if priceCrossesBelowEMA then low else Double.NaN;
arrowDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
arrowDown.SetLineWeight(1);
arrowDown.SetDefaultColor(Color.YELLOW);

# Add the label to the watch list
AddLabel(yes, 
         if is_spike and is_bullish then Concat(AsPercent(vol_change_pct / 10000.0), " - BULLISH SPIKE" + "   ")
         else if is_spike and is_bearish then Concat(AsPercent(vol_change_pct / 10000.0), " - BEARISH SPIKE" + "   ")
         else "", 
         if is_spike and is_bullish then Color.GREEN 
         else if is_spike and is_bearish then Color.LIGHT_RED 
         else Color.BLACK);



###End Code###

 
Last edited:
Hi, very nice study, is there a way a watchlist column can be created for pull back on/off on a 5 min time frame when the tick pulled back. Appreciate your help in advance, thank you
 
Hi, very nice study, is there a way a watchlist column can be created for pull back on/off on a 5 min time frame when the tick pulled back. Appreciate your help in advance, thank you
This is the scan created for the pull back. You can open it in a watch list. Five Minute Pull Back Scan: https://tos.mx/6mTj8VV

If you prefer the watch list column indicator: http://tos.mx/ZCCBpu2
 
Last edited:
Hi thanks for this! Is there a way to set it to scan for a pullback to daily but on an hourly chart?
The ToS platform does not support across Timeframe filters and calculations in the Scan Hacker

MTF scripts are not allowed in the scanner, watchlists, or conditional orders
It is because of the fundamental way that the widgets work.
Before you start, the aggregation period is chosen.
It is locked in.

After that, the scanner executes all filter conditions solely within the aggregation chosen.
If the scanner encounters an aggregation period within the filter script that doesn't match what has already been chosen; it produces the error message: "secondary aggregations not allowed".
 

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
417 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