updated code: https://usethinkscript.com/threads/thinkorswim-risk-reward-indicator.7210/#post-73021
Code:
input amount = 2000;
input risk = 100;
input price = 2.75;
input ratio = 2;
def shares = amount / price;
plot stop = if isnan(close[-1]) then round((amount - risk) / shares) else double.nan;
plot entry = if isnan(close[-1]) then price else double.nan;
plot t1 = if isnan(close[-1]) then price + ratio * (price - stop) else double.nan;
plot t2 = if isnan(close[-1]) then price + (2 * ratio) * (price - stop) else double.nan;
plot t3 = if isnan(close[-1]) then price + (3 * ratio) * (price - stop) else double.nan;
addcloud(price, stop, color.gray, color.gray);
addcloud(t1, t2, color.green, color.green);
addcloud(t2, t3, color.light_green, color.light_green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), price, price, color.white);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t1, "T1 $" + t1, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t2, "T2 $" + t2, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), t3, "T3 $" + t3, color.green);
addchartbubble(isnan(close[2]) and !isnan(close[3]), stop, "STOP $" + stop, color.red, no);
addchartbubble(isnan(close[10]) and !isnan(close[11]), price, "SHARES:" + floor(shares), color.yellow);
Last edited by a moderator: