Position Sizing Calculator for ThinkorSwim

korygill

korygill

Active member
VIP
Based on another thread, I reverse engineered what I think the two labels show.

This is the output of that work.



thinkScript Code

Code:
#
# PositionSizingCalculator
#
# Author: Kory Gill, @korygill
#
#

input RiskUnit = 100;
input AggregationPeriod = AggregationPeriod.FIFTEEN_MIN;

def highVal = high(period = AggregationPeriod);
def lowVal = low(period = AggregationPeriod);

AddLabel(
    yes,
    "High: " + highVal + " Low: " + lowVal,
    Color.Gray
    );

def diff = highVal-LowVal;

AddLabel(
    yes,
    AsDollars(RiskUnit) + " risk with " + AsDollars(diff) + " stop = " + Floor(Round(RiskUnit/diff)) + " shares",
    Color.Gray
    );

Link to the study

http://tos.mx/HwObLl

Thanks,
Kory Gill, @korygill
 
Last edited by a moderator:
G

GetRichOrDieTrying

Member
Is this a fully functioning position sizer? I'm not in front of my computer to test it.
 
G

GetRichOrDieTrying

Member
That's what the original thread was about. A position sizing tool.
 
G

GetRichOrDieTrying

Member
It appears to be that. Your code says PositionSizingCalculator
 
korygill

korygill

Active member
VIP
I don't see anywhere in there what it calculates. High and low over last X minutes? How much the stock can move for +/- $x.x.x in gain/loss? I just wrote code that seems to calculate what the first image showed. Define the rules, and we can write code to do that. Thanks.
 
R

rudy seena

New member
Hi, I copied and pasted in TOS but nothing happens? Any suggestions?
 
J

jdstrader

New member
Hello,

I've been looking for a very simple indicator that can divide my buying power with the price of the stock I'm looking at so it can show me the shares I need to buy quickly. For example, If I have $100k in buying power, I'd like to set up the indicator to divide $50k (I scale into positions) with the current price of the stock let's say $20 so it would show me I need to buy 2,500.
I've been doing this calculation manually every time but I make quick trades and sometimes these seconds I use for my calculations are very costly.

Does anyone know if an indicator like this exists? I haven't been able to find something on my own so far.

Thanks a lot!
 

Top