Trying to write a pivot point script

Vsevolod

New member
I'm just trying to make an indicator that would plot an up arrow every time there's a bar with lower high and lower lows than the previous and next bar and a down arrow every time there's a bar with higher high and lower low than the previous and next bar. I'm not sure where to start. I uploaded an example of where I wanted to plot the arrows. Thanks!

Image is from A Complete Guide to Volume Price Analysis by Anna Coulling
r6CzkXr.png
 
Last edited by a moderator:
Solution
I've tried looking on the website and on the platform. The closest thing I could find on the TOS platform itself is the williams fractals pattern, but it doesn't plot exactly what I want which is indicators/arrows at a candle with lower highs and lower lows than both the candles on either side and vice versa. So I'm thinking that this isn't exactly difficult to code as it isn't super complicated, I'm not sure how to code it though since there aren't tutorials and the language is confusing.

Edit: I did find a study but I had to do some editing to the code.
Here is the edited study
https://tos.mx/4IEK9Ze

Here is the unedited study
https://community.tradovate.com/t/bill-williams-fractal-indicator-from-tos/692
...
I've tried looking on the website and on the platform. The closest thing I could find on the TOS platform itself is the williams fractals pattern, but it doesn't plot exactly what I want which is indicators/arrows at a candle with lower highs and lower lows than both the candles on either side and vice versa. So I'm thinking that this isn't exactly difficult to code as it isn't super complicated, I'm not sure how to code it though since there aren't tutorials and the language is confusing.

Edit: I did find a study but I had to do some editing to the code.
Here is the edited study
https://tos.mx/4IEK9Ze

Here is the unedited study
https://community.tradovate.com/t/bill-williams-fractal-indicator-from-tos/692
 
Last edited:
I've tried looking on the website and on the platform. The closest thing I could find on the TOS platform itself is the williams fractals pattern, but it doesn't plot exactly what I want which is indicators/arrows at a candle with lower highs and lower lows than both the candles on either side and vice versa. So I'm thinking that this isn't exactly difficult to code as it isn't super complicated, I'm not sure how to code it though since there aren't tutorials and the language is confusing.

Edit: I did find a study but I had to do some editing to the code.
Here is the edited study
https://tos.mx/4IEK9Ze

Here is the unedited study
https://community.tradovate.com/t/bill-williams-fractal-indicator-from-tos/692

Hopefully, this modified swing high/low code that I did awhile ago will work as you requested. You can input the number of bars to be in your swing/pivot, show arrows, show price bubbles, and/or show horizontal lines. Theses are all color coded. The chart below is set to 3 bars in a swing.

Screenshot-2021-08-18-071906.jpg
Ruby:
#Swing High/Low (Fractal)
#Higher Highs or Higher Lows are designated by green dots and/or green horizontal lines
#Lower Highs or Lower Lows are designated by red dots and/or red horizontal lines
#User input to select how many horizontal lines are plotted
#User input to plot lines connecting swing highs to each other and swing lows to each other
#User input to plot lines connecting swing highs to swing lows

input swing = 1;
input spacer = 0;


def swinghigh = if Round(Highest(high[1], swing), 2) < Round(high, 2) and
                   Round(high, 2) > Round(Highest(high[-swing], swing), 2) and
                   Round(Lowest(low[1], swing), 2) < Round(Lowest(low[-swing], swing), 2)              
                then 1
                else 0;
def fast      = if swinghigh == 1 then high else fast[1];

plot sh1 = if swinghigh == 1 then high + spacer * TickSize() else Double.NaN;
sh1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
sh1.AssignValueColor(if fast[1] < fast
                     then Color.GREEN
                     else if fast[1] == fast
                     then Color.YELLOW
                     else Color.RED);
sh1.SetLineWeight(4);
sh1.HideBubble();
def swinglow = if Round(low, 2) < Round(Lowest(low[1], swing), 2) and
                  Round(low) < Round(Lowest(low[-swing], swing), 2) and
                  Round(Highest(high[1], swing), 2) > Round(Highest(high[-swing], swing), 2)                
               then 1
               else 0;
def slow = if swinglow == 1 then low else slow[1];



plot sl1 = if swinglow == 1 then low - spacer * TickSize() else Double.NaN;
sl1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
sl1.AssignValueColor(if slow[1] < slow
                     then Color.GREEN
                     else if slow[1] == slow
                     then Color.YELLOW
                     else Color.RED);
sl1.SetLineWeight(4);
sl1.HideBubble();


def sh11    = if !IsNaN(sh1) then high else Double.NaN;
def sl11    = if !IsNaN(sl1) then low else Double.NaN;
def swhigh  = if !IsNaN(sh1) then sh1 else swhigh[1];
def swlow   = if !IsNaN(sl1) then sl1 else swlow[1];
def shcolor = if swhigh != swhigh[1] and swhigh > swhigh[1]
              then 1
              else if shcolor[1] == 1 and swhigh == swhigh[1]
              then 1
              else 0;
def slcolor = if swlow != swlow[1] and swlow > swlow[1]
              then 1
              else if slcolor[1] == 1 and swlow == swlow[1]
              then 1
              else 0;

#Swing Line from High to Low
input showswinghightolowline = yes;
plot hilowline = if showswinghightolowline == no then Double.NaN else if swinghigh then sh11 else sl11;
hilowline.EnableApproximation();
hilowline.SetDefaultColor(Color.BLACK);
hilowline.HideBubble();

#Price Bubbles @Swing
input showbubbles = yes;
AddChartBubble(showbubbles and sh1, high, high, if shcolor == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED, yes);
AddChartBubble(showbubbles and sl1, low, low, if slcolor == 1 then Color.LIGHT_GREEN else Color.LIGHT_RED, no);


#Horizontal Lines
input number_swing_horizontalsstoshow = 2;
input show_horizontallines = yes;
def data = CompoundValue(1, if !IsNaN(sh1) then data[1] + 1 else data[1], 0);
def datacount = (HighestAll(data) - data[1]) + 1;
def data1 = CompoundValue(1, if !IsNaN(sl1) then data1[1] + 1 else data1[1], 0);
def datacount1 = (HighestAll(data1) - data1[1]) + 1;

plot swingHp = if show_horizontallines == no
               then Double.NaN
               else if datacount <= number_swing_horizontalsstoshow
               then swhigh
               else Double.NaN;
swingHp.SetPaintingStrategy(PaintingStrategy.DASHES);
swingHp.setlineWeight(2);
swingHp.AssignValueColor(if shcolor == 1 then Color.GREEN else Color.RED);
swingHp.HideBubble();

plot swingLp = if show_horizontallines == no
               then Double.NaN
               else if datacount1 <= number_swing_horizontalsstoshow
               then swlow
               else Double.NaN;
swingLp.SetPaintingStrategy(PaintingStrategy.DASHES);
swingLp.AssignValueColor(if slcolor == 1 then Color.GREEN else Color.RED);
swinglp.setlineWeight(2);
swingLp.HideBubble();
 
Solution

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
476 Online
Create Post

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