Repaints Trend Reversal for ThinkorSwim

Repaints
Status
Not open for further replies.
@BenTen I added the alert code,
#Alerts
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));
Alert(downArrow, " ", Alert.Bar, Sound.Chimes);
Alert(upArrow, " ", Alert.Bar, Sound.Bell);
to the end of the code and I am still not getting the alerts, is it something I am doing wrong? I know its not my thinkorswim because alerts on the supertrend indicator work.
 

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

@Newbie_789456 Thank you for taking the initiative to re-optimize the codebase. We appreciate it.

You're correct in saying that this indicator uses the ZigZagHighLo component and so it will repaint. As a result, backtesting this script will likely be impossible.

Hello Ben and all!

Call me stubborn if you will, but I just can't let go of the idea of backtesting this. I really suspect this can be quite profitable under certain market conditions, hence the need to backtest systematically.

So I had a few marathon sessions to come up with the closest I could get so far to the strategy including all the false signals... (i.e. the strategy enters trades at each signal (sticky or repainted) and reverses at the next signal or gets stopped out.

WARNING: this is about 90-95% there but at this point myy eyes are starting to cross and i cant think very straight anymore..

So I am dropping the link here for you folks to take a look and hopefully someone can help out in closing the 5-10% gap remaining in getting the code 100% correct...

http://tos.mx/LDjPU09

Would really appreciate if someone wiht a fresh mind/pair of eyes could help out!

Thanks in advance.

Also does anyone have the code to close an open position just before market close?

I was trying : Addorder(Ordertype.Sell_to_close, secondstilltime(1530)<=60 ,open(pricetype.last),1) but it doesnt seem to do the trick....

cheers!

Kind regards,
Newbie
 
Last edited by a moderator:
Hi Ben,

is there a scanner for trend reversal where it can scan for stocks which had a reversal (indicator) uptrend or downtrend on a daily chart.

thank you
Hussain
 
Hello! Long time reader, first time poster.

I think this indicator is very close to being something special. I have been tracking the signals against a single stock, Netflix, for the past month. On the chart I mark a Buy or Sell over the bar manually each time the indicator puts up a flag, so I can see where it repaints. After 21 sessions I viewed a 60% average accuracy rate from the High/Low setting on the indicator, meaning 60% of the events fired from this indicator would have been correct in entering a long or short position.

Currently the indicator has some weaknesses that make up for that 40% repaint that I viewed. The indicator fires Buy/Sell signals during very clear steep trend angles, such as showing a Buy signal when the 20EMA is in a clear downtrend. If the code can be updated to not fire an opposite signal during these steep angles, that would clear up the majority of the repaints. However the indicator does a good job of calling the apex point of an EMA trend, so the filter would need to recognize when the trend has flatlined into a possible reversal.

The second major issue that creates repaints is during choppy periods, where the price action tends to straddle over two EMA lines at once, such as a bar crossing through both the 9EMA and 20EMA at the same time.

The benefit to this indicator from my view is that it seems to detect price reversals very well and can get you into a position before EMA crossover confirmation and even get around some of the whipsaw crossover points so you can get in/out before breaking even on crossover reversals. I prefer the High/Low setting as it "lights up" faster than the default average setting and appears to be more accurate (once you are able to get rid of the repaints above).
 
This is a great indicator. Thank you for posting this. Was wondering, regardless of timeframe in use, 15min, 10min, 5 min, etc,, is there a way to make this indicator show only the last, most recent, 4 Buy or Sell bubbles?
Thank you
 
Hey @BenTen, how do I set an alert for this indicator? Lmaoooo I'm just kidding. Okay everyone, after burning my eyes through 42 pages of replies, I would like to share my thoughts.

1. People really need to read through the entire forum to find what they're looking for; ya'll don't know how frustrated I was seeing tens of thousands of people ask the same question about replacing bubbles with arrows, the scanner, and (my favorite one) the alerts. I understand everyone gets excited when they add this script right away and see a 100% success rate when back testing, even though they didn't know it repainted when Ben clearly says it repaints, but please read all the information before jumping into questions that have been asked!

2. After reviewing the different types of studies and scripts people put together, everyone seems to be so worried about making this the indicator that makes us all rich rather than trying to see how we can maximize our success rate. Having said that, I have a question for the people who have used or still use this Trend Reversal indicator:

Although this indicator repaints, when I used to use it, I still found some success to this study. Does anyone know of a way to maximize the success rate of this indicator by combining it with others such as the MACD, RSI, VWAP, etc?

I have read through all of the replies and I saw only a few people explain how they got success out of it. Many people said "it's great" or "it ****s" but never actually explained how we can use the indicator (other than the fact that it repaints). One explanation was to only buy or sell on the reversal arrow when it was in the proper convergence/divergence. For instance, do not go long when the MACD is showing a divergence and do not short when the MACD is showing a convergence. This is such a basic factor that so many people probably didn't take into account because the only indicator they were looking at was the reversal arrows. The other was on page 42 (allll the way up here, where someone took the time to explain how to get the best use of the indicator), by the way thanks for your backtesting @ThinkPenguin, and part of the explanation was to not buy when the 20SMA is still downtrending and visa versa for shorting. There was more to it, you can scroll above this post to read it.

But here's the thing. I'm here to make money and without this forum I wouldn't be making as money as I do. So for the next couple of days I'm going to use the OnDemand Feature on TOS and live test this indicator on the stock AMD over a period of one month.

1. I'll start from March 1st to March 31st on a 10 minute time frame (Intraday only, not pre or after market)
2. I will long uparrows and short down arrows
3. I will place a stop loss at the break over/under the previous candle (will automatically flatten if arrow disappears, even before it hits my stop loss)
4. I will reverse my position if a new arrow shows a reversal

If I can finish this by Saturday, I will do the same thing with TSLA. I will share my results with some pictures and then review what might have happened to trigger a false entry signal. I want to make some money, so even if I have a success rate of 50%, as long as my RR is greater than 1:1, I will be making money in the long run. My position sizes will all be $10,000 worth of shares. I'm trying to make it as realistic as possible to make some money, because if it's successful I will trade like this. And maybe I find specific reasons why it repaints and what someone who codes can do to fix it.

By the way, this is the exact script that I'll be using: http://tos.mx/rxqzZYh. Please let me know if that's the best one I should be back testing.
 
Last edited:
@Gabrielx77 I'll be interested in your stats as AMD is what I trade but on a 3m. In looking at your parameters it appears I use something a bit different.

This is what I use

Code:
#Trend Reverse Indicator

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;

#Alert(condition = buysignal[1] == 0 and buysignal == 1, text = "Buy Signal", sound = Sound.Bell, "alert type" = Alert.BAR);

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

#Alert(condition = buysignal[1] == 1 and buysignal == 0, text = "Momentum_Down", sound = Sound.Bell, "alert type" = Alert.BAR);

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;

#Alert(condition = sellsignal[1] == 0 and sellsignal == 1, text = "Sell Signal", sound = Sound.Bell, "alert type" = Alert.BAR);

def Momentum_Up = sellsignal[1] == 1 and sellsignal == 0;

#Alert(condition = sellsignal[1] == 1 and sellSignal == 0, text = "Momentum_Up", sound = Sound.Bell, "alert type" = Alert.BAR);

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);
#___________________________________________________________________________

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);
def reversalAmount = if (close * percentamount / 100) > Max(revAmount < atrreversal * reference ATR(atrlength), revAmount) then (close * percentamount / 100) else if revAmount < atrreversal * reference ATR(atrlength) then atrreversal * reference ATR(atrlength) else revAmount;
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;
rec isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue(EI, 1)) and GetValue(isConf, 1));
def EId = if isUp then 1 else 0;

