Convert Future Bar Repainter to a Current Bar Non-Repainter

Vinnertrade

New member
Can someone please help create a scanner and watchlist column for the following indicator?

I understand that the indicator references future candles, which are not supported in Thinkorswim scanners. I am looking for a scanner-compatible version that works only with confirmed/current and historical bars.

Desired scanner behavior​

  • A ticker should appear in the scan when a buy signal is triggered.
  • It should remain in the scan results until a sell signal is triggered.
  • Conversely, once a sell signal occurs, the ticker should no longer appear in the buy-signal scan.

Desired watchlist column​

I would also like a custom watchlist column that displays:

  • The current signal state: Buy, Sell, or Neutral/Blank.
  • The price at which the most recent active signal was triggered—for example, the entry price from the latest buy signal.
The key requirement is that the scan retains symbols after the original buy bar, rather than showing them only on the exact bar where the buy signal occurs.
Code:
input signalOffsetFactor = 0.20;

def signalOffset = Average(TrueRange(high, close, low), 9) * signalOffsetFactor;
plot Data = hlc3;

def triggerSell = If(If(close[-1] < high, 1, 0) and (hlc3[-2] < close[-1] or hlc3[-3] < close[-1]), 1, 0);

def triggerBuy = If(If(close[-1] > low, 1, 0) and (hlc3[-2] > close[-1] or hlc3[-3] > close[-1]), 1, 0);

rec buySellSwitch = If(triggerSell, 1, If(triggerBuy, 0, buySellSwitch[1]));

def thirdBarClosed = If(IsNaN(hlc3[-3]), 0, 1);

plot SBS = If(triggerSell and thirdBarClosed and !buySellSwitch[1], high + signalOffset, If(triggerBuy and thirdBarClosed and buySellSwitch[1], low - signalOffset, Double.NaN));

SBS.SetStyle(Curve.FIRM);
SBS.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SBS.SetLineWeight(2);

SBS.AssignValueColor(if triggerSell then
if thirdBarClosed then
#UpPos
CreateColor(255, 0, 0) else
#UpNeg
CreateColor(255, 0, 0)
else if triggerBuy then
#DnPos
CreateColor(0, 255, 0) else
#DnNeg
CreateColor(0, 255, 0));

# --------------------------------------------------
# BUY ARROW
# --------------------------------------------------

plot BuyArrow =
    If(triggerBuy and thirdBarClosed and buySellSwitch[1],
       low - signalOffset,
       Double.NaN);

BuyArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuyArrow.SetDefaultColor(Color.GREEN);
BuyArrow.SetLineWeight(2);

# --------------------------------------------------
# SELL ARROW
# --------------------------------------------------

plot SellArrow =
    If(triggerSell and thirdBarClosed and !buySellSwitch[1],
       high + signalOffset,
       Double.NaN);

SellArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellArrow.SetDefaultColor(Color.RED);
SellArrow.SetLineWeight(2);

# --------------------------------------------------
# BUY BUBBLE
# --------------------------------------------------

AddChartBubble(
    triggerBuy and thirdBarClosed and buySellSwitch[1],
    low - signalOffset,
    "B " + AsPrice(close),
    Color.GREEN,
    no
);

# --------------------------------------------------
# SELL BUBBLE
# --------------------------------------------------

AddChartBubble(
    triggerSell and thirdBarClosed and !buySellSwitch[1],
    high + signalOffset,
    "S " + AsPrice(close),
    Color.RED,
    yes
);
 
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
1401 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