Trend Reversal Indicator with Signals for ThinkorSwim

rad14733

Well-known member
VIP
@BenTen Is there a certain time to run scans? I ran one and got about 75 Stocks and tried running it since same scan and script errors out. Didn't know if the TOS Server was to busy or, figured if you have used it maybe you could give me some pointers? Like with in 3 bars or what ever thanks.... Just seems like I keep getting Error: Script Execution Timeout.

That error is common if you are trying to scan too many symbols... The solution is to only scan a subset, like one of your watchlists, rather than All Stocks... Are you really going to trade All Stocks...??? 💡
 

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

jjcc

New member
VIP
Getting a lot of execution timeout on the scanner. Anyone else? Worked initially. Scanning about 30 tickers.
 

rad14733

Well-known member
VIP
Is there anything that can be done? Seems to work when I change the look back time, but it's also hit or miss.

The underlying issues with this indicator have been covered multiple times within this thread if you've take the time to read it in its entirety... Sometimes reducing the number of symbols in your watchlist helps... Having fewer Custom Watchlist Columns in your scan results sometimes helps... But finding a better indicator is the ultimate solution to the problem... People think this indicator is a panacea or the Holy Grail but it isn't once you understand its shortcomings... So, find a better indicator that doesn't repaint and isn't as complex and you'll have more reliable results...
 

kganesh1

New member
VIP
@BenTen & Others - In my TOS the reversal alert/bubble always delay by 5 to 10 min, is this something I'm doing wrong. Any settings that you suggest to fix this?
 

rad14733

Well-known member
VIP
@BenTen & Others - In my TOS the reversal alert/bubble always delay by 5 to 10 min, is this something I'm doing wrong. Any settings that you suggest to fix this?

@kganesh1 At best, Custom Watchlist Columns only update every 3 - 7 minutes, so depending on your aggregation period timeframe it could be even longer... The best you can do to lessen the lag is to reduce your aggregation period timeframe for the Custom Watchlist Column... There is no true fix other than to use a Chart Alert which would be real-time, but at the expense of having to keep a chart open for each symbol... Does this help answer your question...???
 

kganesh1

New member
VIP
@kganesh1 At best, Custom Watchlist Columns only update every 3 - 7 minutes, so depending on your aggregation period timeframe it could be even longer... The best you can do to lessen the lag is to reduce your aggregation period timeframe for the Custom Watchlist Column... There is no true fix other than to use a Chart Alert which would be real-time, but at the expense of having to keep a chart open for each symbol... Does this help answer your question...???
@rad14733, Thanks for your response, I'm facing this lag issue in the chart .i.e I'm using 5 min chart and i see a lag of 5 to 10 min which is strange. I agree with you on the watch list which I noticed in the forums. Please advise
 

rad14733

Well-known member
VIP
@rad14733, Thanks for your response, I'm facing this lag issue in the chart .i.e I'm using 5 min chart and i see a lag of 5 to 10 min which is strange. I agree with you on the watch list which I noticed in the forums. Please advise
There should be no lag for Chart Bubbles unless you are using the wrong indicator for the job... Some indicators intentionally lag in an effort to avoid or at least reduce repainting... That lag would also cause Chart Bubbles to lag... If you were to read all 73 pages of this topic you should be aware of the deficiencies this indicator possesses... I'd say it falls into the wrong tool for the job category...
 

kganesh1

New member
VIP
There should be no lag for Chart Bubbles unless you are using the wrong indicator for the job... Some indicators intentionally lag in an effort to avoid or at least reduce repainting... That lag would also cause Chart Bubbles to lag... If you were to read all 73 pages of this topic you should be aware of the deficiencies this indicator possesses... I'd say it falls into the wrong tool for the job category...
@rad14733 , thanks for the note, let me closely monitor for few more days and see. Have a great day.
 

GoldStriple

Member
VIP
I've never been able to get a price color to match indicators and surely not lined up with price action. Something was always off from price action, indicator lag.. etc.. perhaps it's my habit of watching price to much - but isn't that what I'm supposed to do! I've tried slim ribbons, even the macd line with various settings, BOP, SuperTrend CCI, even tried coding a Leledc price color, Also coded a RSM like cloud on BTD percentile with price color. again something was always off... perhaps the use of a neutral three color concept.. Until now - I add the code below to this Trend Reversal. I may have found a keeper.

apologies if someone already posted this.. I admit I didn't go through 73 pages! :)

screenshot doesn't reflect yesterday afternoons great swings.

AssignPriceColor(if isUp then GlobalColor("MyBlue")
else if !isUp then GlobalColor("MyYellow")
else color.current);

 

sunnybabu

