+ Reply to Thread
Results 1 to 14 of 14

Horizontal Bar Chart - Dynamic?

  1. #1
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Horizontal Bar Chart - Dynamic?

    Hello All.
    I am trying to create a horizontal bar chart that plots frequency.
    Basically I have data in cells (From J12-J511) that returns a value of either "WIN" or "LOSS"
    As a note, for example this data is derived from Column G where cell J12 formula would be =IF(D12<$D$7,"WIN","LOSS")
    (Just thought I'd mention this)

    I would love to create a horizontal bar chart that plots all occurances of "WIN" "LOSS" & their frequency.
    Thing is, if I press F9,, the results change, so the data needs to be "dynamic?" (Not sure if this is the correct term to use).

    So,, the chart would show all 2 colour bars, Blue for "WIN", red for "LOSS"
    So in order the chart would 1st show all 1 occurrence, then 2, then 3, then 4 occurrences etc etc
    So for example, if there were "WIN" occurred 4 times in a row out of the 500 trade sample & "LOSS" occurred 6 times, the horizontal bar for "WIN" would be blue and be 4, the horizontal "LOSS" red bar would come out to 6

    I hope the above makes sense.
    My experience in excel is very ltd.
    I have tried looking at google video, some videos with charts, some seem very complicated and I am confused to be honest.
    My spreadsheet is a work in progress that hopefully I can finish and upload to a blog I started.
    I attach the sheet, and a screen capture that might help.

    PS, some of the "Statistics" in the upper frame (IE Actual Losing %) aren't working,, as mentioned a work in progress, hopefully these can be functional at a later date, when I can work out how

    I really hope someone can help me with this.
    Many thanks
    TheGhost
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by theghost; 09-15-2009 at 07:52 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Hi

    I hope the above makes sense.
    Not much, I'm afraid. To me, anyway.

    I would love to create a horizontal bar chart that plots all occurances of "WIN" "LOSS" & their frequency.
    How do you determine the frequency? you have 500 cells, some have WIN, some have LOSS.

    So,, the chart would show all 2 colour bars, Blue for "WIN", red for "LOSS"
    So in order the chart would 1st show all 1 occurrence, then 2, then 3, then 4 occurrences etc etc
    "1 occurrence"??? What do you mean?

    So for example, if there were "WIN" occurred 4 times in a row out of the 500 trade sample & "LOSS" occurred 6 times, the horizontal bar for "WIN" would be blue and be 4, the horizontal "LOSS" red bar would come out to 6
    I don't get it.

    In any case, Excel won't be able to produce a chart from this data. You will need to create a table where you prepare the data for plotting. Excel charts do not summarize, total, or calculate, they can just plot numbers in cells.

    Please try to explain what exactly you want the chart to show, and please keep in mind that we don't know your project as well as you do, so may require explanations for things that seem obvious to you.

    Oh, and you may want to indicate in your profile that you're using 2007....

    cheers

  3. #3
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    Many many thanks for your reply Teylyn.
    I have just got in from work, (6.15am), just read your reply...

    Sorry for confusion
    I have amended my profile also to show excel 2007 as you suggested.

    I have created an example in excel that I have screen captured (wasn't a chart) as I don't know how to do it, so I have created the same (kind of) as an example.
    I attach the .jpeg

    Basically Teylyn, it shows the random 500 trades and how many times Wins or Losses occurred.
    So, for example, down the left hand side (Not sure if this is x or y axis ), there are the numbers 1 to 14.
    This means that out of the 500 trades simulated, you can see that if a "WIN" occurred on it's own (so a loss would precede a win or follow a win), this happened 42 times out of 500 (Or 8.4%)
    If you look at the number 7,,,, you can see the "WINS" that occurred 7 times in a row before a loss happened. 7 WINS in a Row occurred 18 times (Or 3.6% out of 500 trades)
    And "LOSSES" that occurred 7 times in a row before a win happened 12 times (OR 2.4% of the time)

    I hope all the above makes sense....................
    That said,,,, It is now 7.42 AM,, been on long night shift and I can see that I have made a big mistake with the calculations

    I hope the jpeg gives you the right idea,, but I can see that I am way off on my figures,,, as for example,,,
    using the 7 wins or losses in a row,,, I have them showing as occurring 18 times and 12 times,,,, but 18 & 12 would need to be multiplied by 7,,IE (126 Wins have been used up out of the 500 & 84 losses have been used,, so 210 trades have been used out of the 500........

    I would need to do another screen capture with all amended figures so it all works out correctly,,, but my eyes are starting to close (God I hate night shifts ...:-)

    I hope the screen capture helps and explains it all better Teylyn.
    Hopefully you get a better idea of what I'm trying to achieve.
    I hope you can help Teylyn.
    Many thanks again for your reply.

    TheGhost
    Attached Images Attached Images

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Hi Ghost,

    see what you can do with the attached.

    I have mocked up a sheet with 500 trades and I'm using a calculation based on a random number to fill the Status column with either Win or Loss. This gives me a nice data sample, that changes whenever I hit Enter.

    Next to the Status column I count the number of repeats for each Win or Loss until the status changes

    In the next column I determine whether a number is the last in a series of counts, e.g. is the "3" followed by a "4" or is the "3" followed by a "1". The three possible positions are

    new = sits next to a count of 1 followed by a bigger number
    middle = sits next to a number in the middle of a series
    last = sits next to the highest number of the series, i.e. for a single Win/Loss it will be next to a 1, for a series of 5 consecutive Wins it will be next to a 5

    With me so far?

    Now to the juicy bit.

    I now need to count how often the last number of a series is a Win and has a certain number of repeats. I use the SUMPRODUCT function for that. I have a grid with the number of repeats in the first column, and the words Win and Loss at the top. The SUMPRODUCT function in cell H17 calculates the number of sigle wins. It looks like this:

    =SUMPRODUCT(--(status=H$3),--(position="last"),--(count=$G17))

    it will look in the status column for the Wins only
    it will look in the Position column for the "last" only
    it will look in the count column for values that are equal to G17 (which is the 1)

    The function will sum up those occurrences where all three conditions are found true.

    This table is the basis for the bar chart, data labels at the inside of the bar, etc.

    the next challenge is to have the percentage displayed in the chart, too.

    First we need to calculate the percentage for each repeat. As you mentioned, we need to multiply the count values in the table by the repeat number, so the formula is

    wins*repeats/500 - in row 17 this looks like =H17*$G17/500

    This is formatted as percentage. Now we also see all the zero values, but we don't want them to show in the chart, so we better get rid of the zeros by wrapping th percentage calculation in an IF statement

    =IF(H17=0,"",H17*$G17/500)

    Great. Now we have only percentages showing when the numbers are greater than 0

    To place the percentage labels in the chart, we need to add two data series to the chart, one for win and one for loss, and then change the chart type of these two series to be XY (Scatter). The X values for the two series are the same as for the bar chart, but the Y values need a bit of fine tuning. Since the XY chart series are plotted on a secondary Y axis, we can play with the Y values until we have the position just right.

    Next we need a tool that does not come with Excel, but is available for free at www.appspro.com - the XY chart Labeler. Download the add-in and install it.

    Then we use this tool to assing the calculated % values as labels to the XY series. Finally, we format the XY series to show no markers or lines, hide the secondary Y axis and the chart should look like in the attached file.

    Hope that helps
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    Many many thanks for you reply and post Teylyn.
    I really do appreciate it alot

    I looked at it when I got in from work at 6.30am this morning (God how I hate night shifts ),,,
    I really want to reply with an in depth post, and amend my spreadsheet as best as possible, but I have to go to work again tonight (In 40mins).
    I've started doing some stuff, but it isn't complete.
    So, this is a thank you reply, and to say I will be replying in full, hopefully tomorrow.

    That said, I did read your post,
    I really liked the clever but of "new" "last", "middle" ,, very nice.

    I downloaded your spreadsheet, but the chart & repeat/win/loss columns wouldn't refresh like the "Status", "Count","Position" columns.
    I am using excel 2007.
    The chart is exactly how I would want it,,, with repeats & % labeled etc.
    Never heard of XY chart labeler,,, have installed it,, not had time to look yet.

    For now, I upload a newer version of my sheet,, again, I haven't had chance to do it as best I can yet,,, as have to go to work very soon,, but at least you can get an idea of my thinking.
    I have "sleeper cells",, which could house your "count" & "count" columns etc.

    So,, hopefully the chart could be integrated into my sheet.
    I'm late now, trying to get something together, so annoying running out of time...
    Here is my sheet now.
    Sleeper cells highlighted yellow,, I think I can now delete due to formulas in statistic cells.
    Not sure if column N is needed?
    Can't get I6 cell to work ,,,
    I8 & AA8 need sorting also,, but it is getting there Teylyn.

    Hopefully soon I can integrate your chart with this kind of sleeper cell format?
    Have to go,, I attach chart.
    Again, many thanks,, and I'll get back soon.
    All the best
    The Ghost
    Attached Files Attached Files

  6. #6
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Hi Ghost,

    hope you had a good sleep

    I've attached a version of your work sheet with the chart in place.

    Since I'm working with XL2003 on this computer, there may be some stuff that got lost in translation, so please have a good look. I also did not bother with fancy bar formatting. You'll take care of that, ok?

    I downloaded your spreadsheet, but the chart & repeat/win/loss columns wouldn't refresh like the "Status", "Count","Position" columns
    I've created the range names "status", "position" and "count" for the columns J, P and O. These range names are referred to in the summary table of win and loss and if the names aren't defined, the formulas bomb.

    Can't get I6 cell to work ,,,
    Don't know what you want to achieve there, but I6 contains a circular reference. It says:
    If there is data in D5:D9, then divide myself by (myself + AA4)

    If an element of a formula refers to the cell where the formula is stored, the calculation would go in circles - forever. Some times there are valid reasons for circular references, and there are ways to allow them. But most times a circular reference is entered by mistake, you really meant to refer to a different cell. So, once you've caught up with your sleep, try and see if you really mean
    =IF(COUNTA($D$5:$D$9),I6/(I6+AA4),"")
    (the red bits are the problem!)

    By the way, the chart in my first example had a white background, so the white data labels for the win/loss bars were effectively invisible when the value of the bar was zero.

    Now, the chart has a dark gray background, but the data labels are still white. In order to prevent them from showing for all the zero values, I used a formatting trick that you may or may not know.

    Custom format data labels to
    0;;;

    The logic behind this is the syntax of the custom format

    <positive number>;<negative number>;<zero value>;<text>

    If you only specify one of the four options, it will be the default for the other options as well, but if you put the semicolons in the custom format you thus define the format for each of the options, in this case

    positive number = 0 (general)
    negative number = (nothing, will not show)
    zero value = (nothing, will not show)
    etc

    hope this puts you a step further to your goal

    cheers
    Attached Files Attached Files
    Last edited by teylyn; 09-17-2009 at 05:28 PM.

  7. #7
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    Many thanks again for your help Teylyn,
    it really is getting there. :-)

    I have been on the sheet today about 8hrs,, got as far as I can go I think,
    eyes are killing me :-)

    I attach latest version,, so much I could type, but I'll try and keep it tight.

    Managed to sort out most of the " Statistics" data in the top frame, that returns a lot of info.
    I had trouble with 1 formula,(The actual Losing %), took me ages to sort out,,, all it was, was that I had a space before = in the formula bar

    hehe,, also,,, some are array formulas? Not sure exactly what it means but now know I must use Ctrl/Shift/Enter

    The clear button now clears all data correctly.
    Managed to get rid of many hidden Rows of Data.
    (Hidden Rows are now Between Column J & T)

    I've really tried Teylyn to insert all your cells of data correctly.
    Problems are;
    I really didn't know how best to do the "Frequency" Chart.. So I copied and pasted it into this sheet.
    Trouble is,,, I keep getting a security warning about links,, I really don't know how to get ride of it.

    I did have a few issues also,, I attach screen shot,, not even sure what it all was about,, but just thought I'd mention it.

    I see what you mean about "Naming the range of cells",, ie position/count (I called status, Outcome).
    Count & Position Columns Refresh with F9,,
    But I just Can't get the Win/Loss Columns To Update Teylyn? (Columns N & O)

    As to The chart, well, I've done what I can, but if the Win/Loss doesn't update, so it won't work.
    Can you advise on how to do this Teylyn?

    I've also got trouble Formatting % on chart.
    I read your 0;;; but still not displaying correctly
    Only other thing (Apart for "Simulation" but that's a completely different kettle of fish) is I
    would like to include in the stats area:
    "Largest Losing Streak"(Cell I8)
    &
    "Largest Winning Streak" (Cell W8)
    If Cells I7 & W7 can calculate the Longest Losing Streak & Longest Winning Streak, hopefully there might be a way to work out what that amount is?
    If anyone can help with this I would be most grateful,, I really can't do this, it's beyond me.


    I've really tried my best Teylyn.
    Hope you can advise.

    It's really getting close & looking great.
    Worth the effort.

    Again many thanks for your help...
    & One other special mention,
    I had some great help with the Stats formulas from a guy called Jon Von Der Heyden.
    I just want to publicly thank him for his help in the writing of most of the Stats Formulas.
    I couldn't have done this, so I am extremely thankful for his help & time, a very talented excel programmer, many thanks.

    Many thanks for everyone's help.

    Thank you for your time again Teylyn, it really is getting there.
    The spreadsheet wouldn't be where it is now, &I couldn't have done this chart without your help.

    Right, 3.30am, off to bed
    Many Thanks again
    TheGhost :-)
    Attached Images Attached Images
    Attached Files Attached Files

  8. #8
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Hi,

    I fixed the chart so it now shows the percentage labels. Hope you can see it.
    Also, the chart was not pointing to the win/loss data. I fixed that, too.

    Whenever I hit F9, the numbers update and the chart changes.

    I noticed that you have entered the sumproduct formulae in the win/loss table with CTRL-SHIFT-ENTER. There is really no need to enter them as array formulae. I'm not even sure if that is a good thing, but I don't know much about them.

    Apart from the chart, I can't help you much further, I'm afraid, because I don't really understand what the spreadsheet does.

    But you seem to have a good grip on it now.

    cheers
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    Many thanks for your reply Teylyn.
    Sorry for my late reply, had major electrical problems,, sorted now, needed new wall sockets!

    Regarding your uploaded spreadsheet.
    I just can't get it working Teylyn I'm afraid. I can't get the chart or all data to update.
    I've attached a screen capture, showing various options I'm seeing regarding excel and options. (The link problem)

    Is the chart some kind of saved template Teylyn? Where it's looking for info on your HD and so I it won't work properly when you send?
    (That's just a guess, but best I can think of).

    I've attached another sheet Teylyn, MCE7. There is no chart in it.
    Is it possible you can just alter Column N(WIN Column) & Column O, as these 2 are meant to update? Is this right Teylyn?

    It's just that in all the sheets I have ,, none off these columns update.
    I just can't see why not.

    If I can just get all the data working 1st, then I can look at the chart.
    (The chart is another issue Teylyn as I did have problems formatting, but I won't go into that now, so as to keep this email short,, but if you could kindly just show me what is needed in Col N & O so these update correctly.
    Column K (Count) & L (Position) are working fine.

    I just can't see what I've done wrong/or what is missing.

    I attach now
    Again many thanks for your help with all this, it is very much appreciated.
    Many Thanks
    TheGhost
    Attached Images Attached Images
    Attached Files Attached Files

  10. #10
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Hi,

    this is really a troublesome little bugger!

    I think I found what was not working and caused the error messages. Try the attached now.

    I have saved is as a XL 2003 *.xls file, so some of the finer points of XL 2007 formatting and functions may have been lost, but you should see the chart working and changing every time you hit F9.

    Of course, you can save this now as a XL2007 file and continue from there.

    hope that helps
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    Hi Teylyn,
    It's 5.22am here.
    Just got your reply, many thanks.

    I've just downloaded it.
    Still an issue I'm afraid Teylyn.
    1st, for clarity, when you say "The Chart",, The top chart, IE the Equity Graph does change every time you hit F9, that has always been fine.
    What isn't changing is the Win/Loss Frequency Horizontal Chart; this is the one I really would like to see refreshing as well.

    Your new excel sheet does open without a warning message Teylyn, How did you do that ?,, not sure what that was..
    If I click now to Un-hide the columns (So I can view Columns K to S,,, The Win Column (N) & Loss Column (O) still don't update like Column K (Count & Column L (Repeat)
    N & O,,, these are the problems,, not sure why they don't update?
    Also, if these updated, then so should Columns Q & S,, Win % & Loss %??

    I really don't know why they don't update Teylyn,, any ideas?
    Many thanks for trying again,, it is most frustrating


    As a note,, I noticed Column R (IE CELL R12 - is formula like an array,, that column must have been me,, no need to be like {=P12+1},, can be just =P12+1 ,,, Is this right Teylyn?

    Again, many thanks for your help, it really is frustrating,, I take it you must be viewing the excel sheet and seeing the Win/Loss Frequency chart updating like the top equity chart?

    I hope you can see where or what needs fixing in the formulas, as this is above me.

    I' really am not sure why it won't work.

    Again many thanks for your help with this.
    All the best
    The Ghost

  12. #12
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Tell you what: It's 5pm here and I'm going home. In the office I have only xl 2003, but at home I have 2007. I'll open one of the versions above in 2007 and try to get to the bottom of it. If it works for me in 2007, I'll post it back. That should take care of the compatibility issues.

    Hang in there. We'll get it done!

    cheers

  13. #13
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Horizontal Bar Chart - Dynamic?

    Jeeps, this one has me stumped. But you can stop tearing your hair out.

    For some reason, Excel 2007 does not update a formula like

    =SUMPRODUCT(--(Outcome=$O$11),--(position="last"),--(count=M12))

    Not when you hit F9, anyway, only when you edit the formula and hit enter.

    But it does calculate with the syntax

    =SUMPRODUCT((Outcome=$O$11)*(position="last")*(count=M12))

    Also, since Excel 2007 has the new sumifs and countifs formulae, I could use

    =COUNTIFS(Outcome,$N$11,position,"last",count,M12)

    I used the Countifs version in the WIN column and the SUMPRODUCT in the Loss column, so you can enjoy both.

    The links are cleared, the chart updates, --- as far as I'm concerned, this is now working fine.

    I'll never touch this file with XL 2003 again, promise!

    Hope that solves your immediate problem. Cheers! Sleep well!
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    02-19-2007
    Location
    Poole England
    MS-Off Ver
    2010
    Posts
    117

    Re: Horizontal Bar Chart - Dynamic?

    IT WORKS!!!!!!!!!!!!!

    Just off to bed now Teylyn.

    Many many thanks for this,, its brilliant,, truely brilliant

    I'll have to read everything you wrote and try stuff out,, but it all updates great

    Really,, a big thank you.
    I'll be trying to sort it all out later today (But if Im on night shift,, tomorrow).

    Thanks for sticking with it,, almost a "Edison" thing going on,, but you never gave up after failure (Best called feedback),, I respect you for that.

    Again, many many thanks

    All the best
    The Ghost

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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