Repaints TI_MarketPulse Scan, Label, Alerts, MTF

Repaints

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

Hello, I wish to add input to show or not show labels in the below script. Thanks.

Code:
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 vwma13 = sum(volume * close, 13) / sum(volume, 13);
def vwma34 = sum(volume * close, 34) / sum(volume, 34);

def bullish = if vwma8 > vwma13 and vwma13 > vwma34 then 1 else 0;
def bearish = if vwma8 < vwma13 and vwma13 < 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.orange else if bearish then color.blue else if close >=VMA then color.black else color.light_GRAY);

VMA.AssignValueColor(if bearish and close<= VMA then color.blue
else if bullish and close >= VMA then color.orange
else color.black);

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

def distributionToDeceleration = if (bearish and close <= VMA) then 1 else 0;
AddChartBubble(ChartBubblesOn and distributionToDeceleration and !distributionToDeceleration[1], close, "Entering Deceleration", color.orange);
 
@liminal-rider Look for the following snippet in the code:

Code:
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.orange else if bearish then color.blue else if close >=VMA then color.black else color.light_GRAY);

Remove it and add the following to the bottom of your script:

Code:
input labels = yes;
AddLabel(yes and labels, 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.orange else if bearish then color.blue else if close >=VMA then color.black else color.light_GRAY);
 
Customized Market Pulse For ThinkOrSwim
Code:
# cabe1332 20210115_1700
# I have made some modifications customize to my needs and requirements.
# Credit to team TOSindicators [URL]https://tosindicators.com/indicators[/URL]
# Market Pulse, a powerful tool that lets you identify which one of the four market stages ( accumulation, distribution, acceleration) we are currently in.
# It uses Moving Average along with Volume Weighted Moving Averages to try and identify which one of the four market stages.
# I've added Stage Label, indicator bubbles on a plotline that indicates buying increase/decrease (V+/V- bubble) with the price on which candle.

# start of code

input price = close;
input length = 9;

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 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;

AddLabel(yes, if bullish then "Stage: Accelerating " else if bearish then "Stage: Decelerating " 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 and close<= VMA then color.red else if bullish and close >= VMA then color.green else color.gray);

def accumulationtoaccelation = if (bullish and close>=VMA) then 1 else 0;
def distributiontoacceleration = if (bearish and close <= VMA) then 1 else 0;

AddChartBubble(accumulationtoaccelation and !accumulationtoaccelation[1] and close <= close[1], close, "V+ " + round(close,2), color.light_green);
AddChartBubble(distributiontoacceleration and !distributiontoacceleration[1] and close <= close[1], close, "V- " + round(close,2), color.light_orange);

def accelationtoaccumulation = if (bullish and close<=VMA) then 1 else 0;
AddChartBubble(accelationtoaccumulation and !accelationtoaccumulation[1], close, "Accum", color.light_gray);

def distributiontoaccumulationton = if (bearish and close>=VMA) then 1 else 0;
AddChartBubble(distributiontoaccumulationton and !distributiontoaccumulationton[1], close, "Dist", color.light_gray);

# end of code
 
Last edited by a moderator:
Customized Market Pulse For ThinkOrSwim
Code:
# cabe1332 20210115_1700
# I have made some modifications customize to my needs and requirements.
# Credit to team TOSindicators [URL]https://tosindicators.com/indicators[/URL]
# Market Pulse, a powerful tool that lets you identify which one of the four market stages ( accumulation, distribution, acceleration) we are currently in.
# It uses Moving Average along with Volume Weighted Moving Averages to try and identify which one of the four market stages.
# I've added Stage Label, indicator bubbles on a plotline that indicates buying increase/decrease (V+/V- bubble) with the price on which candle.

# start of code

input price = close;
input length = 9;

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 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;

AddLabel(yes, if bullish then "Stage: Accelerating " else if bearish then "Stage: Decelerating " 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 and close<= VMA then color.red else if bullish and close >= VMA then color.green else color.gray);

