Three stacked moving averages and price between two of them


Hello! First of all I want to say a huge thank you for providing your knowledge on youtube! There really isn’t much guidance for thinkscript but you have done an amazing job so thank you!

I am trying to make a scan which combines two things. 1) The close price is inbetween the 30ma and 50ma or the price touches the the 30ma 2) the 30ma is greater than the 50ma and 50ma is greater than the 100ma. Here is what I have so far but I know something is off since my scans have tickers which don’t follow the criteria.

def ma30 = SimpleMovingAvg(close, 30);
def ma50 = SimpleMovingAvg(close, 50);
def ma100 = SimpleMovingAvg(close, 100);
def price = close;
plot scan = (price >= ma30 or (price > ma30 and price <ma50)) and (ma30 < ma50 and ma50 < ma100);


I will also be making one where the 30ma is less than the 50ma and the 50ma is less than the 100ma.

Thank you again!!!!

Sincerely: Someone who can’t code

Marked as spam
Posted by (Questions: 3, Answers: 0)
Asked on October 12, 2020 4:37 pm
Private answer

You do not need to know how to write any code to create scans like this in Thinkorswim. Most of what you have requested has already been solved in the following post:

You can build this scan with nothing more than your mouse. How? Using the Condition Wizard:

The scan tool in Thinkorswim is much more flexible and powerful than most users can even imagine. What you need is for someone to break things down into bite sized pieces and show you hoe everything works. Oh yeah.... I did that already:


Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on October 12, 2020 6:37 pm