OCO Trailing Stop and a Stop Loss

Jam Trades

New member
Hi I'm wondering if it's possible to write a thinkscript to do the following:

Basically I just want to trailstop until my stop is breakeven then convert to a regular stop-loss order.

1) Have a trailstop working order after an order is filled. I would define the trail offset amount.
2) Once the trailstop price reaches my entry/trade price (breakeven) I want to replace the trailstop order with a stop order where the stop=entry.

Another way to do it would be: once trailstop price = entry then the offset should equal MARK - ENTRY.

Any idea on how to accomplish this?

Thanks
 
@Jam Trades In order to accomplish what you are describing you would need an OCO Trailing Stop and a Stop Loss... There is no way to have an order automagically change to another type using Thinkscript... A Trailing Stop Limit order would not provide as much protection... The Thinkorswim Learning Center explains the different Order Types and well worth reviewing...
 
@Jam Trades In order to accomplish what you are describing you would need an OCO Trailing Stop and a Stop Loss... There is no way to have an order automagically change to another type using Thinkscript... A Trailing Stop Limit order would not provide as much protection... The Thinkorswim Learning Center explains the different Order Types and well worth reviewing...
Thank you for the reply. I've looked at this and there are two problems:

1) You can't place a stop loss order with a stop price above the current ask. So setting a stop loss order at my trailstop breakeven is not possible as far as I know.

2) If both orders were active (Stop Loss and Trail Stop) then the Stop Loss would never come into play. Since the Trail Stop is always tightly trailing it will get hit first if price drops and so the Stop Loss would never factor in.

The only way I found was to set one order to cancel based on price point and the other to submit at the same price point. It;'s burdensome to enter all that order information for each trade.

I figured it would have been possible to write a thinkscript to just adjust the Trail Stop offset once a price is reached. Something like this

If Mark Price < Entry, then offset = $0.25
If Mark Price > Entry, the offset = Mark - Entry.
 
@Jam Trades Are you looking for Conditional Order code or Trade Orders...??? I usually have my STOPLOSS set below my entry price and then move it up as the price rises, thus eliminating the potential issue of getting stopped out on entry... If you want it to work as you expect then a Conditional Order would be the way to go...
 
@Jam Trades Are you looking for Conditional Order code or Trade Orders...??? I usually have my STOPLOSS set below my entry price and then move it up as the price rises, thus eliminating the potential issue of getting stopped out on entry... If you want it to work as you expect then a Conditional Order would be the way to go...

The idea would be start with a trail stop loss. Have that follow the price up until the trail stop price is at breakeven (equal to my entry), then either replace that with a stop order (with stop set at entry) or have the offset on the trail stop change at that point, so that it stops following so closely once breakeven is reached. Just looking for ideas on how one might do this.

Again it seems somewhat straightforward in theory. Once I'm breakeven I don't want my trail stop to follow so closely anymore. Obviously I can change it manually but wondering if there is a way to automate.
 
The idea would be start with a trail stop loss. Have that follow the price up until the trail stop price is at breakeven (equal to my entry), then either replace that with a stop order (with stop set at entry) or have the offset on the trail stop change at that point, so that it stops following so closely once breakeven is reached. Just looking for ideas on how one might do this.

Again it seems somewhat straightforward in theory. Once I'm breakeven I don't want my trail stop to follow so closely anymore. Obviously I can change it manually but wondering if there is a way to automate.

Like I stated previously, we can't automate the orders themselves, we can only do what you want using a Conditional Order... You can code whatever logic you want in them, within reason... Your logic sounds doable... Unfortunately, I'm fairly certain Conditional Orders don't work in Paper Trading and Strategies don't mirror Live Trading closely enough to be worthwhile so you'd need to use trial-by-fire Live Trading to test your logic... If you get the entire logic script laid out we can give it a good review before you try it with real money...
 
Like I stated previously, we can't automate the orders themselves, we can only do what you want using a Conditional Order... You can code whatever logic you want in them, within reason... Your logic sounds doable... Unfortunately, I'm fairly certain Conditional Orders don't work in Paper Trading and Strategies don't mirror Live Trading closely enough to be worthwhile so you'd need to use trial-by-fire Live Trading to test your logic... If you get the entire logic script laid out we can give it a good review before you try it with real money...
great thanks!
 
@Jam Trades conditional orders can be tricky and as @rad14733 pointed out, need to be tested live. You can do this by trading one share of a penny stock. And then test your OCO. Thus not incurring any significant losses.
I keep a code editor open w/ my generic OCO script in it. Which I can then cut and paste into the OCO editor and modify as necessary.
HTH
 

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
380 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