Auto Trade (ALGO) in TOS

@Jonessw1 thanks for posting, so a flexgrid would take a lot of real estate with precise coordinates to read images and send clicks to execute trades, do you have a screen shot of how you have it laid out? I was imagining multiple virtualboxes and multiple accounts to accomplish what you are doing. But now I see what you are saying and can imagine it. I was thinking more like 6 instruments ie NQ ES SPY calls and puts and QQQ calls and puts. Are you using imagesearch? I am now devising a system that grabs the TOS strategy buys and sells images and fires off trades with hotkeys but I also have used mouse clicks. I found out the OnDemand does not work with Hotkeys or the flatten button. I will say the execution is lighting fast. Faster than human who sees the signal and clicks on Buy. The only caveat is no stoploss in place as it depends on the strategy to manage the trade, But I was thinking a call to the TOS API could do that.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

So here is my setup. I am using an Excel userform as its the easiest way I know of to attain a GUI while keeping track of open orders. Its a ton of MouseClick coordinates paired with PixelGetColor(), therefore a pain to debug. My real issue, which I am hoping for some help here with, is adding an open position label to the charts. I don't think its possible with FOREX. I'm sure there is a way to store a dynamic variables within autohotkey that could signal an open order and circumvent the use of Excel all together, but I'm not that savvy with the program.

Anyhow, it runs all day/night with minimal monitoring. The signals often fire off in rapid succession which would trigger repeated buy/sells, so I implemented a sleep delay on the loops which cuts down on unnecessary trades. After seeing Svanoy's code, I may switch over to futures on paper for a while, or back out on the number of instruments as well as the TF for FX.

PS. this Isn't a great system. A popup or restart could ruin an account while one was away, but its been fun to figure out.
 
Last edited:
Here's my concept: just with 3 panels for now. Each with a blank canvas, just a strategy running, autohotkey using imagesearch so that when BUY1 comes into view, it then clicks the Buy Market button in the respective ActiveTrader, I also just figured you can have an order template cued that adds the stop loss. You can save the Style and you can save the Grid. It looks like Forex doesn't allow account info, doesn't make sense but that's TOS for you.
TOSLAYOUT.png
 
Right on. Get it working and let me know how it performs with options!

Will you be monitoring it? I would love to link up remote monitoring to mine, but it would be a distraction at work. Currently I just have the ToS web app open all day to ensure my positions aren't racking up. As of now I'm working on a macro involving outlook which will halt trading or liquidate open positions via specific email subject lines.

In pondering, I can't tell if this is a good idea or use of my time. I often just think I should pay for a Sierra account which allows auto trading natively. Then I see things like Altredo, https://www.altredo.com/thinkorswim-trading-robot.aspx , and I think I am on the right track by building this thing and not spending $1500.
 
@Svanoy thanks for the heads up, eventually if this is viable I'll move it to a virtual server that has reliable 99.99% up time. I started using the actual TOS strategy images but I have found them unreliable, so back to the label image. I also found Vis2 which is a very capable OCR, which if you populate your labels with text it can read the text and supply the script with whatever data you need, ie. number of contracts. Something like:
contracts := OCR(10,200,200,250) to read an area of the screen.
I also got to thinking you are no longer strapped to using TDAmeritrade to trade, you can have two apps running side by side with TOS as the study and another broker trade panel open or visa versa, or any two programs, maybe Tradingview and your favorite broker. Its really all about reading the screen and clicking, all done by AutoHotKey. I hope others are inspired to check it out. Even if you are not in to 24/7 autotrade, but just want something that will execute the trade you just missed for a phone call or being at work.
 
Nice.

I have automated GUIs in the past, but that was via AutoIT or PyAutoGUI, and I used those to save time versus manually web site scraping or game-leveling. Looking at this thread, I like the quite literally "outside-the-box" approach of automating the GUI via an external program. I had this idea too, but what I couldn't figure out was a stable way to access the information from ThinkOrSwim at a specific point on screen that I could use a screen-reader against,, but you cleared that hurdle by using the LABELS --- using the label as a spot on the screen that doesn't change positions, and then using that to send commands to the external program that is watching the screen. Also, I really like how you communicate the numbers to the external system via BINARY labeling system.

Because I didn't get that idea to use the Labels, I already went down the rabbit hole of figuring out how to use the TD API via python to send orders (PartTimeLarry has some great Youtube videos), but that's still not quite ready for prime time yet. Since my studies/strategies are already in Thinkscript to start, it'd be a lot easier to try to automate that via something I already understand (PyAutoGUI) and then I can take more time to work on the dream of the automation server in the cloud.

Questions:

#1. Is anyone putting real money on the line? I see that some of you are just testing this out via Paper Trading. I wish that TD API supported paper trading (it doesn't, so I'm using small quantity for testing purposes.)

#2. In the binary label, why are more than two different colors used?

#3. Related to this topic, has anyone devised a GUI automation solution for conditional orders? (the current problem with conditional orders is that they must be manually re-submitted. Just wondering if someone had already made a GUI automation for re-applying conditional order templates. (whether that template be saved within ToS, or it's in a text file sitting in the OS somewhere.)

https://usethinkscript.com/threads/why-doesnt-a-conditional-order-continue-to-run.3586/

https://tlc.thinkorswim.com/center/...Order-Types/thinkScript-in-Conditional-Orders
 
PS. this Isn't a great system. A popup or restart could ruin an account while one was away, but its been fun to figure out.
I implemented a sleep delay on the loops which cuts down on unnecessary trades

