Alert when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected

Devanreddy

New member
VIP
Hello fellow traders.

I am in need of what I consider a simple ToS script. Unfortunately for me I cannot code ToS scripts.
Anyhoo, here goes.

I sell option and collect premium. I would like to have a script that has 5 alerts that I can include on the Option chart that will alert me when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected. I'm currently doing this manually and would like to automate this, since I trade this daily.

Even if someone give me the code for inserting a single alert and then I can replicate it for the other ones.

Thank you in Advance.
Devan
 
Solution
Hello fellow traders.

I am in need of what I consider a simple ToS script. Unfortunately for me I cannot code ToS scripts.
Anyhoo, here goes.

I sell option and collect premium. I would like to have a script that has 5 alerts that I can include on the Option chart that will alert me when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected. I'm currently doing this manually and would like to automate this, since I trade this daily.

Even if someone give me the code for inserting a single alert and then I can replicate it for the other ones.

Thank you in Advance.
Devan

i think this will do what you want.

enter a base price ( premium price)
enter 5 factor numbers

if price goes above a price level (...
Just set a few price action alerts on your chart. I think that would be much easier and simpler.

For example, you sold a put on AAPL and the stock is trading at $250. Set price alerts for $220, $200, and $150, etc.

If the stock price crosses below those alerts, you're definitely going to know that your option premium has increased significantly.
 
Hello fellow traders.

I am in need of what I consider a simple ToS script. Unfortunately for me I cannot code ToS scripts.
Anyhoo, here goes.

I sell option and collect premium. I would like to have a script that has 5 alerts that I can include on the Option chart that will alert me when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected. I'm currently doing this manually and would like to automate this, since I trade this daily.

Even if someone give me the code for inserting a single alert and then I can replicate it for the other ones.

Thank you in Advance.
Devan

i think this will do what you want.

enter a base price ( premium price)
enter 5 factor numbers

if price goes above a price level ( factor * base price) , then a line starts to draw.
if price doesn't go above a level, then the line starts after the last bar.

alert should beep on the first time price goes above a level.
can pick the price used to compare against the levels. default is high.

i used
15 min chart
.T260116C26 0.90
different base price and factor numbers

Code:
#lines_multiples_of_baselevel

#https://usethinkscript.com/threads/alert-when-the-price-of-option-is-at-4x-5x-7x-9x-11x-times-the-premium-collected.21722/
#Alert when the price of option is at 4x, 5x, 7x, 9x, 11x times the premium collected

def na = double.nan;
def bn = barnumber();

input premium_price = 0.8;
def prem = if premium_price > 0 then 1 else 0;

input factor1 = 4.0;
input factor2 = 5.0;
input factor3 = 7.0;
input factor4 = 9.0;
input factor5 = 11.0;

input hiprice = high;

def line1 = if bn == 1 then 0
 else if line1[1] > 0 then line1[1]
 else if isnan(close) then (premium_price * factor1)
 else if (hiprice > (premium_price * factor1)) then (premium_price * factor1)
 else line1[1];


def line2 = if bn == 1 then 0
 else if line2[1] > 0 then line2[1]
 else if isnan(close) then (premium_price * factor2)
 else if (hiprice > (premium_price * factor2)) then (premium_price * factor2)
 else line2[1];

def line3 = if bn == 1 then 0
 else if line3[1] > 0 then line3[1]
 else if isnan(close) then (premium_price * factor3)
 else if (hiprice > (premium_price * factor3)) then (premium_price * factor3)
 else line3[1];

def line4 = if bn == 1 then 0
 else if line4[1] > 0 then line4[1]
 else if isnan(close) then (premium_price * factor4)
 else if (hiprice > (premium_price * factor4)) then (premium_price * factor4)
 else line4[1];

def line5 = if bn == 1 then 0
 else if line5[1] > 0 then line5[1]
 else if isnan(close) then (premium_price * factor5)
 else if (hiprice > (premium_price * factor5)) then (premium_price * factor5)
 else line5[1];


plot lvl0 = if prem then premium_price else na;
lvl0.SetDefaultColor(Color.yellow);
#lvl0.setlineweight(0);
#lvl0.hidebubble();

plot lvl1 = if prem and line1 > 0 then line1 else na;
lvl1.SetDefaultColor(Color.cyan);
#lvl1.setlineweight(0);
#lvl1.hidebubble();

plot lvl2 = if prem and line2 > 0 then line2 else na;
lvl2.SetDefaultColor(Color.cyan);
#lvl2.hidebubble();

plot lvl3 = if prem and line3 > 0 then line3 else na;
lvl3.SetDefaultColor(Color.cyan);
#lvl3.hidebubble();

plot lvl4 = if prem and line4 > 0 then line4 else na;
lvl4.SetDefaultColor(Color.cyan);
#lvl4.hidebubble();

plot lvl5 = if prem and line5 > 0 then line5 else na;
lvl5.SetDefaultColor(Color.cyan);
#lvl5.hidebubble();


input alerts_on = yes;

alert(alerts_on and (line1 > 0 and line1[1] == 0), "Level 1 " + line1, alert.BAR, sound.DING);
alert(alerts_on and (line2 > 0 and line2[1] == 0), "Level 2 " + line2, alert.BAR, sound.DING);
alert(alerts_on and (line3 > 0 and line3[1] == 0), "Level 3 " + line3, alert.BAR, sound.DING);
alert(alerts_on and (line4 > 0 and line4[1] == 0), "Level 4 " + line4, alert.BAR, sound.DING);
alert(alerts_on and (line5 > 0 and line5[1] == 0), "Level 5 " + line5, alert.BAR, sound.DING);

#
 

Attachments

  • 00a-1.JPG
    00a-1.JPG
    72.5 KB · Views: 45
Solution

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