sumi1111
New member
Code:
#
# PositionSizingCalculator
#
# Author: RamonDV. AKA Pelonsax
#
#
input Risk_Amount = 100;
input Shares = 1000;
input Stop_Price = 100.00;
input Choose_Size_and_Risk = yes; #can't choose stop
input Choose_Size_and_Stop = yes; #can't choose risk
input Choose_Risk_and_Stop = yes; #can't choose size
def Mark = close(PriceType = PriceType.MARK);
def Size = Risk_Amount / (Mark - Stop_Price);
def Stop = ((Mark * Shares) - Risk_Amount) / Shares;
def Risk = (mark - Stop_Price) * Shares;
#Display current price
AddLabel(yes, "Current Price: " + AsDollars(Mark), color.gray);
#No defined stop
AddLabel(Choose_Size_and_Risk, "No defined stop: " + Shares + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(stop) + " .", color.gray);
#No defined risk
AddLabel(Choose_Size_and_Stop, "No Defined risk: " + Shares + " Shares with " + AsDollars(risk) + " risk with Stop Loss at " + AsDollars(Stop_Price) + " .", color.gray);
#No defined size
AddLabel(Choose_Risk_and_Stop, "No defined size: " + Floor(Round(size)) + " Shares with " + AsDollars(Risk_Amount) + " risk with Stop Loss at " + AsDollars(Stop_Price) + " .", color.gray);
Hi all , I have been looking around and was wondering how to add an element to this great position size calculator I found by @Pelonsax.
https://usethinkscript.com/threads/position-size-calculator-for-thinkorswim.588/page-6#post-96047
Basically what I want to add is a price level line on the chart for the stop loss that I can adjust, so I won't have to go into the study settings to enter the stop loss price.
Does anyone have any pointers on how to implement this?
Last edited by a moderator: