# Elder Indicators

Does anyone have public versions of the Elder indicators like the impulse system, force index, chandelier etc. ?

### Re: Elder Indicators

Taken from the TS Forum a paintbar for the "Impulse system":Does anyone have public versions of the Elder indicators like the impulse system, force index, chandelier etc. ?

Code: Select all

```
```

[LegacyColorValue = true];

inputs:

Price(close),

maLength(13),

FastMA(12),

SlowMA(26),

Signal(9),

displace(0),

DivPlotWidth(2);

variables:

mavg(0);

Value1 = MACD(Close,FastMA,SlowMA);

Value2 = XAverage(Value1, Signal);

value3 = value1-value2;

SetPlotWidth(1, DivPlotWidth);

if Displace >= 0 or CurrentBar > AbsValue( Displace ) then

begin

mavg = XAverage(price,malength);

if mavg > mavg[1] and value3 > value3[1] then

begin

setplotcolor(1,green);

plotpaintbar[displace] (high,low,"impulse");

end

else if mavg < mavg[1] and value3 < value3[1] then

begin

setplotcolor(1,red);

PlotPaintBar[displace]( High, Low, "impulse" ) ;

end

else begin

setplotcolor(1,blue);

PlotPaintBar[displace]( High, Low, "impulse" ) ;

end ;

end;

Code: Select all

```
inputs: Length1(2),Length2(13),Force_I(Volume * (Close - Close[1]));
```

Plot1(XAverage(Force_I,Length1),"Force1");

Plot2(xAverage(Force_I,Length2),"Force2");

Code: Select all

```
inputs: Price(Close), AvgLen(13);
```

vars: DayLow(0), BearP(0);

if Date > Date[1] then

DayLow = Low;

BearP = DayLow - XAverage(Price, AvgLen);

Plot1(BearP, "Bear Pwr");

Code: Select all

```
inputs: Price(Close), AvgLen(13);
```

vars: DayHigh(0), BullP(0);

if Date > Date[1] then

DayHigh = High;

BullP = DayHigh - XAverage(Price, AvgLen);

Plot1(BullP, "Bull Pwr");

Code: Select all

```
{ 27499 }
```

{Title: Alexander Elder Triple Screen: Initial Screen for Trading Prospects

Description:

1. Paint the bar green when the EMA and the MACD histogram each turn up. Possible long setup.

2. Paint the bar red when the EMA and the MACD histogram each turn down. Possible short setup.

3. Paint the bar yellow when the EMA and the MACD go in different directions. No trade setup.

}

{Declarations}

Inputs:

LongColor(Green), {Paintbar color for possible long}

ShortColor(Red), {Paintbar color for possible short}

NoActionColor(Yellow), {Paintbar color for noaction}

MACDPrice(Close), {MACD Price value used in calculation}

MACDExpMALength(9), {MACD Smoothing Exponential Moving Average Length}

MACDFastLength(12), {MACD Fast length value used in calculation}

MACDSlowLength(26), {MACD Slow length value used in calculation}

MALength(26); {Moving average length}

Variables:

AlertMessage(""), {Content of Alert Message}

PlotColor(0), {Color to be plotted}

PlotMessage(""), {Message to be plotted}

MACDDiff(0), {MACD Difference used to plot MACD histogram}

MAValue(0), {Current moving average value}

MACDAvg(0),

MACDValue(0), {Current MACD value}

OldMACDDiff(0), {Prior MACD Diff Value to which current will be compared}

OldMACDValue(0), {Prior MACD value to which current will be compared}

OldMAValue(0); {Prior Moving average value to which current will be compared}

{Procedure}

OldMAValue=MAValue; {Capture old moving average value before calculating new}

MAValue=Xaverage(Close,MALength);

OldMACDDiff=MACDDiff; {Capture old MACD Diff value before calculating new}

OldMACDValue=MACDValue; {Capture old MACD value before calculating new}

MACDValue=MACD(MACDPrice, MACDFastLength,MACDSlowLength);

MACDAvg=Xaverage(MACD(MACDPrice, MACDFastLength,MACDSlowLength),MACDExpMALength);

MACDDiff=(MACDValue-MACDAvg); {MACDDiff is the diffe between MACD and MACD Exp Value}

If ((MAValue > OldMAValue) and (MACDDiff > OldMACDDiff)) then

begin

PlotColor=LongColor ;

AlertMessage="Long";

end

Else

If ((MAValue < OldMAValue) and (MACDDiff < OldMACDDiff)) then

begin

PlotColor=ShortColor ;

AlertMessage="Short";

end

Else

If ((MAValue <= OldMAValue) and (MACDDiff >= OldMACDDiff)) or ((MAValue >= OldMAValue) and (MACDDiff <= OldMACDDiff)) then

begin

PlotColor=NoActionColor;

AlertMessage="NoAction";

end;

PlotPaintBar(High,Low,Open,Close, "Elder Screen", PlotColor) ;

Alert( AlertMessage ) ;

Code: Select all

```
{ Barry Silberman's version of Alexander Elder's "SafeZone Stop" from book "Come Into My Trading Room", page 173.
```

