Trend Pivot Points Indicator by Mobius For ThinkOrSwim

I made a watch list for this indicator. The numbers show up fine, but the background color does not. It is the same code I use for my other WL indicators. Maybe the code is too complex. I have tried a number of iterations of splitting up the labels and background colors, nothing seems to work. Any thoughts? Thanks!

Code:
#SAI Add 12-14-21
# 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.

#BTO = buy to open
#LL = lower lows (bottom-most line of green plot)
#STO = sell to open
#HH = higher highs (top-most line of red plot)
#STO_RO = Sell to Open Risk On
#BTO_RO = Buy to Open Risk On

def n = 5;
def R_Mult = 1.5;

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;
def hh_ = if x >= HighestAll(xh)
           then HighestAll(if IsNaN(c[-1])
                           then hh
                           else nan)
           else nan;

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

def STO_RO = if x >= HighestAll(xh)
              then HighestAll(if isNaN(c[-1])
                              then STO - Min(hR, TickSize() * 16)
                              else nan)
              else nan;

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;
def ll_ = if x >= HighestAll(xl)
           then HighestAll(if IsNaN(c[-1])
                           then ll
                           else nan)
           else nan;
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];
def 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;
;
def BTO_RO = if x >= HighestAll(xl)
              then HighestAll(if isNaN(c[-1])
                              then BTO + Min(lR, TickSize() * 16)
                              else nan)
              else nan;

# End Code Trend Pivots

#~~~~~~~~~~~~~~~~~~~~~~~~ begin signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

def datadn = close[1] > STO and close < STO;
def dataup = close[1] < BTO and close > BTO;

def datadn_RO = close[1] > STO_RO and close < STO_RO;
def dataup_RO = close[1] < BTO_RO and close > BTO_RO;

     AddLabel(yes, if datadn then "STO $" + STO else if dataup then "BTO $" + BTO else if datadn_RO then "STO_RO $" + STO_RO
        else if dataup_RO then "BTO_RO $" + BTO_RO else " ", color.white);
     AssignBackgroundColor(if datadn then color.red else if dataup then color.dark_green else if datadn_RO then
        color.dark_orange else if dataup_RO then color.green else color.black);



#~~~~~~~~~~~~~~~~~~~~~~~~~ end signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Nice job there evilsurgeon. I do sometimes wonder that watchlist columns don't seem to receive the attention that scans do but for my purposes they are indispensable.

Colored or not I'll be using this. Thanks
 

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

Nice job there evilsurgeon. I do sometimes wonder that watchlist columns don't seem to receive the attention that scans do but for my purposes they are indispensable.

Colored or not I'll be using this. Thanks
Thanks. Glad you found it helpful. I slightly updated the code above.
 
I tried changing to scan down but the code function is all red even with what is the default settings. Anyone have a shared link for scan down function? Thanks
It seems to be working just fine.
Recommend that you delete and re-download.
ONLY works, if you follow these directions exactly:
https://usethinkscript.com/threads/...mobius-for-thinkorswim.1631/page-2#post-76814
Ie5swyl.png
 
It seems to be working just fine.
Recommend that you delete and re-download.
ONLY works, if you follow these directions exactly:
https://usethinkscript.com/threads/...mobius-for-thinkorswim.1631/page-2#post-76814
Ie5swyl.png
I couldn't change it but I could make a new scan by adding the indicator to the scan setting again and then selecting the scan down option. My think or swim might be a newer version and needed to just redo the scan entirely. Thanks for the help though! Great scan!
 
@David45 I updated the above post.

@Yo Adrian Are you using the original code in post #1? If so, replace the current alerts with the below code.

