Percentage Trailing Stops

Percentage Trailing Stops identifies stop loss exit points for long and short positions. Select show index to find entry index number, index numbers are shown in multiples of five. The entry index number may also be found by opening the Cursor Data window. The approximate entry price is taken as the closing price at the entry index. For long positions the stop is placed below the entry price (high-(factor*price/100) and adjusts upwards if the price rises. For short positions the stop is placed above the entry price (low+(factor*low/100) and adjusts downwards if the price falls. The user may change the position (long), index number, show index option and percent factor. This indicator’s definition is further expressed in the condensed code given in the calculation below.

Percentage Trailing Stops1

How To Trade Using Percentage Trailing Stops

Percentage Trailing Stops are designed to aid in stop loss exit decisions. For long positions, if a low and a previous low are below the stop loss line a sell signal is generated. Conversely for short positions if a high and a previous high are above the stop short line a buy to cover signal will be given.

Percentage Trailing Stops2

Percentage Trailing Stops3

How To Access in MotiveWave

Go to the top menu, choose Study>Exit Strategies>Percentage Trailing Stops

or go to the top menu, choose Add Study, start typing in this study name until you see it appear in the list, click on the study name, click OK.

Important Disclaimer: The information provided on this page is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security. Please see our Risk Disclosure and Performance Disclaimer Statement.

Calculation

//position = pos, user defined, default is long
//Index = index number, user defined, default is 100
//show index = showI, user defined, default is false
//percent factor = pct, user defined, default is 10
//enterP = entry price
//index = current bar number, prev = previous
//shortP = short position, longP = long position

longP = pos == "Long";
shortP = pos == "Short";
pct = pct / 100;  //change from percent to decimal
highest = 0, lowest = 0;
enterP = CLOSE;
enterP = round(enterP, 2);
if (index == ind)
    if (longP)
        hhLl[index-1] = enterP;
        stop[index-1] = high - (pct * high);
    endIf
if (shortP)
        hhLl[index-1] = enterP;
        stop[index-1] = low + (pct * low);
    endIf
endIf
prevHH = ifNull(enterP, hhLl[index-1]);
prevLL = ifNull(enterP, hhLl[index-1]);
pSl = ifNull(enterP, stop[index-1]);
pSS = ifNull(enterP, stop[index-1]);
stopL = 0;
stopS = max_value;
if (longP)
    stopL = pSL;
    highest = prevHH;
    if (high moreThan prevHH)
        stopL = high - (pct * high);  //set new higher stop
        highest = high;  //set new highest
    endIf
    hhLl = highest;
    stop = stopL;
endIf
if (shortP)
    stopS = pSS;
    lowest = prevLL;
    if (low lessThan prevLL)
        stopS = low + (pct * low);  //set new lower stop
        lowest = low; //set new lowest
    endIf
hhLl = lowest;
stop = stopS;
endIf
 //Signals
prevL = low[index-1];
prevH = high[index-1];
sell = prevL moreThan stopL AND low lessThan stopL;
buy = prevH lessThan stopS AND high moreThan stopS;