# Trend Reversal Scanner
# Scanner by https://usethinkscript.com/u/theelderwand
# Discuss https://usethinkscript.com/d/183-trend-reversal-indicator-with-signals-for-thinkorswim
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));
It does not show labels...try this
Code:# Trend Reversal Scanner # Scanner by https://usethinkscript.com/u/theelderwand # Discuss https://usethinkscript.com/d/183-trend-reversal-indicator-with-signals-for-thinkorswim 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));
@mikeraya Been using it for awhile.
FYI,....yes, looking for that slight edge, something that makes sense to "your," interpretation, I made an adjustment of 3, 8, 17,....will look into the "5,"When you're day trading, you need all the edge you can get. One other tweak I have seen traders make is changing the superfast to 5. Lemme know how it works out for you!
Look through the script, near the bottom are two "plots,"...........use hashtag "#" to block one short or bullish script.....if you haven't found solution.Can someone please help me out with this error? I pasted the code and the error message just popped up!
"At least one plot should be defined"
I added the alert at the end and it doesn't seem to work? Any thoughts?zzz/BLT,.........can you help me learn and write this scan simpler, error message, "Too Complex." https://tos.mx/GvfXBE3
BTW, after many years I am using several of your creations as standards on every chart I use..........
Got it, thanks Thomas! Could you possibly link me to the page where stocks are green and explained?The complexity of the script and somewhat unstable signals, make it not a good candidate for alerts. I have addded two different columns, but both are generating none precise signals. I mainly trade it visually when stocks are green explained in past threads...
Not quite sure I understand, but try this as a custom column, on a universe of a watchlist and see how it colors, it's really an interpretive column, very complex. https://tos.mx/6UFi8fDGot it, thanks Thomas! Could you possibly link me to the page where stocks are green and explained?
This is just off topic question. I am relatively new to this platform so do you happen to know how to fast forward the back testing process? In other words, when you are at a specific time period and you want the chart to print tick by tick instead of having to wait. I see that there are two buttons, step forward and fast forward 3x, and when you click on them the chart just refreshes which is not what I would want to see.... just keep printing with a certain amount of speed? Thanks in advance!Not quite sure I understand, but try this as a custom column, on a universe of a watchlist and see how it colors, it's really an interpretive column, very complex. https://tos.mx/6UFi8fD
I don't use the Demand feature,.....apologize.......This is just off topic question. I am relatively new to this platform so do you happen to know how to fast forward the back testing process? In other words, when you are at a specific time period and you want the chart to print tick by tick instead of having to wait. I see that there are two buttons, step forward and fast forward 3x, and when you click on them the chart just refreshes which is not what I would want to see.... just keep printing with a certain amount of speed? Thanks in advance!
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.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Repaints Enhanced Trend Reversal Indicator for ThinkorSwim | Indicators | 122 | ||
Reversal Candles (Saikou / Hikui) Trend Change for ThinkorSwim | Indicators | 10 | ||
LNL Trend System for ThinkOrSwim | Indicators | 25 | ||
L3 Banker Fund Flow Trend Oscillator for ThinkOrSwim | Indicators | 33 | ||
Trend Meter For ThinkOrSwim | Indicators | 38 |
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.