Trend Pivot Points Indicator by Mobius For ThinkOrSwim

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

@David45 - In the code you currently have, find the bubbles segment and replace it with this below code.

Code:
#~~~~~~~~~~~~~~~~~~~~~~~~ begin bubble signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input show_bubbles = yes;
input Buy_Sell_Bubble_Data = {default current, historical};

def short;
def long;

switch (Buy_Sell_Bubble_Data)
        {
        case historical:
             short = hh;
             long = ll;
        case current:
             short = hh_;
             long = ll_;
        }

def SOCB1 = Round((Max(PrevL, short - (hR * R_Mult))) / ts, 0) * ts;
def LOCA1 = Round((Min(PrevH, long + (lR * R_Mult))) / ts, 0) * ts;
def SE = close[1] > SOCB1 and close <= SOCB1;
def LE = close[1] < LOCA1 and close >= LOCA1;

def exitbuy = l < long[1];
def exitsell = h > short[1];

def holdLE = if LE and !LE[1] then 1 else if !exitbuy then holdLE[1] else 0;
def holdSE = if SE and !SE[1] then 1 else if !exitsell then holdSE[1] else 0;

def enter_long = !holdLE[1] and holdLE;
def enter_short = !holdSE[1] and holdSE;
def exit_long = holdLE[1] and !holdLE;
def exit_short = holdSE[1] and !holdSE;

AddChartBubble(if show_bubbles then enter_long else nan, low, "Enter Long", Color.GREEN, 0);
AddChartBubble(if show_bubbles then enter_short else nan, high, "Enter Short", Color.RED, 1);
AddChartBubble(if show_bubbles then exit_long else nan, high, "Exit Long", Color.GREEN, 1);
AddChartBubble(if show_bubbles then exit_short else nan, low, "Exit Short", Color.RED, 0);

#~~~~~~~~~~~~~~~~~~~~~~~~~~ end bubble signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Would you happen to know what the reason for current/ historical is for the buy sell data? When i have it set to historical i can obviously see all the signals but when i switch to current I would of expected this to show only the current signal/bubble but nothing is displayed/ no signal shows then. Thanks
 
I added a Half Way Back (50%) yellow line. This could be a good exit target. Just add this code.
Code:
plot HWB = ll_ + (hh_ - ll_)/2 ;
     HWB.SetDefaultColor(Color.yellow);
     HWB.HideBubble();
     HWB.HideTitle();

1693315408576.png
 
Is the 'Trend Pivot Points Indicator' a repainting indicator? If so, when do we know the repainting stopped, so we can use BTO and STO indicators?
 
Is the 'Trend Pivot Points Indicator' a repainting indicator? If so, when do we know the repainting stopped, so we can use BTO and STO indicators?

Support & Resistance studies are a special sort of group of repainting indicators.
The indicator is written to repaint when price breaks above resistance or below support.
This provides the most up-to-date data.

If the price is falling, it may break through support many times, redraw, and break, redraw, etc...
The same is seen when price is rising, and it breaks above resistance multiple times.

It should be pointed out on higher timeframes this behavior is not seen as often except with the more volatile stocks. S&R studies are contra-indicated with more volatile stocks.

So in answer to your question, there is no time that is guaranteed to not repaint.
Use S&R indicators to assist in confirming your signals from your other indicators but never use them in isolation:
https://usethinkscript.com/threads/basics-for-developing-a-good-strategy.8058/
 
I love using the 50% mark you added for this script. Any way you could add the 61.8 and the 38.2?
Sure. Add this code at the bottom.
Code:
plot fib2 = ll_ + (hh_ - ll_)/2.618 ;
     fib2.SetDefaultColor(Color.cyan);
     fib2.HideBubble();
     fib2.HideTitle();

plot fib3 = ll_ + (hh_ - ll_)/1.618 ;
     fib3.SetDefaultColor(Color.cyan);
     fib3.HideBubble();
     fib3.HideTitle();
 
I found the Mobius Trend Pivots study on here somewhere, can't even remember where that was but I want to shorten the clouds. It has a setting in it to set cloud length but that doesn't work, going into the thinkscript and shortening the cloud length there doesn't work either. And a search for the code to add has yielded no results though I'm sure the answer is somewhere in this huge forum of information. The clouds go all the way to the right side of the chart. Sooooo, can someone please tell me how to shorten these clouds? I don't know what else to do after changing it in the input at the top of the thinkscript.

Sorry, forgot to attach a screenshot. See how the AMM clouds are limited? This is what I want for the Pivots code.
1698763862314.png
 