1. Can't you submit your orders via a template that includes stop-loss? (This way, even if your system crashed or you somehow submitted an erroneous order, you would submit your stop at the time you submit your order.
2. You said that you implemented a sleep delay, as that would prevent ordering too frequently, correct?
3. If your're exiting via a market sell or buy anyway, you could enter via stop-loss template, and exit via Flatten Now button?

From https://tlc.thinkorswim.com/center/faq/trade:
If you wish to flatten your position without having to confirm ‘Yes’ in the resulting pop-up window, instead click the ‘Flatten Now’ button. Your position will immediately be closed at the market without a confirmation window popping-up.
 
if you change your settings in App Setting , uncheck reset AT order template, it could retain a canned order template and do as you said and I agree, the Flatten Now will close out the order at market. The possibilities are endless. have a label that shows your entry price read via OCR ,formulate a stop or profit target and fire off the script that could create a clipboard entry for stop loss/profit target. You could have order entry panel open click paste order from clipboard, Whatever you can do manually by clicking or typing can be done by the script.
Looks like part time larry has a lot of videos ie interfacing tradingview with tdameritrade api , Who knows what the possibilities could be, new stuff coming out every day.
 
#1. Is anyone putting real money on the line?
Yes, I've been running live trades since May.

#2. In the binary label, why are more than two different colors used?

In order to use only two colors, you would have to define an area of the screen for each label or check exact coordinates at which the "ON" color is located and assign exact coordinates for each position.

By using a different color for each position, I can define one area encompassing all the labels and then just assign the colors to each position.
 
Last edited:
In order to use only two colors, you would have to define an area of the screen for each label or check exact coordinates at which the "ON" color is located and assign exact coordinates for each position.

By using a different color for each position, I can define one area encompassing all the labels and then just assign the colors to each position.
I guess defining the location of the images is what I thought you were doing already (but I guess I didn't actually look at your application code for full context).

Upon review of your application code and ImageSearch documentation, the light bulb has finally lit.

Thanks for clearing up my confusion.

Reference:
https://www.autohotkey.com/docs/commands/ImageSearch.htm
 
@epete are you using the SAT-daddy app? it looks like it is an alert based trading system, so TOS sends the alert via email or sms and the app that is receiving the alert sends via tdameritrade api, is what I am figuring. Something like what this guy did: python trading thinkorswim . Another approach is youtube guy parttimelarry has tons of videos and code. You are right not everyone can get into coding.
As I learn more each day I find one more solution. @Svanoy has a pretty good one with the labels. In general though I'm finding TOS to be inconsistent and I'm sure part of that is the strategies I'm trying out. I'm finding Tradingview to have better strategy execution and tons of free indicators and strategies already made.
 
Good morning
I want to alert you about the Altredo automatic trading robot.

I have bought it, until you give it the money, they communicate frequently. Once the money that I clear the credit cards has been delivered, they have it classified as fraud. And you can only buy it for transfer. If you do not communicate several times they do not confirm the transfer.

In short, it is not a finished and perfect program that runs without problems. But they communicate and make modifications to your computer. Which is crazy.

Also, you should not update your computer unless they give you a turn beforehand. do it or tell you what and what not to do.

If you have the misfortune that it automatically updates, which is the most normal and healthy thing for your computer, they are not responsible for continuing with technical support and they ask you for $700 more. In addition to the u $ s 1800 that you already transferred, for reattaching the robot to your system.

In summary, it is a scam.
In addition to discovering that they do not let you move the screens on your computer because doing so does not work. Which indicates that they use a pattern recognition to click on the buy and sell key. This is a problem when you want to see your own screen and arrange things your way. Also, of course you cannot use it at all.

As for the profits in the end, the robot is not miraculous by any means, the indicator that they give you is far below the standards that we usually use. It is more the same that they sell for $400 and is edited for make it look like a wonder.

Altredo's robot is nothing more than a fraud that plays with people's hopes.
But it definitely does not do what its videos show that are edited in a moment of volatility and very successful to show that it is like this all the time but this does not it is nowhere near.

And to finish when you pay and you are in, in addition to denying any type of refund, they ask you for the keys to your ThinkOrSwim account in addition to total control of your computer but they cannot install it which is crazy.

I have made a mistake and I assume my loss, that is why I leave this post to help many people who, because of need or curiosity, do not fall for this deception, remember that not for nothing credit cards have it classified as fraud.

Beware of these people.
 
Last edited by a moderator:
Holy ****,......we are all sorry you endured this loss.... it sounds like a person I know who met a trader in first class who talked this person into sendng money to Asia somewhere. Anyway,....without ever hearing from first class but once, this person had to hire a lawyer, who couldn't do anything and he lost his wife's lifetime savings..
 
Holy ****,......we are all sorry you endured this loss.... it sounds like a person I know who met a trader in first class who talked this person into sendng money to Asia somewhere. Anyway,....without ever hearing from first class but once, this person had to hire a lawyer, who couldn't do anything and he lost his wife's lifetime savings..
if they're very dangerous people, that's why you have to sign them so everyone knows who they are
 
I have written and used NT8 strategies with C# and used it to connect to TDA for data feed and auto trade with fake money. My understanding was that connecting to a real account would allow for auto trading.

Well, then why not go directly. I painstakingly improved my algo, and ported it over to thinkscript from C#. It's a strategy within the program, how do I enable the trades seen on the chart to actually execute?

IF it's not possible to use the strategy to auto trade (and that's beyond stupid), is there a way to use thinkscript and a third party software to run the algo?

Going from C# took me over a year to thinkscript, as well as some improvements. Going back to a smarter language from essentially pig Latin would take forever.

Thank you for your help
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
204 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top