For TS 2000

Amendments: (1) John Lynch: code for variable lookback period based on prior swing extremes;

(2) John Lynch: code to indicate stop for next period --- plotted on last bar on chart.

(3) Gary Fritz: use of TS variable instead of arrays

(4) Eric Svendsen: Coloured Stop and trend variable

Notes:

A) Set the chart up with one space to the right. Set plot2's chart style type to point and its color to

your background color if your background is not black (5th line of each Set Plot section).

B) This is an adaptation of Dr. Elder's stop based on the following points that he emphasizes in his book:

(1) you may use the slope of a 22 day EMA to define the trend

(2) SafeZone is not a mechanical gadget to replace independent thought.

(3) Calculate the stops separately for uptrends and downtrends.

(4) The lookback period should not go back beyond the last important turning point. If the market has

reversed from down to up two weeks ago, then the SafeZone for the current long trades should not

look back more than 10 trading days.

(5) An important decision is choosing the coefficient for the SafeZone stop. He says a coefficient

between 2 and 3 provides a margin of safety, but you must research it on your own market data.

(6) You can add it to almost any trading system, including Triple Screen.

(7) The excel code that Dr. Elder used in his book kept the stop from declining for 3 days, by which

time either the uptrend resumes or the stop is hit. This code uses a period of 5. }

INPUTS:

Price((H+L)/2), MALength(22), Lookback(15), Trend(3), AutomaticLookBack(True), Multiplelong(2), Multipleshort(2),

ColourShort(red), ColourLong(blue);

VARIABLES:

MA(0), Ldiff(0), Lday(0), Sdiff(0), Sday(0), Longsum(0), Shortsum(0) , Countlong(0), Countshort(0), Avglow(0),

Avghigh(0), Longstop(0), Shortstop(0), Lstop(0), Sstop(0), ii(0), LookBackTemp(0);

{Determine trend by slope of EMA}

MA = xaverage( Price, MALength );

Condition1 = MA > MA[Trend];

Condition2 = MA < MA[Trend];

{Determine Lookback Period (to prior swing extreme)}

IF LookBackTemp<LookBack THEN LookBackTemp=LookBackTemp+1;

IF Condition1<>Condition1[1] THEN BEGIN

LookBackTemp=LookBack;

Value1=MinList(MALength*0.66,LookBack);

IF Condition1 and AutomaticLookBack THEN IF LowestBar(L,Value1)<LookBack THEN LookBackTemp=LowestBar(L,Value1);

IF Condition2 and AutomaticLookBack THEN IF HighestBar(H,Value1)<LookBack THEN LookBackTemp=HighestBar(H,Value1);

END;

{determine and count number of days with:

for longs - lows being lower than prior lows

for shorts - highs being higher than prior highs}

Ldiff = IFF(L[1] > L, L[1] - L, 0); { Difference of lows }

Lday = IFF(L[1] > L, 1, 0); { 1 if this is a "low's" day }

Sdiff = IFF(H[1] < H, H - H[1], 0); { Difference of highs }

Sday = IFF(H[1] < H, 1, 0); { 1 if this is a "high's" day }

{SAFEZONE FOR LONGS}

{Get average of lows lower than prior low}

Longsum = summation(Ldiff, Lookbacktemp);

Countlong = summation(Lday, Lookbacktemp);

IF Countlong <> 0 THEN Avglow = Longsum / Countlong;

{Calculate stop at "X" times avglow}

Lstop = LOW - (Multiplelong * Avglow);

{Prevent stop from being lowered}

Longstop = MAXLIST(Lstop, Lstop[1], Lstop[2], Lstop[3], Lstop[4], Lstop[5]);

{Set Plot}

IF Condition1 THEN BEGIN

PLOT1(Longstop[1], "STOP", ColourLong);

IF lastbaronchart THEN BEGIN

Plot1[-1](Longstop, "STOP", ColourLong); {Shows tomorrows stop on lastbar+1}

Plot2(Longstop, "StopNext"); {Indicates tomorrows stop: set indicator to point/black}

END;

END;

{SAFEZONE FOR SHORTS}

{Get average of highs higher than prior high}

Shortsum = summation(Sdiff, Lookbacktemp);

Countshort = summation(Sday, Lookbacktemp);

IF Countshort <> 0 THEN Avghigh = Shortsum / Countshort;

{Calculate stop at "X" times avghigh}

Sstop = HIGH + (Multipleshort * Avghigh);

{Prevent stop from rising}

Shortstop = MINLIST(Sstop, Sstop[1], Sstop[2], Sstop[3], Sstop[4], Sstop[5]);

{Set Plot}

IF Condition2 THEN BEGIN

PLOT1(Shortstop[1], "STOP", ColourShort);

IF lastbaronchart THEN BEGIN

Plot1[-1](Shortstop, "STOP", ColourShort); {Shows tomorrows stop on lastbar+1}

Plot2(Shortstop, "StopNext", Black); {Indicates tomorrows stop: set indicator to point/black}

END;

END;

I haven't tested any of the above codes, so no gurantees that they will work as they should .

Enjoy,

Chris