Trend Reversal Indicator with Signals for ThinkorSwim

dougn

dougn

Member
2019 Donor
@dougn This was requested multiple times. At the moment, I don't think it's possible.
...

Josiah (easycators.com) created this custom watchlist column and it's offered here in the spirit of sharing back with this great community.

Based on his description of what he had to do to get it to work, some compromises had to be made. On initial basic testing I can confirm that the signals identified by the column (bearish and bullish in one) match those signaled by the study.
Code:
####################################### COLUMN
# Trend Reversal
# Dixon72 with modifications by tomsk
# Scanner by https://usethinkscript.com/u/theelderwand
# Column modification by Josiah at https://Easycators.com
# 1.20.2020
input offset = 1;
input withinBars = 1;
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 up = within(signal > 0 and signal[1] <= 0, withinBars);
def down = within(signal < 0 and signal[1] >= 0, withinBars);

plot scan = if up[offset] then 2 else if down[offset] then 1 else 0;
scan.assignValueColor(
         if up[offset] then color.dark_green
    else if down[offset] then color.red
    else color.black);
assignBackgroundColor(
         if up[offset] then color.dark_green
    else if down[offset] then color.red
    else color.black);
####################################### END COLUMN
 
G

greentonic

New member
I had a repainting issue today 22/01/20 with $FCEL. Sell signal @$2.9 around 12.30pm . It pushed higher and signal vanished on 5min chart.
 
D

Dhjesus

New member
Hello... I have been using the Trend Reversal Indicator for awhile now, I really enjoy looking at charts and understanding the direction the market is moving. I also have the scanner installed and I was wondering if there is an updated version on the scanner posted on the original post #1. I looks like the scanner and the indicator aren't in sync. I am also using the original (post #1) version of the Trend Reversal indicator. Any help would be greatly appreciated. Thank you.
 
T

tomsk

Well-known member
VIP
There certainly has been quite a few versions of the study that was posted. Because of the repainting feature, don't think you can use this to do live trades though as pointed out by several readers. But the study sure looks so good, that's because it uses future bars to confirm signals - that is the repainting at work!
 
I

ianfaler

New member
Hey guys I love this indicator so far. I feel pretty stupid I have read all throughout this forum. When I am setting up the scanner it says it is too enhanced to use as a scan? I have set it up for the up or down arrow on the daily chart without 3 bars. and I just cant get it to work correctly for me. What am I doing wrong here?

 
BenTen

BenTen

Administrative
Staff
VIP
@ianfaler If this is from the scanner link that we posted in the original thread, it shouldn't give you that error. Have you tried adjusting the watchlist that you'll be using? Sometimes if the watchlist is too big it could become an issue as well.
 
I

ianfaler

New member
@ianfaler If this is from the scanner link that we posted in the original thread, it shouldn't give you that error. Have you tried adjusting the watchlist that you'll be using? Sometimes if the watchlist is too big it could become an issue as well.
Jeez was picking the actual chart indicator not the scanner. Sorry about that! Thanks for your help
 
S

Sohelator

New member
2019 Donor
Hi I love the trend reversal indicator, I tried to set up the scanner but it gave me alot of stocks. Is there a way to scan for the reversal bubbles that pop up? Im looking to scan my watchlist at night for reversals. Thanks
 
BenTen

BenTen

Administrative
Staff
VIP
@Sohelator So the scanner is working? If so, you may want to select your own watchlist instead of the one ThinkorSwim gives you. That way you can be selective about the result.
 
S

Sohelator

New member
2019 Donor
@Sohelator So the scanner is working? If so, you may want to select your own watchlist instead of the one ThinkorSwim gives you. That way you can be selective about the result.
It scans but only if i put only up arrow or down arrow but it wont do both, also when i checked the chart on the scan results, i dont see a reversal bubble. Thanks for trying to help, I love this site
 
S

Sohelator

New member
2019 Donor
Ok i changed it to 1 bar, daily and scanned the snp 100. It gave me results but when i check the daily chart, i dont see any reversal signals 1 bar back.
 
BenTen

BenTen

Administrative
Staff
VIP
@Sohelator Since this indicator repaint, there is a delay in signal, especially the daily chart. So you would need to change from 1 bar to 2 bars.
 
S

Sohelator

New member
2019 Donor
I changed it to 3 and still the reversal signal isnt there. Im sorry and Thanks again
 
BenTen

BenTen

Administrative
Staff
VIP
@Sohelator Take a screenshot of your scanner setting and also let me know which watchlist you're scanning in.
 
S

Sohelator

New member
2019 Donor
btw im using the original Trendreversal, the one with the bubble
 
T

tomsk

Well-known member
VIP
@Sohelator Are you planning to use this as a trading signal - if so please read post # 466
 

Top