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

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

GetRichOrDieTrying

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

GetRichOrDieTrying

New 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.
 
G

GetRichOrDieTrying

New member
This is what I'm looking for. Something that does with this does
 
Thread starter Similar threads Forum Replies Date
G Questions 9
Zachc Questions 5

Top