@TrueDepth Great idea! I'm having trouble getting this to work. Could you point me in the right direction? Thanks!
Can you share you those labels?
Period Moving Average.PMA? i heard of EMA and SMA. But PMA?
Greetings,
The Market Phases indicator is based off of Chuck Dukas Trend Advisor model of identifying what phase a stock is in. Whether is is bullish, bearish, accumulation, distribution etc. I have attached an image below so you can see. With this indicator, you can scan for stocks in all six phases as well as pullbacks to a fast user chosen ema if a stock is under a bullish or bearish phase. I have included a watchlist column so you can use to your liking. Hope this helps.
Please note: On the chart indicator, when you load it, uncheck the show plots for buphase, acphase, rephase, bephase, dphase, wphase. These mess up the chart sizing. If someone knows how to turn those off by default then please do so. Thank you.
Main Indicator Below
Rich (BB code):#Trend Advisor Market Phases; #Credit to the Chuck Dukas for creating the system and for then author of the VolumeTrendLabels whose study was use to create this indicator. Ensure you set the correct aggregation period to then chart, this helps calculate the correct volume and price action. def agg = getAggregationPeriod(); input vPeriod = getAggregationPeriod(); #hint vPeriod: Grabs aggregation period from current chart. def O = open(period = vPeriod); def H = high(period = vPeriod); def C = close(period = vPeriod); def L = low(period = vPeriod); def V = volume(period = vPeriod); def SV = V * (H - C) / (H - L); def BV = V * (C - L) / (H - L); # below determines if volume supports the move, adds conviction AddLabel(yes, "Buyer Vol Strong ", if high > high[1] and low > low[1] and BV*1.05 > SV then Color.GREEN else color.black); AddLabel(yes, "Seller Vol Strong", if high < high[1] and low < low[1] and SV*1.05 > BV then Color.MAGENTA else color.black); # below determines if price supports the move AddLabel(yes, "Price Strong ", if high > high[1] and high [1] > high[2] and low > low[1] and low[1] > low[2] then Color.GREEN else color.black); AddLabel(yes, "Price Weak", if high < high[1] and high[1] < high[2] and low < low[1] and low[1] < low[2] then Color.MAGENTA else color.black); declare upper; input price = close; input displace = 0; input avglength = 10; #hint avgLength: Then exponential average length you want to use for your pullback entries. def fastavg = 50; def slowavg = 200; plot fastsma = Average( price, fastavg); fastsma.SetDefaultColor(Color.Green); plot slowsma = Average(price, slowavg); slowsma.SetDefaultColor(Color.Red); # Bullish criteria define below # Define criteria for Bullish Phase : close > 50 SMA, close > 200 SMA, 50 SMA > 200 SMA def bullphase = fastsma > slowsma && price > fastsma && price > slowsma; # Define criteria for Accumulation Phase : close > 50 SMA, close > 200 SMA, 50 SMA < 200 SMA def accphase = fastsma < slowsma && price > fastsma && price > slowsma; # Define criteria for Recovery Phase : close > 50 SMA, close < 200 SMA, 50 SMA < 200 SMA def recphase = fastsma < slowsma && price < slowsma && price > fastsma; # Bearish Criteria define below # Define criteria for Bearish Phase : close < 50 SMA, close < 200 SMA, 50 SMA < 200 SMA def bearphase = fastsma < slowsma && price < fastsma && price < slowsma; # Define criteria for Distribution Phase : close < 50 SMA, close < 200 SMA, 50 SMA > 200 SMA def distphase = fastsma > slowsma && price < fastsma && price < slowsma; # Define criteria for Warning Phase : close < 50 SMA, close > 200 SMA, 50 SMA > 200 SMA def warnphase = fastsma > slowsma && price > slowsma && price < fastsma; # Below conditions are for a possible entry when price touches the fastema #def pbavg = MovingAverage(Average, price, avglength); def pbavg = ExpAverage(data = price[-displace], length = avglength); input bullpullback = yes; #hint bullpullback: Do you want to display the pullback arrows for bullish fast ema entries. input bearpullback = yes; #hint bearpullback: Do you want to display the pullback arrows for bearish fast ema entries. def bullishpb = low < pbavg && open > pbavg; def bearishpb = high > pbavg && open < pbavg; def bullpb = bullphase is true && bullishpb is true; def bearpb = bearphase is true && bearishpb is true; # Plot Signals plot bullpb1 = if bullpullback then bullpb else 0; bullpb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); bullpb1.SetDefaultColor(Color.CYAN); bullpb1.SetLineWeight(1); plot bearpb1 = if bearpullback then bearpb else 0; bearpb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); bearpb1.SetDefaultColor(Color.red); bearpb1.SetLineWeight(1); plot buphase = bullphase is true; plot acphase = accphase is true; plot rephase = recphase is true; plot bephase = bearphase is true; plot dphase = distphase is true; plot wphase = warnphase is true; # Below adds labels to the chart to identify what phase the underlying is in AddLabel(bullphase, " Bull Phase" , if bullphase is true then Color.GREEN else Color.BLACK); AddLabel(accphase, " Accumation Phase ", if accphase is true then Color.lIGHT_GREEN else Color.BLACK); AddLabel(recphase, " Recovery Phase ", if recphase is true then Color.lIGHT_ORANGE else Color.BLACK); AddLabel(warnphase, " Warning Phase ", if warnphase is true then Color.orANGE else Color.BLACK); AddLabel(distphase, " Distribution Phase ", if distphase is true then Color.light_red else Color.BLACK); AddLabel(bearphase, " Bear Phase ", if bearphase is true then Color.red else Color.BLACK); input colorbars = yes; assignPriceColor(if colorbars and bullphase then Color.GREEN else if bearphase then Color.RED else Color.orange); Alert(condition = bullphase[1] == 1 and bullphase == 0, text = "Bull Phase", sound = Sound.Bell, "alert type" = Alert.BAR); Alert(condition = accphase[1] == 1 and accphase == 0, text = "Accumation Phase", sound = Sound.Bell, "alert type" = Alert.BAR); Alert(condition = recphase[1] == 1 and recphase == 0, text = "Recovery Phase", sound = Sound.Bell, "alert type" = Alert.BAR); Alert(condition = warnphase[1] == 1 and warnphase == 0, text = "Warning Phase", sound = Sound.Bell, "alert type" = Alert.BAR); Alert(condition = distphase[1] == 1 and distphase == 0, text = "Distribution Phase", sound = Sound.Bell, "alert type" = Alert.BAR); Alert(condition = bearphase[1] == 1 and bearphase == 0, text = "Bear Phase", sound = Sound.Bell, "alert type" = Alert.BAR);
Below is the watchlist column.
Updated Watchlist Column
Hi Ben, I read somewhere in this thread that if the Study Agg period is set to HOUR that the time frame on the chart can be changed to anything lower than HOUR and the phases indicated will be correct -- is this CORRECT?? Thx ~Thanks for sharing. Here is the updated code that unplot the phases by default.
Code:#Trend Advisor Market Phases; #Credit to the Chuck Dukas for creating the system and for then author of the VolumeTrendLabels whose study was use to create this indicator. Ensure you set the correct aggregation period to then chart, this helps calculate the correct volume and price action. def agg = getAggregationPeriod(); input vPeriod = AggregationPeriod.HOUR; #hint vPeriod: Enter the chart time you use here. Required to properly caluclate volume and price strength. def O = open(period = vPeriod); def H = high(period = vPeriod); def C = close(period = vPeriod); def L = low(period = vPeriod); def V = volume(period = vPeriod); def SV = V * (H - C) / (H - L); def BV = V * (C - L) / (H - L); # below determines if volume supports the move, adds conviction AddLabel(yes, "Buyer Vol Strong ", if high > high[1] and low > low[1] and BV*1.05 > SV then Color.GREEN else color.black); AddLabel(yes, "Seller Vol Strong", if high < high[1] and low < low[1] and SV*1.05 > BV then Color.MAGENTA else color.black); # below determines if price supports the move AddLabel(yes, "Price Strong ", if high > high[1] and high [1] > high[2] and low > low[1] and low[1] > low[2] then Color.GREEN else color.black); AddLabel(yes, "Price Weak", if high < high[1] and high[1] < high[2] and low < low[1] and low[1] < low[2] then Color.MAGENTA else color.black); declare upper; input price = close; input displace = 0; input avglength = 10; #hint avgLength: Then exponential average length you want to use for your pullback entries. def fastavg = 50; def slowavg = 200; plot fastsma = Average( price, fastavg); fastsma.SetDefaultColor(Color.Green); plot slowsma = Average(price, slowavg); slowsma.SetDefaultColor(Color.Red); # Bullish criteria define below # Define criteria for Bullish Phase : close > 50 SMA, close > 200 SMA, 50 SMA > 200 SMA def bullphase = fastsma > slowsma && price > fastsma && price > slowsma; # Define criteria for Accumulation Phase : close > 50 SMA, close > 200 SMA, 50 SMA < 200 SMA def accphase = fastsma < slowsma && price > fastsma && price > slowsma; # Define criteria for Recovery Phase : close > 50 SMA, close < 200 SMA, 50 SMA < 200 SMA def recphase = fastsma < slowsma && price < slowsma && price > fastsma; # Bearish Criteria define below # Define criteria for Bearish Phase : close < 50 SMA, close < 200 SMA, 50 SMA < 200 SMA def bearphase = fastsma < slowsma && price < fastsma && price < slowsma; # Define criteria for Distribution Phase : close < 50 SMA, close < 200 SMA, 50 SMA > 200 SMA def distphase = fastsma > slowsma && price < fastsma && price < slowsma; # Define criteria for Warning Phase : close < 50 SMA, close > 200 SMA, 50 SMA > 200 SMA def warnphase = fastsma > slowsma && price > slowsma && price < fastsma; # Below conditions are for a possible entry when price touches the fastema #def pbavg = MovingAverage(Average, price, avglength); def pbavg = ExpAverage(data = price[-displace], length = avglength); input bullpullback = yes; #hint bullpullback: Do you want to display the pullback arrows for bullish fast ema entries. input bearpullback = yes; #hint bearpullback: Do you want to display the pullback arrows for bearish fast ema entries. def bullishpb = low < pbavg && open > pbavg; def bearishpb = high > pbavg && open < pbavg; def bullpb = bullphase is true && bullishpb is true; def bearpb = bearphase is true && bearishpb is true; # Plot Signals plot bullpb1 = if bullpullback then bullpb else 0; bullpb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); bullpb1.SetDefaultColor(Color.CYAN); bullpb1.SetLineWeight(1); plot bearpb1 = if bearpullback then bearpb else 0; bearpb1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); bearpb1.SetDefaultColor(Color.red); bearpb1.SetLineWeight(1); #plot buphase = bullphase is true; #plot acphase = accphase is true; #plot rephase = recphase is true; #plot bephase = bearphase is true; #plot dphase = distphase is true; #plot wphase = warnphase is true; # Below adds labels to the chart to identify what phase the underlying is in AddLabel(bullphase, " Bull Phase" , if bullphase is true then Color.GREEN else Color.BLACK); AddLabel(accphase, " Accumation Phase ", if accphase is true then Color.lIGHT_GREEN else Color.BLACK); AddLabel(recphase, " Recovery Phase ", if recphase is true then Color.lIGHT_ORANGE else Color.BLACK); AddLabel(warnphase, " Warning Phase ", if warnphase is true then Color.orANGE else Color.BLACK); AddLabel(distphase, " Distribution Phase ", if distphase is true then Color.light_red else Color.BLACK); AddLabel(bearphase, " Bear Phase ", if bearphase is true then Color.red else Color.BLACK); assignPriceColor(if bullphase then Color.GREEN else if bearphase then Color.RED else Color.orange);
yesHi Ben, I read somewhere in this thread that if the Study Agg period is set to HOUR that the time frame on the chart can be changed to anything lower than HOUR and the phases indicated will be correct -- is this CORRECT?? Thx ~
This indicator maybe best suited to longer time frames, which confirm trend. If you are trading long in a bear, may not be the best direction?Hi Ben, I read somewhere in this thread that if the Study Agg period is set to HOUR that the time frame on the chart can be changed to anything lower than HOUR and the phases indicated will be correct -- is this CORRECT?? Thx ~
@diazlaz, @Billions did anyone figure out a system yet as to how to use this advantageously?As a follow-up to the example on CSCO
It's now enter a Bull Phase on the 5M, Recovery on the 1H, might make a good candidate for a short term trade.
Build and a system and share your ideas. Let us know how you plan to trade it
Curious if you read the book?@diazlaz, @Billions did anyone figure out a system yet as to how to use this advantageously?
Also if anyone wants, here is a PDF copy of the book by Chuck Dukas "TRENDADVISOR GUIDE TO BREAKTHROUGH PROFITS" on my google drive.
https://tinyurl.com/yc8dnhhj
Just started it today...I had read some articles on Chuck Dukas but not his book. Will keep you posted.Curious if you read the book?
# Momentum Keltner Channels Watchlist Column
# Based on the FW_MOBO code by TOS user davidinc (aka Firstwave, aka David Elliott)
# The count displayed in the watchlist shows the number of bars since a break up or break down
input length = 34;
input factor = 0.5;
input displace = 0;
input price = close;
input type = AverageType.EXPONENTIAL;
def nan = double.nan;
def shift = factor * MovingAverage(type, TrueRange(high, close, low), length);
def avg = MovingAverage(type, price, length);
def line1 = avg[-displace] - shift[-displace];
def line2 = avg[-displace] + shift[-displace];
def Chg = if(close > line2, 1, if(close < line1, -1, 0));
def Hold = CompoundValue(1,if(Hold[1] == Chg or Chg == 0, Hold[1], if(Chg == 1, 1, -1)), 0);
def n1 = Hold[0] == 1;
def n2 = Hold[0] == -1;
def count1 = if n1 and !n1[1] then 1 else count1[1]+1;
def count2 = if n2 and !n2[1] then 1 else count2[1]+1;
plot n = if n1 then count1 else if n2 then count2 else double.nan;
n.setdefaultcolor(color.black);
assignbackgroundcolor(if n1 and count1 then color.green else color.red);
#AddLabel(yes, if n1 then "👍" else if n2 then "👎" else " ", if n2 then Color.red else if n1 then Color.green else Color.black);
#AssignBackgroundColor(color.black);
#End of code
The 1st post of this thread has been corrected. Choosing "colorbars "NO" in Customizing, will turn off painting the candles.Is It possible to stop changes in bar color, if I want to keep the default candle colors? Choosing "colorbars "NO" in Customizing Makes all Bars Orange.
Your post did not provide enough information as to why Market Phases is not working on your tick charts.Is there any way this could be converted for tick charts? This might be my favorite candle painting indicator..
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Market Structure Trailing Stop [LuxAlgo] for ThinkOrSwim | Indicators | 11 | ||
Market Bias (CEREBR) Indicator for ThinkOrSwim | Indicators | 15 | ||
T | NextSignal's Market Volume Profile For ThinkOrSwim | Indicators | 16 | |
F | Tea 2.0 - Market Cycle Indicator For ThinkOrSwim | Indicators | 12 | |
S | System Market Intraday Setup for ThinkorSwim | Indicators | 4 |
Start a new thread and receive assistance from our community.
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.
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.