Add To TI Market Pulse Scanning - Help Request

jhorton56

Member
VIP
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:
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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Can you also provide the original code?

Code:
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here: tosindicators.com/indicators/market-pulse
#Code written in 2019


input ChartBubblesOn = no;

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
);
plot VMA = asd;
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 and close >= VMA then "Stage: Acceleration" else if bearish and close <= VMA then "Stage: Deceleration" else if close>=VMA then "Stage: Accumulation" else "Stage: Distribution", if bullish and close >= VMA then color.green else if bearish and close <= VMA then color.red else if close >=VMA then color.yellow else color.orange);

VMA.AssignValueColor(if bearish and close<= VMA 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);
 
Last edited by a moderator:
So, between the transition from red to green and vice versa, there is a neutral period in between (grey).

You want to scan for stocks going from grey to green and grey to red?
 
So, between the transition from red to green and vice versa, there is a neutral period in between (grey).

You want to scan for stocks going from grey to green and grey to red?
Not by color per se. The chart gives you a label for each of the four phases depending on how it calculates. I'm interested in capturing the point of transition from Acceleration to Distribution. Below is their graphic. It seems that price moves in a clockwise direction around the quadrants. The scan they provide goes upward from Accumulation To Acceleration, and downward from Distribution to Deceleration. I want to scan for the time in the chart where Acceleration has slowed down and price moves into the consolidation phase referred to here as Distribution, a movement from left to right across the top of the graphic. My goal is to set up a watchlist for potential shorts down the road as I watch price eventually moving into the Deceleration phase.

1764536780875.png
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
545 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top