Intraday Position Size Calculator Help


New member
Hey everyone,

I have a question, maybe someone can assist, or give any idea.

In this image I uploaded you can see what I did, and what I wish it could be:


In short, I would like to fully convert the Fibonacci Retracement tool to a Risk/Reward tool. I did some of it by a simple study edit of that tool, but I wish also to add automatic indications for the "price difference" between the entry and the stop loss with an automatic calculation of the amount of shares you need to buy (based on your risk)

Somebody maybe know some ThinkScript? Or have any Idea where can I find assistance on that?

Many Thanks!!


Well-known member
Thank You ... Really the most important feature would be if it can calculate the previous candle Risk calculator instead of the current one. The script I would love to have is to calculate the previous candle. Thank you
Also is their a way to position the Trg bracket in descending order. Everytime I use one of the drop down box it keep the most current one a the top which is out of order.

The code in this this post above will calculate based on the previous candle if you set the candleIndex input to 1.

We have no way to control the Active Trader templates.

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


New member
As Merry indicated, we can't do anything on hover. However, TOS already gives you what you're asking for. If you look at the top of the chart, below the symbol entry field, it shows Symbol, Timeframe, Date, Open, High, Low, Close, Range. Range is what you care about. Just add .02 to it if you're keeping that extra two cents.

Alternatively, you could have a lower study that shows you the calculated range as a plot. To see what that would look like, try adding the ATR study to your chart. The numbers won't be what you're looking for. This is just to demonstrate what it would look like and how you can hover over past candles to see the values for those periods in the lower indicator's title bar.

With this range plus a couple cents calculation being simple mental math I just do as I described in the first paragraph.
The only problem with the script above for me is that Its not calculating based on dollar amount its set to % how do we change that???


New member

Just joined.

I am looking for an indicator that calculates the candle stick bar. For example if the bar opens up at 250.01 and closes at 251.10. I want an indicator that quickly tells me the difference which in this example for be 1.09. Is there such an indicator ? this would help me greatly with calculating risk entry size. An indicator that enables me to hover over a candle bar and quickly know the difference. The difference should be posted at the top left of the chart.


New member
Yeah, it looks kind of complicated... I too have recently started. And some of the answers here are helpful to me as well. At first, I didn't quite understand what`s this and why so, and was often confused about the values, especially with calculating the number of shares, but then I found an easy way out for myself. I use this calculator and so far it`s the most convenient for me. You can try it here, the values and numbers might be different but it`s better than using only a chart and following it. Anyway it's all relative.
Last edited:


New member
I modified something I used to use to put something together for you. Give this a try.

input stop = 0.00;
input riskOverride = 0; # use this to force a fixed dollar amount
input riskPercent = 1;

input accountBalanceFallback = 25000; # this is used automatically if GetTotalCash() fails
input accountBalanceOverride = 0;

# reminder = GetTotalCash only works with premarket data on
def bal = GetTotalCash();
# reminder = GetTotalCash only works with premarket data on

def accountBalance =
  if accountBalanceOverride > 0 then accountBalanceOverride
  else if !IsNaN(bal) then bal
  else accountBalanceFallback

def buyingPower = accountBalance * 4;
def risk = RoundDown(if riskOverride == 0 then accountBalance * riskPercent / 100 else riskOverride, 2);

def stopRange = Max(close, stop) - Min(close, stop);
def riskMaxShares = RoundDown(risk / stopRange, 0);
def buyPowerMaxShares = RoundDown(buyingPower / close, 0);
def shares = Min(riskMaxShares, buyPowerMaxShares);

AddLabel(stop > 0, "Shares: " + shares, Color.LIGHT_GRAY);

Is this suppose to be used with fibonacci retracement? If so, it wont work for me. Can you tell me why that might be?
Can you tell me how that study works then?
Last edited by a moderator:


Staff member
Well can you tell me how that study works then?
Did you know that clicking on a member's name will allow you to see when a member was last seen on the uTS forum?
@Slippage has not been seen in a while. :(

No, there are no Fibonacci calculations involved.
To determine if a script is utilizing Fibonacci calculations, you can look for references to Fibonacci numbers.
.236; .382; .618; .786;

The study does this:

You are asking "how" it does this?
You provide all the inputs:
input stop = 0.00;
input riskOverride = 0; # use this to force a fixed dollar amount
input riskPercent = 1;
input accountBalanceFallback = 25000; # this is used automatically if GetTotalCash() fails
input accountBalanceOverride = 0;
The script then does the math to calculate for position size.
Last edited:

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
301 Online
Create Post

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.