Repaints Single Candle Entry (MTF) [Wang] For ThinkOrSwim

Repaints

0DTE

New member
Author states: The "Single Candle Entry Model" indicator is designed to help traders through a simple yet effective trading strategy. This indicator automatically detects candles that encompass both the high and low of the previous candle, creating key price zones for potential market entries.

mxmYDgB.png


Here is the original Tradingview code:
https://www.tradingview.com/script/...e-Entry-with-Multi-Timeframe-Wang-Indicators/

For the new ThinkOrSwim code, you must scroll down to the next post
 
Last edited by a moderator:

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

Hi there,
I was wondering if anyone can convert this pinescript to Thinkorswim Thinkscript. I tried to plug the pinescript into chatgpt but I kept on getting errors. Thanks.
Here is link to the open souce pinescript
https://www.tradingview.com/script/...e-Entry-with-Multi-Timeframe-Wang-Indicators/

Here is an attempt, it's a working draft, it ain't pretty maybe one of the "real" coders can take a whack at it.

Code:
# === SINGLE CANDLE ENTRY MODEL (SCE) - THINKORSWIM ===
# Developed with inspiration from DaveTeaches
declare upper;

# === USER INPUTS ===
input enableHTF1 = yes;
input htf1TimeFrame = AggregationPeriod.FOUR_HOURS;
input enableHTF2 = yes;
input htf2TimeFrame = AggregationPeriod.DAY;
input enableHTF3 = no;
input htf3TimeFrame = AggregationPeriod.WEEK;

# === REGULAR SCE DETECTION ===
def prevHigh = high[1];
def prevLow = low[1];

def isSCE = high > prevHigh and low < prevLow;
def lastSCE = isSCE within 10 bars;  # Ensures labels remain visible for recent events

# === PLOT SCE LABELS ===
AddLabel(lastSCE, "SCE", if close > open then Color.GREEN else Color.RED);
Alert(isSCE, "Single Candle Entry detected!", Alert.BAR, Sound.Ring);

# === PLOT RETRACEMENT LEVELS (30%, 50%, 70%) ===
def level30 = low + (high - low) * 0.30;
def level50 = (high + low) / 2;
def level70 = low + (high - low) * 0.70;

plot Retrace30 = if isSCE then level30 else Double.NaN;
plot Retrace50 = if isSCE then level50 else Double.NaN;
plot Retrace70 = if isSCE then level70 else Double.NaN;

Retrace30.SetDefaultColor(Color.WHITE);
Retrace50.SetDefaultColor(Color.WHITE);
Retrace70.SetDefaultColor(Color.WHITE);

Retrace30.SetStyle(Curve.SHORT_DASH);
Retrace50.SetStyle(Curve.SHORT_DASH);
Retrace70.SetStyle(Curve.SHORT_DASH);

# === HTF SCE DETECTION ===
def htf1PrevHigh = high(period = htf1TimeFrame)[1];
def htf1PrevLow = low(period = htf1TimeFrame)[1];
def htf1SCE = enableHTF1 and high(period = htf1TimeFrame) > htf1PrevHigh and low(period = htf1TimeFrame) < htf1PrevLow;

def htf2PrevHigh = high(period = htf2TimeFrame)[1];
def htf2PrevLow = low(period = htf2TimeFrame)[1];
def htf2SCE = enableHTF2 and high(period = htf2TimeFrame) > htf2PrevHigh and low(period = htf2TimeFrame) < htf2PrevLow;

def htf3PrevHigh = high(period = htf3TimeFrame)[1];
def htf3PrevLow = low(period = htf3TimeFrame)[1];
def htf3SCE = enableHTF3 and high(period = htf3TimeFrame) > htf3PrevHigh and low(period = htf3TimeFrame) < htf3PrevLow;

# === PLOT HTF BOXES ===
AddCloud(if htf1SCE then htf1PrevHigh else Double.NaN, if htf1SCE then htf1PrevLow else Double.NaN, Color.YELLOW, Color.YELLOW);
AddCloud(if htf2SCE then htf2PrevHigh else Double.NaN, if htf2SCE then htf2PrevLow else Double.NaN, Color.YELLOW, Color.GREEN);
AddCloud(if htf3SCE then htf3PrevHigh else Double.NaN, if htf3SCE then htf3PrevLow else Double.NaN, Color.YELLOW, Color.ORANGE);

# === LABEL HTF SCE ===
def lastHTF1 = htf1SCE within 10 bars;
def lastHTF2 = htf2SCE within 10 bars;
def lastHTF3 = htf3SCE within 10 bars;

AddLabel(lastHTF1, "HTF1 SCE", Color.YELLOW);
AddLabel(lastHTF2, "HTF2 SCE", Color.GREEN);
AddLabel(lastHTF3, "HTF3 SCE", Color.ORANGE);
 
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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