#Arrows
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 showarrows = yes;
def U1 = showarrows and signal > 0 and signal[1] <= 0;
#U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#U1.SetDefaultColor(Color.GREEN);
#U1.SetLineWeight(4);
def D1 = showarrows and signal < 0 and signal[1] >= 0;
#D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
#D1.SetDefaultColor(Color.RED);
#D1.SetLineWeight(4);
def barnumber = BarNumber()[10];

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));

def revLineTop;
def revLineBot;

if barnumber and D1 {
revLineBot = Double.NaN;
revLineTop = high[1];
} else if barnumber and U1 {
revLineTop = Double.NaN;
revLineBot = low[1];
} else if !IsNaN(revLineBot[1]) and (Colorbars[2] == 2 or Colorbars[1] == 2) {
revLineBot = revLineBot[1];
revLineTop = Double.NaN;
} else if !IsNaN(revLineTop[1]) and (Colorbars[2] == 1 or Colorbars[1] == 1) {
revLineTop = revLineTop[1];
revLineBot = Double.NaN;
} else {
revLineTop = Double.NaN;
revLineBot = Double.NaN;
}

plot botLine = revLineBot[-1];
botLine.SetDefaultColor(Color.LIGHT_GREEN);
plot topLine = revLineTop[-1];
topLine.SetDefaultColor(Color.LIGHT_RED);

