Position Size Calculator by @Pelonsax ( Based on adjustable stop loss level on chart, and set dollar risk per trade )

sumi1111

New member
Code:
#
# PositionSizingCalculator
#
# Author: RamonDV. AKA Pelonsax
#
#

input Risk_Amount = 100;
input Shares = 1000;
input Stop_Price = 100.00;
input Choose_Size_and_Risk = yes; #can't choose stop
input Choose_Size_and_Stop = yes; #can't choose risk
input Choose_Risk_and_Stop = yes; #can't choose size

def Mark = close(PriceType = PriceType.MARK);
def Size  = Risk_Amount / (Mark - Stop_Price);
def Stop = ((Mark * Shares) - Risk_Amount) / Shares;
def Risk = (mark - Stop_Price) * Shares;

#Display current price
AddLabel(yes, "Current Price: " + AsDollars(Mark), color.gray);

#No defined stop
AddLabel(Choose_Size_and_Risk, "No defined stop: " + Shares + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(stop) + "  .", color.gray);

#No defined risk
AddLabel(Choose_Size_and_Stop, "No Defined risk: " + Shares + " Shares with " + AsDollars(risk) + " risk with Stop Loss at " + AsDollars(Stop_Price) + "  .", color.gray);

#No defined size
AddLabel(Choose_Risk_and_Stop, "No defined size: " + Floor(Round(size)) + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(Stop_Price) + "  .", color.gray);

Hi all , I have been looking around and was wondering how to add an element to this great position size calculator I found by @Pelonsax.
https://usethinkscript.com/threads/position-size-calculator-for-thinkorswim.588/page-6#post-96047

Basically what I want to add is a price level line on the chart for the stop loss that I can adjust, so I won't have to go into the study settings to enter the stop loss price.

Does anyone have any pointers on how to implement this?
 
Last edited by a moderator:
Solution
Basically what I want to add is a price level line on the chart for the stop loss that I can adjust, so I won't have to go into the study settings to enter the stop loss price.

Does anyone have any pointers on how to implement this?
You are asking how to draw a line at a defined point?
Ruby:
input Defined_point = 100;
plot Line = Defined_point;
Basically what I want to add is a price level line on the chart for the stop loss that I can adjust, so I won't have to go into the study settings to enter the stop loss price.

Does anyone have any pointers on how to implement this?
You are asking how to draw a line at a defined point?
Ruby:
input Defined_point = 100;
plot Line = Defined_point;
 
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
495 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