AGAIG 0DTE Buy or Sell Iron Fly for Profit For ThinkOrwim

Tried this a about 10 times. Sometimes it starts to go against you right away, seems like when the underlying price goes down. I have go to work as this comes out so I started to set a OCO bracket with a .40P/L. Seems to be profitable most of the time. Started doing .10 trail stop and get about .10 profit before the stop is hit. Keeps from losing much and I don't have to watch it. I'll keep testing to see overall profit loss. If there are better ways to set up, I'm all ears😊
 
Hi @Cricksdds - Another great indicator going to test in demand mode have you been setting both TP and SL for 35%? Also for the SL is it mental or have you ever had luck setting them in TOS on BF's and or Spreads find that they can be difficult?
Those are recommendations for the wings. You can set them tighter, or further out if you wish. The more legs you have in a trade the harder they are to close as verses a simple Put or Call.
 
The edge is discipline. A hard 35% target plus a defined late-day exit turns a probability edge into consistent, bankable results


When you say “consistent, bankable results,” are you referring to actual live or paper-trading results?

If so, it would be helpful to see a summary of those results, including the number of trades, wins and losses, net P/L, and the period covered.
 
When you say “consistent, bankable results,” are you referring to actual live or paper-trading results?

If so, it would be helpful to see a summary of those results, including the number of trades, wins and losses, net P/L, and the period covered.

paste this extra code to the bottom of the current code just before the final alert:

Code:
# --- Historical touch-rate tracker (based on chart's loaded intraday history) ---
input exitCheckHour = 15;
input exitCheckMinute = 55;

def isExitCheckBar = SecondsFromTime(exitCheckHour * 100 + exitCheckMinute) >= 0 and
SecondsFromTime(exitCheckHour * 100 + exitCheckMinute) < GetAggregationPeriod() / 1000;

# Track the day's high/low from the entry bar forward
def dayHighSinceEntry = if isEntryBar then high
else if newDay then Double.NaN
else if !IsNaN(dayHighSinceEntry[1]) then Max(dayHighSinceEntry[1], high)
else Double.NaN;

def dayLowSinceEntry = if isEntryBar then low
else if newDay then Double.NaN
else if !IsNaN(dayLowSinceEntry[1]) then Min(dayLowSinceEntry[1], low)
else Double.NaN;

# Did either wing get touched today, checked once per day at the exit-check bar
def touchedTodaySell = !IsNaN(dayHighSinceEntry) and
(dayHighSinceEntry >= sellWingUpperFinal or dayLowSinceEntry <= sellWingLowerFinal);
def touchedTodayBuy = !IsNaN(dayHighSinceEntry) and
(dayHighSinceEntry >= buyWingUpper or dayLowSinceEntry <= buyWingLower);

def recordBar = isExitCheckBar and !IsNaN(dayHighSinceEntry);

def totalDaysCount = if IsNaN(totalDaysCount[1]) then (if recordBar then 1 else 0)
else totalDaysCount[1] + (if recordBar then 1 else 0);

def touchedDaysCountSell = if IsNaN(touchedDaysCountSell[1]) then (if recordBar and touchedTodaySell then 1 else 0)
else touchedDaysCountSell[1] + (if recordBar and touchedTodaySell then 1 else 0);

def touchedDaysCountBuy = if IsNaN(touchedDaysCountBuy[1]) then (if recordBar and touchedTodayBuy then 1 else 0)
else touchedDaysCountBuy[1] + (if recordBar and touchedTodayBuy then 1 else 0);

def sellTouchRatePct = if totalDaysCount > 0 then touchedDaysCountSell / totalDaysCount * 100 else Double.NaN;
def buyTouchRatePct = if totalDaysCount > 0 then touchedDaysCountBuy / totalDaysCount * 100 else Double.NaN;

AddLabel(isExitCheckBar, "3:55 CHECK: If GTC not filled, consider closing at market (0DTE only)", Color.ORANGE);
AddLabel(totalDaysCount > 0,
"Historical SELL wing touch rate: " + Round(sellTouchRatePct, 1) + "% over " + totalDaysCount + " days (target " + AsPercent(sellTargetPOT) + ")",
Color.MAGENTA);
AddLabel(totalDaysCount > 0,
"Historical BUY wing touch rate: " + Round(buyTouchRatePct, 1) + "% over " + totalDaysCount + " days (target " + AsPercent(buyTargetPOT) + ")",
Color.MAGENTA);

Alert(isExitCheckBar, "0DTE 3:55 exit check - close if GTC not hit", Alert.BAR, Sound.Bell);


NOTE:

