Repaints Trend Reversal for ThinkorSwim

Repaints
Status
Not open for further replies.
Recently joined and was happy to find some cool indicators so I wanted to share one of my own that I've been using to confirm bull or bear markets in a given time frame. I find that this has worked extremely well for me especially when you overlay Fisher Transform and use both together. Also, if you use JC SqueezePro, it does a good job of forecasting which way the squeeze will fire.

Let me know if you have any questions.

Code:
declare lower;


input method = {default average, high_low};

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 priceh2 = if method == method.high_low then pricehigh else mah;
def pricel2 = if method == method.high_low then pricelow else mal;
def EI = ZigZagHighLow("price h" = priceh2, "price l" = pricel2, "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 == priceh2 then priceh2 else pricel2) - GetValue(EISave, 1);
def isUp = chg > 0;
def isDown = chg < 0;

plot Bullish = isup;
Bullish.SetDefaultColor(Color.green);

plot Bearish = isDown;
Bearish.SetDefaultColor(Color.red);


# Alerts:
#
rec counter;
if (bullish) {
counter = 1;
} else {
if (counter[1] == 1 or counter[1] < 10) {
counter = counter[1] + 1;
} else {
counter = 1;
}
}

rec counterd;
if (bearish) {
counterd = 1;
} else {
if (counterd[1] == 1 or counterd[1] < 10) {
counterd = counterd[1] + 1;
} else {
counterd = 1;
}
}

def LongSignal = counterd == 3;
def ShortSignal = counter == 3;


# BLOCK CODE BELOW
input AlertSoundUP = {default “Bell”, “Chimes”, “Ding”, “NoSound”, “Ring”};
input AlertSoundDOWN = {“Bell”, “Chimes”, “Ding”, “NoSound”, default“Ring”};
alert(LongSignal , text = "UP UP UP", Alert.bar, AlertSoundUP);
alert(ShortSignal , text = "DOWN DOWN DOWN", Alert.bar, AlertSoundDOWN);
SEgRsu2.png
 
Last edited by a moderator:
@farout60 Thanks for sharing such simple and promising study. One thing I would like to ask if you can share mentioned JC SqueezePro study, as I did find it on forum, but willing to try.
 
Thanks for sharing such simple and promising study.
One thing I would like to ask if you can share mentioned JC SqueezePro study, as I did find it on forum, but willing to try.
You are asking for a member to share a paid indicator which is against forum rules... (n)
 
Last edited:
Even don't know that this study is not free one. Sorry for that thing!
No problem... John Carter sells indicators, whether totally coded by him or "borrowed" free code from others that he tweaks (or not) and sells on his site... Some people share freely while others are just out to make a buck any way they can...
 
In the coding... what exactly do these 4 parameters do?
1. Percentage Reversal
2. Absolute Reversal
3. ATR Length
4. ATR Reversal

def EI = ZigZagHighLow("price h" = priceh2, "price l" = pricel2, "percentage reversal" = percentamount, "absolute reversal" = revAmount, "atr length" = atrlength, "atr reversal" = atrreversal);
 
In the coding... what exactly do these 4 parameters do?
1. Percentage Reversal
2. Absolute Reversal
3. ATR Length
4. ATR Reversal

def EI = ZigZagHighLow("price h" = priceh2, "price l" = pricel2, "percentage reversal" = percentamount, "absolute reversal" = revAmount, "atr length" = atrlength, "atr reversal" = atrreversal);
Check the ZigZagHighLow indicator that comes with TOS for the answer to that... You won't find the answer in the script posted above as it references ZigZagHighLow as an external Thinkscript study...
 
@Joreha I tried to. But ThinkorSwim said it's too complex to work in real-time. I'll continue to look into it for now.
@BenTen Hi ben i know this is an old post but when adding this link into the scrip for scanner it states 'Exactly one plot to be expected' at bottom left coner and wont let me to click to ok it...is there another step I'm missing? https://tos.mx/vlVadom
 
Never mind, for some reason it is working now.

I have been using the following indicator (Trend Reversal) in the scanner and it's been working just fine. Now for some reason it doesn't want to co-operate and it is producing this error message. Error: Trying to self-assign a non-initialized rec: state.

Since I am not a coder, I don't know how to resolve this.
 
Last edited:
@farout60 I really like this indicator from a directional standpoint. I've been looking for something like this. I've been trying to figure out if this "re-paints" due to the 'Zig-Zag' feature. Are you able to let me know if it re-paints or not?

[Update] I have been watching both settings today: the average and high-low. Doesn't seem like the average re-paints at all, but the high-low does. Probably because of the moving average in the script that smoothes the average setting out. Correct me if I'm wrong lol.
 
Last edited:
@Bobbydigital83 The best solution would probably be to use the moving averages ('mah' & 'mal') for selling. I made it so you can visualize the moving averages on the chart and helped a lot. Not good for buying for good for selling. Sell calls when 'close < mal' and sell puts when 'close > mah'. Seems like the best solution to me and works fairly well. All you need to do is figure out your buying criteria and use this to sell. The code below are the moving averages from @farout60 but now you can see them! Enjoy!

Code:
input method = {default average, high_low};

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;
plot mah = MovingAverage(averagetype, pricehigh, averagelength);
plot mal = MovingAverage(averagetype, pricelow, averagelength);
def priceh2 = if method == method.high_low then pricehigh else mah;
def pricel2 = if method == method.high_low then pricelow else mal;
def EI = ZigZagHighLow("price h" = priceh2, "price l" = pricel2, "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 == priceh2 then priceh2 else pricel2) - GetValue(EISave, 1);
def isUp = chg > 0;
def isDown = chg < 0;
 
Status
Not open for further replies.

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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