Member
VIP
@BenTen is exactly right! The mega study that @RDMercer posted comprises many different components, notably some variant of what appears to be a Zig Zag High Low Supply Demand study that someone did 4-5 years ago, possibly more. That said, I took a quick look at the study, there are some notable and interesting portions.

The beginning section of the code is some sort of a moving average alignment study, what I have done is to extract the logic and crafted what I'd call a moving average alignment study with bullish and bearish undertones. Candles on the chart would be colored green if there is a bullish state, red if bearish state and yellow if neutral. Also included alerts for state transitions. As this is a complete revamp, I have used internal variables names of my choice to better represent the underlying price action

Enjoy this folks!

Code:
# Moving Average Alignment
# tomsk
# 11.15.2019

# Extracted idea from RDMercer's post #369 of the following thread
# https://usethinkscript.com/threads/trend-reversal-indicator-with-signals-for-thinkorswim.183/page-19

def price = close;
def length1 = 9;
def length2 = 14;
def length3 = 21;
def displace = 0;

def MA1 = ExpAverage(price[-displace], length1);
def MA2 = ExpAverage(price[-displace], length2);
def MA3 = ExpAverage(price[-displace], length3);

def BullishAlignment = MA1 > MA2 and MA2 > MA3 and low > MA1;
def BullBrakes = MA1 <= MA2;
def buysignal = CompoundValue(1, if !BullishAlignment[1] and BullishAlignment and !BullBrakes then 1
                                 else if buysignal[1] and BullBrakes then 0
                                 else buysignal[1], 0);
def Buy_Signal = !buysignal[1] and buysignal;

def BearishAlignment = MA1 < MA2 and MA2 < MA3 and high < MA1;
def BearBrakes = MA1 >= MA2;
def sellsignal = CompoundValue(1, if !BearishAlignment[1] and BearishAlignment and !BearBrakes then 1
                                  else if sellsignal[1] and BearBrakes then 0
                                  else sellsignal[1], 0);
def Sell_Signal = !sellsignal[1] and sellsignal;

def Momentum_Down = buysignal[1] and !buysignal;
def Momentum_Up   = sellsignal[1] and !sellsignal;

Alert(Buy_Signal, "Buy Signal", Alert.BAR, Sound.Ding);
Alert(Sell_Signal, "Sell Signal", Alert.BAR, Sound.Ring);
Alert(Momentum_Up, "Momentum_Up", Alert.BAR, Sound.Ding);
Alert(Momentum_Down, "Momentum_Down", Alert.BAR, Sound.Ring);

def State = if buysignal then 1 else if sellsignal then 2 else if !buysignal or !sellsignal then 3 else 0;
DefineGlobalColor("Buy Signal Bars", Color.GREEN);
DefineGlobalColor("Sell Signal Bars", Color.RED);
DefineGlobalColor("Neutral Bars", Color.YELLOW);
AssignPriceColor(if State == 1 then GlobalColor("Buy Signal Bars")
                       else if State == 2 then GlobalColor("Sell Signal Bars")
                       else GlobalColor("Neutral Bars"));

# End Moving Average Alignment
Hey @tomsk this indicator doesnt repaint correct? Also i'm in the middle of developing a python BOT as such trying to understand for the equivalent of "CompoundValue" in Python ? Appreciate your input.

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/CompoundValue
 
Last edited:

s1111

Active member
@BenTen I have a quick question. How do I remove price after reversal on chat bubble? I was able to change reversal to Buy/Sell but I don't know what I have to remove so the price won't show. Any help is much appreciated. Thanks!!
 

GoldStriple

Member
VIP
ha @MerryDay - respectfully - I love this indicator - and I don't fully agree it re-paints. it corrects itself sure - like today - there was a green Reversal but only for 2-4 candles as price was bouncing under the 34 ema and then sure enough went away. I find it only 're-paints' in little mini counter trend bounces.. which is super obvious it's about to do and the rest of the time it's very spot on. What I found today as well.. is live candle (ie no bubble) will turn my price color - that the very least gives me indication it's reached a potential reversal.
 

GoldStriple

Member
VIP
@BenTen I have a quick question. How do I remove price after reversal on chat bubble? I was able to change reversal to Buy/Sell but I don't know what I have to remove so the price won't show. Any help is much appreciated. Thanks!!
copy study to a proper text editor - ie notepad++, TextPad, even primalscript..etc. Find "Reversal" which should be on the AddChartBubble Line and then remove "+low" and the "+ high"

then overwrite study with mods
 

MerryDay

Well-known member
VIP
@GoldStriple You stated: it only 're-paints' in little mini counter-trends... so you agree it repaints. @sunnybabu is looking to write a python bot which is not going to be able to realize the false signals are "little mini counter-trends".. And therefore needed to know that this study repaints.
HTH
 

Similar threads

Top