Help with TOS OCO Conditional Order Code

ChrisK

New member
I am new to the group and I need some help. I have written two TOS OCO Orders to exit existing option positions. One utilizes the underlying stock price while the second utilizes option pricing. The logic is what I want, but the code works intermittently. My preference to do a zoom meeting with someone that can help. (I have Discord and Zoom accounts if needed). Suggestions please…

The Exit Order Code is generated using Google Spreadsheets

This is the input data
Option Entry Price: 2.27
ATR14: 1.57

Spreadsheet Calculations
.8 * ATR
1.2* Entry
1.4* Entry
1.6* Entry
0.8* Entry
BE + 0.10 (Entry + 0.10)

Spreadsheet Date Calculations
Day0: 20210630
Day1: 20210701
Day2: 20210702
Day3: 20210705

This is the Spreadsheet Generated Code


Underlying Stock Pricing - Daily Chart

#Pullback Exit 1L
(GetYYYYMMDD() is greater than or equal to 20210630 and SecondsFromTime("fromTime" = 0700) is greater than or equal to 0 and high("period" = AggregationPeriod.DAY, "priceType" = PriceType.LAST ) - close("period" = AggregationPeriod.DAY, "priceType" = PriceType.LAST ) is greater than or equal to 1.26) or (GetYYYYMMDD() is greater than or equal to 20210701 and SecondsFromTime("fromTime" = 0930) is greater than or equal to 0 and (high("period" = AggregationPeriod.DAY, "priceType" = PriceType.LAST ) from 1 bars ago - close("period" = AggregationPeriod.DAY, "priceType" = PriceType.LAST ) is greater than or equal to 1.26))
#Pullback Exit 1L - Daily Chart


Option Pricing - 1 Minute Chart

#Pct Gains Exit 2L
(GetYYYYMMDD() is equal to 20210630 and SecondsFromTime("fromTime" = 1545) is greater than or equal to 0 and close("period" = AggregationPeriod.MIN, "priceType" = PriceType.BID ) is less than or equal to 2.72) or (GetYYYYMMDD() is equal to 20210701 and SecondsFromTime("fromTime" = 1545) is greater than or equal to 0 and close("period" = AggregationPeriod.MIN, "priceType" = PriceType.BID ) is less than or equal to 3.18) or (GetYYYYMMDD() is equal to 20210702 and SecondsFromTime("fromTime" = 1545) is greater than or equal to 0 and close("period" = AggregationPeriod.MIN, "priceType" = PriceType.BID ) is less than or equal to 3.63) or (GetYYYYMMDD() is greater than or equal to 20210705 and SecondsFromTime("fromTime" = 1545) is greater than or equal to 0) or (GetYYYYMMDD() is greater than or equal to 20210701 and SecondsFromTime("fromTime" = 0935) is greater than or equal to 0 and close("period" = AggregationPeriod.MIN, "priceType" = PriceType.BID ) is less than or equal to 2.37) or (GetYYYYMMDD() is greater than or equal to 20210630 and SecondsFromTime("fromTime" = 0935) is greater than or equal to 0 and close("period" = AggregationPeriod.MIN, "priceType" = PriceType.BID ) is less than or equal to 1.26)
#Pct Gains Exit 2L - Minute Chart

Additionally, I would like to pull in the ATR14 value in TOS to eliminate manual entry.

Please advise. Thanks
 

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