Scan for SMA conditions that stay true


Category:
0
0

Hello again Pete,

I have a question regarding a simple scan. Im trying to filter for an uptrend by stating different Sma and vwap be higher than they were X amount of bars ago.   vwap>vwap [x]…    and so forth with a 9 sma and 20 sma, and vwap..    What im trying to figure out is if there is a way to ‘prioritize’ stocks that meet the scan conditions, for longer . Say conditions true for 15 bars are ‘higher-up’ on the scan than 1 bar.  The scan so far returns decent up trends but, Im still flipping through charts more than id like to.   Ive used the scan as a watchlist for intraday trading.     Any help will be much appreciated.  Learned so much from your content already.

Thank you again

Attachments:
Marked as spam
Posted by (Questions: 11, Answers: 15)
Asked on September 9, 2020 6:21 pm
83 views
0
Private answer

A scan on Thinkorswim is only able to return a list of stocks that meet the filter criteria. There is not way for a scan to sort or rank the output. For that, what you actually need is a custom watchlist column. In your specific example, you would need to write a recursive variable that counts the number of bars that the conditions have been true. Then display that value in a custom watchlist column.

You cannot do this using the Condition Wizard and it does require some advanced code writing techniques. There are many examples in the "Watchlist" topic of this forum showing how to count the number of bars since a condition was true. I suggest you take some time to review those examples and see if you can work this out on your own.

If you cannot, then you will need to post this again in the "Watchlist" topic but when you write the title of your question it needs to describe exactly what you are trying to achieve within 6-8 words. The title should include the fact you are using an SMA and VWAP study to determine the trend of stocks and include the detail that you need to display the count since the condition was true. That in itself is a challenge since you have a lot of moving pieces here.

I love it when folks say "I have a very simple....". LOL. You have no idea how many times I have heard that. It is a red flag. Whenever someone says, this is really simple.... it usually means they do not understand how complex the solution must be to accomplish this very "simple" thing.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 9, 2020 7:08 pm
0
LOL. bad day? ill keep at it
( at September 9, 2020 7:38 pm)
0
Sorry about that. Didn't mean any of that to come across with any sort of attitude. I actually had an awesome day yesterday. I always try to encourage folks to try and find their own solutions to assist in the learning process. If you can't work this out using examples elsewhere in the forum then please post this again in the Watchlist topic, where we can provide a solution that fits the context.
( at September 10, 2020 9:11 am)