Vertical Spread Strategy

stone

Member
Hi, I noticed in TOS studies that it buys or sells 100 shares. Is it possible to create a study to back test for selling verticle credit spreads? I've been researching code today. I'm not a coder but the easiest strategy is to sell a put credit spread using the 30 & 15 Delta, when price is above 30SMA, 50SMA, and 200 SMA. The expiration is monthly's 30-40 days. Sell a call credit spread with the opposite happens price below 30, 50, 200SMA. After watching youtube this is what I came up with but I'm stuck. Any help would be appreciated.

input shortMA length = 30;
input mediumMA length = 50;
input longMA length = 200;

def shortMA = SimpleMovingAvg(length = shortMAlength;
def mediumMA = SimpleMovingAvg(length = mediumMAlength;
def longMA = SimpleMovingAvg(length = longMAlength;

def buy =
YIKES!
 
Last edited by a moderator:
Solution
@stone Have you ever played with Simulate Trades on the Trade tab before...??? That's the quickest and simplest way to test various Options Strategies... Thinkorswim just doesn't provide the resources needed to adequately backtest Option Strategies, even with complex code...
@stone Are you thinking of having a Study/Strategy select your credit spread automagically, because that would be a daunting task at best using Thinkscript... The conditional triggers can be done, it's the calculation of proper options that presents the problem... Can you provide more details on your desires please...???
 
@stone Are you thinking of having a Study/Strategy select your credit spread automagically, because that would be a daunting task at best using Thinkscript... The conditional triggers can be done, it's the calculation of proper options that presents the problem... Can you provide more details on your desires please...???
hi, thanks for the quick response. just curious how to back test a strategy selling credit spreads. Is there a way? maybe using demand and going through dates? wow that's daunting. I just thought there would be a way to back test maybe every 10 days if price is over the SMA's?
I was just looking at another simple command maybe would be 10 day expire, price above 200 and 30 sma, sell a put spread at -.15 delta. and the short leg just below that. Any thoughts would be great. Just wanting to back test that.
 
@stone Have you ever played with Simulate Trades on the Trade tab before...??? That's the quickest and simplest way to test various Options Strategies... Thinkorswim just doesn't provide the resources needed to adequately backtest Option Strategies, even with complex code...
 
Last edited by a moderator:
Solution
@stone Have you ever played with Simulate Trades on the Trade tab before...??? That's the quickest and simplest way to test various Options Strategies... Thinkorswim just doesn't provide the resources needed to adequately backtest Option Strategies, even with complex code...
Rad, I've never used that. So it is a little faster thank using on demand based on slow buffer (could be my laptop). Though it is time consuming. So another idea. I noticed on all strategies withing floating P/L; the code says.. Example at the end of the strategy. Is there a way to code buy a call or sell a call? The p/l is so different with options...hence maybe I can use an already coded strategy but dictate an option class of some sort? By the way thank you for all u do.
AddOrder(OrderType.BUY_AUTO, diff crosses above 0, tickColor = GetColor(0), arrowColor = GetColor(0), name = "MACDStratLE");
AddOrder(OrderType.SELL_AUTO, diff crosses below 0, tickColor = GetColor(1), arrowColor = GetColor(1), name = "MACDStratSE");
 
@stone We can only apply AddOrder() to the current chart symbol so, no, there is no way to tell Thinkscript we want to Buy or Sell an Option...
 
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
269 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