Change % to $

TraderDan0639

New member
Plus
Hello everyone,

I already have a script written that appears in my option chain as a percentage. All I want to do is change this to appear in an actual dollar amount, and I don't really know think script. I can't even fumble through it. Everything I have tried is wrong. I have made minor alterations to think script and have cut and paste; however, I've never written a script.

This would be very simple for someone who knew what they were doing, I'm sure, lol. So, obviously, that is not me 🤦🤷🤝.

I would GREATLY appreciate it if someone could alter this.

Thank you in advance for any assistance and guidance.


input maxPctThreshold = 0.5;

def maxShares = 100;
def maxContracts = 1;

def premium = maxContracts * close * 100;
def premiumPct = premium/(MaxShares * close(getUnderlyingSymbol()));

def strikePriceGain = getStrike() - close(getUnderlyingSymbol());
def premiumPlusSharesPct = ((strikePriceGain * maxShares) + premium)/(MaxShares * close(getUnderlyingSymbol()));


AddLabel(yes, AsPercent(premiumPlusSharesPct), if premiumPlusSharesPct >= 0.5 then color.green else color.black);
 
Hello everyone,

I already have a script written that appears in my option chain as a percentage. All I want to do is change this to appear in an actual dollar amount, and I don't really know think script. I can't even fumble through it. Everything I have tried is wrong. I have made minor alterations to think script and have cut and paste; however, I've never written a script.

This would be very simple for someone who knew what they were doing, I'm sure, lol. So, obviously, that is not me 🤦🤷🤝.

I would GREATLY appreciate it if someone could alter this.

Thank you in advance for any assistance and guidance.


input maxPctThreshold = 0.5;

def maxShares = 100;
def maxContracts = 1;

def premium = maxContracts * close * 100;
def premiumPct = premium/(MaxShares * close(getUnderlyingSymbol()));

def strikePriceGain = getStrike() - close(getUnderlyingSymbol());
def premiumPlusSharesPct = ((strikePriceGain * maxShares) + premium)/(MaxShares * close(getUnderlyingSymbol()));


AddLabel(yes, AsPercent(premiumPlusSharesPct), if premiumPlusSharesPct >= 0.5 then color.green else color.black);
this section is showing as AsPercent(premiumPlusSharesPct) change to

"$" + AsText(premiumPlusSharesPct, NumberFormat.TWO_DECIMAL_PLACES)
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

this section is showing as AsPercent(premiumPlusSharesPct) change to

"$" + AsText(premiumPlusSharesPct, NumberFormat.TWO_DECIMAL_PLACES)
Hello,

I do appreciate the help and you got further than me, I couldn't get past red :) !

Unfortunately, it's not quite correct yet. So, here is my option chain. From left to right - The first Cover % you see is the %age of profit if I sell a Cover Call and keep just the premium. The second Cover %age you see is the Percentage (%) of profit if that stock hits the strike and I keep the profit from the stock and the premium. This calculation is the script that I posted and am asking to be altered to show the dollar amount of that calculation. That is what is supposed to be the third column with the red over it. I made the changes you posted and something is off in the calculations and is not showing the correct amount.

I highlighted the 79 call in this chain. The 2.58% is correct; therefore, the dollar amount should be about $201.00 and it is showing $0.03.

Just for clarification, I wrote about because the spread is .85 to 1.05 and I used 1.00 and I am pretty close to that %age. I don't know exactly how that is calculated in the script/formula. "Pretty Close" is the script showing 2.58% and I calculated 2.54%, so about 201 is right there.

I hope this clarifies my request and you can make further suggestions.

1724296383847.png
 
I'm no expert in cover calls and the process behind it. I thought you needed data display change.

can't promise anything. is this what you need?

Python:
input maxPctThreshold = 0.5;

def maxShares = 100;
def maxContracts = 1;

def premium = maxContracts * close * 100;

def strikePriceGain = getStrike() - close(getUnderlyingSymbol());

def premiumPlusSharesAmount = (strikePriceGain * maxShares) + premium;

AddLabel(yes, AsDollars(premiumPlusSharesAmount),
    if premiumPlusSharesAmount >= maxPctThreshold * maxShares * close(getUnderlyingSymbol()) then Color.GREEN else Color.BLACK);
 
I'm no expert in cover calls and the process behind it. I thought you needed data display change.

can't promise anything. is this what you need?

Python:
input maxPctThreshold = 0.5;

def maxShares = 100;
def maxContracts = 1;

def premium = maxContracts * close * 100;

def strikePriceGain = getStrike() - close(getUnderlyingSymbol());

def premiumPlusSharesAmount = (strikePriceGain * maxShares) + premium;

AddLabel(yes, AsDollars(premiumPlusSharesAmount),
    if premiumPlusSharesAmount >= maxPctThreshold * maxShares * close(getUnderlyingSymbol()) then Color.GREEN else Color.BLACK);
Hello again,

Thank you so much. When I saw the original script correction you posted, I thought this might not work. I also realized that you did exactly what I asked. I thought I was being all detailed and did not really clarify that I wanted it to calculate the max profit in dollars and then display it too, not just display the percent amount in dollars.

Yes, this seems to be working well and is accurate best I can tell. Well, I did the math and it seems great!! Thank you again for all your help.

Have a great evening, week, and upcoming weekend.

Respectfully,
Daniel
 
Hello again,

Thank you so much. When I saw the original script correction you posted, I thought this might not work. I also realized that you did exactly what I asked. I thought I was being all detailed and did not really clarify that I wanted it to calculate the max profit in dollars and then display it too, not just display the percent amount in dollars.

Yes, this seems to be working well and is accurate best I can tell. Well, I did the math and it seems great!! Thank you again for all your help.

Have a great evening, week, and upcoming weekend.

Respectfully,
Daniel
Hello again,

One more question. Since the results are round numbers, is there a way to remove the .00 at the end of the number. I did not see anything in the script that showed a decimal positions to change. It is written and displays as $180.00 in the platform instead of $180 or 180. It would just be cleaner and take up less space.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
489 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