Last edited by a moderator:
I found the Mobius Trend Pivots study on here somewhere, can't even remember where that was but I want to shorten the clouds. It has a setting in it to set cloud length but that doesn't work, going into the thinkscript and shortening the cloud length there doesn't work either. And a search for the code to add has yielded no results though I'm sure the answer is somewhere in this huge forum of information. The clouds go all the way to the right side of the chart. Sooooo, can someone please tell me how to shorten these clouds? I don't know what else to do after changing it in the input at the top of the thinkscript.

Sorry, forgot to attach a screenshot. See how the AMM clouds are limited? This is what I want for the Pivots code.
View attachment 20041

You should now be able to control the length of the cloud @ input cloud_length = 15;

Screenshot 2023-10-31 090255.png
Code:
# Mobius
# V01.01.29.2019
# Uses trend of higher highs with higher lows and trend of lower lows with lower highs to locate pivots. Distance for trend is set by the user. Confirmation of a reversal from pivots is set with a multiple of the pivot bars range. That multiple is also a user input.
# Trading Rules
# 1) Trade when price crosses and closes outside the pivot Confirmation line. At that point looking for best entry. Min trade is 2 contracts
# 2) Know your risk point before entering trade. Typical risk point is the pivot line itself. If your risk is crossed look for an exit. Never use hard stops - you'll often get out for little or no loss
# 3) Know your Risk off point before entering. Typical Risk Off is an ATR multiple. Offer Risk Off as soon as possible for a Risk Free trade
# 4) set mental stop one tick above entry when Risk Off is achieved
# 5) if trade continues your way move mental stop for your runner to last support / resistance each time a new support / resistance is hit.
# 10.31.2023 added cloud length limiter by request @usethinkscript by Ringandpinion

input n = 5;
input R_Mult = .7;

def o = open;
def h = high;
def l = low;
def c = close;
def x = BarNumber();
def nan = Double.NaN;
def ts = TickSize();
def tr = TrueRange(h, c, l);
def hh = if Sum(h > h[1], n) >= n and
            Sum(l > l[1], n) >= n - 1
         then h
         else if h > hh[1]
              then h
              else hh[1];
def xh = if h == hh
         then x
         else nan;
plot hh_ = if x >= HighestAll(xh)
           then HighestAll(if IsNaN(c[-1])
                           then hh
                           else nan)
           else nan;
hh_.SetDefaultColor(Color.RED);
hh_.HideTitle();
hh_.HideBubble();
def hR = if h == hh
         then Round(Average(tr, n) / TickSize(), 0) * TickSize()
         else hR[1];
def PrevL = if h == hh
            then l[1]
            else PrevL[1];
plot STO = if x >= HighestAll(xh)
           then HighestAll(if IsNaN(c[-1])
           then Round((Max(PrevL, hh_ - (hR * R_Mult))) / ts, 0) * ts
                           else nan)
           else nan;
STO.SetDefaultColor(Color.RED);
STO.HideTitle();
STO.HideBubble();
plot STO_RO = if x >= HighestAll(xh)
              then HighestAll(if IsNaN(c[-1])
                              then STO - Min(hR, TickSize() * 16)
                              else nan)
              else nan;
STO_RO.SetStyle(Curve.LONG_DASH);
STO_RO.SetDefaultColor(Color.WHITE);
STO_RO.HideBubble();
STO_RO.HideTitle();
#AddChartBubble(x == HighestAll(x), STO_RO, "RO", STO_RO.TakeValueColor(), 0);
def ll = if Sum(l < l[1], n) >= n and
            Sum(h < h[1], n) >= n - 1
         then l
         else if l < ll[1]
              then l
              else ll[1];
def xl = if l == ll
         then x
         else nan;
plot ll_ = if x >= HighestAll(xl)
           then HighestAll(if IsNaN(c[-1])
                           then ll
                           else nan)
           else nan;
ll_.SetDefaultColor(Color.GREEN);
ll_.HideTitle();
ll_.HideBubble();
def lR = if l == ll
         then Round(Average(tr, n) / TickSize(), 0) * TickSize()
         else lR[1];
def PrevH = if l == ll
            then h[1]
            else PrevH[1];
plot BTO = if x >= HighestAll(xl)
           then HighestAll(if IsNaN(c[-1])
           then Round((Min(PrevH, ll_ + (lR * R_Mult))) / ts, 0) * ts
                           else nan)
           else nan;
BTO.SetDefaultColor(Color.GREEN);
BTO.HideTitle();
BTO.HideBubble();
plot BTO_RO = if x >= HighestAll(xl)
              then HighestAll(if IsNaN(c[-1])
                              then BTO + Min(lR, TickSize() * 16)
                              else nan)
              else nan;
