Risk / Position Calculator based on prior bar range

Jaaackjack

New member
VIP
Amazing!! Is it possible to use this script
https://usethinkscript.com/threads/...ls-bubbles-for-thinkorswim.10422/#post-104360
and come up with a position size calculator based off of a $ of risk that I input into the study?

So it would take my risk $ amount and calculate how many shares I could buy based off of the risk being the prior bar's range?

I look to take entries after the break of the prior bar's high or low so this would be phenomenal

Is it possible to create a label that displays the max number of shares I can trade based on my input risk $ amount with a stop the size of the prior bar's range?

For example if I want to go short with a protective stop above or below the prior bar on $500 of risk, and the prior bar's range is $0.13, then I could short up to 3,846 shares. My entry trigger's at the break of the prior bar's high or low.

Any help much appreciated! I've looked around and searched through the forums but I can't find anything that factors risk based on the prior bar's range. Though there is 1 study that uses the current bar's range, however that doesn't help me for my entries and stops since it's based on prior bar not current bar.
 
Last edited by a moderator:
Solution
For anyone that could use a risk calculator / position size calculator based on the prior bar's range and a customizeable amount of risk - I had chatGPT write a script for this and it's perfect, exactly what I needed.

What a time to be alive.


Code below and screen shot for reference

input riskAmount = 100;

declare lower;

# Calculate the prior bar's range
def priorBarRange = high[1] - low[1];

# Calculate the number of shares you can trade
def sharesToTrade = riskAmount / priorBarRange;

# Create a label to display the shares to trade
AddLabel(yes, "Shares to Trade: " + sharesToTrade, color.white);
For anyone that could use a risk calculator / position size calculator based on the prior bar's range and a customizeable amount of risk - I had chatGPT write a script for this and it's perfect, exactly what I needed.

What a time to be alive.


Code below and screen shot for reference

input riskAmount = 100;

declare lower;

# Calculate the prior bar's range
def priorBarRange = high[1] - low[1];

# Calculate the number of shares you can trade
def sharesToTrade = riskAmount / priorBarRange;

# Create a label to display the shares to trade
AddLabel(yes, "Shares to Trade: " + sharesToTrade, color.white);
 

Attachments

  • thinkorswim_iUiqVZjfZd.png
    thinkorswim_iUiqVZjfZd.png
    32.5 KB · Views: 197
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
442 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