Repaints Trend Reversal for ThinkorSwim

Repaints
Status
Not open for further replies.
@9inemill According to the code:

Code:
plot Colorbars = if buysignal == 1 then 1 else if sellsignal == 1 then 2 else if buysignal == 0 or sellsignal == 0 then 3 else 0;
Colorbars.Hide();
Colorbars.DefineColor("Buy_Signal_Bars", Color.GREEN);
Colorbars.DefineColor("Sell_Signal_Bars", Color.RED);
Colorbars.DefineColor("Neutral", Color.PLUM);

Purple bubbles = neutral.

I don't think you can get sound alert for this indicator because of its repainting factor.

The following seems to work as a sound alert for this indicator:

Code:
#Alerts
input alerts = yes;
def bullish2 = if signal > 0 and signal[1] <= 0 then 1 else 0;
def bearish2 = if signal < 0 and signal[1] >= 0 then 1 else 0;
Alert(alerts and bullish2[1] == 1, "Up   ", Alert.BAR, Sound.Chimes);
Alert(alerts and bearish2[1] == 1, "Down ", Alert.BAR, Sound.Bell);
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

@SleepyZ Sure, you can write it but the repaint will cause false Alerts... I have Alerts in my copy but had to turn them off and then just stopped using this Study altogether... I've tried a bunch of trend reversals and written an few but they just aren't all that reliable... The Fractal version is the most reliable of the bunch as I recall...
 
I find this script very helpful on the chart but I still can't get it to scan. I have a hard time getting scripts to scan in TOS. What am i doing wrong?
 
I find this script very helpful on the chart but I still can't get it to scan. I have a hard time getting scripts to scan in TOS. What am i doing wrong?

How are you going about creating your scans and what errors are you receiving...??? I don't think this Study plays well with the scanner as has been covered previously...
 
I tried to import your trend reversal indicator, it worked but the scanner didn't work. It won't allow me to save in scan tab. Can you send me code for trend reversal scanner that worked?
 
@andyrubie @Godwin @rad14733 @BenTen @Angry_Raven

This is the code I have been using for the scanner. You have to remove the fibs otherwise it will give a complex error and not run. I also took out some alerts and plots, but the main two for the signals (bullish, bearish) are the ones you really need. I've only built the scanner on my end to search for S&P 500 stocks and for potential bullish signals. So in my scanner I'm looking for: UpArrow is true within 2 bars.

Code:
def price = close;
def superfast_length = 9;
def fast_length = 14;
def slow_length = 21;
def displace = 0;

def mov_avg9 = ExpAverage(price[-displace], superfast_length);
def mov_avg14 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);

#moving averages
def Superfast = mov_avg9;
def Fast = mov_avg14;
def Slow = mov_avg21;

def buy = mov_avg9 > mov_avg14 and mov_avg14 > mov_avg21 and low > mov_avg9;
def stopbuy = mov_avg9 <= mov_avg14;
def buynow = !buy[1] and buy;
def buysignal = CompoundValue(1, if buynow and !stopbuy then 1 else if buysignal[1] == 1 and stopbuy then 0 else buysignal[1], 0);

def Buy_Signal = buysignal[1] == 0 and buysignal == 1;
def Momentum_Down = buysignal[1] == 1 and buysignal == 0;

def sell = mov_avg9 < mov_avg14 and mov_avg14 < mov_avg21 and high < mov_avg9;
def stopsell = mov_avg9 >= mov_avg14;
def sellnow = !sell[1] and sell;
def sellsignal = CompoundValue(1, if sellnow and !stopsell then 1 else if sellsignal[1] == 1 and stopsell then 0 else sellsignal[1], 0);
def Sell_Signal = sellsignal[1] == 0 and sellsignal;


input method = {default average, high_low};
def bubbleoffset = .0005;
def percentamount = .01;
def revAmount = .05;
def atrreversal = 2.0;
def atrlength = 5;
def pricehigh = high;
def pricelow = low;
def averagelength = 5;
def averagetype = AverageType.EXPONENTIAL;
def mah = MovingAverage(averagetype, pricehigh, averagelength);
def mal = MovingAverage(averagetype, pricelow, averagelength);
def priceh = if method == method.high_low then pricehigh else mah;
def pricel = if method == method.high_low then pricelow else mal;
def EI = ZigZagHighLow("price h" = priceh, "price l" = pricel, "percentage reversal" = percentamount, "absolute reversal" = revAmount, "atr length" = atrlength, "atr reversal" = atrreversal);
rec EISave = if !IsNaN(EI) then EI else GetValue(EISave, 1);
def chg = (if EISave == priceh then priceh else pricel) - GetValue(EISave, 1);
def isUp = chg >= 0;
def EIL = if !IsNaN(EI) and !isUp then pricel else GetValue(EIL, 1);
def EIH = if !IsNaN(EI) and isUp then priceh else GetValue(EIH, 1);
def dir = CompoundValue(1, if EIL != EIL[1] or pricel == EIL[1] and pricel == EISave then 1 else if EIH != EIH[1] or priceh == EIH[1] and priceh == EISave then -1 else dir[1], 0);
def signal = CompoundValue(1, if dir > 0 and pricel > EIL then if signal[1] <= 0 then 1 else signal[1] else if dir < 0 and priceh < EIH then if signal[1] >= 0 then -1 else signal[1] else signal[1], 0);

