Join useThinkScript to post your question to a community of 21,000+ developers and traders.
https://usethinkscript.com/threads/...obius-for-thinkorswim.1631/page-3#post-116680Is there a scan for TOS for this indicator?
This is Cool! Is there any way you can make the zones stay in their place after it's been reached without them disappearing.Trend Pivot Indicator by Mobius For ThinkOrSwimView attachment 6604
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
This is Cool! Is there any way you can make the zones stay in their place after it's been reached without them disappearing.
Can the look back length be extended back further on the zones?@David45 Here you go. I included a yes/no input for the arrows as well.
Code:# Trend Pivots # 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. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Code has added historical pivot plots as well as visual trade signals. # No guarantees as to accuracy or reliability. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ input n = 5; input R_Mult = .7; 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(); 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(); AddCloud(STO, hh_, Color.LIGHT_RED, Color.LIGHT_RED); AddCloud(ll_, BTO, Color.LIGHT_GREEN, Color.LIGHT_GREEN); # End Code Trend Pivots #~~~~~~~~~~~~~~~~~~~~~~~~~ begin historical pivots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ input show_historical_pivots = no; plot lowestpivot = if show_historical_pivots then ll else nan; lowestpivot.SetDefaultColor(Color.GREEN); plot highestpivot = if show_historical_pivots then hh else nan; highestpivot.SetDefaultColor(Color.RED); plot shortoncrossbelow = if show_historical_pivots then Round((Max(PrevL, highestpivot - (hR * R_Mult))) / ts, 0) * ts else nan; shortoncrossbelow.SetDefaultColor(Color.RED); plot longoncrossabove = if show_historical_pivots then Round((Min(PrevH, lowestpivot + (lR * R_Mult))) / ts, 0) * ts else nan; longoncrossabove.SetDefaultColor(Color.GREEN); plot buyRO = if show_historical_pivots then longoncrossabove + Min(lR, TickSize() * 16) else nan; buyRO.SetDefaultColor(Color.WHITE); buyRO.SetStyle(Curve.LONG_DASH); plot sellRO = if show_historical_pivots then shortoncrossbelow - Min(hR, TickSize() * 16) else nan; sellRO.SetDefaultColor(Color.WHITE); sellRO.SetStyle(Curve.LONG_DASH); AddCloud(highestpivot,shortoncrossbelow,Color.RED,Color.RED); AddCloud(lowestpivot,longoncrossabove,Color.GREEN,Color.GREEN); #~~~~~~~~~~~~~~~~~~~~~~ end historical pivots ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~ begin arrow signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ input show_arrows = yes; def SOCB = Round((Max(PrevL, hh - (hR * R_Mult))) / ts, 0) * ts; def LOCA = Round((Min(PrevH, ll + (lR * R_Mult))) / ts, 0) * ts; def BRO = LOCA + Min(lR, TickSize() * 16); def SRO = SOCB - Min(hR, TickSize() * 16); def datadn = close > SRO and high[1] > SOCB and close < SOCB; def dataup = close < BRO and low[1] < LOCA and close > LOCA; plot arrowdn = if show_arrows then !datadn[1] and datadn else nan; arrowdn.setpaintingstrategy(paintingstrategy.boolean_arrow_down); arrowdn.setdefaultcolor(color.magenta); arrowdn.setlineweight(3); plot arrowup = if show_arrows then !dataup[1] and dataup else nan; arrowup.setpaintingstrategy(paintingstrategy.boolean_arrow_up); arrowup.setdefaultcolor(color.cyan); arrowup.setlineweight(3); #~~~~~~~~~~~~~~~~~~~~~~~~~ end arrow signals ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~~ 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 BRO1 = LOCA + Min(lR, TickSize() * 16); def SRO1 = SOCB - Min(hR, TickSize() * 16); def SE = close > SRO1 and high[1] > SOCB1 and close <= SOCB1; def LE = close < BRO1 and low[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 exit_long = holdLE[1] and !holdLE; def exit_short = holdSE[1] and !holdSE; AddChartBubble(if show_bubbles then !LE[1] and LE else nan, low, "Enter Long", Color.GREEN, 0); AddChartBubble(if show_bubbles then !SE[1] and SE 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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #~~~~~~~~~~~~~~~~~~~~~~~ begin explanation bubbles ~~~~~~~~~~~~~~~~~~~~~~~~~ input explanation_bubbles = yes; AddChartBubble(explanation_bubbles and x == HighestAll(x), STO_RO, "Risk Off", STO_RO.TakeValueColor(), 0); AddChartBubble(explanation_bubbles and x == HighestAll(x), BTO_RO, "Risk Off", BTO_RO.TakeValueColor(), 1); AddChartBubble(explanation_bubbles and x == HighestAll(x), STO, "Entry Line", STO.TakeValueColor(), 0); AddChartBubble(explanation_bubbles and x == HighestAll(x), BTO, "Entry Line", BTO.TakeValueColor(), 1); AddChartBubble(explanation_bubbles and x == HighestAll(x), hh_, "Pivot Line", hh_.TakeValueColor(), 1); AddChartBubble(explanation_bubbles and x == HighestAll(x), ll_, "Pivot Line", ll_.TakeValueColor(), 0); #~~~~~~~~~~~~~~~~~~~~~~~~ end explanation bubbles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit: Added buy/sell bubbles. Please test before using - perform your own due diligence.
Can the look back length be extended back further on the zones?
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
LNL Trend System for ThinkOrSwim | Indicators | 25 | ||
L3 Banker Fund Flow Trend Oscillator for ThinkOrSwim | Indicators | 30 | ||
Trend Meter For ThinkOrSwim | Indicators | 38 | ||
J | Donchian Channel Trend For ThinkOrSwim | Indicators | 5 | |
Donchian Trend Ribbon For ThinkOrSwim | Indicators | 18 |
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.