# ATR Scaled Elhers Decycler

##### Well-known member
I whipped this up today, its a work in progress but already successful nonetheless. Arrows are the study's simple signals but there will be more complex ones to come.
Code:
``````#
# TD Ameritrade IP Company, Inc. (c) 2015-2020
#

declare lower;
declare real_size;
input length = 20;
input averageType = AverageType.WILDERS;
def ATR = MovingAverage(averageType, TrueRange(high/close, close/close, low/close) * 100, length);
def price2 = ATR;
input length2 = 30;
input displace = 0;
input showBreakoutSignals = no;
def ATRAvgExp = ExpAverage(price2[-displace], length);

input price = close;
input roofCutoffLength = 60;
input k = 1.0;

def decycler = reference EhlersSimpleDecycler(price = price, "roof cutoff length" = roofCutoffLength);

plot DecyclerOsc = 100 * k * reference EhlersHighpassFilter(price = decycler, "roof cutoff length" = 0.5 * roofCutoffLength) / price;
plot ZeroLine = 0;
plot max = ATRAvgExp/4;
plot min = -ATRAvgExp/4;
plot sellmin = -ATRAvgExp/1.75;
input SellEntry = 3;

def QS = Lowest(low, SellEntry);
plot trueqb = qb[1];
plot trueqs = qs[1];

plot midline = (qs[1]+qb[1])/2;

plot up = (decyclerosc[1] <= min[1]) and (decyclerosc > min);
plot down = (decyclerosc[1] >= min[1]) and (decyclerosc < min);``````

#### TrueDepth

##### Member
VIP
Awesome. I am going to try it out. Is this better than your "Potential Breakout Arrow Plots Indicator" or a continuation of it?

#### HighBredCloud

##### Well-known member
VIP
@YungTraderFromMontana for some reason it is not displaying correctly in the lower studies on my end...even after FIT STUDIES is unchecked.

##### Well-known member
@HighBredCloud here is a chart link with plots https://tos.mx/yEFUgSG @TrueDepth It is calculated with completely new values but when I'm done experimenting with this I may try to make a hybrid. One tip for both of you is monitor the slope of the oscillator line as it crosses the min value. Avoid crossings with a weak slope.

#### TrueDepth

##### Member
VIP
Here is the code for the Arrows on this study, if you want it as a LOWER study.

Code:
``````plot up = if (decyclerosc[1] <= (min[1]+ .01)) and (decyclerosc >= min) then min else double.nan;
plot down = if (decyclerosc[1] >= min[1]) and (decyclerosc <= min) then min else double.nan;
plot sellup =  (decyclerosc[1] >= zeroline[1]) and (decyclerosc <= zeroline);

up.setPaintingStrategy(paintingstrategy.ARROW_UP) ;
up.setdefaultColor(color.green);
up.SetLineWeight(5);

down.setPaintingStrategy(paintingstrategy.ARROW_DOWN);
down.setdefaultColor(color.red);
down.SetLineWeight(5);``````

#### bobomatic

##### New member
@YungTraderFromMontana Nice one. I was testing earlier and noticed the candles at potential reversals repaint after they close? That your experience?