Thinkorswim trading bot for moving average crossover


Category:
0
0

Hello, Pete and everyone else!

I tried to get Opera Aria to write me a trading bot code in thinkscript but it doesn’t have that function. It did it in Pine Script, C++, and Javascript, but no Thinkscript. I am wondering if any of you programmers could help me out.

Here is the description of the strategy: Enter a long position when the 10 moving average crosses over the 50 moving average, and close that position when the 10 moving average crosses under the 20 moving average. Enter a short position when the 10 moving average crosses under the 50 moving average, and close that position when the 10 moving average crosses over the 20 moving average. Enter a long position when the 50 moving average crosses over the 200 moving average, and close that position when the 20 moving average crosses under the 50 moving average. Enter a short position when the 50 moving average crosses under the 200 moving average, and close that position when the 20 crosses over the 50 moving average.

If you want to tell me to buzz off and learn code, okay, I get it. But time is of the essence.

Thank you.

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on January 24, 2024 10:20 am
91 views
0
Private answer

First up, please notice I moved this question into the "Strategy Guide" topic. The topic you selected was for TradeStation. I also updated the title of your question to reflect the context of your request. Entering a title of "Need Help With Thinkscript Code" it far to generalized. If I permitted that type of title, this entire forum would be filled with subject lines that tell users nothing about the context of each post. And it would make it impossible for viewers to use the search function and find what the are seeking.

I just wanted to explain that so you understand why I made changes and how you can participate in the forum in a way that helps you achieve your goals. (Full context in the question title helps others find your post and offer suggestions).

Ok, now let's try to address your questions and give you some tools to help you arrive somewhere close to your intended destination.

First and foremost. Thinkorswim provides only the most basic forms of trade automation. There is no way to build a "Trading Bot" within the Thinkorswim platform itself. Fully automated trading is simply not supported on the current version of Thinkorswim.

Now that you understand what Thinkorswim is NOT able to do. Let's help you understand what it can do. And more importantly, how you can use the available features on Thinkorswim to get close to your intended goal.

The good news is that I have already published a couple of free video tutorials which demonstrate nearly everything that is possible on the current version of Thinkorswim, in regards to automated trade entries and exits.

The very first video was published here:

https://www.hahn-tech.com/thinkorswim-autotrade-almost/

And the second one takes the knowledge from the first video and takes Thinkorswim trade automation to the absolute limits:

https://www.hahn-tech.com/thinkorswim-automated-round-trip-trades/

And in that second video you find the main example used was based on price crossing a moving average. Very close to what you described. The main tool you will need to master for this process is called the "Condition Wizard". Which is a tool provided by Thinkorswim enabling users to build their conditions using nothing more than a few clicks of the mouse.

You will find my master class on this topic here:

https://www.hahn-tech.com/thinkorswim-condition-wizard/

So let's close out this solution by showing you an example of how to build a condition for your long entry condition of a 10 period average crossing above a 50 period average. The screenshot below shows how that condition is constructed within the Condition Wizard. And when you click the save button, it actually generates a section of code. Here is the code that was generated from the example in the screenshot below:

SimpleMovingAvg("length" = 10)."SMA" from 1 bars ago crosses above SimpleMovingAvg("length" = 50)."SMA" from 1 bars ago

To summarize. Thinkorswim does support fully automated trading. "Trading Bots" cannot be created withing the Thinkorswim platform. The solution is to learn how to use the Condition Wizard to build your entry and exit signals. Then learn how to apply those conditions to Conditional Orders.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 24, 2024 10:44 am
0
Thank you, Mr. Hahn for your quick reply and feedback. I apologize for being a forum halfwit - I don't post to forums much. I came to you because several years ago, I made a general inquiry into a moving average cross alert, which you provided a simple code for and I have used it since - or, more precisely, whenever I've been able to use it, it worked as needed. Thank you. What you have given here is stellar and I will get on the project forthwith. It is exactly what I was looking for. I will keep you updated as to my results, if you like. Again, thank you.
( at January 24, 2024 12:24 pm)
0
Glad I I was able to help you get closer to your goal. Don't worry about your lack of experience in Q&A Forums. We all have to learn by doing. And this is the main reason I hold new questions in moderation. So I can review them and make changes, to optimize every post in this form for the benefit of all. Best of luck to you in your trading journey!
( at January 24, 2024 12:28 pm)