Looking for Suggestions to Improve My Trap Zone Indicator

TRADERSAM

Member
VIP
I put together a ThinkScript indicator that tries to find important trap zones by looking for volume-confirmed breakouts of recent highs and lows. It draws two horizontal lines—one at the last big high breakout and one at the last big low breakout. The lines change color based on whether the price is above or below them, turning green when price is above (like support) and red when below (like resistance). It’s a simple way to visualize key levels, but honestly, it’s not working as well as I hoped. The signals can be unclear or unreliable at times. I’m open to any suggestions or improvements, like better ways to track states, filter false breakouts, or confirm signals. I’d appreciate any help to make it more useful. And feel free to roast my coding skills lol—I’m here to learn! Here is the code:
Code:
input lookback = 20;
input VolumeMultiplier = 1.5;

def h = high;
def l = low;
def c = close;
def v = volume;
def na = Double.NaN;

def HL = Highest(h, lookback);
def LL = Lowest(l, lookback);

def BA = h > HL[1];
def BB = l < LL[1];
def avgV = Average(v, lookback);
def VS = v > avgV * VolumeMultiplier;
def BU = BA and VS;
def BD = BB and VS;

def CBIU = c < HL and BU[1];
def CBID = c > LL and BD[1];
def TU = CBIU;
def TD = CBID;

def trapUpValue = if TU then HL else trapUpValue[1];
def trapDownValue = if TD then LL else trapDownValue[1];

def showTrapHigh = CompoundValue(1, if TU then 1 else showTrapHigh[1], 0);
def showTrapLow = CompoundValue(1, if TD then 1 else showTrapLow[1], 0);

# Color logic: green if price above line, red if below
def highLineColorGreen = c > trapUpValue;
def lowLineColorGreen = c > trapDownValue;

# Plot Trap High Line
plot TrapHigh_Resist = if showTrapHigh then trapUpValue else na;
TrapHigh_Resist.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TrapHigh_Resist.AssignValueColor(
    if highLineColorGreen then Color.GREEN else Color.RED
);
TrapHigh_Resist.SetLineWeight(2);

# Plot Trap Low Line
plot TrapLow_Support = if showTrapLow then trapDownValue else na;
TrapLow_Support.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
TrapLow_Support.AssignValueColor(
    if lowLineColorGreen then Color.GREEN else Color.RED
);
TrapLow_Support.SetLineWeight(2);

# Trap arrows
plot TrapUpArrow = TU;
TrapUpArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
TrapUpArrow.SetDefaultColor(Color.RED);

plot TrapDownArrow = TD;
TrapDownArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
TrapDownArrow.SetDefaultColor(Color.GREEN);
Thanks in advance!
 
Solution
Man there is no beating this one https://tos.mx/!n2c4uHKE (converted by Samer800) you can see the testing and Break outs on the supply and demands bars - these have stood the test of time for me
1754545633243.png

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