I hope Ihelped, sometimes I stick my nose in where I shouldn't lol@antwerks - thanks much for not only the study, but also the helpful comments!
As far as I’m concerned you can give any & all input you want!I hope Ihelped, sometimes I stick my nose in where I shouldn't lol
I worked across the weekend to get the code tweaked for the watchlist. Will update performance on a full scan. Your insight and experience is always appreciated.I hope Ihelped, sometimes I stick my nose in where I shouldn't lol
@whoDAT Do you have any idea why the up/down signals don't plot?
I am looking for a zigzag function that I can use in a custom watchlist column to provide a "heads up" that trend is shifting. I tried using criksdds AGAIG No Arrows but it is a repainter and does not work in a watchlist.
The goal is to change the background in the watchlist column based on trend direction and I think that if I can figure out why the up/down signals are not showing, I'll be able to capture the info.
View attachment 27075
Thanks.
Hi, I like your buy and sell signals. What indicator or thinkscript code are your buy and sell signals?
Thank you.
I've updated this a bit and am planning on making a post about my latest setup. It will be early next week when I make this and will reply to let you know.Hi, I like your buy and sell signals. What indicator or thinkscript code are your buy and sell signals?
Thank you.
# =========================================
# ANTWERKS UNIFIED ENGINE + SESSION INTELLIGENCE
# =========================================
declare lower;
# =========================
# INPUTS
# =========================
input fastLength = 9;
input slowLength = 21;
input atrLength = 14;
input expansionLevel = 0.3;
input stretchLevel = 0.8;
input higherAgg = AggregationPeriod.HOUR;
# 🔥 NEW SESSION CONTROLS
input useSessionFilter = yes;
input restrictToRTH = yes;
# =========================
# SESSION ENGINE (NEW)
# =========================
def isRTH =
SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) > 0;
def isEXT = !isRTH;
def sessionActive =
if !useSessionFilter then 1
else if restrictToRTH then isRTH
else 1;
# =========================
# CURRENT TF
# =========================
def fastEMA = ExpAverage(close, fastLength);
def slowEMA = ExpAverage(close, slowLength);
def atr = Average(TrueRange(high, close, low), atrLength);
def spread = (fastEMA - slowEMA) / atr;
# 🔥 MOMENTUM ENGINE
def spreadSlope = spread - spread[1];
def accelerating = spreadSlope > 0;
def decelerating = spreadSlope < 0;
# 🔥 TREND + STATE
def bullishTrend = fastEMA > slowEMA;
def bearishTrend = fastEMA < slowEMA;
def compression = AbsValue(spread) < expansionLevel;
def expandingUp = spread > expansionLevel and spread > spread[1];
def expandingDown = spread < -expansionLevel and spread < spread[1];
def trendStrength = AbsValue(fastEMA - slowEMA);
# 🔥 QUALITY FILTER (UNCHANGED CORE)
def validCompression =
compression and
trendStrength > atr * 0.5;
# =========================
# HIGHER TF
# =========================
def hClose = close(period = higherAgg);
def hFast = ExpAverage(hClose, fastLength);
def hSlow = ExpAverage(hClose, slowLength);
def higherBull = hFast > hSlow;
def higherBear = hFast < hSlow;
# =========================
# LIQUIDITY SWEEP ENGINE (MERGED)
# =========================
input sweepLookback = 10;
def sweepRefHigh = Highest(high[1], sweepLookback);
def sweepRefLow = Lowest(low[1], sweepLookback);
def sweepHigh =
high > sweepRefHigh and
close < sweepRefHigh and
close < open;
def sweepLow =
low < sweepRefLow and
close > sweepRefLow and
close > open;
# =========================
# PIVOT SWEEP ENGINE (MERGED)
# =========================
input pivotLength = 10;
def swingHigh =
high[pivotLength] == Highest(high, pivotLength * 2 + 1);
def swingLow =
low[pivotLength] == Lowest(low, pivotLength * 2 + 1);
rec lastHigh =
if swingHigh then high[pivotLength]
else lastHigh[1];
rec lastLow =
if swingLow then low[pivotLength]
else lastLow[1];
def bearSweep =
high > lastHigh and
close < lastHigh;
def bullSweep =
low < lastLow and
close > lastLow;
# =========================
# SIGNAL LOGIC (UNCHANGED CORE)
# =========================
def pullback =
bullishTrend and
higherBull and
compression and
spread > 0;
def qualifiedPullback =
pullback and sweepLow;
def momentumFailure =
spread > expansionLevel and
spreadSlope < 0 and
spreadSlope[1] < 0;
# =========================
# 🚫 SESSION FILTER APPLIED HERE (KEY)
# =========================
def finalLong =
qualifiedPullback
and sessionActive;
def finalShort =
momentumFailure
and sessionActive;
# =========================
# PLOTS
# =========================
plot SpreadATR = spread;
SpreadATR.SetLineWeight(2);
SpreadATR.AssignValueColor(
if spread > stretchLevel then Color.GREEN
else if spread > expansionLevel then Color.DARK_GREEN
else if spread < -stretchLevel then Color.RED
else if spread < -expansionLevel then Color.DARK_RED
else Color.YELLOW
);
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
# =========================
# SIGNAL ARROWS (NOW SESSION-AWARE)
# =========================
plot LongSignal =
if finalLong then spread else Double.NaN;
LongSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LongSignal.SetDefaultColor(Color.CYAN);
LongSignal.SetLineWeight(3);
plot ShortSignal =
if finalShort then spread else Double.NaN;
ShortSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ShortSignal.SetDefaultColor(Color.YELLOW);
ShortSignal.SetLineWeight(3);
# =========================
# SWEEP VISUALS (UNCHANGED)
# =========================
plot SweepUp =
if sweepLow then spread else Double.NaN;
SweepUp.SetPaintingStrategy(PaintingStrategy.POINTS);
SweepUp.SetDefaultColor(Color.GREEN);
plot SweepDown =
if sweepHigh then spread else Double.NaN;
SweepDown.SetPaintingStrategy(PaintingStrategy.POINTS);
SweepDown.SetDefaultColor(Color.RED);
# =========================
# SESSION LABELING (NEW)
# =========================
AddLabel(yes,
if isRTH then "SESSION: RTH"
else "SESSION: EXTENDED",
if isRTH then Color.GREEN else Color.GRAY
);
AddLabel(useSessionFilter,
if !sessionActive then "SIGNALS BLOCKED (EXT)"
else "SIGNALS ACTIVE",
if sessionActive then Color.GREEN else Color.RED
);
# =========================
# ORIGINAL LABELS PRESERVED
# =========================
AddLabel(higherBull and bullishTrend,
"MTF ALIGN: BULL",
Color.GREEN);
AddLabel(pullback,
"PULLBACK READY",
Color.YELLOW);
AddLabel(expandingUp,
"EXPANSION TRIGGER",
Color.CYAN);
# =========================
# MOMENTUM SHIFT DOTS (RESTORED)
# =========================
def momentumShiftUp =
accelerating
and spread > 0
and spread[1] <= 0;
plot momentumShiftUp1 =
if momentumShiftUp then spread else Double.NaN;
momentumShiftUp1.SetPaintingStrategy(PaintingStrategy.POINTS);
MomentumShiftUp1.SetDefaultColor(Color.CYAN);
MomentumShiftUp1.SetLineWeight(3);
plot MomentumShiftDown =
if decelerating and spread > 0 then spread else Double.NaN;
MomentumShiftDown.SetPaintingStrategy(PaintingStrategy.POINTS);
MomentumShiftDown.SetDefaultColor(Color.YELLOW);
MomentumShiftDown.SetLineWeight(2);
Hey Antwerks, I've tried and failed to find the script you put out to add bubbles for this study. If you get a chance can you put it here?Just for anyone interested I tweaked the EMA_TREND_METER for better reads and signals
Code:# ========================================= # ANTWERKS UNIFIED ENGINE + SESSION INTELLIGENCE # ========================================= declare lower; # ========================= # INPUTS # ========================= input fastLength = 9; input slowLength = 21; input atrLength = 14; input expansionLevel = 0.3; input stretchLevel = 0.8; input higherAgg = AggregationPeriod.HOUR; # 🔥 NEW SESSION CONTROLS input useSessionFilter = yes; input restrictToRTH = yes; # ========================= # SESSION ENGINE (NEW) # ========================= def isRTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) > 0; def isEXT = !isRTH; def sessionActive = if !useSessionFilter then 1 else if restrictToRTH then isRTH else 1; # ========================= # CURRENT TF # ========================= def fastEMA = ExpAverage(close, fastLength); def slowEMA = ExpAverage(close, slowLength); def atr = Average(TrueRange(high, close, low), atrLength); def spread = (fastEMA - slowEMA) / atr; # 🔥 MOMENTUM ENGINE def spreadSlope = spread - spread[1]; def accelerating = spreadSlope > 0; def decelerating = spreadSlope < 0; # 🔥 TREND + STATE def bullishTrend = fastEMA > slowEMA; def bearishTrend = fastEMA < slowEMA; def compression = AbsValue(spread) < expansionLevel; def expandingUp = spread > expansionLevel and spread > spread[1]; def expandingDown = spread < -expansionLevel and spread < spread[1]; def trendStrength = AbsValue(fastEMA - slowEMA); # 🔥 QUALITY FILTER (UNCHANGED CORE) def validCompression = compression and trendStrength > atr * 0.5; # ========================= # HIGHER TF # ========================= def hClose = close(period = higherAgg); def hFast = ExpAverage(hClose, fastLength); def hSlow = ExpAverage(hClose, slowLength); def higherBull = hFast > hSlow; def higherBear = hFast < hSlow; # ========================= # LIQUIDITY SWEEP ENGINE (MERGED) # ========================= input sweepLookback = 10; def sweepRefHigh = Highest(high[1], sweepLookback); def sweepRefLow = Lowest(low[1], sweepLookback); def sweepHigh = high > sweepRefHigh and close < sweepRefHigh and close < open; def sweepLow = low < sweepRefLow and close > sweepRefLow and close > open; # ========================= # PIVOT SWEEP ENGINE (MERGED) # ========================= input pivotLength = 10; def swingHigh = high[pivotLength] == Highest(high, pivotLength * 2 + 1); def swingLow = low[pivotLength] == Lowest(low, pivotLength * 2 + 1); rec lastHigh = if swingHigh then high[pivotLength] else lastHigh[1]; rec lastLow = if swingLow then low[pivotLength] else lastLow[1]; def bearSweep = high > lastHigh and close < lastHigh; def bullSweep = low < lastLow and close > lastLow; # ========================= # SIGNAL LOGIC (UNCHANGED CORE) # ========================= def pullback = bullishTrend and higherBull and compression and spread > 0; def qualifiedPullback = pullback and sweepLow; def momentumFailure = spread > expansionLevel and spreadSlope < 0 and spreadSlope[1] < 0; # ========================= # 🚫 SESSION FILTER APPLIED HERE (KEY) # ========================= def finalLong = qualifiedPullback and sessionActive; def finalShort = momentumFailure and sessionActive; # ========================= # PLOTS # ========================= plot SpreadATR = spread; SpreadATR.SetLineWeight(2); SpreadATR.AssignValueColor( if spread > stretchLevel then Color.GREEN else if spread > expansionLevel then Color.DARK_GREEN else if spread < -stretchLevel then Color.RED else if spread < -expansionLevel then Color.DARK_RED else Color.YELLOW ); plot ZeroLine = 0; ZeroLine.SetDefaultColor(Color.GRAY); # ========================= # SIGNAL ARROWS (NOW SESSION-AWARE) # ========================= plot LongSignal = if finalLong then spread else Double.NaN; LongSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP); LongSignal.SetDefaultColor(Color.CYAN); LongSignal.SetLineWeight(3); plot ShortSignal = if finalShort then spread else Double.NaN; ShortSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); ShortSignal.SetDefaultColor(Color.YELLOW); ShortSignal.SetLineWeight(3); # ========================= # SWEEP VISUALS (UNCHANGED) # ========================= plot SweepUp = if sweepLow then spread else Double.NaN; SweepUp.SetPaintingStrategy(PaintingStrategy.POINTS); SweepUp.SetDefaultColor(Color.GREEN); plot SweepDown = if sweepHigh then spread else Double.NaN; SweepDown.SetPaintingStrategy(PaintingStrategy.POINTS); SweepDown.SetDefaultColor(Color.RED); # ========================= # SESSION LABELING (NEW) # ========================= AddLabel(yes, if isRTH then "SESSION: RTH" else "SESSION: EXTENDED", if isRTH then Color.GREEN else Color.GRAY ); AddLabel(useSessionFilter, if !sessionActive then "SIGNALS BLOCKED (EXT)" else "SIGNALS ACTIVE", if sessionActive then Color.GREEN else Color.RED ); # ========================= # ORIGINAL LABELS PRESERVED # ========================= AddLabel(higherBull and bullishTrend, "MTF ALIGN: BULL", Color.GREEN); AddLabel(pullback, "PULLBACK READY", Color.YELLOW); AddLabel(expandingUp, "EXPANSION TRIGGER", Color.CYAN); # ========================= # MOMENTUM SHIFT DOTS (RESTORED) # ========================= def momentumShiftUp = accelerating and spread > 0 and spread[1] <= 0; plot momentumShiftUp1 = if momentumShiftUp then spread else Double.NaN; momentumShiftUp1.SetPaintingStrategy(PaintingStrategy.POINTS); MomentumShiftUp1.SetDefaultColor(Color.CYAN); MomentumShiftUp1.SetLineWeight(3); plot MomentumShiftDown = if decelerating and spread > 0 then spread else Double.NaN; MomentumShiftDown.SetPaintingStrategy(PaintingStrategy.POINTS); MomentumShiftDown.SetDefaultColor(Color.YELLOW); MomentumShiftDown.SetLineWeight(2);
Bubbles? What bubbles? this script never had bubbles. If you are referring to the buy and sell bubbles they are here _ https://usethinkscript.com/threads/...tup-for-thinkorswim.18436/page-10#post-153512Hey Antwerks, I've tried and failed to find the script you put out to add bubbles for this study. If you get a chance can you put it here?
Sorry for my confusion . I blame it on old age.Bubbles? What bubbles? this script never had bubbles. If you are referring to the buy and sell bubbles they are here _ https://usethinkscript.com/threads/...tup-for-thinkorswim.18436/page-10#post-153512
Join the crowd LOLSorry for my confusion . I blame it on old age.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
| Thread starter | Similar threads | Forum | Replies | Date |
|---|---|---|---|---|
|
|
Multiple Non-Linear Regression [ChartPrime] for ThinkOrSwim | Custom | 0 | |
|
|
Running Count of Non-Overlapping Bar Bodies For ThinkOrSwim | Custom | 4 | |
| S | Fractal Chaos Bands for ThinkorSwim non-repainting version | Custom | 0 |
Start a new thread and receive assistance from our community.
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.
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.