Repaints Trend Reversal for ThinkorSwim

Repaints
Status
Not open for further replies.
@BenTen Oh sorry, guess I didn't mention that I get the above when trying to create an alert for the arrows. I'm trying to get alerted when the next 15 minute Trend Reversal arrow is displayed on a chart.
 

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

I watched Pete Hahn's video, added "within 8 days" at the end of the script and it still doesn't work. I'd gladly add a screenshot to show what's happening, but I can't figure out how to add a picture to this thread to save my life...

My scan parameters are: Trend_Reversal_SCAN()."downArrow" equals 1 within 8 bars
The error I get is, "Error processing referenced script Trend_Reversal_scan: No such function: CompoundValue at 1:1 Expected double" and "Trend_Reversal_Scan()" is highlighted in red as though thinkscript has issues with the scan itself...
Please paste the scan script , I will try to replicate and find if I can see the same error
 
@2sureshk That would be awesome!! The script that I have is below. I can only assume it's the most current version...

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));
 
@Dixon72 I looked through the code you posted - noticed that there re several calls to CompoundValue() that the scanner typically reports problems with. All CompoundValue() does is that it initializes the code to a value. I have a version going that replaces this with a standard if-then-else comparison. While the scanner no longer complains, I am unable to obtain any signals from the scanner. Looks like this study utilizes a combination of Moving Average crossover comparisons with the TOS ZigZagHighLow study.
 
as you mentioned the code with in the scan is not fetching the list. as per my observation it cold be due to the complexity of the code. but I find the alternative option. follow the below and see if you see the same results.

1. Copy the code and create a study (example study name: Trendreversaltest)
2. Go to the Scan and add the Filter select Study.
3. Find the newly created study Trendreversaltest - > upArrow is True with in 2 Bars. ( Daily Scan)

  • Note Criterial for ALL Stocks All optionable it appears that there could be a limitation TOS if you don't select this option you see Error
  • I recommend to use your limited Watch list instead of selecting All stocks
  • you should see the editor script as below

Trendreversaltest()."upArrow" is true within 2 bars

it should give the Bullish2 scan list.

follow the same for Bearish by selecting the DownArrow is true.


Thanks,
Suresh K
 
@BenTen my apologies, I am asking the same question here I did for a different trend reversal indicator. This is correct link I wanted to ask about. Can you create an alert on say the daily chart when the reversal happens up or down in a watchlist of favorite stocks? I am not looking for a scanner for reversals just how to create an alert on the watchlist of stocks. Thank you.
 
@tomsk Scanning works just fine for me. Where I have issues is putting the scan/indicator into an alert so I'm notified (email, etc.). Does your if-then-else fix error when you select it in an alert?
 
Sorry , it could be only possible to see sound alert ,, for some of the studies TOS email alert is not possible . This could be one of them . Or some another expert may be can help with any idea
 
As noted in my earlier post, the Trend Reversal code has BOTH a moving average component as well as the TOS ZigZagHighLow component.
The crux of the issue is that ZigZag uses future bars and the scanner doesn't see future bars you won’t be able to scan for it. The other issue is that recursive expressions are not permitted in MarketWatch Alerts. Since there is a fair amount of recursion in the code, does not appear to have any easy solution.
 
I tried to scan with the trend reversal indicator, but it doesn't seem to work. I loaded to study into the scan and asked that if the UpArrow was true within 3 days to list result. The error I am getting says "Error: Trying to self-assign a non-initialized rec: state." Can you tell me what I need to do to get it to work? Thanks, newbie here, struggling.
 
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
388 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