Pivot Points from Super OrderBlock For ThinkOrSwim

airgb

Member
6mgcdwQ.jpg

Guys are there any of you that can convert this Tradingview indicator option into TOS script (or make an indictor like it)? It's basically a three candle formation for high and low pivot points which form a line at that pivot point. I have made a pattern in TOS but that only gives me a point indicator on the last 3rd candle of the formation which is no where close to this. I have copied the pivot source out of the TV script code and posted it below if that helps, and if needed I can post the full indicator code if needed. Any help with this would greatly be appreciated.

I only want the pivot point lines which is part of this Tradingview code:
Super OrderBlock / FVG / BoS Tools by makuchaku & eFe
https://www.tradingview.com/script/aZACDmTC-Super-OrderBlock-FVG-BoS-Tools-by-makuchaku-eFe/
 
Last edited by a moderator:
6mgcdwQ.jpg

Guys are there any of you that can convert this Tradingview indicator option into TOS script (or make an indictor like it)? It's basically a three candle formation for high and low pivot points which form a line at that pivot point. I have made a pattern in TOS but that only gives me a point indicator on the last 3rd candle of the formation which is no where close to this. I have copied the pivot source out of the TV script code and posted it below if that helps, and if needed I can post the full indicator code if needed. Any help with this would greatly be appreciated.

I only want the pivot point lines which is part of this Tradingview code:
Super OrderBlock / FVG / BoS Tools by makuchaku & eFe
https://www.tradingview.com/script/aZACDmTC-Super-OrderBlock-FVG-BoS-Tools-by-makuchaku-eFe/


plotPVT = input.bool(defval=true, title='Plot Pivots', group='Pivots')
pivotLookup = input.int(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5')
pvtTopColor = input.color(defval=color.new(color.silver, 0), title='Pivot Top Color', group='Pivots', inline='PVT Color')
pvtBottomColor = input.color(defval=color.new(color.silver, 0), title='Pivot Bottom Color', group='Pivots', inline='PVT Color')
//////////////////// Pivots ////////////////////
hih = ta.pivothigh(high, pivotLookup, pivotLookup)
lol = ta.pivotlow(low , pivotLookup, pivotLookup)
top = ta.valuewhen(hih, high[pivotLookup], 0)
bottom = ta.valuewhen(lol, low [pivotLookup], 0)
plot(top, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top")
plot(bottom, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom")
check the below

CSS:
input plotPVT = yes;#(defval=true, title='Plot Pivots', group='Pivots')
input pivotLookup = 1;#(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5')

def na = Double.NaN;
#valuewhen (cond, source, occurrence) =>
script valuewhen {
    input cond = 0;
    input source = 0;
    input occurrence = 0;
    def n = occurrence + 1;
# start at 0 so it looks at current bar
    def offset2 = fold j = 0 to 200
    with p
    while p < n + 1
    do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
    plot price = GetValue(source, offset2 - 1);
    plot offset = offset2;
}
#//////////////////// Pivots ////////////////////
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}

def hih = findpivots(high, 1, pivotLookup, pivotLookup);
def lol = findpivots(low , -1, pivotLookup, pivotLookup);
def top =   if !isNaN(hih) then hih else  if isNaN(top[1]) then high[pivotLookup] else top[1];
def bottom = if !isNaN(lol) then lol else if isNaN(bottom[1]) then low[pivotLookup] else bottom[1];
plot PvtTop = if isNaN(close) or !top then na else  top;#, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top")
PvtTop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot PvtBit = if isNaN(close) or !bottom then na else  bottom;#, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom")
PvtBit.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
check the below

CSS:
input plotPVT = yes;#(defval=true, title='Plot Pivots', group='Pivots')
input pivotLookup = 1;#(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5')

def na = Double.NaN;
#valuewhen (cond, source, occurrence) =>
script valuewhen {
    input cond = 0;
    input source = 0;
    input occurrence = 0;
    def n = occurrence + 1;
# start at 0 so it looks at current bar
    def offset2 = fold j = 0 to 200
    with p
    while p < n + 1
    do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
    plot price = GetValue(source, offset2 - 1);
    plot offset = offset2;
}
#//////////////////// Pivots ////////////////////
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}

def hih = findpivots(high, 1, pivotLookup, pivotLookup);
def lol = findpivots(low , -1, pivotLookup, pivotLookup);
def top =   if !isNaN(hih) then hih else  if isNaN(top[1]) then high[pivotLookup] else top[1];
def bottom = if !isNaN(lol) then lol else if isNaN(bottom[1]) then low[pivotLookup] else bottom[1];
plot PvtTop = if isNaN(close) or !top then na else  top;#, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top")
PvtTop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot PvtBit = if isNaN(close) or !bottom then na else  bottom;#, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom")
PvtBit.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Thank you Samer800, works very well. Here's the one I have been using lately that I found somewhere. It's okay but not as good as yours.

def swingHigh = high > high[1] and high > high[2] and high > high[-1] and high > high[-2];
rec trackSwingHigh = if swingHigh[2] then high[2] else trackSwingHigh[1];
plot swingHighLevels = trackSwingHigh[-2];
swingHighLevels.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def swinglow = low < low[1] and low < low[2] and low < low[-1] and low < low[-2];
rec trackSwinglow = if swinglow[2] then low[2] else trackSwinglow[1];
plot swinglowLevels = trackSwinglow[-2];
swinglowLevels.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
check the below

CSS:
input plotPVT = yes;#(defval=true, title='Plot Pivots', group='Pivots')
input pivotLookup = 1;#(defval=1, minval=1, maxval=5,title='Pivot Lookup', group='Pivots', tooltip='Minimum = 1, Maximum = 5')

def na = Double.NaN;
#valuewhen (cond, source, occurrence) =>
script valuewhen {
    input cond = 0;
    input source = 0;
    input occurrence = 0;
    def n = occurrence + 1;
# start at 0 so it looks at current bar
    def offset2 = fold j = 0 to 200
    with p
    while p < n + 1
    do p + ( if p == n then j - n else if GetValue(cond, j) then 1 else 0 );
# def bnz = bn - offset2 + 1;
    plot price = GetValue(source, offset2 - 1);
    plot offset = offset2;
}
#//////////////////// Pivots ////////////////////
script FindPivots {
    input dat = close; # default data or study being evaluated
    input HL  = 0;    # default high or low pivot designation, -1 low, +1 high
    input lbL  = 5;    # default Pivot Lookback Left
    input lbR  = 1;    # default Pivot Lookback Right
    ##############
    def _nan;    # used for non-number returns
    def _BN;     # the current barnumber
    def _VStop;  # confirms that the lookforward period continues the pivot trend
    def _V;      # the Value at the actual pivot point
    ##############
    _BN  = BarNumber();
    _nan = Double.NaN;
    _VStop = if !IsNaN(dat) and lbR > 0 and lbL > 0 then
                fold a = 1 to lbR + 1 with b=1 while b do
                    if HL > 0 then dat > GetValue(dat, -a) else dat < GetValue(dat, -a) else _nan;
    if (HL > 0) {
        _V = if _BN > lbL and dat == Highest(dat, lbL + 1) and _VStop
            then dat else _nan;
    } else {
        _V = if _BN > lbL and dat == Lowest(dat, lbL + 1) and _VStop
            then dat else _nan;
    }
    plot result = if !IsNaN(_V) and _VStop then _V else _nan;
}

def hih = findpivots(high, 1, pivotLookup, pivotLookup);
def lol = findpivots(low , -1, pivotLookup, pivotLookup);
def top =   if !isNaN(hih) then hih else  if isNaN(top[1]) then high[pivotLookup] else top[1];
def bottom = if !isNaN(lol) then lol else if isNaN(bottom[1]) then low[pivotLookup] else bottom[1];
plot PvtTop = if isNaN(close) or !top then na else  top;#, offset=-pivotLookup, linewidth=1, color=(top != top[1] ? na : (plotPVT ? pvtTopColor : na)), title="Pivot Top")
PvtTop.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot PvtBit = if isNaN(close) or !bottom then na else  bottom;#, offset=-pivotLookup, linewidth=1, color=(bottom != bottom[1] ? na : (plotPVT ? pvtBottomColor : na)), title="Pivot Bottom")
PvtBit.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

Hi Samer800,

Can you please help to improvise it by adding an arrow head pointer (or a caret similar to fractal pattern) to the candle that framed structure break, like shown below?

el5goCu.png


Hi Samer800,

Never mind my request.
I see you have done something similar and more in this post: https://usethinkscript.com/threads/order-block-finder-for-thinkorswim.12162/

There is a bit of complexity and excess functionality there in the code. I turned off some of the plots and was able to get what I needed. I was just after the candle marker :)