How to read it: once the chart has loaded enough days, two magenta labels show up — "Historical SELL wing touch rate" and "Historical BUY wing touch rate" — each telling you the actual observed percentage of days the respective wings got touched, versus the theoretical target (35% / 70%) the model was aiming for. If the empirical number drifts a lot from the target over time, that's a sign the IV input or the zero-drift assumption isn't matching real QQQ behavior well, and worth investigating before trusting the live signal too much.


To control how many days it's measuring, adjust your chart's lookback period (Chart Settings → gear icon → "from" date or number of days) rather than anything in the code — the study just counts whatever's loaded.
  • ThinkScript can't do a true multi-year backtest inside a chart study. It can only look back over however much intraday (5-min) history your chart has currently loaded — on ToS that's typically somewhere around 30-60 trading days depending on your data plan and chart settings, not years.
  • This will give you an empirical touch rate: of all the days the chart has loaded, how often did price actually touch the sell-side wings vs. the buy-side wings — so you can sanity-check the theoretical 35%/70% targets against what actually happened.
  • For a real historical backtest (months/years, with P&L, not just touch frequency), you'd want to export data to Excel/Python, or use ToS's dedicated strategy backtester — a chart study isn't built for that scale.
 
Last edited by a moderator:
I posted this type of trading as one way to trade. There are as many ways to trade as there are ways to get to Orlando from here in The Villages. One should always find a style that works for them. As a teacher trader I will continue to show different methods but, will admit, there is no holy grail that works every time. In my experience the easiest trades to get in/out from are ones with fewer arms and legs. It's easiest to get in/out of a straight call or put and adding other parts to the trade usually cut down on getting filled especially getting out. I have also found that trades placed a few days out gives the trader more flexibility. My current trading is simple calls or puts with no 0DTE even though my goal is in/out the same day. Also taking smaller profits instead of swinging for the trees leads to better overall success. Currently I am trading the SPY and QQQ quite frequently and maybe one or two more stocks that have volatility of 5+ daily movement as these also have good intra-day movement. Basically an option has the same price today, tomorrow and/or next week with the difference in price being the time factor. I quit screening for trades several years ago as a waste of time. The stocks (ETFs all do the same thing) up/down/sideways. Don't make your life more complicated than it needs to be. I find that the SPY and QQQ usually change direction around 10:00 a.m. and a few correctly placed contracts where at least two+ plus of my indicators suggest a change-in-direction make the day satisfactorily profitable without giving some of it back in the afternoon. Sorry for these ramblings of an old man. Much success in your trading! Just don't make it harder than it needs to be.
 
I posted this type of trading as one way to trade. There are as many ways to trade as there are ways to get to Orlando from here in The Villages. One should always find a style that works for them. As a teacher trader I will continue to show different methods but, will admit, there is no holy grail that works every time. In my experience the easiest trades to get in/out from are ones with fewer arms and legs. It's easiest to get in/out of a straight call or put and adding other parts to the trade usually cut down on getting filled especially getting out. I have also found that trades placed a few days out gives the trader more flexibility. My current trading is simple calls or puts with no 0DTE even though my goal is in/out the same day. Also taking smaller profits instead of swinging for the trees leads to better overall success. Currently I am trading the SPY and QQQ quite frequently and maybe one or two more stocks that have volatility of 5+ daily movement as these also have good intra-day movement. Basically an option has the same price today, tomorrow and/or next week with the difference in price being the time factor. I quit screening for trades several years ago as a waste of time. The stocks (ETFs all do the same thing) up/down/sideways. Don't make your life more complicated than it needs to be. I find that the SPY and QQQ usually change direction around 10:00 a.m. and a few correctly placed contracts where at least two+ plus of my indicators suggest a change-in-direction make the day satisfactorily profitable without giving some of it back in the afternoon. Sorry for these ramblings of an old man. Much success in your trading! Just don't make it harder than it needs to be.
Your sage advice and guidance are always appreciated, as are your easy to use (and visually appealing) charts! One thing I have realized about trading: it's inherently hard and difficult. Anyone who makes it seem easy is being dis-honest. In various forums, I see people posting profits and numbers without ever showing how they achieved the results. Sort of like the math teacher showing the answer to the problem without showing the calculations to get the answer. An exercise in ego-boosting and not very helpful to others. You, sir, on the other hand are to be commended for your willingness to help others profit and for your generosity with your time and efforts. Well done. 🙏
 
Your sage advice and guidance are always appreciated, as are your easy to use (and visually appealing) charts! One thing I have realized about trading: it's inherently hard and difficult. Anyone who makes it seem easy is being dis-honest. In various forums, I see people posting profits and numbers without ever showing how they achieved the results. Sort of like the math teacher showing the answer to the problem without showing the calculations to get the answer. An exercise in ego-boosting and not very helpful to others. You, sir, on the other hand are to be commended for your willingness to help others profit and for your generosity with your time and efforts. Well done. 🙏
Kind words…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
1300 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