+ Reply to Thread
Results 1 to 18 of 18

Can't highlight lowest and highest points of OHLC candlestick chart in excel

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Hello Friends,

    I made a candlestick (Open-High-Low-close) chart in excel and facing two problems:
    1. Within the chart, I want to put a arrow, text box, marker or any indicator to highlight the lowest and highest point. I tried to add two helper columns to detect the highest and lowest value but could not integrate/combine that series with the existing OHLC chart. Can someone give me an idea on how to do it?
    2. When I remove last two records of the data, the last two candle disappears but the chart does not resize. What i want to do is, when the last few records are remove, the existing candle should take up the entire space and make the visible candles fat.
    i have attached sample data and chart with this post. Appreciate help on the two points i have mentioned.

    Thank you.

    chart.png
    Attached Files Attached Files
    Last edited by sabha; 06-16-2023 at 03:57 AM. Reason: added an image for better understanding

  2. #2
    Registered User
    Join Date
    06-09-2023
    Location
    US
    MS-Off Ver
    21
    Posts
    5

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Did you try "smart art"?

  3. #3
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    thanks for you reply. I tried but there is no option for candlestick chart there.
    Last edited by AliGW; 06-16-2023 at 05:05 AM. Reason: Please do NOT quote unnecessarily!

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    One thing I have found about these built in "specialty" charts is that they work very well when you want no more and no less than what the chart is designed for. As soon as you want to add something or remove something from the specialty chart, their inflexibility becomes apparent.

    In most if not all cases, these specialty charts can be easily created as "standard" charts if you work out the details. In the case of a "candlestick" (a kind of box and whisker) chart, you can easily create the chart as a stacked column chart. If you build the chart from a standard chart type, you will find little difficulty in adding additional data series/points to highlight your overall high and low.

    Here's a tutorial for box and whisker diagrams that should cover all the steps needed to create your candlestick chart as a stacked column chart: https://peltiertech.com/excel-box-an...ams-box-plots/
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Thank you for the assistance.

    I went through the tutorial but i cannot relate my data with the box and whisker chart because in my dataset, all the data in column D are Whisker- and all data in column C are Whisker+. In the tutorial, only one row is dedicated for Whisker- and Whisker+. Also I found difficulty in getting the volume chart at the bottom the way I presented in my first post. I feel instead of Excel, I will have to see if it can be done in javascript with some readymade chart scripts. Meanwhile, do let me know if there is any other way to do it in Excel because I am comfortable with Excel and have limited knowledge of javacript.

    Thank you very much for looking into it.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    I'm not sure I understand your objections to Peltier's tutorial. I can see that your high/low data in C and D are inconsistent. Sometimes column C contains the High and sometimes it contains the Low (same for column D). I expect it will be easier to build the chart if the raw data are more consistent (Column C always has the High value and column D always has the Low value). I also notice that in one case (row 4/3 Jan), your open and close values are both smaller than your "Low" value.

    With those observations, here's what I did:

    1) Since high and low are inconsistent, I add helper columns so that the high will always be the highest value for the day and the low will always be the lowest value for the day. In L1, I enter "high" and in L2 I enter =MAX($B2:$E2). In M1, I enter "low" and in M2 I enter =MIN($B2:$E2). Copy/paste/fill down.
    2) Following Peltier's tutorial, I need a "bottom" column/series that will be the smaller of the open or close value. In N1 I enter "bottom" and in N2 I enter =MIN(B2,E2).
    3) There's only one "box" value in this case, so I calculate the absolute value of the difference between open and close. In O1 I enter "box" and In O2 I enter =ABS(B2-E2).
    4) For the positive whisker, I need the difference between the high and the higher of open/close. In P1, I enter "whisker+" and in P2 =L2-MAX(B2,E2)
    5) For the negative whisker, I need the difference between the smaller of open/close and the low. In Q1, I enter "whisker-" and in Q2 =MIN(B2,E2)-M2. Select N2:Q2 and copy/paste/fill down.
    6) For the overall maximum, I enter "maximum" in R1 and in R4 I enter 7. For the overall minimum, I enter "minimum" in S1 and in S3 I enter 1.
    7) Now I have all of the data for the chart and I can build the chart. Select B2:B6,N2:O6,R2:S6 -> Insert stacked column chart.
    8) Select the minimum and maximum series and change the chart type to "line with marker".
    9) Select the "box" series and add positive error bars using the values in P2:P6
    10) Select the "bottom" series and add negative error bars using the values in Q2:Q6.
    11) Format chart elements as desired

    By all means, if you are more comfortable doing this with a Javascript based chart engine, use the programming language that you are more comfortable with. I'm far more comfortable with spreadsheets than Javascript, so I won't be able to help with that approach. If you just had some confusion/misunderstandings about how this works, then see if my outline will help you see your confusion/misunderstandings.

  7. #7
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Yes, i made a blunder in my raw data and i agree with your observations with inconsistent low and high data. I have corrected that now.

    before reading your solution, i was trying some other approach. i dont know what exactly i did, but I came close to my desired output with some issues.

    I have attached another file. Kindly check. meanwhile, i will check your solution.

    the issues that i am facing in this new chart are:
    1. the candles are displayed in reverse order. 9 am candle is at extreme right whereas i wanted it to be in the extreme left - if i format axis as "categories in reverse order", it just changes the axis values but the candles does not change
    2. The actual volume data in F2:F6 are 300, 200, 300, 500 & 200 but when i set these values, the candles becomes very small and are not visible. For time being, I changed the volume data in F2:F6 as 3,2,3,5,2 but the candles overlaps the volume chart - dont know how to take in on another axis.
    3. when i remove last two rows A5:H6, the candles does not take up the chart size. after removing last two entries, i want the 3 candles turn fatter and take the entire chart space.
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    I'm not sure how you got the chart you have either. I'm unable to recreate the chart. Whatever you did, it appears that you are still starting with the open-high-low-close-volume specialty stock chart. As I said before, I find that these specialty charts are useful when I don't want anything other than exactly what the chart template expects, but when I want any additional stuff or any flexibility, it is far easier to go back to a basic chart type and build the equivalent of the specialty chart using basic chart types.

  9. #9
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    I found the below article from where i took reference from ( last post by @omegastripes ) and played a bit by changing the data. It also has your reply on the post.
    https://www.excelforum.com/excel-gen...ine-chart.html

    based on this solution, i attached my revised file "Chart1". In this solution, neither open-high-low-close nor box and whiskers were used, It has a combination of line charts on different axis. this is where i am confused. the line and markers series and the ohlc series both start from different directions. i am totally confused and breaking my head over this since a very long time.

    the latest solution you provided has different columns for whiskers- and whiskers+ and for some reason, i do not want it that way.

    I am not sure if i am able to convey what and how exactly i want it to be.

    I want the ohlc series (candles), volume chart and line with markers start from left the right keeping the axis on the right side like how it show up on a stock chart. Preferably I want only the volume chart on a different axis to avoid overlapping.
    Last edited by sabha; 06-20-2023 at 04:29 AM.

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Now I understand how you got the chart you have.

    Now that I understand how you created the chart, I notice that you have deleted the secondary axes, even though 4 of your data series are plotted on the secondary axis system. When you delete the secondary axis system like this, edits to the primary axis system don't always show up in the series that are plotted on the secondary axis system.

    The relatively simple "fix" is to show the secondary axis system so that you can readily edit it. In your file I:

    1) Select the chart.
    2) Show the secondary vertical and secondary horizontal axes.
    3) Format all four axes to have the desired formats -- including making sure that both horizontal axes have the same "show categories in reverse order" setting (checked or unchecked, whichever you want).

    The challenge with this approach is going to be getting the volume data correct. Using the up-down and high-low bars to get the box and whisker effect creates an inflexibility (the secondary axis system for the line chart series must have exactly four data series on it -- no more and no less). As long as you are content with "scaling" the volume data so that it "fits" into the same vertical axis scale as the OHLC data like you show in your example, there should be no problem. If you want to be able to use the correct volume data without scaling, I don't think this "line with 4 series and up/down high/low bars + column chart" combination chart approach is going to work very well, because it forces you to have your H and L data series on the same, primary axis as the volume data.

    Assuming I am understanding everything you want to do, I don't think there is any way to get exactly what you want within the constraints that you have given. I see a few ways forward on this:

    1) If you can be content with scaling the volume data, then what you currently have is essentially all that is needed. A few formatting tweaks and the chart is done.
    2) It is possible to eliminate the H and L data series and format individual points on the High and Low data series in order to highlight the overall max and min. This approach is difficult to implement, because you either end up manually formatting the highlighted points every time the data changes, or you end up writing a macro script to format the correct data points for you.
    3) You can follow my encouragements to build this as a stacked column + line combination chart -- complete with the helper columns that are necessary to the method.

    What feels like the best way forward?

    3. when i remove last two rows A5:H6, the candles does not take up the chart size. after removing last two entries, i want the 3 candles turn fatter and take the entire chart space.
    I realize that I have not, yet, addressed this issue. Once we get the chart built the way you want it, this will be straightforward. If we end up using a macro script, it will be relatively easy to incorporate a "define the series to be the used range in each column" step as part of the macro script. If we don't end up with a macro, we can use dynamic named ranges inside of the series definitions so that the chart only shows the used range. Or we can make sure that the chart data is in a structured table. In any case, I wouldn't worry too much about this part of the problem until you are satisfied with the methods you are going to otherwise use to create, edit, and maintain this chart. Once you are otherwise completely satisfied with the chart, then we can worry about making it scale with the number of data points.

  11. #11
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Thank you very much for your insights. After reading your last response, I tried a small trick on the Primary and Secondary Axes on the "Char1" file I shared.

    I selected the chart and from the "Design" tab, from "Add Chart Element", I went to "Axes", I selected secondary Horizontal
    Right clicked on bottom axis, went to "Format Axis", unticked "Categories in reverse order"

    This solved the problem
    But it automatically brings another axis on top. so I selected the top axis and deleted it.

    Now the only thing I wanted is that I wanted to move the the left size axis towards right
    So I right clicked on the left side axis, went to "Format Axis" from "Labels" dropdown, changed the position to "High"

    This solves all my problems,
    1. The candles are shown from left to right
    2. Highest and Lowest values are highlighted
    3. It also shows volume bars.

    Now two more things are pending:
    1. scaling volume to solve the overlapping insue if i keep the volume as 300,300,300,500,200 instead of 3,2,3,5,2,
    2. dynamic named range to show only used range

    but before work on the pending 2 things, I want to check what I have done is correct or if that is another efficient way of doing it.

    Kindly check.

    Thank you so much for your assistance

    PS: I really dont want to go for macro/vba solution, neither i want to highlight the overall highest and lowest manually

  12. #12
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Hi!
    I have added a new realtime dataset of 30 rows
    The first row is intentionally kept blank and in cell F2, I have calculated (max volume x 5). I am going to hide this volume bar. This is done to avoid overlapping of volume bars and price candles.
    In last two columns (G&H) I am detecting where is the highest and lowest value but they are not showing up on the chart (see the red and green arrows marked on the below image)
    I am happy with the chart output but highest and lowest markers are not getting plotted probably because of axis issues I guess.

    I want the markers to take their place. Can I achieve this without coding or manually changing the highest and lowest value?

    Lets work on this chart going forward. I am posting image of this chart below and have attached new file
    Attached Images Attached Images
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    I want the markers to take their place. Can I achieve this without coding or manually changing the highest and lowest value?
    I'm not sure I understand the requirement here. As we noted earlier, the problem is that the H and L values belong on the secondary axis, but we cannot actually move them to the secondary axis because our use of the up/down bars and high/low lines will not allow us to have more than 4 data series on the secondary axis. The only way I can see to position the H and L values correctly is to change the values in column G and H. This change doesn't necessarily need to be done manually. Both axes are basic, linear axes, so a simple linear transformation can compute the value for the primary axis that corresponds with a given value on the secondary axis. See if this fits within your requirement of "without coding or manually changing the highest and lowest value:"

    1) I need a table in the spreadsheet with the max and min of each axis.
    Please Login or Register  to view this content.
    2) I will use the TREND() function to perform the transformation. In G2, I edit the formula to be =IF(C2=MAX($B:$E),TREND($U$2:$U$3,$V$2:$V$3,MAX($B:$E),NA()). A similar edit in H2. Copy/paste/fill down.

    That should position the H L markers in the correct positions. As data are changed/added/edited, it should continue to work just fine as long as Excel's "auto" algorithm for the axis limits continues to choose the same values for the axis limits of both axes. If Excel ever chooses different axis limits, it will be easy enough to update those values in the spreadsheet, or you can set the axis limits to "fixed" at values of your choosing, and change them manually when change is needed. The only thing that is "off" is that a reader who goes to column G in the spreadsheet expecting to see 152.85 in G28 (or 122.45 in L7) will instead see a value around 9E6 (and 3.7E6). The solution to this problem might be to have helper columns perform the transformation and leave the values/formulas in columns G and H unchanged.

    I don't know if that falls under the restriction of "manually changing the highest and lowest values," but, as I said, I don't see a way to do this without changing those values somehow. This approach should automate those changes. The only manual changes will be when the axis limits change. If you have the foresight now to say that 100 to 160 are good choices or to choose better values for the axis limits, you can further minimize how often those manual edits will need to be made.

    Again, I don't see a way to do this without changing the values in G and H. Is that an acceptable approach to those changes?

  14. #14
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Thank you once again for the additional help and explanation. If both, the price candles and H & L values cannot come on the same secondary axis, then I am ok with the small helper table. I am not worried about the reader because, my end-user will only see the chart, not the raw data and the reader will never go to column G & H to see whats in there. I am going to keep this chart in excel and link it to my powerpoint slide.

    I wanted to see how it works so I tried your approach with the additional small table and changed the values in G and H with the trend formula you suggested. Initially, I got an error in the formula and then I understood that one closed parenthesis was missing in the formula just before ",NA". I was satisfied with the output and I can say that it is an acceptable approach. However, I wanted to discuss few things.


    1. I DO NOT want to keep the axis limits fixed and want excel to calculate as per its algorithm. Also, I DO NOT want to keep changing values in the additional helper table manually if there are change in axis limits because of new dataset changes.

    2. The lowest value on the axis (100) was set manually. Actually, I want excel to set it using its algorithm. When I go to Format Axis and Reset the Minimum value (100), it directly takes zero by default which make the candles size smaller. On the axis scale, I want to keep the lowest value of the axis to little under 122.45 which is the low of the data range and the highest value of the axis to a round figure little more than 152.85 which is the high of the data range. Approximately a round figure near 20% down from low and 10% up from high. So in this case, the axis values should start from 100 which is little less than 20% of the low and end at 160 which is little less than 10% of the high. Hope you understood this point. Can we achieve this somehow?

    3. I am going to change the dataset on a frequent basis. This process will change the axis limits. So instead of having constant 1E7 in U2, can we keep =MAX(F2:F32) and in U3, can we keep =MIN(F2:F32)? I tried doing that but it changes the placements of H & L markers. - what could be the solution?

    Ideally, I want to keep a ready-template for the chart and keep on chaning the dataset and want the chart to auto update with proper axis scale, and markers at its correct position without any manual intervention. Also, one more important thing. The H & L markers covers the tip of the high and low line. I wanted the low red marker just little below the lowest point and the high green marker little above the highest point so that the high and low lines are clearly visible. Can this also be done somehow?

    Sorry for the big ask. I am also going to play around with this and I also have to try to understand your trend linear transformation solution on how exactly the formula works in the meantime. I am learning a lot. Thank you so much.

  15. #15
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Without a macro script (which you've said you don't want), there is no way to modify Excel's default "auto" algorithm for choosing axis limits. Also, without a macro script, there is no way to automatically link spreadsheet cells and chart axis limits. At this point, you as the programmer have a decision to make. You must decide whether to make this part of the process automatic with a macro script or continue doing it manually without a macro. If you decide that you would rather have it automated and use a macro script, Jon Peltier has a solid script already developed that will link chart axis values to spreadsheet cells: https://peltiertech.com/chart-udf-control-axis-scale/ You would still need to come up with your desired algorithm for the desired axis parameters and program that algorithm into the spreadsheet.

    One thing I will add here. Whether you do it manually or choose to use a macro script to automate the process of controlling the axis limits, once you decide that you are going to control the axis limits rather than leave them to Excel's default "auto" algorithm, you will no longer need the "dummy point" in row 2 to force Excel to "auto" choose a higher value for the primary axis max.

    At this point, it's your decision how you want to proceed.

  16. #16
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240
    Thanks for sharing your thoughts. I was little disappointed to read yoir last response but if there is no way to achieve the desired result, then i guess macro is the best way forward as per your advice. The problem is, i am not a programmer and I wont be able to write a code completely using the link you shared incorporating my own logics due to limited coding knowledge. Another reason is, in my workbook, i may have 25+ different charts on different worksheets so programming multiple macros for all charts would be another super difficult task for me. I really dont want to bother you for further assistance as you have already spared your valuable time for me. Thank you so much.God bless !

  17. #17
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    There is often a cost-benefit analysis to programming spreadsheets. Is it better to invest time and effort now programming a more automated solution, or is it better to save the time and effort in favor of some manual effort in the future.

    I think it might be worth some effort to see if you can use Peltier's UDF without modification. In the limited occasions I've had to use it, his UDF seems pretty robust and adaptable to a variety of scenarios. His UDF has parameters for "sheet name" and "chart name," so, with 25 charts, I would see if you could make 25 copies of the UDF in your spreadsheet, supply the appropriate arguments to each copy of the UDF, and see if you can get his UDF to work for you. That shouldn't require too much of a time investment, and, if you decide it will end up requiring a complete rewrite of the procedure and you don't want to make that investment, you can drop it then.

  18. #18
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Can't highlight lowest and highest points of OHLC candlestick chart in excel

    Thank you for showing me direction. I think I can take it up from hereon. However, if I get stuck somewhere, I will reply on this thread. Thank you very much.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Assign rank/points based upon highest, lowest, median values
    By avs_10 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-24-2022, 11:24 AM
  2. Replies: 12
    Last Post: 06-02-2022, 11:41 AM
  3. [SOLVED] Find highest score and lowest points
    By sirdon in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 18
    Last Post: 11-01-2019, 07:07 AM
  4. Highest score and lowest points
    By sirdon in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 10-30-2019, 06:30 PM
  5. Find highest score and lowest points
    By sirdon in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-30-2019, 03:52 AM
  6. Highlight highest and lowest value
    By GPetcu in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-11-2019, 07:44 AM
  7. [SOLVED] Highlight highest lowest value every nth row in a column
    By Cicada in forum Excel General
    Replies: 8
    Last Post: 02-04-2013, 02:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1