Design a custom scan, run it against all US Stocks and auto-buy 100 shares of the first scan result


  • Questions
  • Strategy Guide
  • Design a custom scan, run it against all US Stocks and auto-buy 100 shares of the first scan result
Category:
0
0

If you wanted to scan all US Stocks and automatically enter a position in the first stock that met your strategy or criteria, would you be able to do this in thinkorswim? Since looking at your videos we know it is possible to almost place an automated order for a stock we know beforehand, if we can do that much, can we scan all US stocks and enter a position based on our strategy (not knowing stocks beforehand)? Either through thinkorswim API, or third party API? I am sure after watching your videos that if we are this close to placing automated orders, then using API, or using third party or even maybe thinkorswim features there might be a way to place an order for a stock directly. Pete, is there a way to do this? If so, can you please enlighten us?

 

Or if anyone else knows, please do let me know!

 

Thanks!

Marked as spam
Posted by (Questions: 3, Answers: 5)
Asked on April 28, 2017 5:27 pm
694 views
0

this is the video I’m referring to: https://www.youtube.com/watch?v=YW8ruMckbEw&t=831s

( at April 28, 2017 5:28 pm)
0
Private answer

You covered quite a lot of ground with your question so let’s break it down into pieces. I won’t provide any code here, because most of what I have to say is completely theoretical. I just want to describe the framework. It’s up to you to determine the details.

First section: Scan all stocks, enter position in first stock that met your strategy criteria

Since you did not give any criteria I will manufacture my own. In regards to the part about entering a position on first stock that met the criteria. Well how do you pick one from the list of scan results? How do you sort them? You have to sort them before you can pick the “first”. So for our example we’ll say that condition one is the 50 ma above the 200 ma. Condition 2 is the 21 ema above the 50 ma. The trigger is when the 8 ema crosses above the 21 ema. So we have two conditions and one trigger. We set the scan up to find stocks the meet conditions 1 and 2. Let’s say the scan returns 500 stocks. How do you sort the list of results to “pick the first one”? You can create a ranking. Perhaps you take the distance between the 21 ema and the 5o ma and convert that to a percentage of the current close. You place that code in a custom column in the results screen. Then you sort your results by that custom column. Then you enter a conditional order for the one at the top of the list. The conditional order filters for conditions 1 and 2 and also contains the trigger. The end.

Second section: This section deals with the suggestion of using the API

This is an extremely advanced proposition. Someone would need to build the entire structure from the ground up. It would be either a web based application or a multi-platform application that would run locally on your computer. It would be completely independent of Thinkorswim. The cost to construct and maintain it would be enormous.

Conclusion:

For those interested in pursuing a truly Automated Trading System I recommend you move to a platform that already supports this. Such as NinjaTrader or TradeStation.

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 28, 2017 7:44 pm
0
Private answer

Hi Pete,

Sorry by ‘first’ I meant the first one that shows up in the scan, not necessarily the first one in a sorted list. It can be any of the ones in the scan. I don’t care which one. Like what if I wanted to scan for all stocks that are between $1 – $3, have a volume of at least 100,000 and are up 3%. Stocks A, B, C and D show up. I don’t mind if I enter a position in stock A, or B, or C, or D. What if I am happy with my strategy and I just arbitrarily want to enter any of them? Like the first one that shows up in the scan?

Marked as spam
Posted by (Questions: 3, Answers: 5)
Answered on April 29, 2017 5:19 pm
0

Well the first one that shows up in the scan is going to depend on how you have the results sorted. The results are sorted by alphabetically by symbol number unless you change it. So you are always dealing with a sorted list. So in your example you would simply take the symbol at the top of the result list and enter a conditional order set to trigger your entry based on the rules you set. There is absolutely no way to have the scan automatically create the order. (in case I did not already make that perfectly clear in my original response).

( at April 29, 2017 5:56 pm)