Re: Fun with ThinkScript May 16, 2014 08:15AM |
Registered: 10 years ago Posts: 271 |
Re: Fun with ThinkScript May 16, 2014 03:29PM |
Registered: 10 years ago Posts: 615 |
Quote
linter
Hi, Robert -- great stuff and i can't believe how adept at it you are. anyway, sorry for a request being my first post on the forum, but what can you do?
I am using part of your very helpful ADX study with the slow stochastics indicator as a set up. I use 11, 11 for the ADX and 8, 3 for sto. The idea is a signal is fired when the ADX rises from beneath 20 to above 20 at roughly the same time as the sto rises from beneath 80 to over 80. I'm wondering if there's not a way to combine the two ideas into one that i could use as a custom column on my watch list and/or get some other kind of alert, so i don't have to keep flipping through screens from stock to stock and wearing out my already frazzled eyeballs to see where things stand.
I've attached a screen shot of the set up. It's the red line to the right.
And, actually, for the ADX, it'd be awesome if I could adjust the crossover number up or down a little. For instance, 18 might be better than twenty, just so I have time to get to the chart and study things before the combo fires.
What do you think? Possible? And, if so, is this anything you might want to take a thwack at?
If you have any questions, fire away!
OTOH, something like this might already be in ToS. If so, forgive my ignorance.
input DI_length = 11; input ADX_length = 11; input ADX_Crossover = 20; def DX = if (DIPlus(DI_length) + DIMinus(DI_length) > 0) then 100 * AbsValue(DIPlus(DI_length) - DIMinus(DI_length)) / (DIPlus(DI_length) + DIMinus(DI_length)) else 0; def ADX = WildersAverage(DX, ADX_length); input over_bought = 80; input over_sold = 20; input KPeriod = 8; input DPeriod = 3; input smoothingType = {Default SMA, EMA}; def SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,high,low,close,3,smoothingType).FullK; def signalup = if ADX crosses above ADX_Crossover and SlowK > over_bought then 1 else if SlowK > over_bought and signalup[1] == 1 then signalup[1] else 0; def signaldn = if ADX crosses above ADX_Crossover and SlowK < over_sold then 1 else if SlowK < over_sold and signaldn[1] == 1 then signaldn[1] else 0; plot arrowUP = if signalup and !signalup[1] then low * 0.9985 else Double.NaN; arrowUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); arrowUP.SetLineWeight(4); arrowUP.SetDefaultColor(Color.GREEN); plot arrowUP = if signalup and !signalup[1] then low * 0.9985 else Double.NaN; arrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); arrowDN.SetLineWeight(4); arrowDN.SetDefaultColor(Color.PINK);
input DI_length = 11; input ADX_length = 11; input ADX_Crossover = 20; def DX = if (DIPlus(DI_length) + DIMinus(DI_length) > 0) then 100 * AbsValue(DIPlus(DI_length) - DIMinus(DI_length)) / (DIPlus(DI_length) + DIMinus(DI_length)) else 0; def ADX = WildersAverage(DX, ADX_length); input over_bought = 80; input over_sold = 20; input KPeriod = 8; input DPeriod = 3; input smoothingType = {Default SMA, EMA}; def SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,high,low,close,3,smoothingType).FullK; def signalup = if ADX crosses above ADX_Crossover and SlowK > over_bought then 1 else if SlowK > over_bought and signalup[1] == 1 then signalup[1] else 0; def signaldn = if ADX crosses above ADX_Crossover and SlowK < over_sold then 1 else if SlowK < over_sold and signaldn[1] == 1 then signaldn[1] else 0; def UP = signalup and !signalup[1]; def DOWN = signalup and !signalup[1]; addlabel(UP, " " ); addlabel(Down, " " ); addlabel(!UP and !DOWN, " " ); assignbackgroundcolor(if UP then color.green else if DOWN then color.red else color.current);
Re: Fun with ThinkScript May 16, 2014 03:35PM |
Registered: 10 years ago Posts: 615 |
Quote
NCTrader
Robert,
Excellent job on the code you have been able to develop. I know very little about TOS other than I want to throw the computer out the window every time I try to navigate the platform.
Re: Fun with ThinkScript May 16, 2014 05:18PM |
Registered: 10 years ago Posts: 271 |
Re: Fun with ThinkScript May 16, 2014 05:26PM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 16, 2014 06:24PM |
Registered: 10 years ago Posts: 615 |
Quote
linter
com.devexperts.tos.thinkscript.runtime.ScriptAndData$TooComplexException: The complexity of the expression suggests that it may not be reliable with real-time data.
input DI_length = 11; input ADX_length = 11; input ADX_Crossover = 20; def DX = if (DIPlus(DI_length) + DIMinus(DI_length) > 0) then 100 * AbsValue(DIPlus(DI_length) - DIMinus(DI_length)) / (DIPlus(DI_length) + DIMinus(DI_length)) else 0; def ADX = WildersAverage(DX, ADX_length); input over_bought = 80; input over_sold = 20; input KPeriod = 8; input DPeriod = 3; input smoothingType = {Default SMA, EMA}; def SlowK = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,high,low,close,3,smoothingType).FullK; def SlowD = reference StochasticFull(over_bought,over_sold,KPeriod,DPeriod,high,low,close,3,smoothingType).FullD; def signalup = if ADX crosses above ADX_Crossover and SlowK > over_bought then 1 else if SlowK > over_bought and signalup[1] == 1 then signalup[1] else 0; def signaldn = if ADX crosses above ADX_Crossover and SlowK < over_sold then 1 else if SlowK < over_sold and signaldn[1] == 1 then signaldn[1] else 0; plot arrowUP = if signalup and !signalup[1] then low * 0.9985 else Double.NaN; arrowUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); arrowUP.SetLineWeight(4); arrowUP.SetDefaultColor(Color.GREEN); plot arrowDN = if signaldn and !signaldn[1] then high * 1.0015 else Double.NaN; arrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); arrowDN.SetLineWeight(4); arrowDN.SetDefaultColor(Color.PINK);
Re: Fun with ThinkScript May 16, 2014 06:27PM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 16, 2014 06:38PM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript May 16, 2014 07:47PM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 18, 2014 01:03AM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript May 18, 2014 08:32AM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript May 18, 2014 06:46PM |
Registered: 11 years ago Posts: 70 |
Re: Fun with ThinkScript May 18, 2014 07:47PM |
Registered: 11 years ago Posts: 70 |
Re: Fun with ThinkScript May 18, 2014 10:54PM |
Registered: 9 years ago Posts: 17 |
Re: Fun with ThinkScript May 20, 2014 08:32AM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 20, 2014 09:58AM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript May 20, 2014 10:35AM |
Registered: 10 years ago Posts: 143 |
Fun with ThinkScript May 20, 2014 12:01PM |
Registered: 9 years ago Posts: 10 |
Re: Fun with ThinkScript May 20, 2014 02:27PM |
Registered: 9 years ago Posts: 10 |
Re: Fun with ThinkScript May 20, 2014 03:58PM |
Registered: 10 years ago Posts: 615 |
Quote
Tan
Is a code possible that can issue an audible and written alert whenever the volume of the last bar is say 3 times the volume average, more than 30 minutes after market open?
Tan
input AverageLength = 10; input VolumeMultiplier = 3; input MinutesAfterOpen = 30; def AvgVol = average(volume, AverageLength); def VolX = (volume > AvgVol * VolumeMultiplier) and (secondsfromtime(0930) >= 60000 * MinutesAfterOpen); Alert(VolX, Concat(GetSymbolPart(), " has a large volume spike." ), Alert.BAR, Sound.Bell);
Re: Fun with ThinkScript May 20, 2014 04:06PM |
Registered: 10 years ago Posts: 615 |
Quote
mkaltenborn
I have a watchlist with a custom column for average volume. I like to watch the 10 day average volume and compare it to the current day's volume. I would like to edit the column indication to make this comparison for me and change the background color when the current volume is above the 10 day average. I have tinkered with editing the average volume study, but I just screw it up. Any ideas how to edit the indicator?
def AvgVol = average(volume, 10); plot vol = volume; assignbackgroundcolor(if vol > AvgVol then color.dark_green else color.current);
Re: Fun with ThinkScript May 20, 2014 05:00PM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 20, 2014 06:05PM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript May 20, 2014 06:52PM |
Registered: 9 years ago Posts: 10 |
Re: Fun with ThinkScript May 20, 2014 07:14PM |
Registered: 10 years ago Posts: 615 |
Quote
mkaltenborn
Hello Robert, Thank you for helping. The trouble that remains is that the new study is not available in the customize column menu of the watchlist. Any ideas?
Re: Fun with ThinkScript May 21, 2014 04:46AM |
Registered: 9 years ago Posts: 78 |
Re: Fun with ThinkScript May 21, 2014 09:47AM |
Registered: 9 years ago Posts: 10 |
Re: Fun with ThinkScript May 21, 2014 10:21AM |
Registered: 10 years ago Posts: 615 |
Re: Fun with ThinkScript May 21, 2014 11:01AM |
Registered: 10 years ago Posts: 143 |
Re: Fun with ThinkScript May 21, 2014 12:37PM |
Registered: 10 years ago Posts: 615 |