BTO_RO.SetStyle(Curve.LONG_DASH);
BTO_RO.SetDefaultColor(Color.WHITE);
BTO_RO.HideBubble();
BTO_RO.HideTitle();
#AddChartBubble(x == HighestAll(x), BTO_RO, "RO", BTO_RO.TakeValueColor(), 1);
input cloud_length = 15;
def xxh = if h == hh then x else xxh[1]; # recursive
def h_cloud = xxh; #necessary as xxh, a recursive, not allowed to used in clouds
AddCloud(if x <= h_cloud + cloud_length then STO else nan, hh_, Color.LIGHT_RED, Color.LIGHT_RED);
def xxl = if l == ll then x else xxl[1]; # recursive
def l_cloud = xxl; #necessary as xxl, abandonedBaby recursive, not allowed to be used in clouds
AddCloud(if x <= l_cloud + cloud_length then ll_ else nan, BTO, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
Alert(c crosses below STO, "", Alert.BAR, Sound.Bell);
Alert(c crosses above BTO, "", Alert.BAR, Sound.Chimes);
# End Code Trend Pivots
 
You should now be able to control the length of the cloud @ input cloud_length = 15;
Thanks so much. But......the lines it paints continue without the clouds. My initial request was wrong, I want the whole line and cloud shortened. As it is now, the lines still go all the way across. Thanks again.
 
Thanks so much. But......the lines it paints continue without the clouds. My initial request was wrong, I want the whole line and cloud shortened. As it is now, the lines still go all the way across. Thanks again.

This will limit the line and associated cloud plot to the input plot_limit_length.

Due to the way that the original code is constructed, the prior pivot will only plot the limited length and not the other lines and cloud, if the plot limit length does not cause the prior pivot line to exceed the bar starting at the most recent pivot. See the image below.

Screenshot 2023-10-31 110052.png
Code:
# Mobius
# V01.01.29.2019
# Uses trend of higher highs with higher lows and trend of lower lows with lower highs to locate pivots. Distance for trend is set by the user. Confirmation of a reversal from pivots is set with a multiple of the pivot bars range. That multiple is also a user input.
# Trading Rules
# 1) Trade when price crosses and closes outside the pivot Confirmation line. At that point looking for best entry. Min trade is 2 contracts
# 2) Know your risk point before entering trade. Typical risk point is the pivot line itself. If your risk is crossed look for an exit. Never use hard stops - you'll often get out for little or no loss
# 3) Know your Risk off point before entering. Typical Risk Off is an ATR multiple. Offer Risk Off as soon as possible for a Risk Free trade
# 4) set mental stop one tick above entry when Risk Off is achieved
# 5) if trade continues your way move mental stop for your runner to last support / resistance each time a new support / resistance is hit.
# 10.31.2023 added plot line and associated cloud limited to input plot_limit_length

input plot_limit_length = 25;
input n = 5;
input R_Mult = .7;

def o = open;
def h = high;
def l = low;
def c = close;
def x = BarNumber();
def nan = Double.NaN;
def ts = TickSize();
def tr = TrueRange(h, c, l);
def hh = if Sum(h > h[1], n) >= n and
            Sum(l > l[1], n) >= n - 1
         then h
         else if h > hh[1]
              then h
              else hh[1];
def xh = if h == hh
         then x
         else nan;
plot hh_ = if x >= HighestAll(xh) and x <= HighestAll(xh) + plot_limit_length
           then HighestAll(if IsNaN(c[-1])
                           then hh
                           else nan)
           else nan;
hh_.SetDefaultColor(Color.RED);
hh_.HideTitle();
hh_.HideBubble();
def hR = if h == hh
         then Round(Average(tr, n) / TickSize(), 0) * TickSize()
         else hR[1];
def PrevL = if h == hh
            then l[1]
            else PrevL[1];
plot STO = if x >= HighestAll(xh) and x <= HighestAll(xh) + plot_limit_length
           then HighestAll(if IsNaN(c[-1])
           then Round((Max(PrevL, hh_ - (hR * R_Mult))) / ts, 0) * ts
                           else nan)
           else nan;
STO.SetDefaultColor(Color.RED);
STO.HideTitle();
STO.HideBubble();
plot STO_RO = if x >= HighestAll(xh) and x <= HighestAll(xh) + plot_limit_length
              then HighestAll(if IsNaN(c[-1])
                              then STO - Min(hR, TickSize() * 16)
                              else nan)
              else nan;
STO_RO.SetStyle(Curve.LONG_DASH);
STO_RO.SetDefaultColor(Color.WHITE);
STO_RO.HideBubble();
STO_RO.HideTitle();
#AddChartBubble(x == HighestAll(x), STO_RO, "RO", STO_RO.TakeValueColor(), 0);
def ll = if Sum(l < l[1], n) >= n and
            Sum(h < h[1], n) >= n - 1
         then l
         else if l < ll[1]
              then l
              else ll[1];
def xl = if l == ll
         then x
         else nan;
plot ll_ = if x >= HighestAll(xl) and x <= HighestAll(xl) + plot_limit_length
           then HighestAll(if IsNaN(c[-1])
                           then ll
                           else nan)
           else nan;
ll_.SetDefaultColor(Color.GREEN);
ll_.HideTitle();
ll_.HideBubble();
def lR = if l == ll
         then Round(Average(tr, n) / TickSize(), 0) * TickSize()
         else lR[1];
def PrevH = if l == ll
            then h[1]
            else PrevH[1];
plot BTO = if x >= HighestAll(xl) and x <= HighestAll(xl) + plot_limit_length
           then HighestAll(if IsNaN(c[-1])
           then Round((Min(PrevH, ll_ + (lR * R_Mult))) / ts, 0) * ts
                           else nan)
           else nan;
BTO.SetDefaultColor(Color.GREEN);
BTO.HideTitle();
BTO.HideBubble();
plot BTO_RO = if x >= HighestAll(xl) and x <= HighestAll(xl) + plot_limit_length
              then HighestAll(if IsNaN(c[-1])
                              then BTO + Min(lR, TickSize() * 16)
                              else nan)
              else nan;
BTO_RO.SetStyle(Curve.LONG_DASH);
BTO_RO.SetDefaultColor(Color.WHITE);
BTO_RO.HideBubble();
BTO_RO.HideTitle();
#AddChartBubble(x == HighestAll(x), BTO_RO, "RO", BTO_RO.TakeValueColor(), 1);
AddCloud(STO, hh_, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud(ll_, BTO, Color.LIGHT_GREEN, Color.LIGHT_GREEN);
Alert(c crosses below STO, "", Alert.BAR, Sound.Bell);
Alert(c crosses above BTO, "", Alert.BAR, Sound.Chimes);
# End Code Trend Pivots
 
Sure. Add this code at the bottom.
Code:
plot fib2 = ll_ + (hh_ - ll_)/2.618 ;
     fib2.SetDefaultColor(Color.cyan);
     fib2.HideBubble();
     fib2.HideTitle();

plot fib3 = ll_ + (hh_ - ll_)/1.618 ;
     fib3.SetDefaultColor(Color.cyan);
     fib3.HideBubble();
     fib3.HideTitle();
Hi Chewei76, can you please help to add chart bubble for each fib point for the above?
 
Hi Chewei76, can you please help to add chart bubble for each fib point for the above?
Add this after the HWB line. The other Fibs won't always be correct depending on the direction of the lines. So only the 50% will work correctly.

Code:
def HWB_50 =(if isNaN(HWB[1]) then HWB else Double.NaN);
addchartBubble(HWB, HWB_50,"50%",color.yellow);
 
Support & Resistance studies are a special sort of group of repainting indicators.
The indicator is written to repaint when price breaks above resistance or below support.
This provides the most up-to-date data.

If the price is falling, it may break through support many times, redraw, and break, redraw, etc...
The same is seen when price is rising, and it breaks above resistance multiple times.

It should be pointed out on higher timeframes this behavior is not seen as often except with the more volatile stocks. S&R studies are contra-indicated with more volatile stocks.

So in answer to your question, there is no time that is guaranteed to not repaint.
Use S&R indicators to assist in confirming your signals from your other indicators but never use them in isolation:
https://usethinkscript.com/threads/basics-for-developing-a-good-strategy.8058/
Thanks. When you say higher time frame, is it 1-hour or higher?
 
Support & Resistance studies are a special sort of group of repainting indicators.
The indicator is written to repaint when price breaks above resistance or below support.
This provides the most up-to-date data.

If the price is falling, it may break through support many times, redraw, and break, redraw, etc...
The same is seen when price is rising, and it breaks above resistance multiple times.

It should be pointed out on higher timeframes this behavior is not seen as often except with the more volatile stocks. S&R studies are contra-indicated with more volatile stocks.

So in answer to your question, there is no time that is guaranteed to not repaint.
Use S&R indicators to assist in confirming your signals from your other indicators but never use them in isolation:
https://usethinkscript.com/threads/basics-for-developing-a-good-strategy.8058/

Thanks. What other indicators we can use along with this
Support & Resistance studies are a special sort of group of repainting indicators.
The indicator is written to repaint when price breaks above resistance or below support.
This provides the most up-to-date data.

If the price is falling, it may break through support many times, redraw, and break, redraw, etc...
The same is seen when price is rising, and it breaks above resistance multiple times.

It should be pointed out on higher timeframes this behavior is not seen as often except with the more volatile stocks. S&R studies are contra-indicated with more volatile stocks.

So in answer to your question, there is no time that is guaranteed to not repaint.
Use S&R indicators to assist in confirming your signals from your other indicators but never use them in isolation:
https://usethinkscript.com/threads/basics-for-developing-a-good-strategy.8058/
So What other indicators you suggest to use along with the "Trend Pivot Points Indicator"?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
326 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