@Ronathan Edwards Hey, us grandparents have to stick together ..Amazing, amazing, amazing! You made my weekend! Thank you sooo much! I owe you a Scotch!
@Ronathan Edwards Hey, us grandparents have to stick together ..Amazing, amazing, amazing! You made my weekend! Thank you sooo much! I owe you a Scotch!
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I put the newest (v4) code into a new section in post 1 for this thread. For those who do not want mobile support, I left v3 in there as well.
-mashume
Thanks for the new V4Code, is there a major difference between V3 and V4 of the indicatorI put the newest (v4) code into a new section in post 1 for this thread. For those who do not want mobile support, I left v3 in there as well.
-mashume
If I recall, the v4 has support for plotting colors on mobile. It does it by having separate plots (which you can then colour differently).Thanks for the new V4Code, is there a major difference between V3 and V4 of the indicator
Is there a way to have a label that calculates The outstanding shares multiplied by the current price of the stock??Thank you for sharing this. Since ToS shareable links are still not working, I went ahead and posted the source code for both the upper and lower study directly into the post. I hope you don't mind
Got it, Thanks alots@leelee Did you check out this post?
https://usethinkscript.com/threads/...cavity-2nd-derivatives.1803/page-5#post-17554
Disregard previous request found it. TYThank you all for your comments and encouragement.
I have a laundry list of things in this post:
- Variations to scripts
- Scanner
- Testing
Script Variations
@chillc15, I'm intrigued by the Arnaud Legoux MA, and so here is a variant of the upper study that will allow you to choose between Hull, Simple, Exponential, Williams, and ALMA. I haven't gone through the various permutations, but bear in mind that the 'overshoot' and smoothing of the Hull is part of what makes the turning point signal so attractive.
@Miket Used your posted code for the ALMA. Hope you're good with this use. Thanks!
Code:# # Multiple Moving Average Concavity and Turning Points # or # The Second Derivative of the A Moving Average # # via useThinkScript # request from chillc15 # Added Arnaud Legoux MA and other Moving Averages # # Author: Seth Urion (Mahsume) # Version: 2020-02-22 V2 # # This code is licensed (as applicable) under the GPL v3 # # ---------------------- declare upper; input price = HL2; input MA_Length = 21; input lookback = 2; input MovingAverage = {default "HMA", "EMA", "SMA", "WMA", "ALMA"}; script ALMA { # Attributed to Miket # https://tos.mx/9mznij # https://usethinkscript.com/threads/alma-arnaud-legoux-ma-indicator-for-thinkorswim.174/ input Data = close; input Window = 9; input Sigma = 6; input Offset = 0.85; def m = (Offset * (Window - 1)); def s = Window/Sigma; def SumVectorData = fold y = 0 to Window with WS do WS + Exp(-(sqr(y-m))/(2*sqr(s))) * getvalue(Data, (Window-1)-y); def SumVector = fold z = 0 to Window with CW do CW + Exp(-(sqr(z-m))/(2*sqr(s))); plot ALMA = SumVectorData / SumVector; } plot MA; switch (MovingAverage) { case EMA: MA = MovAvgExponential(price, length = MA_Length); case SMA: MA = simpleMovingAvg(price, length = MA_Length); case WMA: MA = wma(price, length = MA_Length); case ALMA: MA = ALMA(Data = price, window = MA_Length); default: MA = HullMovingAvg(price = price, length = MA_Length); } def delta = MA[1] - MA[lookback + 1]; def delta_per_bar = delta / lookback; def next_bar = MA[1] + delta_per_bar; def concavity = if MA > next_bar then 1 else -1; plot turning_point = if concavity[-1] != concavity then MA else double.nan; MA.AssignValueColor(color = if concavity == -1 then if MA > MA[1] then color.dark_orange else color.red else if MA < MA[1] then color.dark_green else color.green); MA.SetLineWeight(3); turning_point.SetLineWeight(4); turning_point.SetPaintingStrategy(paintingStrategy = PaintingStrategy.POINTS); turning_point.SetDefaultColor(color.white); plot MA_Max = if MA[-1] < MA and MA > MA[1] then MA else Double.NaN; MA_Max.SetDefaultColor(Color.WHITE); MA_Max.SetPaintingStrategy(PaintingStrategy.SQUARES); MA_Max.SetLineWeight(3); plot MA_Min = if MA[-1] > MA and MA < MA[1] then MA else Double.Nan; MA_Min.SetDefaultColor(Color.WHITE); MA_Min.SetPaintingStrategy(PaintingStrategy.TRIANGLES); MA_Min.SetLineWeight(3); plot sell = if turning_point and concavity == 1 then high else double.nan; sell.SetDefaultColor(Color.DARK_ORANGE); sell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN); sell.SetLineWeight(3); plot buy = if turning_point and concavity == -1 then low else double.nan; buy.SetDefaultColor(Color.CYAN); buy.SetPaintingStrategy(PaintingStrategy.ARROW_UP); buy.SetLineWeight(3); def divergence = MA - next_bar; addLabel(yes, concat("DIVERGENCE: " , divergence), color = if concavity < 0 then if divergence[1] > divergence then Color.RED else color.PINK else if divergence[1] < divergence then color.green else color.yellow);
SCANS
@mailbagman2000 , Scans, yes...
Scan 1 -- Buy signals.
This scan relies on the upper study being called "Concavity" and is entered on the scan page as a custom.
Code:Concavity("hma length" = 55, price = CLOSE)."buy" is true within 2 bars
Scan 2 -- Stocks approaching possible Buy signals
I thought that, since the lower indicator crossovers can generate signals, that an 'early warning' scan might be of interest. We can scan for any HMA that has a negative convergence, and look for a decrease in the distance below zero. It may be a long way off, it may never get there, but we are alerted before the trade entry.
Code:script ConcavityDivergence { # # Hull Moving Average Concavity Divergence # or # The Second Derivative of the Hull Moving Average # # Author: Seth Urion (Mahsume) # Version: 2020-02-21 Initial Public # # This code is licensed (as applicable) under the GPL v3 # # ---------------------- declare lower; input price = HL2; input HMA_length = 34; input lookback = 2; def HMA = HullMovingAvg(length = HMA_length, price = price); def delta = HMA[1] - HMA[lookback + 1]; def delta_per_bar = delta / lookback; def next_bar = HMA[1] + delta_per_bar; def concavity = if HMA > next_bar then 1 else -1; plot zero = 0; zero.setdefaultcolor(color.gray); zero.setpaintingstrategy(PaintingStrategy.DASHES); plot divergence = displacer(-1, HMA - next_bar); divergence.setDefaultColor(Color.LIME); divergence.SetLineweight(2); plot cx_up = if divergence crosses above zero then 0 else double.nan; cx_up.SetPaintingStrategy(PaintingStrategy.POINTS); cx_up.SetDefaultColor(Color.LIGHT_GREEN); cx_up.SetLineWeight(4); plot cx_down = if divergence crosses below zero then 0 else double.nan; cx_down.SetPaintingStrategy(PaintingStrategy.POINTS); cx_down.SetDefaultColor(Color.RED); cx_down.SetLineWeight(4); } def signal = ConcavityDivergence("hma length" = 55)."concavity"; def HMA = ConcavityDivergence("hma length" = 55)."HMA"; def next = ConcavityDivergence("hma length" = 55)."next_bar"; plot buy = signal < 0 and (HMA - next) > (HMA[1] - next[1]);
TESTING
I used the built-in strategy feature of thinkorswim, with block sizes of 100. All tests were run on 1 year Daily charts, with an HMA length of 55 and set price to CLOSE
First SPX
Buy and Hold: $55,600
Strategy: $77,372
Delta + $21772
Next ADI
Buy and Hold: $1718
Strategy: $5202
Delta: + $3483
Last BA
Buy and Hold: ($9322)
Strategy: $14393
Delta: + $23715
SHORT TIME FRAMES
I did not take time today to test shorter timeframes, though I imagine the results would be good. If there is interest, I'll try to post up some another time.
If you've read this far, thank you.
Happy trading and good luck.
Thank you. Is working now.To Scan For Lower Study Divergences
Part One --
Load Shared Link: http://tos.mx/11zv4QA Save the study under the name: Mashume_Hull_Lower. (if you skip this part the scanner in part two will not work)
Click here for --> Easiest way to load shared links
Part Two --
Import the link for the scanner:
Shared Link: http://tos.mx/xbNexZB
It goes without saying, but I will say it anyway ... No trade should ever be entered into based on one indicator or one time frame
Read more: Basic Tenets Of A Good Strategy
There are a bunch of scans scattered around, but I don't have off the top of my head. Sorry. You can find some good threads about how to use studies in scans here abouts somewhere too.@mashume Do you have a script for scanning for the sell and buy signals/point at which the arrows are plotted please?
Thanks for your prompt reply. My question was specifically about concavity. None of the scans I have come across specifically picks out the buy/sell signals.There are a bunch of scans scattered around, but I don't have off the top of my head. Sorry. You can find some good threads about how to use studies in scans here abouts somewhere too.
-mashume
@MerryDay Thank you - that's the missing piece I was looking for.
@BenTen is there any easier way for when setting up a new Usethinkscript thread that all posts can be more ORGANIZED and in CHRONOLOGICAL ORDER so as to not confuse people that are not experts and have all posts that have SCRIPTS and LINKS with MULTIPLE VERSIONS again MORE ORGANIZED AND IN ORDER so as to research, learn and experience this sites content a hell of a lot easier??
Thanks!!
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Exponential Hull Moving Average (EHMA) for ThinkorSwim | Indicators | 8 | |
Safe Hull Moving Average Indicator for ThinkorSwim | Indicators | 3 | ||
Hull Format, Label, Watchlist, Scan for ThinkorSwim | Indicators | 115 | ||
L | A Volume Pressure Moving Average For ThinkOrSwim | Indicators | 15 | |
T | Mega Moving Average For ThinkOrSwim | Indicators | 26 |
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.