Reference A Study As A Conditional Order Trigger In ThinkOrSwim

mluttph

Member
I've seen people say you can reference a study as conditional order trigger. I think my code is too long to paste in, so that may work. But I don't see how to reference a study as the order trigger.

I think I found it. You go over to the top right and hit inspector.
 
Last edited by a moderator:
Solution
Today my orders on a margin account and a regular account both bought using newly created 1st trgs seq orders using custom studies. So it looks like the problem may have been modifying saved orders.
On the margin account the buy was to cover a short, it triggered a buy to open. The next order in the seq would be a sell to close triggered by a study. I have not had a day that needed to go that deep into my 1st trgs seq so I don't know if that would work.
Instead of clicking on thinkscript editor and stuffing all your code in.
Click on the tab before the editor: Condition Wizard.
It will open the same widget that you use to filter scan hacker, chart alerts conditional orders, etc...

If you haven't used the Condition Wizard before, see the scan hacker tutorial:
https://usethinkscript.com/threads/how-to-use-thinkorswim-stock-hacker-scans.284/
cyOvADz.png
 
Last edited:

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

So today I had a 1st triggers seq. It was a sell 100%. It should have sold but it didn't. When I look at the Monitor page it shows that the 100% sell triggered but didn't actually sell, then there is another sell that magically appeared, this time it has the number of shares I own. But it did not trigger. I'm hoping that using the 100% sell instead of the exact numbers is the problem.
 
So today I had a 1st triggers seq. It was a sell 100%. It should have sold but it didn't. When I look at the Monitor page it shows that the 100% sell triggered but didn't actually sell, then there is another sell that magically appeared, this time it has the number of shares I own. But it did not trigger. I'm hoping that using the 100% sell instead of the exact numbers is the problem.
To determine if there is a syntax issue, test conditional orders as a chart alert.
  • right-click on your chart
  • scroll down to alerts
  • use the condition wizard to set up your alert.
If the chart alert triggers then the issue is not with your script.
 
Ok I will try this. I have the buy and sell studies set up to show in a lower panel. It triggered there today like it should. I did the alert after the fact with the sell study and it shows it should have triggered. I have a buy alert setup now.
Thanks for your help

Looking at the monitor page and what should have been a sell 100% to close and then a sell to open, instead turned into two sell to close one being 100% and the next close being the number of shares 100% would have been. Then a sell to open.
The one time I got this to work I used an exact shares number, I'm thinking that it doesn't like the 100% or a dollar amount. I'll keep trying.

What I think is happening is when you use 100% or a dollar amount, thinkorswim figures the number of shares and resubmits the conditional order.
If you are using code to trigger the conditional order the resubmitted order is still true. But when using a study like mine once its triggered its no longer true. Its now looking for the opposite trade. So it doesn't trigger the resubmitted order. Just my best guess.

Today the study called for a buy, but the conditional order or the test alert, did not fire. When I look at the monitor page the conditional order has a blank in the symbol area. Which is strange because the condition order I submitted had the symbol. My condition order should trigger a second order that is just a simple math equation that will always trigger. It does have the symbol. Only the ones that are based on a study are missing the symbol. I'm now editing the submitted conditional orders to add the symbol. Hope it works.

The missing symbol happens when I use a saved 1st trgs seq conditional order. It doesn't happen when I create a new 1st trgs seg conditional order.

Today it should have sold. The study did in a lower panel. But the order did not trigger. No clue why. Hope someone can give me a clue.
I found this, "In Conditional Orders, you can use either a regular study or an expression." , I don't believe my custom study would qualify as a regular study.

I wonder how many people are triggering a conditional order with a study and do complex custom studies work?
 
Last edited:
I don't believe my custom study would qualify as a regular study.

I wonder how many people are triggering a conditional order with a study and do complex custom studies work?

I use Sequential Conditional Orders quite often. It can and has worked with my Custom Studies. One thing I have found out is if you re-used a saved Conditional Order TOS will screw it up when you reload it. And if submitted it will not trigger either a Buy or Sell. There is a Heads Up about this. You might want to read it if you re-use saved Conditional orders. But I also have noticed this behavior. I have reported it to TOS Support via their Chat and also emailed them about it. You might also want to chat with TOS Support or email them or both. The more squeeky wheels reporting the issue the better the chances of it getting fixed. I can share more information about how I build my SCO's if you want. Let me know.
 
I use Sequential Conditional Orders quite often. It can and has worked with my Custom Studies. One thing I have found out is if you re-used a saved Conditional Order TOS will screw it up when you reload it. And if submitted it will not trigger either a Buy or Sell. There is a Heads Up about this. You might want to read it if you re-use saved Conditional orders. But I also have noticed this behavior. I have reported it to TOS Support via their Chat and also emailed them about it. You might also want to chat with TOS Support or email them or both. The more squeeky wheels reporting the issue the better the chances of it getting fixed. I can share more information about how I build my SCO's if you want. Let me know.
I use a medium size custom study for spy with 5min bars, 180 day time frame. I divided it into a buy and a sell study. I edit every day to add some daily numbers from the previous day. It worked once and hasn't worked since. I'm on vacation now but will work on it when I get back. Any suggestions will be appreciated.

I think I will try creating a new 1st trgs seq, instead of altering a saved one.
 
Last edited:
Today my orders on a margin account and a regular account both bought using newly created 1st trgs seq orders using custom studies. So it looks like the problem may have been modifying saved orders.
On the margin account the buy was to cover a short, it triggered a buy to open. The next order in the seq would be a sell to close triggered by a study. I have not had a day that needed to go that deep into my 1st trgs seq so I don't know if that would work.
 
Last edited:
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
338 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