The TI website offers up a free scan to plot either the transition from Accumulation To Acceleration or from Distribution to Deceleration.
You just change one or the other "def" in the last two parts to "Plot" depending on the transition scan you want. Here's my question: I want to scan for the transition from Acceleration to Distribution, but not being a coder, I took a stab at adding the code below. It works, sort of. While some of the charts in the scan are in Distribution, it's also picking up some in Acceleration. I'd like for it to find only Distribution. Any suggestions to improve the additional code is much appreciated!
#Plot Transition From Acceleration To Distribution
plot accelerationToDistribution = if (!bullish[1]) and (!bearish[1]) then 1 else 0;
The TI Transition Scan code as it stands now:
You just change one or the other "def" in the last two parts to "Plot" depending on the transition scan you want. Here's my question: I want to scan for the transition from Acceleration to Distribution, but not being a coder, I took a stab at adding the code below. It works, sort of. While some of the charts in the scan are in Distribution, it's also picking up some in Acceleration. I'd like for it to find only Distribution. Any suggestions to improve the additional code is much appreciated!
#Plot Transition From Acceleration To Distribution
plot accelerationToDistribution = if (!bullish[1]) and (!bearish[1]) then 1 else 0;
The TI Transition Scan code as it stands now:
Code:
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 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;
#Plot Transition From Accumulation To Acceleration
plot accumulationToAcceleration = if (bullish and close>=VMA) and (!bullish[1]) then 1 else 0;
#Plot Transition From Distribution To Deceleration
def distributionToDeceleration = if (bearish and close <= VMA)and (!bearish[1]) then 1 else 0;
Last edited by a moderator: