Elders Safezone Stops

Elders Safezone Stops (ESSS) was authored, not surprisingly by Alexander Elder. ESSS identifies stop loss exit points for long and short positions. Optional entry points are also displayed. The user may change the position (long), input (close), method (EMA), period lengths, look back, factor and show entry option. This indicator’s definition is further expressed in the condensed code given in the calculation below.

Elders Safezone Stops1

How To Trade Using Elders Safezone Stops

Elders Safezone Stops are designed to aid in stop loss exit decisions. However entry points are optionally provided. These are based on five consecutive increases in an uptrend (buy) or five consecutive decreases in a down trend (sell).

Elders Safezone Stops2

How To Access in MotiveWave

Go to the top menu, choose Study>Exits>Elders Safezone 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
//input = price, user defined, default is close
//method = moving average (ma), user defined, default is EMA
//period1 = p1, user defined, default is 63
//period2 = p2, user defined, default is 22
//period3 = p3, user defined, default is 3
//look back = lb, user defined, default is 5
//factor = fac, user defined, default is 2.5
//show entry = showE, user defined boolean, default is false
//index = current bar number, prev = previous
//LOE = less or equal, MOE = more or equal
//shortP = short position, longP = long position

ma = ma(method, index, p1, input);
prevP = price[index-1];
upTrend = price moreThan ma;
dnTrend = price lessThan ma;
longP = pos == "Long";
shortP = pos == "Short";
dmPlus = 0;
dmMinus = 0;
dmAv = 0;
safeZ = 0.0;
countP = 0, countM = 0;
for (i = index - (p2 + 1); i LOE index; i++) {
    ihigh = high[i];
    prevH = high[i-1];
    ilow = low[i];
    prevL = low[i-1];
    if (prevL moreThan low) countM++; dmMinus = dmMinus + (prevL - low);
    if (high moreThan prevH) countP++; dmPlus = dmPlus + (high - prevH);
endFor
if (upTrend AND countM != 0)
    dmAv = dmMinus / countM;
    safeZ = prevL - fac * dmAv;
    safeZ = highest(p3, SAFEZ);
if (dnTrend AND countP != 0)
    dmAv = dmPlus / countP;
    safeZ = prevH + fac * dmAv;
    safeZ = lowest(p3, SAFEZ);
endIf
 //Signals
lowFive = false;
for (i = -(lb-1); i lessOr=0; i++)
    cLow = low[index+i];
    pLow = low[index+i -1];
    cMa = MA[index+i];
    pMa = MA[index+i-1];
    lowFive =  (cLow lessThan pLow AND cLow lessThan cMa AND pLow lessThan pMa);
    if (!lowFive) break;
endFor
highFive = false;
for (i = -(lb-1); i LOE 0; i++)
    cHigh = high[index+i];
    pHigh high[index+i -1];
    cMa = MA[index+i];
    pMa = MA[index+i-1];
    highFive =  (cHigh moreThan pHigh AND cHigh moreThan cMa AND pHigh moreThan pMa);
    if (!highFive) break;
endFor
sell = false, buy = false;
if (safeZ != 0) {
    if (longP AND upTrend)
sell = prevP moreThan safeZ AND price lessThan safeZ;  //sell to exit
        buy = highFive AND showE;  //buy
    endIf
    if (shortP AND dnTrend) {
        sell = lowFive AND showE;   //sell short
        buy = prevP lessThan safeZ AND price moreThan safeZ;  //buy to cover
    endIf
endIf