def accumulationtoaccelation = if (bullish and close>=VMA) then 1 else 0;
def distributiontoacceleration = if (bearish and close <= VMA) then 1 else 0;

AddChartBubble(accumulationtoaccelation and !accumulationtoaccelation[1] and close <= close[1], close, "V+ " + round(close,2), color.light_green);
AddChartBubble(distributiontoacceleration and !distributiontoacceleration[1] and close <= close[1], close, "V- " + round(close,2), color.light_orange);

def accelationtoaccumulation = if (bullish and close<=VMA) then 1 else 0;
AddChartBubble(accelationtoaccumulation and !accelationtoaccumulation[1], close, "Accum", color.light_gray);

def distributiontoaccumulationton = if (bearish and close>=VMA) then 1 else 0;
AddChartBubble(distributiontoaccumulationton and !distributiontoaccumulationton[1], close, "Dist", color.light_gray);

# end of code
is this base on vma= 10 (days)? if not what line do I change on the script? thks.
 
Is there a way to make some of these indicators work with forex, I find many great indicators I use for equities don't work on forex?? Is there something I should be looking up to change in some of these scripts??
 
Is there a way to make some of these indicators work with forex, I find many great indicators I use for equities don't work on forex?? Is there something I should be looking up to change in some of these scripts??
Forex lacks a centralized marketplace therefore therefore volume data cannot be collected.
Therefore, no indicator that uses volume as a variable will work with Forex.
 
@MerryDay thank you for the information, I'm fairly new to forex, I really like it, love the price action and scalping, its been pretty simple using a 5 lot and just simple going for 15 pips on swing and lows!! I don't know if your a forex trader but any heads up on indicators would be greatly appreciated!!
 
Scan for a formula result at 9:30 am. I am unable to get it right, even with your examples.

The script below is from TI_MarketPulse with unrelated code removed. I added code at the bottom for a plot to scan on. This same code works in a subgraph of the price chart. Can anyone tell me what I'm doing wrong?
Thanks.

PS The original code can be downloaded from tosindicators.com/indicators/market-pulse.

The scan code:

Code:
#TOS Indicators
#Home of the Volatility Box
#More info regarding this indicator here: tosindicators.com/indicators/market-pulse
#Code written in 2019
#Full Youtube Tutorial here: [MEDIA=youtube]Hku6dLR-m_A[/MEDIA]


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;

#Added.
def SignalCalc = compoundValue(1,if SecondsTillTime(930) >= 0 then (bullish and close>=VMA) else SignalCalc[1],0);

#def SignalCalc = if SecondsTillTime(930) >= 0 then (bullish and close>=VMA) else SignalCalc[1];

plot Signal = SignalCalc;
 
Last edited by a moderator:
Scan for a formula result at 9:30 am. I am unable to get it right, even with your examples.
You are correct.
It is not possible to get valid results with repainting scripts. Because they repaint.

Scripts that repaint should NOT be used for finding entry or in Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies.
read more:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-57833

More on the correct use of repainters by @csricksdds:
https://usethinkscript.com/threads/agaig-non-repaint-verses-repaint-indicators-for-tos.20126/

@antwerks
 
Last edited:
You are correct.
It is not possible to get valid results with repainting scripts. Because they repaint.

Scripts that repaint should NOT be used for finding entry or in Scans, Labels, Watchlists, Alerts, Conditional Orders or Backtesting Strategies.
read more:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-57833

More on the correct use of repainters by @csricksdds:
https://usethinkscript.com/threads/agaig-non-repaint-verses-repaint-indicators-for-tos.20126/

@antwerks
Thank you, and i appreciated @antwerks as well.
 
I revisited my code and the related scan after reviewing the post Scan for Stocks Above/Below Pre-Market in ThinkorSwim.
My code was good, the error was a foolish oversight in the scan ( The scan should have been run against an intraday setting, I left the default "D" in place. I fixed it, and it works as intended.

I was confused by your lecture on repainting. Perhaps I was not clear regarding the purpose of my scan, but thank you anyway for your assistance.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
231 Online
Create Post

Similar threads

Similar threads

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