Continuation/Reversal Indicator For ThinkOrSwim

ExtremelyRough

New member
Hi,

I have a simple concept here, continuation/reversal indicator. Simply put, this will look for large candles where the body is the majority of the candle and it will determine if the candle is a continuation or reversal. Entry will be at the open of the next candle.

2025-08-28-TOS_CHARTS.png

I recommend using it on the 15min or higher. I have good results with the 15 and 30 minute for scalps and the daily for swings. I aim for 3 points per scalp.

indicatorwithlines.png

Optionally you can print entry lines as well as tp and sl lines calculated from average up and down moves from candle open.


Code:
# Kishan - Candle Data Analysis for Strength and Follow-Through

# -----------------------
# Inputs
# -----------------------
input startTime = 1000;          # Skip first 30min
input endTime   = 1530;          # Skip last 30min
input showAvgCandle = yes;
input showPercentOfCandle = yes;
input percentageThreshold = 100;
input length = 163;              # Period to average over (adjustable)

# -----------------------
# Session Filter
# -----------------------
def inSession = SecondsFromTime(startTime) >= 0 and SecondsTillTime(endTime) >= 0;

# -----------------------
# Candle Calculations
# -----------------------
def candleSize = high - low;
def bodySize = AbsValue(close - open);
def greenCandle = close > open;

# -----------------------
# Directional Moves
# -----------------------
def upCandle = high > high[1];
def downCandle = low < low[1];

# -----------------------
# Calculate average move up and down from open
# -----------------------
def upMove = high - open;
def downMove = open - low;
def averageUpMove = Average(upMove, 50);
def averageDownMove = Average(downMove, 50);

# -----------------------
# Volume Analysis
# -----------------------
def volumeAvgBuffer = Average(volume, 50) * 1.3;
def volumeGrowth = volume >= (volume[1] * 1.5);
def lowVolume = volume < volumeAvgBuffer;
def highVolume = volumeGrowth and volume > volumeAvgBuffer;

# -----------------------
# Candle Averages & Percentages
# -----------------------
def averageCandleSize = Average(candleSize, length);
def percentageOfAvg = if averageCandleSize != 0 then (candleSize / averageCandleSize) * 100 else 0;
def percentageOfBody = if candleSize != 0 then (bodySize / candleSize) * 100 else 0;

# -----------------------
# Entry / Reversal Signals
# -----------------------
plot entryLong = inSession and !volumeGrowth and greenCandle and percentageOfAvg > percentageThreshold and percentageOfBody >= 60;
plot entryShort = inSession and !volumeGrowth and !greenCandle and percentageOfAvg > percentageThreshold and percentageOfBody >= 60;
plot reversalLong = inSession and highVolume and !greenCandle and percentageOfAvg > percentageThreshold;
plot reversalShort = inSession and highVolume and greenCandle and percentageOfAvg > percentageThreshold;

# Painting strategies
entryLong.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
entryLong.SetDefaultColor(Color.LIGHT_GREEN);

entryShort.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
entryShort.SetDefaultColor(Color.PINK);

reversalLong.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
reversalLong.SetDefaultColor(Color.GREEN);

reversalShort.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
reversalShort.SetDefaultColor(Color.RED);

# -----------------------
# Labels
# -----------------------
AddLabel(showAvgCandle, "Average Candle Size: " + Round(averageCandleSize, 2), Color.GRAY);
AddLabel(showPercentOfCandle, "Body to Candle %: " + Round(percentageOfBody, 1) + "%",
         if percentageOfBody > 60 then Color.GREEN else Color.RED);

# -----------------------
# Trade Lines & Winning Trades
# -----------------------

# Signals for next-bar entry
def nextBarEntryLong = entryLong[1] or reversalLong[1];
def nextBarEntryShort = entryShort[1] or reversalShort[1];

# Entry price = next candle open
def entryPriceLong = if nextBarEntryLong then open else Double.NaN;
def entryPriceShort = if nextBarEntryShort then open else Double.NaN;

# Targets based on average moves
def takeProfitLong = if !IsNaN(entryPriceLong) then entryPriceLong + averageUpMove else Double.NaN;
def stopLossLong = if !IsNaN(entryPriceLong) then entryPriceLong - (averageDownMove * 1.2) else Double.NaN;

def takeProfitShort = if !IsNaN(entryPriceShort) then entryPriceShort - averageDownMove else Double.NaN;
def stopLossShort = if !IsNaN(entryPriceShort) then entryPriceShort + (averageUpMove * 1.2) else Double.NaN;

# Plot Entry Line
plot entryLongLine = entryPriceLong;
entryLongLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
entryLongLine.SetDefaultColor(Color.BLUE);
entryLongLine.SetLineWeight(2);

plot entryShortLine = entryPriceShort;
entryShortLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
entryShortLine.SetDefaultColor(Color.ORANGE);
entryShortLine.SetLineWeight(2);

# Plot TP & SL as dotted lines
plot tpLongLine = takeProfitLong;
tpLongLine.SetPaintingStrategy(PaintingStrategy.DASHES);
tpLongLine.SetDefaultColor(Color.LIGHT_GREEN);

plot slLongLine = stopLossLong;
slLongLine.SetPaintingStrategy(PaintingStrategy.DASHES);
slLongLine.SetDefaultColor(Color.PINK);

plot tpShortLine = takeProfitShort;
tpShortLine.SetPaintingStrategy(PaintingStrategy.DASHES);
tpShortLine.SetDefaultColor(Color.LIGHT_GREEN);

plot slShortLine = stopLossShort;
slShortLine.SetPaintingStrategy(PaintingStrategy.DASHES);
slShortLine.SetDefaultColor(Color.PINK);

Share link: Continuation/Reversal
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
243 Online
Create Post

Similar threads

Similar threads

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