Position Sizing Calculator for ThinkorSwim

korygill

korygill

Member
VIP
Warehouse
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

Member
VIP
Warehouse
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.
 
Thread starter Similar threads Forum Replies Date
2 Questions 1
R Questions 1
S Questions 2
G Questions 13
Zachc Questions 5

Top