Conditional Orders

Tomahawk6117

Member
Plus
I have recently placed an order to sell a stock when 1 of 2 conditional orders were met, and this worked. The first conditional order was to sell the stock if the price increased at least 10% from the market open price. The second conditional order was to sell the stock if the price decreased at least 20% from the market open price. The stock price increased 10% from the market open, and it triggered, which is great.

I then tried inserting a third conditional order to sell the stock at the time, 15:55:00. I put this conditional order in place in the instance that neither of the original conditional orders filled. However, when I included this third conditional order, none of the conditional orders worked, even though this stock increased more than 10% from the market open.

I have tested the thinkScript for the third conditional order on its own, and it did trigger at approximately 15:55:00. However, when included as the third conditional order, the other two conditional orders did not trigger. Below I have included the code for the third conditional order, as well as a screenshot of what my conditional order entries look like. The code is revised from an original code I learned about through a post by @halcyonguy, thank you. May someone please provide me with some guidance so that all three conditions will work? Thank you very much for your time and your help.

Code:
input time1 = 1555;

def timez = SecondsFromTime(time1) == 0;
def desiredbar = timez;

plot z1 = desiredbar;

eLOKuOi.png
 
Hi @MerryDay, I hope you are doing well. I know you have posted about conditional orders before, and I was wondering, would you please be able to offer any advice to the post above? Thank you very much for your time and your help.
 
The number of conditional orders does not matter.

So we have to look at other issues.
My guess is that your trigger order (step 2):
2. Wait until trigger order for this group is filled
is preventing you from ever getting to (step 3):
3. Wait until at least one of the following conditions is satisfied

should look like:
vYrYCJd.png
 
The number of conditional orders does not matter.

So we have to look at other issues.
My guess is that your trigger order (step 2):
2. Wait until trigger order for this group is filled
is preventing you from ever getting to (step 3):
3. Wait until at least one of the following conditions is satisfied

should look like:
vYrYCJd.png
Thank you very much @MerryDay, I really appreciate your response. The reason why there is a step 2, "Wait until trigger order for this group is filled," is because I am executing a "1st trgs seq" order. In order for the sell order to execute, there has to be a buy order first, which is executed at the market open.

In regards to the code below, which is the 3rd conditional order, do you believe there is anything I can do to improve upon it? I am trying to set a code so that the the stock sells at 15:55:00 if the other conditions are not met. Or do you have any other suggestions to try first? Thank you very much for your time and your help @MerryDay.

Code:
input time1 = 1555;

def timez = SecondsFromTime(time1) == 0;
def desiredbar = timez;

plot z1 = desiredbar;
 
Thank you very much @MerryDay, I really appreciate your response. The reason why there is a step 2, "Wait until trigger order for this group is filled," is because I am executing a "1st trgs seq" order. In order for the sell order to execute, there has to be a buy order first, which is executed at the market open.

In regards to the code below, which is the 3rd conditional order, do you believe there is anything I can do to improve upon it? I am trying to set a code so that the the stock sells at 15:55:00 if the other conditions are not met. Or do you have any other suggestions to try first? Thank you very much for your time and your help @MerryDay.

Code:
input time1 = 1555;

def timez = SecondsFromTime(time1) == 0;
def desiredbar = timez;

plot z1 = desiredbar;
My understanding of your situation is:

You want the sell order to execute if:
(condition1 or condition3)
OR
(condition 2 or condition3)

To test if this works:
1. Add condition 3 to condition1 script
2. Add condition3 to condition2 script.
3.Test and debug using these steps:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-80482
 
Is it possible to create an order that always selling price higher than the buying price? Do I need to function "if"?


To stop losses in stocks, would these commands be helpful? (close < EntryPrice() + 0.05) or (EntryPrice is less than bid)
 
Last edited by a moderator:
entryprice() is not an available data field in OCOs
When I conditionally sell my stock, It appears that establishing the EntryPrice within the Study function and comparing it with "less than" against the bid price in the prices, would enable the creation of the Stop Loss Conditional Order on Bid for ThinkOrSwim. What do I think about it?
 
When I conditionally sell my stock, It appears that establishing the EntryPrice within the Study function and comparing it with "less than" against the bid price in the prices, would enable the creation of the Stop Loss Conditional Order on Bid for ThinkOrSwim. What do I think about it?
Yes, EntryPrice() functions works on charts and in backtesting with AddOrder statements.
But supposedly not in conditional orders.

How Conditional Orders work:
In the below conditional order, it says sell when close>close[10] bars ago
See where the alert indicator at the bottom ticks up to 1 when the condition is true, ticks down to zero for false?
7f5uRDp.png



Now, here is an example using EntryPrice().
I bought $PWR at $178.85
hVGF51J.png

Here is a sell order to sell when EntryPrice() < $200
There are no upticks at the bottom, because the conditional order does not recognize the EntryPrice() function. This order will never fill.
kCkIgIA.png


I do use OCOs extensively; but to be honest, I have never used EntryPrice() in my OCOs.
Given that conditional orders need to be set up manually. And given that I know my entry price, I just hard-code it into my conditional orders.
This is the fastest and easiest way from me to get my OCOs set up.

Here is how to run your conditional orders though testing:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-80482

If you get it to work in the above testing process. Why not try it live?
Come back and relay your experiences.
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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