EMA-SMA-VWAP Stacked Indicator for ThinkorSwim

Partner

New member
VIP
Can anyone help to create a script to identify the ticker when stacking of VWAP, 200 SMA, 9 EMA, 21 SMA, 34 EMA & 89 EMA are together - Timeframe 3 mins. (Pls note, we already have the script in the forum when 8EMA>21EMA>34EMA>55EMA>89EMA. However, looking for a script when they are merged together irrespective of the order). What I have observed when they merged together we normally see a big move in a ticker on either side. Below are two examples from Friday, 4th Dec.

And if possible to add - if the price is above VWAP the signal turns to Green and if the price is below VWAP the signal turns to Red.

Hw9WuEh.png
JcXP7Fu.png
 
Last edited:

petech

New member
I got as far as pulling up the MovingAvgCrossover, in the scan section pressing the pencil button, then press the edit button. I looked through all the available options and can't figure it out. You talked about finding the cross of these MA within 2 bars. I couldn't find a way in that menu I was looking through to specify 2 bars.
 

XeoNoX

Well-known member
VIP
you can to code it like this:
the 3,9,20,50 simple moving average are within XYZ percent of each other


the code for MA1 is within XYZ percent of MA2 is on the forum somewhere. From that you can just add to custom code in the TOS scanner and make a scan for each pair crossing till you covered all 9 Possibilities. (i think its 9, could be more)
 
Last edited:

petech

New member
I don't know how to code. I'm doing my best to figure it out. I'll keep clicking around TOS to see if I can figure it out from reading everyone's responses.
 

XeoNoX

Well-known member
VIP
you dont need to know ho to code, you just search for the code on the forums, find it, plug in your 2 moving averages and then add it to the tos scan. then repeat for the rest of the MAs
 

MerryDay

Well-known member
VIP
@petech Posters to this forum aren't expected to be coders. However, in order to be a successful trader, it is important to be able to do your own research. One of the most important components of research is the ability to search the internet and this forum for the answers you need.

So when you searched this forum, did you attempt to change the simple moving averages in the below link to your lengths and run your scan? If so what issues did you have? Continue to provide screenshots, as you have, as you ask questions. A picture is worth a 1000 words
https://usethinkscript.com/threads/bullish-stack-smas-scan.3655/#post-53895
HTH
 

petech

New member
@Xeono

I'm still looking...so far I found this page

https://usethinkscript.com/threads/scanner-to-find-distance-between-price-and-moving-average.699/

The code on there doesn't work like I'm expecting it to.

@MerryDay, thanks for the link. I'm about to try it out now. I did do some google search before I came to post. I didn't see what I was looking for. Or perhaps I used inadequate search terms. I didn't even know what a conditional wizard was an hour ago. There is a big knowledge gap on my end.
 

petech

New member
@petech Posters to this forum aren't expected to be coders. However, in order to be a successful trader, it is important to be able to do your own research. One of the most important components of research is the ability to search the internet and this forum for the answers you need.

So when you searched this forum, did you attempt to change the simple moving averages in the below link to your lengths and run your scan? If so what issues did you have? Continue to provide screenshots, as you have, as you ask questions. A picture is worth a 1000 words
https://usethinkscript.com/threads/bullish-stack-smas-scan.3655/#post-53895
HTH
I just copied and pasted the script you linked to into TOS and ran the scanner. There were 2697 results. One of them was AZFL, which was also picked up by the other code form the other page I linked in the last message. On the daily chart for today, the candle is no where near the 9/20/50 MA.
 

petech

New member
#Price is within X% max of the 20 SMA #### Change percentvalue to percent % in decimal format ### Example .02 is 2% and .025 is 2.5% def percentvalue = .01; #Price is with X of X EMA def ma = simpleMovingAvg(close,20); def s3 = ma*percentvalue; plot scan = absvalue(close - ma) is less than or equal to s3;
I found this one, this seems promising, now just need to figure out how to edit it.
 

MerryDay

Well-known member
VIP
@petech The script needs to be saved as a custom study, then you can edit it and then run a scan.
Most scripts are NOT pasted directly in the scanner.
Google the internet for " thinkorswim scan custom study " videos to understand the scan hacker screen.
 

petech

New member
@petech The script needs to be saved as a custom study, then you can edit it and then run a scan.
Most scripts are NOT pasted directly in the scanner.
Google the internet for " thinkorswim scan custom study " to understand the scan hacker screen.

