Scan for AccumulationDistribution indicator

lowtrade

Member
VIP
I'm trying to build a scan where the AccumulationDistribution indicator is in accumulation mode (Green bars).

YfNvt5v.jpg


In the scan option, it is only showing Range Ratio or Range Factor but not sure how to get the accumulation only in the scan results. Any help will be appreciated.

wSw3Sya.jpg
 

BenTen

Administrative
Staff member
Staff
VIP
@lowtrade Take a look at the code:

Ruby:
RangeRatio.AssignValueColor( if (RangeRatio < RangeFactor) then RangeRatio.Color("Consolidation") else RangeRatio.Color("Non-consolidation"));
RangeFactor.SetDefaultColor(GetColor(7));

You should scan for RangeRatio less than RangeFactor.
 

cabe1332

Active member
@lowtrade try the code below. Add as study. Good luck! cabe1332

Code:
#scan script that will look for accumulation/distribution stage stocks watchlist study.
#cabe1332

# start code

input price1 = high;
input length1 = 144;
input displace = 0;

def HMA = MovingAverage(AverageType.HULL, price1, length1)[-displace];
def uptrend = price1 > HMA;
def downtrend = price1 < HMA;

input price = close;
input length = 10;

def tmp1 = if price > price[1] then price - price[1] else 0;
def tmp2 = if price[1] > price then price[1] - price else 0;
def d2 = sum(tmp1, length);
def d4 = sum(tmp2, length);
def cond = d2 + d4 == 0;
def ad3 = if cond then 0 else (d2 - d4) / (d2 + d4) * 100;
def coeff = 2 / (length + 1) * AbsValue(ad3) / 100;
def asd = compoundValue("visible data" = coeff * price + (if IsNaN(asd[1]) then 0 else asd[1]) * (1 - coeff), "historical data" = price
);
def VMA = asd;

def vma8 = sum(volume * close,8) / sum(volume,8);
def vma21 = sum(volume * close,21) / sum(volume,21);
def vma34 = sum(volume * close,34) / sum(volume,34);

def bullish = if vma8 > vma21 and vma21 > vma34 then 1 else 0;
def bearish = if vma8 < vma21 and vma21 < vma34 then 1 else 0;
def distribution = if !bullish and !bearish then 1 else 0;

def stackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 55)."AvgExp"
and MovAvgExponential("length" = 55)."AvgExp" is greater than MovAvgExponential("length" = 89)."AvgExp";

def state = if stackedUp and uptrend and distribution then 1 else 0;
plot data = state;

#end code

sQ9V6hk.png
 
Last edited:

Similar threads

Top