Sunteți pe pagina 1din 6

Volatility Stop Indicator for TOS – Steve Coombs

A special thanks to Steve Coombs for writing this code to allow this indicator to match what is seen
used in the TC2000 program.

This document will walk you through two different ways to save this custom indicator to use on your
charts – 1) from a link that Steve shared and 2) by creating a new indicator and adding the code he
has provided at the end of this document.

First Way to Save - TOS – Opening and Saving a Shared Item for an Indicator

This is a link to open the indicator as a shared item in the thinkorswim program http://tos.mx/aH4Zeh

Once you put the link in the shared item URL space, click on Preview and you will get this screen –
then click on “Open”

Volatility Stop Indicator for TOS Page 1 of 6


Once you click on “Open” you will see this pop up – Click on “Rename”

Once you click on “Rename” you will see this pop up and you can rename the indicator to a name
that works for you

Once you have named the indicator, it will appear in


your studies list and can be added to any chart.

Volatility Stop Indicator for TOS Page 2 of 6


Second Way to Save - TOS – Creating a New Indicator with the Code Provided

Volatility Stop Indicator for TOS Page 3 of 6


On the pages below is the code to be placed in the window in Step 3 – DO NOT CHANGE ANYTHING
IN THIS CODE.

Highlight all of the code and right-click to copy then paste or highlight and use CTRL C to copy and
CTRL V to paste in the window.

Volatility Stop Indicator for TOS Page 4 of 6


DO NOT CHANGE ANYTHING IN THIS CODE – COPY ALL BELOW THIS POINT

## Volatility Trailing Stop


## Version 1.1
## By Steve Coombs
## This ATR Trailing Stop is calculated using the Highest Close in an uptrend or
## the Lowest Close in a downtrend, rather than just the Close that is used
## in the standard TOS ATRTrailing Stop

#input StopLabel = yes; #ATRStop Label is Stop value from yesterdays ATR calculation
input ATRPeriod = 10;
input ATRFactor = 1.5;
input firstTrade = {default long, short};
input averageType = AverageType.SIMPLE;

Assert(ATRFactor > 0, "'atr factor' must be positive: " + ATRFactor);


def trueRange = TrueRange(high, close, low);
def loss = ATRFactor * MovingAverage(averageType, trueRange, ATRPeriod);

def state = {default init, long, short};


def trail;
def mclose;
switch (state[1]) {
case init:
if (!IsNaN(loss)) {
switch (firstTrade) {
case long:
state = state.long;
mclose = close;
trail = close - loss;
case short:
state = state.short;
mclose = close;
trail = close + loss;
}
} else {
state = state.init;
trail = Double.NaN;
mclose = Double.NaN;
}
case long:
if (close > trail[1]) {
state = state.long;
mclose = Max(mclose[1], close);
trail = Max (trail[1], mclose - loss);
} else {
state = state.short;
mclose = close;

Volatility Stop Indicator for TOS Page 5 of 6


trail = mclose + loss;
}
case short:
if (close < trail[1]) {
state = state.short;
mclose = Min(mclose[1], close);
trail = Min(trail[1], mclose + loss);
} else {
state = state.long;
mclose = close + 0;
trail = mclose - loss;
}
}

#AddLabel(StopLabel, "ATR Stop =" + Round(trail[1], 2), color = Color.BLUE);


plot TrailingStop = trail;

TrailingStop.SetPaintingStrategy(PaintingStrategy.POINTS);
TrailingStop.SetLineWeight(lineWeight = 3);
TrailingStop.DefineColor("Buy", GetColor(5));
TrailingStop.DefineColor("Sell", GetColor(1));
TrailingStop.AssignValueColor(if state == state.long
then TrailingStop.Color("Sell")
else TrailingStop.Color("Buy"));

Volatility Stop Indicator for TOS Page 6 of 6

S-ar putea să vă placă și