Yes I know how to save the code into the scanner and run it. I've done that part already. That is how I know that code does correctly scan for price close to the 20MA. I've looked at the code for quite a few minutes, but I don't know how to add to it. I have some high school level coding, from many years ago. So I do know what a variable is, so I do understand what I am looking at. But that is the extent of my understanding. I would know how to change the 20MA to a 50MA, but I wouldn't know how to get it to also scan for all the other MA in combination
 

petech

New member
Also is there a way to limit the scan I've setup to either a singular stock or a small hand full of stocks that I hand pick? I would like to setup an alert for when those conditions are met intra day. I've already done a google search. Can't find it. Please let me know what phrase I should type in search to go look for it again. Thank you in advance.
 

MerryDay

Well-known member
VIP
@petech Really? There was just a thread posted in the last hour on how to scan for a single stock and you didn't see it when you searched the forum? WTF? Doing your own research was the point of this thread. You need to do the searches and then ask the question. Trying different terms in your searches is a learning process. Googling is a learned process. You need to do the work I am done.
 
Last edited:

petech

New member
@petech Really? There was just a thread posted in the last hour on how to scan for a single stock and you didn't see it when you searched the forum? WTF? Doing your own research was the point of this thread. You need to do the searches and then ask the question. Trying different terms in your searches is a learning process. Googling is a learned process. You need to do the work I am done.
I just went straight to google search. Apologies for missing it. There is a lot of things about thinkorswim that I don't know how to do. Before today I didn't know what a conditional wizard was. I didn't even know how to create a watchlist. I google it just now after look at your post on how to create an alert for a single stock. It wasn't an unwillingness to try or do it myself, it is more that I don't know what I don't know. I also find looking at other people's lengthy code very intimidating. Looking at code is something I almost never do.

It wasn't my intent to be difficult. I've found the entire process very overwhelming.
 
Last edited:

s1111

Member
Here is my actual Watchlist Column code... It's almost identical to the code above... I just use colors without text because I need the screen real estate for other things... Green = StackedUp, Red = StackedDown, Gray = NotStacked...

Ruby:
#EMA_Stack
#Used to indicate that 8, 21, 34, 55, 89  EMA's are ALL stacked trend-wise
#Created by rad14733 for usethinkscript.com
#v1.0 2021-01-02

def stackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is greater than MovAvgExponential("length" = 89)."AvgExp";


def stackedDn = MovAvgExponential("length" = 8)."AvgExp is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is less than MovAvgExponential("length" = 89)."AvgExp";

def state = if stackedUp then 1 else if stackedDn then -1 else 0;

AddLabel(yes, state, if stackedUp then Color.DARK_GREEN else if stackedDn then Color.DARK_RED else Color.DARK_GRAY);

AssignBackgroundColor(if stackedUp then Color.DARK_GREEN else if stackedDn then Color.DARK_RED else Color.DARK_GRAY);
When I put this code on the watchlist I get an error def stackedDN code. Is there anything I need to do ?
 

s1111

Member
@rad14733 Just a comment regarding MACD info, the code sent was how it appeared in my collection. I fiddle with pieces, but never with titles.
Included is MA_Cloud,. https://tos.mx/dPHW9IK
MA_Crossover-w-clouds https://tos.mx/DfjXMQC
SLM code,.. https://tos.mx/Vei7CId
Thank you so much for this script . I used your ma crossober with clouds . Clean chart and great script . I removed ma short bubble display that hovers around the candles but other than that its tits :). Before I was using 9/15ema and 45 ema for conformation on a 1 min chart . Here is my chart setup, any suggestions will be appriciated. Hope someone finds this setup useful .
https://tos.mx/blUIgeo

One quick question @Thomas , when bubble popps up with C and the price , what does C stand for ? green C with price is Buy and red C with price a sell . Seen red arrow down a few times today but never got green arrow when it was bullish .
 

XeoNoX

Well-known member
VIP
Also is there a way to limit the scan I've setup to either a singular stock or a small hand full of stocks that I hand pick? I would like to setup an alert for when those conditions are met intra day. I've already done a google search. Can't find it. Please let me know what phrase I should type in search to go look for it again. Thank you in advance.
create a watchlist, add the stock or stock(s) you want to scan against. Go to the stockhacker and where it says "scan in" change it to the name of your watchlist

https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker


SH_exclude.2020-01-30-09-48-42.png
 

Similar threads

Top