Looking for accumulation/distribution indicator in TOS

N

netleo

New member
Lifetime
Hello,

a quick question: I'm trying to find accumulation/distribution indicator in thinkorswim (it should be a line based on 3 factors such as
Accumulation Distribution Components
The calculation of the A/D consists of three components- money flow multiplier (MFM), money flow volume (MFV), and accumulation distribution line (ADL).
Money Flow Multiplier (MFM)
MFM = ((Close – Low) – (High – Close)) / (High – Low)
Money Flow Volume (MFV)
MFV = MFM x Volume on the Period

You can see full link in here: https://tradingsim.com/blog/accumulation-distribution-indicator/

ThinkorSwim has AD indicator but its not a line and I believe its only based on price, not volume+price. Is there any way to obtain the code for AD indicator in thinkorswim?

Thank you in advance,
Leo
 
A

anty

New member
I cut and pasted a couple indicators (can't remember where from) to come up with the following modified Williams Accumulation Distribution indicator.

declare lower;
input overBought = -20;
input overSold = -80;
input MAlength = 21;
input price = close;
input ChartBubblesOn = no;

plot WAD = AccumDistBuyPr();
WAD.SetDefaultColor(GetColor(1));



plot VMA = Average(WAD, MAlength);
VMA.SetDefaultColor(GetColor(0));

def WADDownCross = Crosses(( WAD < 0) != 0, 0.5, yes );
plot SignalDn = if WADDownCross then VMA else Double.NaN;
SignalDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SignalDn.SetDefaultColor(Color.DOWNTICK);
SignalDn.SetLineWeight(5);

def WADUpCross = Crosses(( WAD > 0) != 0, 0.5, yes );
plot SignalUp = if WADUpCross then VMA else Double.NaN;
SignalUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SignalUp.SetDefaultColor(Color.UPTICK);
SignalUp.SetLineWeight(5);

AddCloud(WAD, VMA, Color.UPTICK);


def VMAUpCross = Crosses((VMA > WAD) != 0, 0.5, no );# && VMAUpCross
#rec flip = if VMAUpCross == VMAUpCross[1] then 0 else 1;
plot ArrowUp = if VMAUpCross then VMA else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetDefaultColor(Color.CYAN);

def VMADnCross = Crosses((VMA < WAD) != 0, 0.5, no );# && VMAUpCross
#rec flop = if VMADnCross or flop then 1 else 0;
plot ArrowDn = if VMADnCross then VMA else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.YELLOW);

def relativeVMA = Round((VMA - LowestAll(VMA)) / (HighestAll(VMA) - LowestAll(VMA)), 2) * 100;
AddLabel(yes, Concat( Round(relativeVMA, 2), Concat("", "%")), if relativeVMA > 80 then Color.RED else if relativeVMA < 20 then Color.GREEN else Color.GRAY );

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, MAlength);
def d4 = Sum(tmp2, MAlength);
def cond = d2 + d4 == 0;
def ad3 = if cond then 0 else (d2 - d4) / (d2 + d4) * 100;
def coeff = 2 / (MAlength + 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);
VMA.SetDefaultColor(GetColor(0));

def vwma8 = Sum(volume * close, 8) / Sum(volume, 8);
def vwma21 = Sum(volume * close, 21) / Sum(volume, 21);
def vwma34 = Sum(volume * close, 34) / Sum(volume, 34);

def bullish = if vwma8 > vwma21 and vwma21 > vwma34 then 1 else 0;
def bearish = if vwma8 < vwma21 and vwma21 < vwma34 then 1 else 0;
def distribution = if !bullish and !bearish then 1 else 0;

AddLabel (yes, if bullish then "Stage: Acceleration" else if bearish then "Stage: Deceleration" else if close >= VMA then "Stage: Accumulation" else "stage: Distribution", if bullish then Color.GREEN else if bearish then Color.RED else if close >= VMA then Color.YELLOW else Color.ORANGE);

VMA.AssignValueColor(if bearish then Color.RED else if bullish and close >= VMA then Color.GREEN else Color.GRAY);

def accumulationToAcceleration = if (bullish and close >= VMA) then 1 else 0;
AddChartBubble(ChartBubblesOn and accumulationToAcceleration and !accumulationToAcceleration[1], close, "Entering Acceleration", Color.GREEN);

def distributionToDeceleration = if (bearish and close <= VMA) then 1 else 0;
AddChartBubble(ChartBubblesOn and distributionToDeceleration and !distributionToDeceleration[1], close, "Entering Deceleration", Color.RED);
 
S

samks_30

New member
2019 Donor
#KSK: Green candles can work as base; Big red candles as top
declare lower;

input max_distday = 9;
input accumulation_or_distribution = {"accum", default "dist"};

def uVolume = close("$UVOL");
def dVolume = close("$DVOL");

plot baseline = 0;
plot distribution_day = max_distday;

plot volume;

switch(accumulation_or_distribution){
case accum:
volume = uVolume / dVolume;
default:
volume = dVolume / uVolume;
}

volume.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
volume.DefineColor("Positive", Color.UPTICK);
volume.DefineColor("Negative", Color.DOWNTICK);
volume.AssignValueColor(if volume >= max_distday then volume.color("Positive") else volume.color("Negative"));
 
T

tomsk

Well-known member
VIP
TASC put together a study for thinkorswim based on the article “Portfolio Strategy Based On Accumulation/Distribution”, authored by Domenico D’Errico.

Code:
# Accumulation/Distribution
# Domenico D’Errico
# Technical Analysis of Stocks & Commodities, Aug 2018
# 8.7.2018
# http://traders.com/Documentation/FEEDbk_docs/2018/08/TradersTips.html

declare lower;

input length = 4;
input factor = 0.75;
input mode = {default Range, ATR};

def range;
switch (mode) {
case Range:
    range = Highest(high, length) - Lowest(low, length);

case ATR:
    range = reference ATR();
}

plot RangeRatio = range / range[length];
plot RangeFactor = factor;

RangeRatio.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RangeRatio.DefineColor("Consolidation", GetColor(4));
RangeRatio.DefineColor("Non-consolidation", GetColor(1));

RangeRatio.AssignValueColor( if (RangeRatio < RangeFactor) then RangeRatio.Color("Consolidation") else RangeRatio.Color("Non-consolidation"));
RangeFactor.SetDefaultColor(GetColor(7));
 
Last edited by a moderator:

Similar threads

Top