#Alerts

Alert(downArrow, " ", Alert.Bar, Sound.Chimes);
Alert(upArrow, " ", Alert.Bar, Sound.Bell);
 
Last edited by a moderator:
@tenacity11 Okay sounds good. I just finished testing the first two weeks of AMD in March on the 10 minute time frame. Since OnDemand is a hassle, theres a "next chapter" button that allows you to skip time intervals by 10 minutes. I was originally going to try it out on the 5 minute, but it would be more time consuming. I was also going to set a stop loss and play a 1:2 risk to reward, but I rather just test out the whole indicator with no variables. Just use it as a reversal indicator to signify when I should buy and sell. After, I'll go back and see where I could've maximized profits on the arrows that stayed and repainted by looking at the other indicators.

As for the trend reversal indicator, when I look back at the 3m and 5m charts, there seems to be a few more reversal indications than the higher timeframes. I believe this can be beneficial, but at the same time, there are most likely more fake reversal indications compared to the higher timeframes like the 10, 15 and 30 minute. I'll try to see if I can backtest the 3m and 5m, but no promises. After I post my results, I can walk you step by step if you'd like to test it yourself. I'm going to start using the 10m when day trading after this experiment.
 
@Gabrielx77 42 pages of *** whoopin. Everything you pointed out was a *****slap, all needed. Yes, readers needed to read the entire thread, then the same questions on each new thread would not be asked. Here's what I use in combo with this indicator, because it's terrific, it's one of two on every chart, even with your ratio, you can make money as someone pointed out, the 60% ratio, hell, big success.......and I use it like this,....when Hi_Lo candle appears,....place an alert, above or below,....reversal signal normally takes place the third candle https://tos.mx/3pEArzX
 
Some Script genius,......I share this because there are few pieces I noticed in both reversal scripts....maybe it's nothing. I use this as an entryline BTW, ZZ1-2-No, XX out plot, Priceline yes.......
https://tos.mx/GYk0sPT

@tenacity11 Mind sharing your chart,....or a few extra pics,...I noticed you using it for DT,...I would use for swing, position.....
 
@Thomas

zgxmAVs.png
 
@tenacity11 Your 10 minute time frame,...indicator worked well on that time frame, it's your favorite DT time frame,....worked well on specific symbols..works well with the reversal indicator on that time frame?????? Hahaha,...sorry.
 
Your 10 minute time frame,...indicator worked well on that time frame, it's your favorite DT time frame,....worked well on specific symbols..works well with the reversal indicator on that time frame?????? Hahaha,...sorry.
Sorry I don't trade a 10m so not sure who or what you're referring to but if you checkout the 3m C chart I got a great signal and trade with the method I use. what is the Hahahaha?
 
Did you not post your chart,.....my questions were all based off the chart you posted in this thread, the "HaHa," referred to endless questions I had for you......and your use of the TMO with the reversal signals......specifically on that 10 minute time frame??????????

This little signal may confirm reversal candle when used with "Hi_Lo," and "Reversal,".......longer time frame, haven't seen anything print on dayTrade
 
Last edited by a moderator:
Did you not post your chart,.....my questions were all based off the chart you posted in this thread, the "HaHa," referred to endless questions I had for you......and your use of the TMO with the reversal signals......specifically on that 10 minute time frame??????????
Ok got it...Sometimes it's hard to discern meaning as a post.
 
@tenacity11 - i am curious how you are doing with this on the 3min setup. I tried out on many different time frames today and if i was just patient i think it would have worked quite well. It is hard on the 1 min as it produce some false positives. Have you been able to incorporate a good scanner that could flag a stock or possibly those in your watch list that "alert" when a green buy is triggered?
 
Last edited:
Status
Not open for further replies.

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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