Thank you!
 
Last edited:
Hi Samer800,

Can you please help to improvise it by adding an arrow head pointer (or a caret similar to fractal pattern) to the candle that framed structure break, like shown below?

el5goCu.png


Hi Samer800,

Never mind my request.
I see you have done something similar and more in this post: https://usethinkscript.com/threads/order-block-finder-for-thinkorswim.12162/

There is a bit of complexity and excess functionality there in the code. I turned off some of the plots and was able to get what I needed. I was just after the candle marker :)

Thank you!
@Sree Do you mind sharing what you came up with..Thanks

Sure. Here is what I was looking for...


fxJbUVm.png
TY...Actually I was looking for what you took out of the code to create that.. So in essence it is the new code that was created.
 
Last edited by a moderator:
@Sree Do you mind sharing what you came up with..Thanks


Sure. Here is what I was looking for...


fxJbUVm.png


TY...Actually I was looking for what you took out of the code to create that.. So in essence it is the new code that was created.
Apologies if my comment was misleading. Like I had mentioned earlier, I just turned off a few plots in the settings menu - thats all. no code changes were applied.
 
Sure. Here is what I was looking for...


fxJbUVm.png



Apologies if my comment was misleading. Like I had mentioned earlier, I just turned off a few plots in the settings menu - thats all. no code changes were applied.
You weren't misleading I think I was. I wanted to know what you turned off and somehow went off the rails with asking about the code. LOL
 
@Sree In working with this concept I found that using +5 works best with what I'm doing. I'm not good with coding so I'm hoping you would be able to help me with adding those lines to be extended to the right side of the chart. TIA
 
@Sree In working with this concept I found that using +5 works best with what I'm doing. I'm not good with coding so I'm hoping you would be able to help me with adding those lines to be extended to the right side of the chart. TIA

Honestly, I think the line is just the right size to show the fractal nature of the bars. If extended to right, since it cant be erased once its drawn, as the chart grows to the right the lines will be present. Over a period of time, the chart will look loaded with horizontal lines and cluttered. just my 2 cents :)
 
Honestly, I think the line is just the right size to show the fractal nature of the bars. If extended to right, since it cant be erased once its drawn, as the chart grows to the right the lines will be present. Over a period of time, the chart will look loaded with horizontal lines and cluttered. just my 2 cents :)
Thanks and I see the point and it will become too cluttered which is exactly what I don't want so I spent the weekend going over some things and correlating to working with stocks as opposed to futures...Appreciate the feedback..
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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