def bullish2 = signal > 0 and signal[1] <= 0;
plot upArrow = bullish2;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetDefaultColor(CreateColor(145, 210, 144));

def bearish2 = signal < 0 and signal[1] >= 0;
plot downArrow = bearish2;
downArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
downArrow.SetDefaultColor(CreateColor(255, 15, 10));

AddChartBubble(signal > 0 and signal[1] <= 0, if isUp then low else high, if signal > 0 and signal[1] <= 0 then "" + low else "" , Color.Lime, no);

AddChartBubble(signal < 0 and signal[1] >= 0, if IsUp then low else high, if signal < 0 and signal[1] >= 0 then "" + low else "" , Color.LIGHT_ORANGE, no);
 
I really like this script, but is there any way to make the bubble show up to the Left of the candles? It always shows up and covers the current candle; driving me crazy....
 
Ben 10 to the rescue!... Again!

@rad14733 Read that, it only shows how to make bubbles, doesn't show how to make them appear on one side or the other. So that's why I asked to see if anyone better than me had a solution. I'll start letting you guys know that I read something in the future.
 
Ben 10 to the rescue!... Again!

@rad14733 Read that, it only shows how to make bubbles, doesn't show how to make them appear on one side or the other. So that's why I asked to see if anyone better than me had a solution. I'll start letting you guys know that I read something in the future.

What you found there was that it obviously can't be done, otherwise it would have been in the documentation... 💡 Go with the suggestion provided by @BenTen...
 
What you found there was that it obviously can't be done, otherwise it would have been in the documentation... 💡 Go with the suggestion provided by @BenTen...
Oh, ok well thanks for your super helpful post, jackass. And nothing obvious about it, because it's a beginners bubble tutorial; I was hoping for something else that was maybe 1 level deeper so I asked sorry to bother the forum.... And I did go with Ben10's suggestion, as you can see by my post where I said "Ben 10 to the rescue!"

Switching you to ignore
 
@CaptainNORDO, here is an example code I made to help further explain the addchartbubble function.

Code:
#Addchartbubble example on how to move a bubble in the right expansion area from side to side and up/down. The same movements can be applied to bubblles elsewhere on a chart. Also how to add text and data to a bubble.

input bubblemoverside_to_side = 3; #used to move the bubble left and right
def n = bubblemoverside_to_side;
def n1 = n + 1;
input bubblemover_updown = 2; #used to move the bubble up and down
AddChartBubble(IsNaN(close[n]),
close[n1] + TickSize() * bubblemover_updown,
"Enter Text Here\nEnter another line of text by using the \n forwardslash n (\ n) function" + "\nYou can add data eg " + close[n1],
Color.WHITE, yes);
#bubbles automatically stacked when reference to the same point on chart
AddChartBubble(IsNaN(close[n]),
close[n1] + TickSize() * bubblemover_updown,
"Enter Text Here\nEnter another line of text by using the \n forwardslash n (\ n) function" + "\nYou can add data eg " + close[n1],
Color.CYAN, yes);

As bubble orientation is not currently (although often requested of TOS) part of addchartbubble functtion, in regards to your trendreversal indicator bubble request, here is alternate way to place the bubbles at the topline or botline. You could also use the bubblemover_updown from above. https://tos.mx/z4NbIlj
 
@Godwin I had the same problem. Change your scan to a specific watchlist and the complex error will go away. Also, make sure the scan is set to within 3 bars. That should resolve the issue. If you have several watchlists, then duplicate the scan for each watchlist by saving the scan as a different name, then change it to scan that particular watchlist. If you look up just above the filters you'll see the "scan in:' selection which will show your various watchlists. That resolved that issue for me. Been working great ever since!

Question for the code geniuses. Have any of you heard of a reversal spiral? I see this on various stock charts, but is there a way to develop a scan for it? Or is that possibly already in this reversal scan?
 
Status
Not open for further replies.

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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