rlohmeyer
Active member
ATR Risk Control Indicator for ThinkorSwim
I have worked on this indicator quite a while and am now using it consistently on my daily charts for swing trading. You can see it in the image posted below. Based on the parameters you set for (1) the ATR risk set-up (Type of Average to use for the ATR, Length of average, and the percent of the Avg ATR to use for your stop) and (2) your Dollar Amount to Risk on the trade...The indicator will then calculate (1) the number of shares to purchase based on those parameters (2) the cost of those shares (3) and then place the stops over and under each bar to indicate the Long Entry stop OR the Short entry stop.
The image below the chart image shows what will show up on your chart once you enter a position.
And then the final image will shows the input section for your parameters. The code is below that. The indicator was inspired by Mobius ATR Trend indicator and the ToS APTR indicator.
I hope this indicator will help some better control risks of swing trades.
Regards,
Bob
This image is from an entry I made today for a long entry. It shows the shares I purchased. My entry price and my cost. The P/L label is from another indicator.
I have worked on this indicator quite a while and am now using it consistently on my daily charts for swing trading. You can see it in the image posted below. Based on the parameters you set for (1) the ATR risk set-up (Type of Average to use for the ATR, Length of average, and the percent of the Avg ATR to use for your stop) and (2) your Dollar Amount to Risk on the trade...The indicator will then calculate (1) the number of shares to purchase based on those parameters (2) the cost of those shares (3) and then place the stops over and under each bar to indicate the Long Entry stop OR the Short entry stop.
The image below the chart image shows what will show up on your chart once you enter a position.
And then the final image will shows the input section for your parameters. The code is below that. The indicator was inspired by Mobius ATR Trend indicator and the ToS APTR indicator.
I hope this indicator will help some better control risks of swing trades.
Regards,
Bob
This image is from an entry I made today for a long entry. It shows the shares I purchased. My entry price and my cost. The P/L label is from another indicator.
Code:
# @rlohmeyer: Inspired by Mobius work on ATR Trend Indicator and TOS APTR indicator
# Declaration
declare upper;
#Inputs
input AvgType = AverageType.EXPONENTIAL;
input Length = 20;
input StopOffset = 1.00;
input DollarAmountRisk = 25.0;
input showStops = yes;
# Basic Definitions
def shares = GetQuantity();
def oneTick = .01;
def h = high;
def l = low;
def c = close;
def o = open;
def AP = Round(GetAveragePrice(), 2);
def OPL = GetOpenPL();
def na = double.NaN;
# Def Stops
def TR = TrueRange(h, c, l);
def atrr = Round(MovingAverage(AvgType, tr, Length) / oneTick, 2) * oneTick;
def offsetAmt = Round((atrr * StopOffset) / oneTick, 2) * oneTick;
def StopL = c - offsetAmt;
def StopS = c + offsetAmt;
# Plots
plot stopLongEntry = StopL;
plot stopShortEntry = StopS;
stopLongEntry.SetDefaultColor(Color.white);
stopLongEntry.SetPaintingStrategy(PaintingStrategy.DASHES);
stopLongEntry.HideBubble();
stopLongEntry.HideTitle();
stopShortEntry.SetDefaultColor (Color.white);
stopShortEntry.SetPaintingStrategy(PaintingStrategy.DASHES);
stopShortEntry.HideBubble();
stopShortEntry.HideTitle();
# Define Num of Shares by Stop Size and Dollar Amount Risk
def stopSize = Round(AbsValue(c - StopL), 2);
def stopSizeTicks = (stopSize / oneTick);
def oneShareRiskAmt = stopSizeTicks * oneTick;
def numberOfShares = RoundDown(((DollarAmountRisk / oneShareRiskAmt)), 0);
#Risk Label
def ATRP = Round(APTR(Length,AvgType),1);
def TRP =Round(APTR(1),1);
def EXP = AvgType == 1;
def SMPL = AvgType == 0;
def WGHT = AvgType == 2;
def WLDR = AvgType == 3;
def HULL = AvgType == 4;
AddLabel(yes,(if EXP then "EXP" else if SMPL then "SMPL" else if WGHT then "WGHT" else if WLDR then "WLDR" else "HULL") + "-" + Length + "-" + (StopOffset * 100) + "%" + "-" + ATRP +"%"+" Rsk|$" + DollarAmountRisk + " Cst|$" + Round(numberOfShares * C, 0)+ " Shares|" + numberOfShares , Color.ORANGE);
#Entry Label
def cost = Round(shares * AP, 0);
AddLabel (if AP>0 then yes else no," Shares:" + shares + " Ent:$" + AP + " Cst:$" + Round(cost, 0) , if cost == 0 then color.light_gray else CreateColor(137, 178, 245));
Last edited by a moderator: