How to calculate and plot pivots on an Excel chart
If you study a stock chart you will discover that sometimes significant trend reversals happen when a stock chart bar is higher than the previous bar and the following bar, especially in a monthly bar chart. Excel is a fantastic tool as you know, it can help us identify these major turning points or pivots.
The picture above shows the simple logic, a bar that is lower than the previous and next bar is interesting to analyze if the stock market is going up (bull market).
Likewise, if a bar is higher than the previous and the following one, keep an eye on these pivots if the market is going down.
What's on this page
Major turning points often happen when the price moves past a pivot. See the picture below.
The chart above shows the S&P500 during the house market crash 2007-2009, Each pivot excel identifies has a dotted line and if it is breached a buy or sell signal is generated. Subsequent signals of the same kind are not shown in the chart.
A blue dotted line shows "high" pivots and a red dotted line shows "low" pivots if a new pivot is found the old one's dotted line ends.
2. Formulas
Here is the sheet that made it possible, you can press with left mouse button on to enlarge.
The user defined array formula in cell C23:I355:
Enter this udf array formula in cell range C23:I355. It fetches data from yahoo and a stock ticker you specify. You can read more about this udf here: Excel udf: Import historical stock prices from yahoo
Formula in cell A23:
This formula returns the YEAR from a date in cell C23.
Formula in cell B23:
This formula returns the first letter from a month.
Formula in cell K24:
This formula checks if the high is higher than the previous and next values. If TRUE change the value to the new high, if FALSE repeat the previous high value.
Formula in cell L24:
This formula checks if the low is lower than the previous and next values. If TRUE change the value to the new low, if FALSE repeat the previous low value.
Formula in cell M24:
This keeps track of whether a buy or sell was the latest signal.
Formula in cell N24:
Checks if the highest price point is above buy pivot. IF TRUE display buy pivot price.
Formula in cell O24:
Checks if the lowest price point is below sell pivot. IF TRUE display sell pivot price.
Formula in cell P24:
Returns the buy pivot price if the last signal was a sell signal. This avoids subsequent buy signals of the same kind.
Formula in cell Q24:
Returns the sell pivot price if the last signal was a buy signal. This avoids subsequent sell signals of the same kind.
Copy cells and paste below as far as needed.
3. Named ranges
The purpose of these named ranges is that if you change the date range the chart will automatically use the new range. Basically, it looks for the last row not equal to "#N/A" in column C and returns a cell range we can use in the chart.
MClose
MHigh200
MLow200
BPivotlines
BuyPivots
Dates200
Sellm200
SellPivots
SPivotlines
4. Setting up the chart
Insert a new stock chart
- Go to tab "Insert" on the ribbon.
- Select cell range E23:G46 on your worksheet.
- Press with left mouse button on the "Other Charts" button.
- Press with left mouse button on the "High-Low-Close" chart button.
- Press with right mouse button on on the chart you just created.
- Press with left mouse button on "Select Data..".
- Select "Series1" and press with left mouse button on the "Edit" button.
- Change Series values to: =Pivots!MHigh200
- Press with left mouse button on OK.
- Select "Series2" and press with left mouse button on the "Edit" button.
- Change Series values to: =Pivots!MLow200
- Select "Series3" and press with left mouse button on the "Edit" button.
- Change Series values to: =Pivots!MClose
- Press with left mouse button on OK.
- Press with left mouse button on "Edit" button below Horizontal (Category) Axis Labels.
- Change Axis Label range to: =Pivots!Dates200.
- Press with left mouse button on OK.
- Press with left mouse button on OK.
5. Reverse horizontal axis
- Press with right mouse button on on the horizontal axis
- Press with left mouse button on "Format Axis..."
- Enable "Categories in reverse order"
- Press with left mouse button on OK
Add "High" pivots to chart
- Press with right mouse button on on chart
- Press with left mouse button on "Select Data..."
- Press with left mouse button on "Add" button below Legend Entries (Series)
- Type Pivots!BPivotlines in Series values
- Press with left mouse button on OK button
- Press with left mouse button on Ok
- Go to tab "Layout" on the ribbon. If you can't find it make sure you have the chart selected
- Select chart element "Series 4" in the drop down list
- Press with left mouse button on "Format Selection" button
- Press with left mouse button on "Secondary Axis"
- Go to "Marker Options" on the menu to the left
- Press with left mouse button on Built-in and select a type and size
- Press with left mouse button on Close button
Reverse Series 4
- Select Series 4 on the chart
- Go to tab Layout on the ribbon
- Press with left mouse button on "Axis button, press with left mouse button on "Secondary Horizontal Axis" and then press with left mouse button on "Show Left to Right"
- Press with right mouse button on on the secondary horizontal axis
- Press with left mouse button on "Format Axis"
- Press with left mouse button on "Categories in reverse order"
- Press with left mouse button on Close
- Select secondary horizontal axis again and delete
- Select the chart legend and delete
- Select Series 4
- Go to tab Layout on the ribbon
- Press with left mouse button on button "Axis"
- Go to secondary vertical axis
- Press with left mouse button on None
6. Add remaining series
- Repeat above steps described in "Add High pivots to chart" and "Reverse Series 4" with Low Pivots, Buy and Sell signals
- Here are the named ranges:
Low Pivots - SPivotlines
Buy - BuyPivots
Sell - SellPivots
7. Change the marker type
- Go to tab "Layout" and Select Buy (Series 6)
- Press with left mouse button on "Fomat Selection"
- Go to "Marker Options" and choose a Built-in one
- Now select Sell (Series 7)
- Press with left mouse button on "Format Selection" button
- Go to "Marker Options" and choose a Built-in one
8. Add Data Labels
- Go to tab "Layout" and Select Buy (Series 6)
- Press with left mouse button on "Data Labels" button
- Press with left mouse button on "More Data Label Options.."
- Make sure "Series Name" and "Above" is enabled, see picture above.
- Press with left mouse button on Close
- Repeat above steps with Sell (Series 7)
9. Change minimum and maximum value on the vertical axis
- Press with right mouse button on on vertical axis
- Press with left mouse button on "Format Axis"
- Change minimum value to 600
- Change maximum value to 1600
10. Change bar color
- Go to tab "Layout" on the ribbon
- Select "Series 3"
- Press with left mouse button on "Format Selection"
- Go to "Marker Line Color"
- Press with left mouse button on "Solid Line" and pick a color, I chose black.
- Press with left mouse button on Close
11. Resize chart
Stock market trend category
In my previous post, I described how to build a dynamic stock chart that lets you easily adjust the date […]
Excel categories
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form