Fixed risk calculator

darkelvis

New member
Platform
  1. Thinkorswim
Here is a fixed risk calculator that was designed by myself and a couple other people that I have traded with in the past. It gives you a bunch of labels so you can figure out how many shares you can buy based on your pre determined max spending and max risk.

Adjust your settings to your liking.

low in last: this sets your stop to just under the lowest point of the last xx number of bars
trade amount: this is the MAX you are willing to put in to the trade
risk amount: this is the MAX you are willing to lose on the trade
rr factor, factor2, factor3: these set your price targets based on the current price of the stock and your risk amount

Set all that fun stuff to your liking and you will now have some nifty labels you can take a quick glance at to set your position sizing and targets for the trade.

My biggest complaint on this one is the "low in last"... I've never been able to find an accurate pivot or support indicator that I could integrate with this code so it would set the stop at a more "logical" spot. Unfortunately all of the auto pivot and auto support indicators look great on historical charts but are very slow to print when trading live, maybe this is where @barbaros could add his input on this one and make it perfect. :)

There are a lot of labels, so just ## out whichever ones you don't want to see. I typically just keep the "Shares" and "STOP $" ones. The "TRADE/NO TRADE" one is set so if your stop is less than 7% away from current price it says "TRADE" if it is further away than 7% it says "NO TRADE".... This was designed when I was primarily playing small caps that would run 100+ % in a day, so you may want to change that to your liking also.


Code:
##Calculator with reward by darkelvis, Inar, and Sly on Atlas Trading

declare upper;
input lowInLast = 1;
def lastBar = !IsNaN(close) && IsNaN(close[-1]);
def Data = if lastBar then Lowest(low, lowInLast) else Data[1];
def lowest = if IsNaN(low[-lowInLast - 1]) then Data[-lowInLast] else Double.NaN;
input TradeAmount = 25000;
input riskAmount = 250;
input RRFactor = 1;
input RRFactor2 = 2;
input RRFactor3 = 3;

def StopPoint = lowest * .999;
def StopPointPercent = 100 - ((stopPoint / close) * 100);
def maxRisk = Floor(riskAmount  / (close - StopPoint));
def maxShares = Floor(TradeAmount / close);

def Nshares;
if maxRisk > maxShares {
    Nshares = maxShares;
}
else {
    Nshares = maxRisk;
}

def profitPoint1 = (((close - StopPoint) * RRFactor) + close);
def profitPoint2 = (((close - StopPoint) * RRFactor2) + close);
def profitPoint3 = (((close - StopPoint) * RRFactor3) + close);
plot stoploss = lowest * .999;
stoploss.SetDefaultColor(Color.RED);


AddLabel(yes, "Shares: " + Nshares, Color.YELLOW);
AddLabel(yes, "Price: " + Close, color.light_green);
AddLabel(yes, "Stop $: " + StopPoint, Color.RED);
AddLabel(yes, "RISK:" + (Close - StopPoint), Color.PINK);
AddLabel(yes, "Stop %:" + Round(StopPointPercent), if StopPointPercent <= 7.00 then color.green else color.red);
AddLabel(yes, If StopPointPercent <= 7.00 then "TRADE" else "NO TRADE", if StopPointPercent <= 7.00 then color.green else color.red);
AddLabel(yes, "PT1: " + profitPoint1, Color.cyan);
AddLabel(yes, "PT2: " + profitPoint2, Color.cyan);
AddLabel(yes, "PT3: " + profitPoint3, Color.CYAN);
AddLabel(yes, "Cost: " + maxShares * close, Color.light_green);
AddLabel(yes, "Risk $: " + (close - StopPoint) * Nshares, Color.pink);
 
Last edited:
Top