# Intraday Position Size Calculator Help

#### lambda100

##### 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!!

#### Slippage

##### 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.

#### voltron

##### 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???

#### Slippage

##### Well-known member
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???

I'll refer you to the comment in the code...

Ruby:
``input riskOverride = 0; # use this to force a fixed dollar amount``

#### Krsna

##### New member
Hi,

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.

#### DylanRussell

##### 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 https://www.earnforex.com/position-size-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:

#### Scale

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

Ruby:
``````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);

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:

#### MerryDay

Staff member
Staff
VIP
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:

87k+ Posts
301 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?