Code:
Alert(c crosses below STO_RO, "", Alert.Bar, Sound.Bell);
Alert(c crosses above BTO_RO, "", Alert.Bar, Sound.Chimes);
Appreciate the attention to detail that everyone has give to addting Mobius' original code. However, to my embarrassement, I am unable to follow the logic of the code settings to really make use of the additional signals (. In general though I like the original Trend Pivot PT Indicator in its Original Form.), Also May I humbly suggest that a trader might consider adding 2 classical indicators for spotting entries long and short ?
1. TTM Sqeeze indicator on the Lower Panel as well as consider a Parabolic Sar on the Price panel. the Parabolic sar has the added virtue of not cluttering up the chart so that other signals are clearly visible ( Wilder's very reliable price pivot stop and reverse indicator which is very responsive on intraday moves. These combinations (1-2-3 which I toggle off and on during the day on my intraday chart whenever I sense a change of direction). I find it very useful as a visual aid in scalping for profits.. especially volatile small caps and options. Best to all, Sincerely Magicquotes
 
Appreciate the attention to detail that everyone has give to addting Mobius' original code. However, to my embarrassement, I am unable to follow the logic of the code settings to really make use of the additional signals (. In general though I like the original Trend Pivot PT Indicator in its Original Form.), Also May I humbly suggest that a trader might consider adding 2 classical indicators for spotting entries long and short ?
1. TTM Sqeeze indicator on the Lower Panel as well as consider a Parabolic Sar on the Price panel. the Parabolic sar has the added virtue of not cluttering up the chart so that other signals are clearly visible ( Wilder's very reliable price pivot stop and reverse indicator which is very responsive on intraday moves. These combinations (1-2-3 which I toggle off and on during the day on my intraday chart whenever I sense a change of direction). I find it very useful as a visual aid in scalping for profits.. especially volatile small caps and options. Best to all, Sincerely Magicquotes
what time frame do you use?
 
For the input n, the default value is 5. Should we change it according to the timeframe we are using? For example. I am using 1m, 5m, and 15m charts. So the n should be changed to 1, 5, or 15? Or can we use the default value for all timeframes?

How about the R_Mult input? do we need to change it for different timeframes in order to get a better result?
 
what time frame do you use?
For the input n, the default value is 5. Should we change it according to the timeframe we are using? For example. I am using 1m, 5m, and 15m charts. So the n should be changed to 1, 5, or 15? Or can we use the default value for all timeframes?

How about the R_Mult input? do we need to change it for different timeframes in order to get a better result?
@predictably-irrational
This indicator works on all timeframes.
@oldyoungguy
The default values work on all timeframes. If you do try changing them, come back and tell us the results.
 
Trend Pivot Indicator by Mobius For ThinkOrSwim
knmHfyS.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.

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);
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
I love this inidcator. Is there a way to put the indicator on a watchlist that shows/alerts support or resistance on 1 minute and 2 minutes ?
Thank you

@murkr I feel it is best to let the creator of the study explain how he trades with this study. :) These are the notes from the study header, written by Mobius, the trader who coded this.



Risk Off is closing out 1 contract, leaving 1 as a runner. The picture shows my interpretation of this method.

knmHfyS.png
I love this indidcator. Is there a way to put on watchlist
I mean I would like the code to be added on a colunm in a watchlist. The watchlist shows when a stock is in resistance or support level.
 
Last edited by a moderator:
Sorry, if this is a lame question.
Can anyone explain what these denote?
input n = 5;
input R_Mult = .7;
From the comments in the code, n = Distance for trend
Trying to understand what that means in practical terms...
I see that changing the value, physically moves the 2 areas closer or apart. Trying to understand why we would want to do that
 
Last edited by a moderator:
Sorry, should have better clarified my question. From the comments in the code, n = Distance for trend
Trying to understand what that means in practical terms...
I see that changing the value, physically moves the 2 areas closer or apart. Trying to understand why we would want to do that
Look up something called Average True Range and how/why it's used. The 'n' denotes how many bars are used for the atr calculation, and the mult is what amount/percentage of the ATR is used. So 0.7 is what amount of 1 ATR is used. so MULTiply the 0.7 times 1 atr and thats what you're using in the indicator.
 
Look up something called Average True Range and how/why it's used. The 'n' denotes how many bars are used for the atr calculation, and the mult is what amount/percentage of the ATR is used. So 0.7 is what amount of 1 ATR is used. so MULTiply the 0.7 times 1 atr and thats what you're using in the indicator.
Finally, been able to understand this. Appreciate it
 
Hey all, I'm new here (first post). I'm just trying to figure it all out and this is my (humble) interpretation:

BTO = buy to open
LL = lower lows (bottom-most line of green plot)
STO = sell to open
HH = higher highs (top-most line of red plot)
@barbaros said:
STO_RO = Sell to Open Risk On
BTO_RO = Buy to Open Risk On
all correct i think except STO_RO is gonna be: Sell To Open Risk Off
and BTO_RO is gonna be: Buy To Open Risk Off

those are the trade Exit points.

green and red are the trade entry points, white-dashes are the trade exit points.
 
Sorry, if this is a lame question.
Can anyone explain what these denote?
input n = 5;
input R_Mult = .7;
From the comments in the code, n = Distance for trend
Trying to understand what that means in practical terms...
I see that changing the value, physically moves the 2 areas closer or apart. Trying to understand why we would want to do that
Whenever, i lower 5 to 3 and raise 0.7 to 0.9 for a setting to set up for PPS staying within a limited range.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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