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